Browse Source

remove schedule/setWindowContent, fix -log, browser

master
Odilitime 5 years ago
parent
commit
255391ec56
  1. 59
      src/main.cpp

59
src/main.cpp

@ -1,12 +1,14 @@ @@ -1,12 +1,14 @@
#include "CommandLineParams.h"
#include "graphics/opengl/Window.h"
#include "graphics/components/TabbedComponent.h"
#include "environment/Environment.h"
#include "html/HTMLParser.h"
#include "Log.h"
#include "URL.h"
#include "WebResource.h"
#include "tlsf.h"
#include "scheduler.h"
//#include "scheduler.h"
#include "browser.h"
#include <ctime>
#include <iostream>
@ -26,15 +28,16 @@ extern "C"{ @@ -26,15 +28,16 @@ extern "C"{
#define PLATFORM "amd64-pc-winnt"
#endif
const std::unique_ptr<Window> window = std::make_unique<Window>();
//const std::unique_ptr<Window> window = std::make_unique<Window>();
std::unique_ptr<Browser> browser = nullptr;
// why can't I const this?
std::unique_ptr<Scheduler> scheduler = std::make_unique<Scheduler>();
//std::unique_ptr<Scheduler> scheduler = std::make_unique<Scheduler>();
//URL currentURL;
/*
bool setWindowContent(URL const& url) {
logDebug() << "main::setWindowContent - " << url << std::endl;
// download URL
WebResource res = getWebResource(url);
if (res.resourceType == ResourceType::INVALID) {
@ -76,6 +79,7 @@ bool setWindowContent(URL const& url) { @@ -76,6 +79,7 @@ bool setWindowContent(URL const& url) {
}
return true;
}
*/
bool isAbsolutePath(const std::string s);
bool isAbsolutePath(const std::string s) {
@ -90,19 +94,26 @@ bool fileExists(const std::string s) { @@ -90,19 +94,26 @@ bool fileExists(const std::string s) {
int main(int argc, char *argv[]) {
// show help msg when "--help" appears
if (argv[1] && (strcmp(argv[1], "--help")==0)) {
std::cout << "./netrunner [http://host.tld/|/path/to/file.html] [-log <error|warning|notice|info|debug>]" << std::endl;
return 1;
if (argc > 1) {
// has to be set up for logging before first logging call
initCLParams(argc, argv);
if (strcmp(argv[1], "--help")==0) {
std::cout << "./netrunner [http://host.tld/|/path/to/file.html] [-log <error|warning|notice|info|debug>]" << std::endl;
return 1;
}
}
#ifdef _WIN32
init_heap(); // the NT port requires it. We do it at startup now, to allow 2LSF to run at any time
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 << "/g/ntr - NetRunner build " << __DATE__ << ": rev-" << VERSION << " for " << PLATFORM << std::endl;
#else
std::cout << "/g/ntr - NetRunner build " << __DATE__ << std::endl;
std::cout << "/g/ntr - NetRunner build " << __DATE__ << ": internal-dev non-Makefile build" << std::endl;
#endif
Environment::init();
/*
// 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;
@ -111,10 +122,15 @@ int main(int argc, char *argv[]) { @@ -111,10 +122,15 @@ int main(int argc, char *argv[]) {
if (!window->window) {
return 1;
}
*/
browser = std::make_unique<Browser>();
browser->addWindow();
if (!browser->windows.front().get()->window) {
return 1;
}
//std::cout << "argc " << argc << std::endl;
if (argc > 1) {
initCLParams(argc, argv);
// this isn't going to work
std::string rawUrl = getCLParamByIndex(1);
// if we do this here, shouldn't we do this in parseUri too?
@ -133,13 +149,29 @@ int main(int argc, char *argv[]) { @@ -133,13 +149,29 @@ int main(int argc, char *argv[]) {
}
}
//logDebug() << "pre URL parse [" << url << "]" << std::endl;
window->currentURL = URL(rawUrl);
logDebug() << "loading [" << window->currentURL << "]" << std::endl;
//window->currentURL = URL(rawUrl);
logDebug() << "loading [" << rawUrl << "]" << std::endl;
TabbedComponent *tabComponent = dynamic_cast<TabbedComponent*>(browser->windows.front().get()->tabComponent.get());
if (tabComponent) {
tabComponent->addTab("Start Tab, Loading...");
tabComponent->selectTab(tabComponent->tabs.front());
browser->render();
}
/*
if (!setWindowContent(window->currentURL)) {
return 1;
}
*/
std::shared_ptr<DocumentComponent> docComponent = browser->getActiveDocumentComponent();
if (docComponent) {
// now tell it to navigate somewhere
docComponent->navTo(rawUrl);
}
}
browser->loop();
/*
while (!glfwWindowShouldClose(window->window)) {
//const std::clock_t begin = clock();
window->render();
@ -156,5 +188,6 @@ int main(int argc, char *argv[]) { @@ -156,5 +188,6 @@ int main(int argc, char *argv[]) {
//const std::clock_t end = clock();
//std::cout << '\r' << std::fixed << (((static_cast<double>(end - begin)) / CLOCKS_PER_SEC) * 1000) << std::scientific << " ms/f " << std::flush;
}
*/
return 0;
}

Loading…
Cancel
Save