Browse Source

new banner, cleanup tree for new merge

master
despair 5 years ago
parent
commit
7d0e8a928b
  1. 12
      NTMakefile
  2. 7
      banner.txt
  3. 3705
      lynx.cfg
  4. 130
      src/CFGFileParser.cpp
  5. 8
      src/CFGFileParser.h
  6. 1000
      src/graphics/opengl/TextWindow.cpp
  7. 80
      src/graphics/opengl/TextWindow.h
  8. 6
      src/main.cpp

12
NTMakefile

@ -5,8 +5,8 @@ CC = gcc @@ -5,8 +5,8 @@ CC = gcc
GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
ifdef DEBUG
CXXFLAGS = -Og -g3 -fstack-protector-strong -fPIE -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
CFLAGS = -Og -g3 -fstack-protector-strong -fPIE -std=c11 -DVERSION=\"$(GIT_VERSION)\"
CXXFLAGS = -O0 -g3 -fstack-protector-strong -fPIE -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
CFLAGS = -O0 -g3 -fstack-protector-strong -fPIE -std=c11 -DVERSION=\"$(GIT_VERSION)\"
else
ifdef RELEASE_PACK
CXXFLAGS = -O3 -march=i686 -mtune=generic -fstack-protector-strong -fPIE -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
@ -18,8 +18,8 @@ endif @@ -18,8 +18,8 @@ endif
endif
ifdef AMD64_DEBUG
CXXFLAGS = -Og -g3 -fstack-protector-strong -fPIE -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
CFLAGS = -Og -g3 -fstack-protector-strong -fPIE -std=c11 -DVERSION=\"$(GIT_VERSION)\"
CXXFLAGS = -O0 -g3 -fstack-protector-strong -fPIE -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
CFLAGS = -O0 -g3 -fstack-protector-strong -fPIE -std=c11 -DVERSION=\"$(GIT_VERSION)\"
else
ifdef AMD64_RELEASE
CXXFLAGS = -O3 -march=opteron -mtune=opteron -mfpmath=sse -fstack-protector-strong -fPIE -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
@ -38,7 +38,7 @@ CWARN = -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization @@ -38,7 +38,7 @@ CWARN = -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization
# i686 builds
ifdef DEBUG
LIBS = -lglfw -lopenGL32 -lGLEW32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
LDFLAGS = -L ./deps/lib/nt_i386 -Og -g3 -fstack-protector-strong -fPIE
LDFLAGS = -L ./deps/lib/nt_i386 -O0 -g3 -fstack-protector-strong -fPIE
else
ifdef RELEASE_PACK
LIBS = -lglfw -lopenGL32 -lGLEW32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
@ -51,7 +51,7 @@ endif @@ -51,7 +51,7 @@ endif
ifdef AMD64_DEBUG
LIBS = -lglfw -lopenGL32 -lglew32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
LDFLAGS = -L ./deps/lib/nt_amd64 -Og -g3 -fstack-protector-strong -fPIE
LDFLAGS = -L ./deps/lib/nt_amd64 -O0 -g3 -fstack-protector-strong -fPIE
else
ifdef AMD64_RELEASE
LIBS = -lglfw -lopenGL32 -lglew32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz

7
banner.txt

@ -1,7 +0,0 @@ @@ -1,7 +0,0 @@
# # ######
## # ###### ##### # # # # # # # # ###### #####
# # # # # # # # # ## # ## # # # #
# # # ##### # ###### # # # # # # # # ##### # #
# # # # # # # # # # # # # # # # #####
# ## # # # # # # # ## # ## # # #
# # ###### # # # #### # # # # ###### # #

3705
lynx.cfg

File diff suppressed because it is too large Load Diff

130
src/CFGFileParser.cpp

