From 2a0b9f194f63d2de662488a3495db06c91b3bf18 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sat, 14 Sep 2024 10:02:00 +0300 Subject: [PATCH] remove extra members --- .../main/tab/page/content/text/gemini.cpp | 13 +- .../tab/page/content/text/gemini/reader.cpp | 166 ++++++++---------- .../tab/page/content/text/gemini/reader.hpp | 15 +- 3 files changed, 83 insertions(+), 111 deletions(-) diff --git a/src/app/browser/main/tab/page/content/text/gemini.cpp b/src/app/browser/main/tab/page/content/text/gemini.cpp index ffdfda7f..2a4b0532 100644 --- a/src/app/browser/main/tab/page/content/text/gemini.cpp +++ b/src/app/browser/main/tab/page/content/text/gemini.cpp @@ -10,20 +10,15 @@ Gemini::Gemini( NULL, NULL ) { - // Init components - auto geminiReader = Gtk::make_managed( - GEMTEXT - ); - - // Grab title - title = geminiReader->get_title(); - // Init widget set_scroll_to_focus( false ); set_child( - * geminiReader + * Gtk::make_managed( + GEMTEXT, + title + ) ); } \ No newline at end of file diff --git a/src/app/browser/main/tab/page/content/text/gemini/reader.cpp b/src/app/browser/main/tab/page/content/text/gemini/reader.cpp index 4c28b7de..e957fe28 100644 --- a/src/app/browser/main/tab/page/content/text/gemini/reader.cpp +++ b/src/app/browser/main/tab/page/content/text/gemini/reader.cpp @@ -3,8 +3,83 @@ using namespace app::browser::main::tab::page::content::text::gemini; Reader::Reader( - const Glib::ustring & GEMTEXT + const Glib::ustring & GEMTEXT, + Glib::ustring & title ) { + // Build markup + Glib::ustring markup; + + std::istringstream stream( + GEMTEXT + ); + + std::string line; + + while (std::getline(stream, line)) + { + // Header + int level; + Glib::ustring header; + + if (Line::Match::header(line, level, header)) + { + markup.append( + Make::header( + level, + header + ) + ); + + if (title.empty()) + { + title = header; + } + + continue; + } + + // Link + Glib::ustring address; + Glib::ustring date; + Glib::ustring alt; + + if (Line::Match::link(line, address, date, alt)) + { + markup.append( + Make::link( + address, + date, + alt + ) + ); + + continue; + } + + // Quote + Glib::ustring quote; + + if (Line::Match::quote(line, quote)) + { + markup.append( + Make::quote( + quote + ) + ); + + continue; + } + + // @TODO other tags.. + + // Default + markup.append( + Make::plain( + line + ) + ); + } + // Init widget set_valign( Gtk::Align::START @@ -23,9 +98,7 @@ Reader::Reader( ); set_markup( - make( - GEMTEXT - ) + markup ); // Connect CSS @@ -52,12 +125,6 @@ Reader::Reader( ); } -// Getters -Glib::ustring Reader::get_title() -{ - return title; -} - // Match tools bool Reader::Line::Match::header( const Glib::ustring & GEMTEXT, @@ -132,85 +199,6 @@ bool Reader::Line::Match::quote( } // Markup tools -Glib::ustring Reader::make( - const Glib::ustring & GEMTEXT -) { - Glib::ustring pango; - - std::istringstream stream( - GEMTEXT - ); - - std::string line; - - while (std::getline(stream, line)) - { - // Header - int level; - Glib::ustring header; - - if (Line::Match::header(line, level, header)) - { - pango.append( - Make::header( - level, - header - ) - ); - - if (title.empty()) - { - title = header; - } - - continue; - } - - // Link - Glib::ustring address; - Glib::ustring date; - Glib::ustring alt; - - if (Line::Match::link(line, address, date, alt)) - { - pango.append( - Make::link( - address, - date, - alt - ) - ); - - continue; - } - - // Quote - Glib::ustring quote; - - if (Line::Match::quote(line, quote)) - { - pango.append( - Make::quote( - quote - ) - ); - - continue; - } - - // @TODO other tags.. - - // Default - pango.append( - Make::plain( - line - ) - ); - } - - return pango; -} - Glib::ustring Reader::Make::header( const int & LEVEL, const Glib::ustring & TEXT diff --git a/src/app/browser/main/tab/page/content/text/gemini/reader.hpp b/src/app/browser/main/tab/page/content/text/gemini/reader.hpp index b826bed5..f3991376 100644 --- a/src/app/browser/main/tab/page/content/text/gemini/reader.hpp +++ b/src/app/browser/main/tab/page/content/text/gemini/reader.hpp @@ -62,26 +62,15 @@ namespace app::browser::main::tab::page::content::text::gemini ); }; - Glib::ustring make( - const Glib::ustring & GEMTEXT - ); - - /* - * Private members - */ - Glib::ustring title; - /* * Reader class API */ public: Reader( - const Glib::ustring & GEMTEXT + const Glib::ustring & GEMTEXT, + Glib::ustring & title ); - - // Getters - Glib::ustring get_title(); }; }