foreseen

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

commit f3e01437c8be4ab1eb3ca740a4d996c1cb36ae8c
parent 56f7e76165748123b1c0b83f90129cd33c6cb1f9
Author: Andrew Laack <andrew@laack.co>
Date:   Sun, 27 Sep 2026 11:42:01 -0500

Refactoring

Diffstat:
MTODO.txt | 8++++++++
Minclude/browser.hpp | 4+---
Minclude/cache.hpp | 1-
Ainclude/shared.hpp | 12++++++++++++
Minclude/utils.hpp | 3---
Msrc/cache.cpp | 2+-
Msrc/link.cpp | 1+
Msrc/main.cpp | 6------
Msrc/preformatted.cpp | 2+-
9 files changed, 24 insertions(+), 15 deletions(-)

diff --git a/TODO.txt b/TODO.txt @@ -63,3 +63,11 @@ - I'm wary to make it too interactive as that might draw focus away from the text being read. - bookmarks + +--- + +- testing for all the ways to parse inputs / urls + +--- + +- diff --git a/include/browser.hpp b/include/browser.hpp @@ -11,9 +11,7 @@ #include "cache.hpp" #include "link.hpp" #include "utils.hpp" - -const int SITE_CACHE_LIMIT = 10; -const int THREAD_NUM = 4; +#include "shared.hpp" class Browser { private: diff --git a/include/cache.hpp b/include/cache.hpp @@ -5,7 +5,6 @@ #include <optional> #include <unordered_map> -const int CACHE_SIZE = 500; class Cache { private: diff --git a/include/shared.hpp b/include/shared.hpp @@ -0,0 +1,12 @@ +#pragma once + +#include <string> + +const std::string DEFAULT_SEARCH_ENGINE="gemini://tlgs.one/search?"; + +const int SITE_CACHE_LIMIT = 10; // number of links to prefetch per page +const int THREAD_NUM = 4; // thread count in thread pool for pre-fetching +const int maxWidth = 80; // max text width (left and right will be padded if COLS > maxWidth) +const int CACHE_SIZE = 500; // max number of elements in history cache and prefetch cache (500 for both) +const int COLOR_LINK = 159; // color used for links +const int COLOR_PREFORMATTED = 201; // color used for preformatted text regions diff --git a/include/utils.hpp b/include/utils.hpp @@ -6,9 +6,6 @@ #include "line.hpp" #include "../vendor/uri.hpp" -const int COLOR_LINK = 159; -const int COLOR_PREFORMATTED = 201; - struct TextRender { int color; bool isBold; diff --git a/src/cache.cpp b/src/cache.cpp @@ -1,7 +1,7 @@ #include "../include/cache.hpp" #include "../include/site.hpp" +#include "../include/shared.hpp" #include <cassert> -#include <iostream> #include <mutex> #include <optional> diff --git a/src/link.cpp b/src/link.cpp @@ -2,6 +2,7 @@ #include <optional> #include <string> #include "../include/utils.hpp" +#include "../include/shared.hpp" #include "../vendor/uri.hpp" #include <ncurses.h> diff --git a/src/main.cpp b/src/main.cpp @@ -4,7 +4,6 @@ #include <cassert> #include <cstddef> #include <filesystem> -#include <iostream> #include <ncurses.h> #include <string> #include <unctrl.h> @@ -20,11 +19,6 @@ int lowestPos(std::vector<std::pair<std::string, TextRender>>& strLs) { return (strLs.size() - (LINES - 2)) + 1; // this gives us two new lines at the end because the last line should contain a \n. } -const int maxWidth = 80; - -const std::string DEFAULT_SEARCH_ENGINE="gemini://tlgs.one/search?"; - - bool isValidUserInput(int uinput) { if ((uinput >= 0x20 && uinput <= 0x7E)) { return true; diff --git a/src/preformatted.cpp b/src/preformatted.cpp @@ -1,5 +1,5 @@ #include "../include/preformatted.hpp" -#include "../include/utils.hpp" +#include "../include/shared.hpp" #include <ncurses.h> Preformatted::Preformatted(std::string input) : text(input) {}