@ -1,44 +1,86 @@ @@ -1,44 +1,86 @@
#include "CFGFileParser.h"
#include <climits>
#include <string.h>
CFGFileParser::CFGFileParser(const char* filename){
// Open the config file, get its size,
// allocate the buffer, read it into
// the buffer, close the file
cfg_file = fopen(filename, "r");
stat(filename, cfg_fileinfo);
buffer = static_cast<char*>(tlsf_calloc(cfg_fileinfo->st_size & INT_MAX, sizeof(char) & INT_MAX));
size_t bytesRead = fread(buffer, sizeof(char) & INT_MAX, cfg_fileinfo->st_size & INT_MAX, cfg_file);
fclose(cfg_file);
}
CFGFileParser::~CFGFileParser(){
// clean up!
tlsf_free(buffer);
}
namespace ntr{
size_t string_hash(const fast_string &str){
size_t out = 0;
// instead of tying this to i386/amd64, because someone is eventually going to
// port this to ARM or some RISC nonsense
#if UINTPTR_MAX == 0xffffffff
MurmurHash3_x86_128 ( &str, sizeof(str), 7904542L, &out );
#elif UINTPTR_MAX == 0xffffffffffffffff
MurmurHash3_x64_128 ( &str, sizeof(str), 5484754L, &out );
#else
#endif
return out;
}
bool fast_string_compare(fast_string t1, fast_string t2){
int i = strcmp(t1.c_str(), t2.c_str());
if (!i){
return true;
}
else{
return false;
}
}
}
#include "CFGFileParser.h"
#include <climits>
#include <string.h>
CFGFileParser::CFGFileParser(const char* filename){
// Open the config file, get its size,
// allocate the buffer, read it into
// the buffer, close the file
cfg_file = fopen(filename, "rb"); // On NT, opening in text mode translates \n into \r\n
stat(filename, cfg_fileinfo);
buffer = static_cast<char*>(tlsf_calloc(cfg_fileinfo->st_size & INT_MAX, sizeof(char) & INT_MAX));
cfg = new BrowserConfiguration();
bytesRead = fread(buffer, sizeof(char) & INT_MAX, cfg_fileinfo->st_size & INT_MAX, cfg_file);
fclose(cfg_file);
}
CFGFileParser::~CFGFileParser(){
// clean up!
tlsf_free(buffer);
}
void CFGFileParser::ParseText() {
// Initial buffer for pass 1. tmp holds the config file (fmr. buffer)
// token holds the actual token. pass1_length to keep track of memory,
// reallocate as needed.
char *tmp, *token;
size_t pass1_length = 0;
// Second pass. All comments and .tags stripped out. Starts off at 4KB, increases if necessary.
char* directives = static_cast<char*>(tlsf_calloc(4096, sizeof(char)));
token = strtok_r(buffer, "\n", &tmp);
while (tmp != nullptr) {
if (token[0] == '#' || token[0] == '.' || token[0] == '\n'){ // Comment, Perl directive, or single <LF> found, skip over
token = strtok_r(nullptr, "\n", &tmp);
}
else { // Config directive found, add to second-pass buffer
// once we reach the 4KB mark, realloc exactly enough to keep going
if (pass1_length >= 4096){
tlsf_realloc(directives, pass1_length+strlen(token)+2);
}
strcat(directives, token);
strcat(directives, "\t");
pass1_length = strlen(directives);
token = strtok_r(nullptr, "\n", &tmp); // continue
}
}
// First pass complete, second pass: break up into single directives and <key, value> pairs
tmp = reinterpret_cast<char*>(45); // just some random junk to avoid breaking out
char *key, *value;
while (tmp != nullptr){
key = strtok_r(directives, ":", &tmp);
value = strtok_r(nullptr, "\t", &tmp);
//cfg->Settings.insert({key, value});
}
}
// Writes the fully parsed configuration to a BrowserConfiguration
// object supplied by the user.
void CFGFileParser::WriteConfig(BrowserConfiguration &config){
config.Settings = cfg->Settings;
}
namespace ntr{
size_t string_hash(const fast_string &str){
size_t out = 0;
// instead of tying this to i386/amd64, because someone is eventually going to
// port this to ARM or some other RISC nonsense
#if UINTPTR_MAX == 0xffffffff
MurmurHash3_x86_128 ( &str, sizeof(str), 7904542L, &out );
#elif UINTPTR_MAX == 0xffffffffffffffff
MurmurHash3_x64_128 ( &str, sizeof(str), 5484754L, &out );
#else
#endif
return out;
}
bool fast_string_compare(fast_string t1, fast_string t2){
int i = strcmp(t1.c_str(), t2.c_str());
if (!i){
return true;
}
else{
return false;
}
}
}

8
src/CFGFileParser.h

