foreseen

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

commit b5da7c6c76348ff0c4097b9ef72da3cfdaa1270b
parent 51fc7aff41df5b57877e09e8b6c0849e98bda9f0
Author: Andrew Laack <andrew@laack.co>
Date:   Tue, 22 Sep 2026 14:47:18 -0500

Improved back / forward external semantics

Diffstat:
Msrc/browser.cpp | 9++++++++-
Msrc/main.cpp | 9---------
2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/src/browser.cpp b/src/browser.cpp @@ -3,7 +3,6 @@ #include "../include/gemini-client.hpp" #include "../include/utils.hpp" #include <cstddef> -#include <iostream> #include <optional> #include <utility> #include <vector> @@ -116,9 +115,17 @@ void Browser::followLinkNumber(int linkToFollow) { void Browser::goBack() { previousIdx -= 1; goToSite(this->siteHistory[previousIdx]->getLinkDestination().to_string(), false); + while(!(this->getCurrentSite()->getStatusCode() >= 20 && this->getCurrentSite()->getStatusCode() <= 29)) { + previousIdx -= 1; + goToSite(this->siteHistory[previousIdx]->getLinkDestination().to_string(), false); + } } void Browser::goForward() { previousIdx += 1; goToSite(siteHistory[previousIdx]->getLinkDestination().to_string(), false); + while(!(this->getCurrentSite()->getStatusCode() >= 20 && this->getCurrentSite()->getStatusCode() <= 29)) { + previousIdx += 1; + goToSite(this->siteHistory[previousIdx]->getLinkDestination().to_string(), false); + } } diff --git a/src/main.cpp b/src/main.cpp @@ -222,18 +222,12 @@ int main(int argc, char** argv) { y -= LINES / 2; } else if(input == 'f') { b.goForward(); - while(!(b.getCurrentSite()->getStatusCode() >= 20 && b.getCurrentSite()->getStatusCode() <= 29)) { - b.goForward(); - } current = b.renderSite(); removeNonAscii(current); } else if(input == 'b') { b.goBack(); - while(!(b.getCurrentSite()->getStatusCode() >= 20 && b.getCurrentSite()->getStatusCode() <= 29)) { - b.goBack(); - } current = b.renderSite(); removeNonAscii(current); @@ -258,9 +252,6 @@ int main(int argc, char** argv) { Direction dir = handleRedir(ds); if(dir == BACKWARD) { b.goBack(); - while(!(b.getCurrentSite()->getStatusCode() >= 20 && b.getCurrentSite()->getStatusCode() <= 29)) { - b.goBack(); - } } else { b.goToSite(b.getCurrentSite()->getMeta(),true); }