foreseen

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

commit 886800f1960a1ae770a27769fa24524ac7c706cc
parent b1983d79fe1b1599ed3445c819f2aa0c22f76990
Author: Andrew Laack <andrew@laack.co>
Date:   Sun,  4 Oct 2026 11:47:03 -0500

Refactor colors

Diffstat:
MTODO.txt | 1-
Minclude/shared.hpp | 11+++++++++++
Msrc/format-switch.cpp | 3++-
Msrc/heading.cpp | 8++++----
Msrc/list-item.cpp | 3++-
Msrc/plaintext.cpp | 3++-
Msrc/quote.cpp | 3++-
Msrc/render.cpp | 2+-
Msrc/shared.cpp | 11+++++++++++
9 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/TODO.txt b/TODO.txt @@ -10,4 +10,3 @@ - tests - remove useless ones - formatter -- put all colors into shared.hpp diff --git a/include/shared.hpp b/include/shared.hpp @@ -10,6 +10,17 @@ extern int MAX_WIDTH; // max text width extern int CACHE_SIZE; // max elements in history cache and max in prefetch cache extern uint8_t COLOR_LINK; // color used for links extern uint8_t COLOR_PREFORMATTED; // color used for preformatted text regions +extern uint8_t COLOR_QUOTE; // color used for quote lines + +extern uint8_t COLOR_H3; // color used for H3 lines +extern uint8_t COLOR_H2; // color used for H2 lines +extern uint8_t COLOR_H1; // color used for H1 lines + +extern uint8_t COLOR_LIST_ITEM; // color used for list items +extern uint8_t COLOR_FORMAT_SWITCH; // color used for format switch lines +extern uint8_t COLOR_PLAINTEXT; // color used for plaintext lines + + // We guarantee responses can be at least the size limit, and at most 4096 additional bytes extern int RESPONSE_SIZE_LIMIT_MB; diff --git a/src/format-switch.cpp b/src/format-switch.cpp @@ -1,4 +1,5 @@ #include "../include/format-switch.hpp" +#include "../include/shared.hpp" #include <cstdint> #include <ncurses.h> @@ -9,7 +10,7 @@ std::string FormatSwitch::textToDraw() { } uint8_t FormatSwitch::getColor() { - return COLOR_WHITE; + return COLOR_FORMAT_SWITCH; } LineType FormatSwitch::type() { diff --git a/src/heading.cpp b/src/heading.cpp @@ -1,6 +1,6 @@ #include "../include/heading.hpp" -#include "../include/errors.hpp" #include "../include/utils.hpp" +#include "../include/shared.hpp" #include <cstdint> #include <ncurses.h> #include <stdexcept> @@ -39,11 +39,11 @@ std::string Heading::textToDraw() { uint8_t Heading::getColor() { switch (headingLevel) { case 3: - return COLOR_CYAN; + return COLOR_H3; case 2: - return COLOR_GREEN; + return COLOR_H2; case 1: - return COLOR_RED; + return COLOR_H1; } throw std::runtime_error("This is an invalid program state."); } diff --git a/src/list-item.cpp b/src/list-item.cpp @@ -1,5 +1,6 @@ #include "../include/list-item.hpp" #include "../include/utils.hpp" +#include "../include/shared.hpp" #include <cstdint> ListItem::ListItem(std::string input) { @@ -16,7 +17,7 @@ std::string ListItem::textToDraw() { } uint8_t ListItem::getColor() { - return 15; + return COLOR_LIST_ITEM; } LineType ListItem::type() { diff --git a/src/plaintext.cpp b/src/plaintext.cpp @@ -1,4 +1,5 @@ #include "../include/plaintext.hpp" +#include "../include/shared.hpp" #include <cstdint> Plaintext::Plaintext(std::string input) : text(input) {} @@ -8,7 +9,7 @@ std::string Plaintext::textToDraw() { } uint8_t Plaintext::getColor() { - return 15; + return COLOR_PLAINTEXT; } LineType Plaintext::type() { diff --git a/src/quote.cpp b/src/quote.cpp @@ -1,4 +1,5 @@ #include "../include/quote.hpp" +#include "../include/shared.hpp" #include "../include/utils.hpp" #include <cstdint> #include <ncurses.h> @@ -14,7 +15,7 @@ std::string Quote::textToDraw() { } uint8_t Quote::getColor() { - return COLOR_MAGENTA; + return COLOR_QUOTE; } LineType Quote::type() { diff --git a/src/render.cpp b/src/render.cpp @@ -195,7 +195,7 @@ void draw(DrawState& ds) { truncated += (char)toascii(ch); } - if(ds.issueText.size() > ds.columns) { + if((int)ds.issueText.size() > ds.columns) { truncated = truncated.substr(0,ds.columns - 3) + "..."; } diff --git a/src/shared.cpp b/src/shared.cpp @@ -5,6 +5,17 @@ int SITE_CACHE_LIMIT = 10; int THREAD_NUM = 4; int MAX_WIDTH = 80; int CACHE_SIZE = 500; + uint8_t COLOR_LINK = 159; uint8_t COLOR_PREFORMATTED = 201; +uint8_t COLOR_QUOTE = 5; + +uint8_t COLOR_H3 = 6; +uint8_t COLOR_H2 = 2; +uint8_t COLOR_H1 = 1; + +uint8_t COLOR_LIST_ITEM = 15; +uint8_t COLOR_FORMAT_SWITCH = 7; +uint8_t COLOR_PLAINTEXT = 15; + int RESPONSE_SIZE_LIMIT_MB = 5; // This will truncate at the specified size.