foreseen

A text-based gemini browser with prefetching.
git clone git://git.laack.co/foreseen.git
Log | Files | Refs | README | LICENSE

commit 4318c2cc7870e72f527e0e8969673d561df0b526
parent cff44cd3cd810a6641c61cb751725dee536cf438
Author: Andrew Laack <andrew@laack.co>
Date:   Wed, 23 Sep 2026 21:53:53 -0500

Improved init for many classes, improved cli startup positional args specification

Diffstat:
Minclude/link.hpp | 4++--
Msrc/format-switch.cpp | 4+---
Msrc/heading.cpp | 3+--
Msrc/link.cpp | 1-
Msrc/list-item.cpp | 4+---
Msrc/main.cpp | 10+++++++---
Msrc/plaintext.cpp | 4+---
Msrc/preformatted.cpp | 4+---
Msrc/quote.cpp | 4+---
Msrc/site.cpp | 5+----
10 files changed, 16 insertions(+), 27 deletions(-)

diff --git a/include/link.hpp b/include/link.hpp @@ -7,10 +7,10 @@ class Link : public Line { private: + bool invalid = false; + int linkNumber = -1; uri linkDestination = uri("gemini://example.com"); std::optional<std::string> linkText; - bool invalid; - int linkNumber; uri parseDestination(std::string destination, std::optional<uri> prior); public: Link(std::string text, std::optional<uri> prior = std::nullopt, int linkNumber = -1); diff --git a/src/format-switch.cpp b/src/format-switch.cpp @@ -1,9 +1,7 @@ #include "../include/format-switch.hpp" #include <ncurses.h> -FormatSwitch::FormatSwitch(std::string input) { - text = input; -} +FormatSwitch::FormatSwitch(std::string input) : text(input) {} std::string FormatSwitch::textToDraw() { return text + "\n"; diff --git a/src/heading.cpp b/src/heading.cpp @@ -2,9 +2,8 @@ #include "../include/errors.hpp" #include <ncurses.h> -Heading::Heading(std::string text) { +Heading::Heading(std::string text) : actualText(text) { - actualText = text; // TODO: Actually handle whitespace correctly here. if(text.substr(0,3) == "###") { headingLevel = 3; diff --git a/src/link.cpp b/src/link.cpp @@ -1,5 +1,4 @@ #include "../include/link.hpp" -#include <iostream> #include <optional> #include <string> #include "../include/utils.hpp" diff --git a/src/list-item.cpp b/src/list-item.cpp @@ -1,8 +1,6 @@ #include "../include/list-item.hpp" -ListItem::ListItem(std::string input) { - text = input; -} +ListItem::ListItem(std::string input) : text(input) {} std::string ListItem::textToDraw() { return text + "\n"; diff --git a/src/main.cpp b/src/main.cpp @@ -18,8 +18,6 @@ // bc ppl use lots of emojis on gemini sites. void removeNonAscii(std::vector<std::pair<std::string, TextRender>>& strLs) { - - for(std::size_t i = 0; i < strLs.size(); ++i) { std::string& s = strLs[i].first; @@ -273,7 +271,13 @@ int main(int argc, char** argv) { if(argc > 1) { // TODO: This should have tests. std::string path = "file:///" + std::filesystem::current_path().string() + "/" + argv[1]; - b.goToSite(path,true); + + if(std::filesystem::exists(path)) { + b.goToSite(path,true); + } else { + b.goToSite(std::string {"gemini://"} + argv[1], true); + } + } else { b.goToSite("gemini://tlgs.one",true); } diff --git a/src/plaintext.cpp b/src/plaintext.cpp @@ -1,8 +1,6 @@ #include "../include/plaintext.hpp" -Plaintext::Plaintext(std::string input) { - text = input; -} +Plaintext::Plaintext(std::string input) : text(input) {} std::string Plaintext::textToDraw() { return text + "\n"; diff --git a/src/preformatted.cpp b/src/preformatted.cpp @@ -1,9 +1,7 @@ #include "../include/preformatted.hpp" #include <ncurses.h> -Preformatted::Preformatted(std::string input) { - text = input; -} +Preformatted::Preformatted(std::string input) : text(input) {} std::string Preformatted::textToDraw() { return text + "\n"; diff --git a/src/quote.cpp b/src/quote.cpp @@ -1,9 +1,7 @@ #include "../include/quote.hpp" #include <ncurses.h> -Quote::Quote(std::string input) { - text = input; -} +Quote::Quote(std::string input) : text(input) {} std::string Quote::textToDraw() { return text + "\n"; diff --git a/src/site.cpp b/src/site.cpp @@ -2,10 +2,7 @@ #include <algorithm> #include <string> -Site::Site(std::string header, std::string body) { - this->body = body; - this->header = header; -} +Site::Site(std::string h, std::string b) : body(b), header(h) {} std::string Site::getHeader() { return header;