summaryrefslogtreecommitdiff
path: root/src/app.c
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-02-16 08:50:37 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-02-16 08:50:37 +0200
commit902ccb3d65db97ad4f8d17279806b0290d7ca332 (patch)
tree97ef9f469a2812e11ac44722e3b78da1f15dd6a1 /src/app.c
parent180e0add685b16a916292d775b7497e8443048e7 (diff)
Search engine queries via the navbar
Any text that doesn't look like a URL is passed onto the configured search URL as a query string. IssueID #157
Diffstat (limited to 'src/app.c')
-rw-r--r--src/app.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/app.c b/src/app.c
index 3d3dc6f8..b5eb5688 100644
--- a/src/app.c
+++ b/src/app.c
@@ -227,6 +227,7 @@ static iString *serializePrefs_App_(const iApp *d) {
227 appendFormat_String(str, "proxy.gopher address:%s\n", cstr_String(&d->prefs.gopherProxy)); 227 appendFormat_String(str, "proxy.gopher address:%s\n", cstr_String(&d->prefs.gopherProxy));
228 appendFormat_String(str, "proxy.http address:%s\n", cstr_String(&d->prefs.httpProxy)); 228 appendFormat_String(str, "proxy.http address:%s\n", cstr_String(&d->prefs.httpProxy));
229 appendFormat_String(str, "downloads path:%s\n", cstr_String(&d->prefs.downloadDir)); 229 appendFormat_String(str, "downloads path:%s\n", cstr_String(&d->prefs.downloadDir));
230 appendFormat_String(str, "searchurl address:%s\n", cstr_String(&d->prefs.searchUrl));
230 return str; 231 return str;
231} 232}
232 233
@@ -937,6 +938,8 @@ static iBool handlePrefsCommands_(iWidget *d, const char *cmd) {
937 isSelected_Widget(findChild_Widget(d, "prefs.ostheme"))); 938 isSelected_Widget(findChild_Widget(d, "prefs.ostheme")));
938 postCommandf_App("decodeurls arg:%d", 939 postCommandf_App("decodeurls arg:%d",
939 isSelected_Widget(findChild_Widget(d, "prefs.decodeurls"))); 940 isSelected_Widget(findChild_Widget(d, "prefs.decodeurls")));
941 postCommandf_App("searchurl address:%s",
942 cstr_String(text_InputWidget(findChild_Widget(d, "prefs.searchurl"))));
940 postCommandf_App("cachesize.set arg:%d", 943 postCommandf_App("cachesize.set arg:%d",
941 toInt_String(text_InputWidget(findChild_Widget(d, "prefs.cachesize")))); 944 toInt_String(text_InputWidget(findChild_Widget(d, "prefs.cachesize"))));
942 postCommandf_App("proxy.gemini address:%s", 945 postCommandf_App("proxy.gemini address:%s",
@@ -1122,6 +1125,15 @@ iBool willUseProxy_App(const iRangecc scheme) {
1122 return schemeProxy_App(scheme) != NULL; 1125 return schemeProxy_App(scheme) != NULL;
1123} 1126}
1124 1127
1128const iString *searchQueryUrl_App(const iString *queryStringUnescaped) {
1129 iApp *d = &app_;
1130 if (isEmpty_String(&d->prefs.searchUrl)) {
1131 return collectNew_String();
1132 }
1133 const iString *escaped = urlEncode_String(queryStringUnescaped);
1134 return collectNewFormat_String("%s?%s", cstr_String(&d->prefs.searchUrl), cstr_String(escaped));
1135}
1136
1125iBool handleCommand_App(const char *cmd) { 1137iBool handleCommand_App(const char *cmd) {
1126 iApp *d = &app_; 1138 iApp *d = &app_;
1127 if (equal_Command(cmd, "config.error")) { 1139 if (equal_Command(cmd, "config.error")) {
@@ -1292,6 +1304,10 @@ iBool handleCommand_App(const char *cmd) {
1292 } 1304 }
1293 return iTrue; 1305 return iTrue;
1294 } 1306 }
1307 else if (equal_Command(cmd, "searchurl")) {
1308 setCStr_String(&d->prefs.searchUrl, suffixPtr_Command(cmd, "address"));
1309 return iTrue;
1310 }
1295 else if (equal_Command(cmd, "proxy.gemini")) { 1311 else if (equal_Command(cmd, "proxy.gemini")) {
1296 setCStr_String(&d->prefs.geminiProxy, suffixPtr_Command(cmd, "address")); 1312 setCStr_String(&d->prefs.geminiProxy, suffixPtr_Command(cmd, "address"));
1297 return iTrue; 1313 return iTrue;
@@ -1474,6 +1490,7 @@ iBool handleCommand_App(const char *cmd) {
1474 setText_InputWidget(findChild_Widget(dlg, "prefs.cachesize"), 1490 setText_InputWidget(findChild_Widget(dlg, "prefs.cachesize"),
1475 collectNewFormat_String("%d", d->prefs.maxCacheSize)); 1491 collectNewFormat_String("%d", d->prefs.maxCacheSize));
1476 setToggle_Widget(findChild_Widget(dlg, "prefs.decodeurls"), d->prefs.decodeUserVisibleURLs); 1492 setToggle_Widget(findChild_Widget(dlg, "prefs.decodeurls"), d->prefs.decodeUserVisibleURLs);
1493 setText_InputWidget(findChild_Widget(dlg, "prefs.searchurl"), &d->prefs.searchUrl);
1477 setText_InputWidget(findChild_Widget(dlg, "prefs.proxy.gemini"), &d->prefs.geminiProxy); 1494 setText_InputWidget(findChild_Widget(dlg, "prefs.proxy.gemini"), &d->prefs.geminiProxy);
1478 setText_InputWidget(findChild_Widget(dlg, "prefs.proxy.gopher"), &d->prefs.gopherProxy); 1495 setText_InputWidget(findChild_Widget(dlg, "prefs.proxy.gopher"), &d->prefs.gopherProxy);
1479 setText_InputWidget(findChild_Widget(dlg, "prefs.proxy.http"), &d->prefs.httpProxy); 1496 setText_InputWidget(findChild_Widget(dlg, "prefs.proxy.http"), &d->prefs.httpProxy);