diff options
-rw-r--r-- | xxxterm.1 | 8 | ||||
-rw-r--r-- | xxxterm.c | 26 | ||||
-rw-r--r-- | xxxterm.conf | 1 |
3 files changed, 28 insertions, 7 deletions
diff --git a/xxxterm.1 b/xxxterm.1 index f97f053..48ff5b0 100644 --- a/xxxterm.1 +++ b/xxxterm.1 @@ -639,6 +639,14 @@ Enable or disable showing tabs. Enable or disable showing the url and toolbar. .It Cm show_statusbar Enable or disable showing the status bar. +.It Cm guess_search +When enabled +.Nm +will try to guess if the string you entered, in the URI entry widget or +the command widget, is term you want to search for using search_string +(see above). If the string does not contain a dot nor a slash, is not a +path to a local file and does not resolves to an IP then it is assumed +to be a search term. .It Cm single_instance If set only one .Nm diff --git a/xxxterm.c b/xxxterm.c index a1e9002..ddd0d6f 100644 --- a/xxxterm.c +++ b/xxxterm.c @@ -475,6 +475,7 @@ int save_global_history = 0; /* save global history to disk */ char *user_agent = NULL; int save_rejected_cookies = 0; time_t session_autosave = 0; +int guess_search = 0; struct settings; int set_download_dir(struct settings *, char *); @@ -579,6 +580,7 @@ struct settings { { "single_instance", XT_S_INT, XT_SF_RESTART , &single_instance, NULL, NULL }, { "show_tabs", XT_S_INT, 0, &show_tabs, NULL, NULL }, { "show_url", XT_S_INT, 0, &show_url, NULL, NULL }, + { "guess_search", XT_S_INT, 0, &guess_search, NULL, NULL }, { "show_statusbar", XT_S_INT, 0, &show_statusbar, NULL, NULL }, { "ssl_ca_file", XT_S_STR, 0 , NULL, &ssl_ca_file, NULL }, { "ssl_strict_certs", XT_S_INT, 0 , &ssl_strict_certs, NULL, NULL }, @@ -1024,13 +1026,23 @@ guess_url_type(char *url_in) if (url_out != NULL) return (url_out); - /* If the string isn't a path to a local file and there is no dot in the - string, assume the user wants to search for the string. */ - if (stat(url_in, &sb) != 0 && strchr(url_in, '.') == NULL) { - enc_search = soup_uri_encode(url_in, XT_RESERVED_CHARS); - url_out = g_strdup_printf(search_string, enc_search); - g_free(enc_search); - return (url_out); + if (guess_search) { + + /* If there is no dot nor slash in the string and it isn't a + * path to a local file and doesn't resolves to an IP, assume + * that the user wants to search for the string. + */ + + if (strchr(url_in, '.') == NULL && + strchr(url_in, '/') == NULL && + stat(url_in, &sb) != 0 && + gethostbyname(url_in) == NULL) { + + enc_search = soup_uri_encode(url_in, XT_RESERVED_CHARS); + url_out = g_strdup_printf(search_string, enc_search); + g_free(enc_search); + return (url_out); + } } /* XXX not sure about this heuristic */ diff --git a/xxxterm.conf b/xxxterm.conf index f70c8c3..641131e 100644 --- a/xxxterm.conf +++ b/xxxterm.conf @@ -23,6 +23,7 @@ show_tabs = 1 show_url = 1 show_statusbar = 0 session_autosave = 0 +guess_search = 0 # note that cookies_enabled must be set to 1 for this to work save_rejected_cookies = 0 |