commit 24d4aa82f41fdf3b990dd542ba6e8fee8432516b
parent 62f6e0d8e4d1f1da4b96f4596c23c608f2f15ee5
Author: Andrew Laack <andrew@laack.co>
Date: Wed, 23 Sep 2026 22:15:57 -0500
Simple heuristic to check if we want to 1) use search engine 2) go directly to a site 3) follow a link
Diffstat:
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/src/main.cpp b/src/main.cpp
@@ -1,4 +1,5 @@
#include "../include/browser.hpp"
+#include <iostream>
#include <malloc.h>
#include "../include/utils.hpp"
#include <algorithm>
@@ -9,6 +10,9 @@
#include <utility>
#include <vector>
+
+const std::string DEFAULT_SEARCH_ENGINE="gemini://tlgs.one/search?";
+
// we do this because this is built against ncurses, would be nice to do away w/ this
// bc ppl use lots of emojis on gemini sites.
@@ -92,7 +96,13 @@ void draw(DrawState ds) {
move(0,(COLS / 2) - (ds.header.size() / 2) );
attron(A_BOLD);
- addstr(ds.header.c_str());
+
+ if(ds.header.size() < COLS) {
+ addstr(ds.header.c_str());
+ } else {
+ addstr((ds.header.substr(0,COLS-3) + "...").c_str());
+ }
+
attroff(A_BOLD);
for(int i = ds.y;i-ds.y+1 < LINES && i < ds.strLs.size(); ++i) {
@@ -316,7 +326,11 @@ int main(int argc, char** argv) {
} catch (...) {
if(locationToGo != "") {
if(locationToGo.find(":") == -1) { // TODO: Is this how we which scheme was specified?
- locationToGo = "gemini://" + locationToGo;
+ if(locationToGo.find('.') != -1 && urlEncode(locationToGo) == locationToGo) { // hmm, this feels weak. Like I can't search something if I add a period?
+ locationToGo = "gemini://" + locationToGo;
+ } else {
+ locationToGo = DEFAULT_SEARCH_ENGINE + urlEncode(locationToGo);
+ }
}
b.goToSite(locationToGo, true);
}
@@ -345,9 +359,9 @@ int main(int argc, char** argv) {
removeNonAscii(current);
current = breakLines(current,COLS);
-
y = std::max(0,y);
y = std::max(0,std::min(y,lowestPos(current)));
+
ds.y = y;
ds.strLs = current;
auto* clk = b.getCurrentLink();