LibreWeb-Browser/src/mainwindow.cc

54 lines
1.2 KiB
C++
Raw Normal View History

2020-11-12 14:27:47 -08:00
#include "mainwindow.h"
#include "md-parser.h"
#include <chrono>
#include <iostream>
#ifdef LEGACY_CXX
#include <experimental/filesystem>
namespace n_fs = ::std::experimental::filesystem;
#else
#include <filesystem>
namespace n_fs = ::std::filesystem;
#endif
2020-11-12 14:27:47 -08:00
2020-11-14 14:13:00 -08:00
MainWindow::MainWindow()
2020-11-12 14:27:47 -08:00
{
2020-11-28 14:47:34 -08:00
set_title("Browser");
set_default_size(800, 600);
2020-11-29 20:12:35 -08:00
set_position(Gtk::WIN_POS_CENTER_ALWAYS);
2020-11-14 14:13:00 -08:00
2020-11-28 14:47:34 -08:00
add(m_scrolledWindow);
2020-11-14 14:13:00 -08:00
2020-11-28 14:47:34 -08:00
m_scrolledWindow.add(m_renderArea);
m_scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
2020-11-28 20:00:32 -08:00
show_all_children();
2020-11-28 14:47:34 -08:00
// Setup parser
setupParser();
}
MainWindow::~MainWindow()
{
delete parser;
}
void MainWindow::setupParser()
{
parser = new Parser();
std::string exePath = n_fs::current_path().string();
std::string filePath = exePath.append("/../../test.md");
printf("Path: %s\n", filePath.c_str());
cmark_node *root_node = parser->parseFile(filePath);
if (root_node != NULL) {
2020-11-29 18:54:21 -08:00
/*std::string html = parser->renderHTML(root_node);
printf("HTML %s\n\n", html.c_str());*/
2020-11-28 20:00:32 -08:00
// process AST, which can then be drawed on render/drawing area
m_renderArea.processDocument(root_node);
cmark_node_free(root_node);
}
2020-11-12 20:27:47 -08:00
}