foreseen

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

commit 17358a436dd2fe80b9adc5f9ee99d35950f0946f
parent 058290e6880bb407ce17efc60eeb501483abccdf
Author: Andrew Laack <andrew@laack.co>
Date:   Fri, 25 Sep 2026 16:14:31 -0500

Fixing up some link stuff

Diffstat:
MTODO.txt | 15++++++++++++---
Minclude/utils.hpp | 1+
Msrc/link.cpp | 6+++---
Msrc/main.cpp | 11++++++-----
4 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/TODO.txt b/TODO.txt @@ -2,9 +2,6 @@ - Be able to: - use a certificate - detect cert changes w/ tofu -- multi-color lines - - current object model only supports text + color + bold, but not specifying any of this on the basis of characters - - this would be useful for link lines, which look nice to have the asterick colored differently than the text - saving files - footprints mode - download all files to disk for sites you access @@ -23,3 +20,15 @@ - what would the abstraction look like for that? - This would likely take as an input a line text and output a pair with start / stop chars for selection - iff delta p_1 - p_0 > 0 then highlight this line. + +--- + +- multi-color lines + - decided against this because 1) this slows it down 2) this adds complexity 3) I don't like the look that much + - it looks a bit too busy (imo). + +--- + +- add site history. +- different color lines + - would be nice for link lines to vary depending on if they've been visited in history diff --git a/include/utils.hpp b/include/utils.hpp @@ -5,6 +5,7 @@ #include "line.hpp" #include "../vendor/uri.hpp" +const int COLOR_LINK = 112; struct TextRender { int color; diff --git a/src/link.cpp b/src/link.cpp @@ -87,14 +87,14 @@ std::optional<std::string> Link::getLinkText() { std::string Link::textToDraw() { if(linkText != std::nullopt) { - return "[" + std::to_string(linkNumber) + "] - " + linkText.value() + "\n"; + return "[" + std::to_string(linkNumber) + "] " + linkText.value() + "\n"; } - return "[" + std::to_string(linkNumber) + "] - " + linkDestination.to_string() + "\n"; + return "[" + std::to_string(linkNumber) + "] " + linkDestination.to_string() + "\n"; } int Link::getColor() { - return COLOR_RED; + return COLOR_LINK; } LineType Link::type() { diff --git a/src/main.cpp b/src/main.cpp @@ -55,8 +55,12 @@ void removeNonAscii(std::vector<std::pair<std::string, TextRender>>& strLs) { void initColors() { - for (int c = 0; c < COLORS; ++c) { - init_pair(c + 1, c, -1); + if(has_colors()) { + start_color(); + use_default_colors(); + for (int c = 0; c < COLORS && c+1 < COLOR_PAIRS; ++c) { + init_pair(c + 1, c, -1); + } } } struct DrawState { @@ -329,9 +333,6 @@ int main(int argc, char** argv) { curs_set(0); // hide cursor keypad(stdscr,TRUE); - // TODO: Check colors available first - start_color(); - use_default_colors(); initColors(); b.goToSite("about:newtab",true);