2020-11-12 14:27:47 -08:00
|
|
|
#include "mainwindow.h"
|
2020-11-17 19:33:25 -08:00
|
|
|
#include "md-parser.h"
|
|
|
|
|
2020-11-20 16:35:30 -08:00
|
|
|
#include <chrono>
|
|
|
|
#include <iostream>
|
2020-11-20 15:21:30 -08:00
|
|
|
#ifdef LEGACY_CXX
|
|
|
|
#include <experimental/filesystem>
|
|
|
|
namespace n_fs = ::std::experimental::filesystem;
|
|
|
|
#else
|
2020-11-17 19:33:25 -08:00
|
|
|
#include <filesystem>
|
2020-11-20 15:21:30 -08:00
|
|
|
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-17 19:33:25 -08:00
|
|
|
|
2020-11-28 14:47:34 -08:00
|
|
|
// Setup parser
|
2020-11-17 19:33:25 -08:00
|
|
|
setupParser();
|
|
|
|
}
|
|
|
|
|
2020-11-21 15:46:22 -08:00
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
delete parser;
|
|
|
|
}
|
|
|
|
|
2020-11-17 19:33:25 -08:00
|
|
|
void MainWindow::setupParser()
|
|
|
|
{
|
|
|
|
parser = new Parser();
|
|
|
|
|
2020-11-20 15:21:30 -08:00
|
|
|
std::string exePath = n_fs::current_path().string();
|
2020-11-17 19:33:25 -08:00
|
|
|
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);
|
2020-11-17 19:33:25 -08:00
|
|
|
cmark_node_free(root_node);
|
|
|
|
}
|
2020-11-12 20:27:47 -08:00
|
|
|
}
|