Re: [Vimprobable-users] [patch] to escape auto focused inputs on page load
Vimprobable is a lean web browser optimised for full keyboard control
Brought to you by:
hanness
From: Matthew C. <je...@gm...> - 2012-01-22 18:58:05
|
Hello all, Further testing shows a bug when changing modes that was causing PASS-THROUGH mode to be set when mousing over certain links (not sure how - I guess my lazy coding). I have rewritten the problematic statement and attached is the good patch file for main.c (the old config.h patch file should still be good). Let me know of any bugs you may find if you do try this out. Thanks, -Matt On Sat, Jan 21, 2012 at 02:20:48AM -0500, Matthew Carter wrote: > Hello all, > > My best patch set to date. > > These two patches do the following: > > Add toggleable option: > > set escapeinput=[true|false] > > With true (default) the following new behavior happens: > > Any auto-focused inputs are immediately escaped on page load (done > inside main.c so it no longer relies on a javascript call). > > With false the new behavior above is ignored. > > In both modes, vimprobable2 will now correctly see focused fields > and change to "insert mode" so you can type in the highlighted field > (finally no more being stuck in an insert box without being in "insert > mode"). > > This also works with any unique website features which put the user into an > input box (such as duckduckgo.com's bang syntax box to the right of main > search bar) and will properly convert to "insert mode". > > Lastly, > > I set the default search engine to duckduckgo (also changed default > command bar color to a darker theme). > > Hannes, hopefully this saved you some work. With these changes I have > hopefully resolved some annoyances of vimprobable2 for all. > > Next up I want to add password saving (possibly just unsecure/plaintext). > Has this been done in the past and discarded due to fattening up the code? > > Also how do I get my name added to LICENSE? :) > > Thanks, > -Matthew Carter > > On Sat, Jan 21, 2012 at 12:56:29PM +0600, Alexander Aksarin wrote: > > On 20:40 Fri 20 Jan , Hannes Schüller wrote: > > > Matt Carter <je...@gm...> wrote: > > > > Patch for hinting.js file, not sure if anyone else will find it useful > > > > but it escapes auto-focused input fields (such as on google.com) which > > > > mess up the current vimprobable2 mode detection (focused input without > > > > being in insert mode). > > Thank You. Auto-focus input fields is annoying. > > > > > This is an interesting one. I think there are two options, out of which > > > this is one. The other way would be to actually go to INSERT mode > > > automatically if a form element is focused (which would mean > > > re-introducing focus watchers in some limited way). > > > > > > Everyone - which behaviour is preferable? > > I prefer first, because it's more predictable and confortable for me. > > > > ------------------------------------------------------------------------------ > > Try before you buy = See our experts in action! > > The most comprehensive online learning library for Microsoft developers > > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, > > Metro Style Apps, more. Free future releases when you subscribe now! > > http://p.sf.net/sfu/learndevnow-dev2 > > _______________________________________________ > > Vimprobable-users mailing list > > Vim...@li... > > https://lists.sourceforge.net/lists/listinfo/vimprobable-users > > -- > Matthew Carter > je...@gm... > diff --git a/config.h b/config.h > index b2f8e78..0e8ef4f 100644 > --- a/config.h > +++ b/config.h > @@ -28,8 +28,8 @@ char sslcolor[MAX_SETTING_SIZE] = "#000000"; /* color for sta > > /* normal, warning, error */ > static const char *urlboxfont[] = { "monospace normal 8", "monospace normal 8", "monospace bold 8"}; > -static const char *urlboxcolor[] = { NULL, "#ff0000", "#ffffff" }; > -static const char *urlboxbgcolor[] = { NULL, NULL, "#ff0000" }; > +static const char *urlboxcolor[] = { "#ffffff", "#ff0000", "#ffffff" }; > +static const char *urlboxbgcolor[] = { "#222222", NULL, "#ff0000" }; > > /* normal, error */ > static const char *completionfont[] = { "monospace normal 8", "monospace bold 8" }; > @@ -82,13 +82,14 @@ gboolean complete_case_sensitive = TRUE; > > /* search engines */ > static Searchengine searchengines[] = { > + { "d", "http://duckduckgo.com/?q=%s" }, > { "i", "http://ixquick.com/do/metasearch.pl?query=%s" }, > { "s", "https://ssl.scroogle.org/cgi-bin/nbbwssl.cgi?Gw=%s" }, > { "w", "https://secure.wikimedia.org/wikipedia/en/w/index.php?title=Special%%3ASearch&search=%s&go=Go" }, > { "wd", "https://secure.wikimedia.org/wikipedia/de/w/index.php?title=Special%%3ASearch&search=%s&go=Go" }, > }; > > -static char defaultsearch[MAX_SETTING_SIZE] = "i"; > +static char defaultsearch[MAX_SETTING_SIZE] = "d"; > > /* command mapping */ > Command commands[COMMANDSIZE] = { > @@ -185,4 +186,5 @@ static Setting browsersettings[] = { > { "statusbar", NULL, "", FALSE, TRUE, FALSE, FALSE }, > { "inputbox", NULL, "", FALSE, TRUE, FALSE, FALSE }, > { "completioncase", NULL, "", FALSE, TRUE, FALSE, FALSE }, > + { "escapeinput", NULL, "", FALSE, TRUE, FALSE, FALSE }, > }; > diff --git a/main.c b/main.c > index f106245..fe21823 100644 > --- a/main.c > +++ b/main.c > @@ -6,6 +6,7 @@ > (c) 2010-2011 by Thomas Adam > (c) 2011 by Albert Kim > (c) 2011 by Daniel Carl > + (c) 2012 by Matthew Carter > see LICENSE file > */ > > @@ -141,6 +142,8 @@ static char followTarget[8] = ""; > char *error_msg = NULL; > char *config_base = NULL; > > +static gboolean escape_input_on_load = TRUE; > + > GList *activeDownloads; > > #include "config.h" > @@ -214,6 +217,14 @@ webview_load_committed_cb(WebKitWebView *webview, WebKitWebFrame *frame, gpointe > > void > webview_load_finished_cb(WebKitWebView *webview, WebKitWebFrame *frame, gpointer user_data) { > + if(escape_input_on_load) { > + Arg a = { .i = Silent, .s = g_strdup("hints.clearFocus();") }; > + script(&a); > + g_free(a.s); > + a.i = ModeNormal; > + a.s = NULL; > + set(&a); > + } > if (HISTORY_MAX_ENTRIES > 0) > history(); > update_state(); > @@ -638,7 +649,16 @@ notify_event_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data) { > Arg a = { .i = ModeNormal }; > set(&a); > } > - } > + } else { > + gchar *value = NULL, *message = NULL; > + jsapi_evaluate_script("window.getSelection().focusNode", &value, &message); > + Arg a; > + if(!strcmp(value, "[object HTMLFormElement]")) > + a.i = ModeInsert; > + g_free(value); > + g_free(message); > + set(&a); > + } > return FALSE; > } > > @@ -1921,7 +1941,9 @@ process_set_line(char *line) { > gtk_widget_set_visible(GTK_WIDGET(statusbar), boolval); > } else if (strlen(my_pair.what) == 8 && strncmp("inputbox", my_pair.what, 8) == 0) { > gtk_widget_set_visible(inputbox, boolval); > - } > + } else if (strlen(my_pair.what) == 11 && strncmp("escapeinput", my_pair.what, 11) == 0) { > + escape_input_on_load = boolval; > + } > > /* reload page? */ > if (browsersettings[i].reload) -- Matthew Carter je...@gm... |