diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-16 08:50:37 +0200 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-02-16 08:50:37 +0200 |
commit | 902ccb3d65db97ad4f8d17279806b0290d7ca332 (patch) | |
tree | 97ef9f469a2812e11ac44722e3b78da1f15dd6a1 /src/ui/window.c | |
parent | 180e0add685b16a916292d775b7497e8443048e7 (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/ui/window.c')
-rw-r--r-- | src/ui/window.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/ui/window.c b/src/ui/window.c index cd813acb..563d57ae 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -47,6 +47,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
47 | 47 | ||
48 | #include <the_Foundation/file.h> | 48 | #include <the_Foundation/file.h> |
49 | #include <the_Foundation/path.h> | 49 | #include <the_Foundation/path.h> |
50 | #include <the_Foundation/regexp.h> | ||
50 | #include <SDL_hints.h> | 51 | #include <SDL_hints.h> |
51 | #include <SDL_timer.h> | 52 | #include <SDL_timer.h> |
52 | #include <SDL_syswm.h> | 53 | #include <SDL_syswm.h> |
@@ -419,9 +420,14 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { | |||
419 | !isFocused_Widget(findWidget_App("lookup"))) { | 420 | !isFocused_Widget(findWidget_App("lookup"))) { |
420 | iString *newUrl = copy_String(text_InputWidget(url)); | 421 | iString *newUrl = copy_String(text_InputWidget(url)); |
421 | trim_String(newUrl); | 422 | trim_String(newUrl); |
422 | postCommandf_App( | 423 | if (!isEmpty_String(&prefs_App()->searchUrl) && !isLikelyUrl_String(newUrl)) { |
423 | "open url:%s", | 424 | postCommandf_App("open url:%s", cstr_String(searchQueryUrl_App(newUrl))); |
424 | cstr_String(absoluteUrl_String(&iStringLiteral(""), collect_String(newUrl)))); | 425 | } |
426 | else { | ||
427 | postCommandf_App( | ||
428 | "open url:%s", | ||
429 | cstr_String(absoluteUrl_String(&iStringLiteral(""), collect_String(newUrl)))); | ||
430 | } | ||
425 | return iTrue; | 431 | return iTrue; |
426 | } | 432 | } |
427 | } | 433 | } |
@@ -1168,7 +1174,7 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) { | |||
1168 | //updateRootSize_Window_(d, iTrue); | 1174 | //updateRootSize_Window_(d, iTrue); |
1169 | invalidate_Window_(d); | 1175 | invalidate_Window_(d); |
1170 | d->isMinimized = iFalse; | 1176 | d->isMinimized = iFalse; |
1171 | //printf("restored %d\n", snap_Window(d)); fflush(stdout); | 1177 | printf("restored %d\n", snap_Window(d)); fflush(stdout); |
1172 | return iTrue; | 1178 | return iTrue; |
1173 | case SDL_WINDOWEVENT_MINIMIZED: | 1179 | case SDL_WINDOWEVENT_MINIMIZED: |
1174 | d->isMinimized = iTrue; | 1180 | d->isMinimized = iTrue; |