@ -23,7 +23,7 @@ namespace ntr{ @@ -23,7 +23,7 @@ namespace ntr{
// being processed by CFGFileParser. No longer a "trivial class"
// just select by cfg->GlobalSettings....
struct BrowserConfiguration{
ntr::stringmap GlobalSettings;
ntr::stringmap Settings;
// fast allocation!
static void* operator new(std::size_t n){
if (void *mem = tlsf_malloc(n)) {
@ -40,6 +40,8 @@ class CFGFileParser { @@ -40,6 +40,8 @@ class CFGFileParser {
public:
CFGFileParser(const char* filename);
~CFGFileParser();
void ParseText();
void WriteConfig(BrowserConfiguration &config);
static void* operator new(std::size_t n) {
if (void *mem = tlsf_malloc(n)){
return mem;
@ -51,6 +53,8 @@ public: @@ -51,6 +53,8 @@ public:
private:
FILE *cfg_file;
char *buffer;
struct stat *cfg_fileinfo;
struct stat *cfg_fileinfo = reinterpret_cast<struct stat*>(tlsf_malloc(sizeof(struct stat)));
BrowserConfiguration *cfg;
size_t bytesRead;
};
#endif // __CFGFILEPARSER_H__

1000
src/graphics/opengl/TextWindow.cpp

File diff suppressed because it is too large Load Diff

80
src/graphics/opengl/TextWindow.h

@ -0,0 +1,80 @@ @@ -0,0 +1,80 @@
#ifndef TEXTWINDOW_H
#define TEXTWINDOW_H
#include "../components/ComponentBuilder.h"
#include "../components/Component.h"
#include "ShaderLoader.h"
#include "../../html/Node.h"
#include "Window.h"
#include <memory>
#include <vector>
#include <algorithm>
#include "../../networking/HTTPResponse.h"
#include "../../URL.h"
class TextWindow : public Window {
private:
public:
~TextWindow();
bool init();
void render();
void setDOM(const std::shared_ptr<Node> rootNode);
void createComponentTree(const std::shared_ptr<Node> rootNode, const std::shared_ptr<Component> &parentComponent);
void renderComponentType(std::string str, std::shared_ptr<Component> component);
void onResize(int passedWidth, int passedHeight);
void checkForResize();
void resize();
void resizeComponentTree(const std::shared_ptr<Component> &component, const int windowWidth, const int windowHeight);
std::shared_ptr<Component> searchComponentTree(const std::shared_ptr<Component> &component, const int x, const int y);
void navTo(std::string url);
// properties
int maxTextureSize = 0;
float transformMatrix[16] = {
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
};
bool transformMatrixDirty = true;
GLFWwindow *window;
int windowWidth;
int windowHeight;
//std::shared_ptr<Node> domRootNode = nullptr;
bool domDirty = false;
bool renderDirty = true;
ComponentBuilder componentBuilder;
std::shared_ptr<Component> rootComponent = std::make_shared<Component>();
// I hate doing this but we currently require this
std::shared_ptr<Component> tabComponent = nullptr;
std::shared_ptr<Component> addressComponent = nullptr;
// could break these out in some sort of cursor class
// to minimize dependencies
std::shared_ptr<Component> focusedComponent = nullptr;
std::shared_ptr<Component> hoverComponent = nullptr;
double cursorX = 0;
double cursorY = 0;
unsigned int delayResize = 0;
GLFWcursor* cursorHand;
GLFWcursor* cursorArrow;
GLFWcursor* cursorIbeam;
URL currentURL;
ShaderLoader shaderLoader;
// is there only one selection per window? (probably not)
int highlightStartX = 0;
int highlightStartY = 0;
std::vector<std::shared_ptr<Component>> selectionList;
};
bool setWindowContent(URL const& url);
void handleRequest(const HTTPResponse &response);
extern const std::unique_ptr<Window> window;
#endif

6
src/main.cpp

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
#include "URL.h"
#include "WebResource.h"
#include "scheduler.h"
#include "CFGFileParser.h"
#include <ctime>
#include <iostream>
@ -97,11 +98,14 @@ int main(int argc, char *argv[]) { @@ -97,11 +98,14 @@ int main(int argc, char *argv[]) {
init_heap(); // the NT port requires it. We do it at startup now, to allow 2LSF to run at any time
#endif
#if defined(VERSION) && defined(PLATFORM)
std::cout << "# # ######" << std::endl << "## # ###### ##### # # # # # # # # ###### #####" << std::endl << "# # # # # # # # # ## # ## # # # #" << std::endl << "# # # ##### # ###### # # # # # # # # ##### # #" << std::endl << "# # # # # # # # # # # # # # # # #####" << std::endl << "# ## # # # # # # # ## # ## # # #" << std::endl << "# # ###### # # # #### # # # # ###### # #" << std::endl;
std::cout << "/g/ntr - NetRunner build " << __DATE__ << ": rev-" << VERSION << " for " << PLATFORM << std::endl;
#else
std::cout << "/g/ntr - NetRunner build " << __DATE__ << std::endl;
#endif
Environment::init();
Environment::init();
CFGFileParser *parser = new CFGFileParser("lynx.cfg");
parser->ParseText();
// we need to set up OGL before we can setDOM (because component can't be constructed (currently) without OGL)
// but should be after CommandLineParams incase we need to change some type of window config
window->windowWidth = 1024;

Loading…
Cancel
Save