.B quit, q
Close the browser.
.TP
+.B focus-input
+Set the cursor to the first found editable element on the page and switch
+PROJECT into insert mode.
+.TP
.B source
Toggle between normal view and source view for the current page.
.TP
.B g\-F
Opend the Web Inspector for current page.
.TP
+.B g\-i
+Set cursor to the first editable element in the page and switch to insert
+mode.
+.TP
.B :
Start command mode and print `:' to the input box.
.TP
{"queue-clear", NULL, command_queue, {COMMAND_QUEUE_CLEAR}},
#endif
{"pass-through", NULL, command_mode, {VB_MODE_PASSTHROUGH}},
+ {"focus-input", NULL, command_focusinput, {0}},
};
static void editor_resume(GPid pid, int status, OpenEditorData *data);
return vb_set_mode(arg->i, false);
}
+gboolean command_focusinput(const Arg *arg)
+{
+ if (dom_focus_input(vb.gui.webview)) {
+ vb_set_mode(VB_MODE_INSERT, false);
+
+ return true;
+ }
+ return false;
+}
+
gboolean command_editor(const Arg *arg)
{
char *file_path = NULL;
gboolean command_queue(const Arg *arg);
#endif
gboolean command_mode(const Arg *arg);
+gboolean command_focusinput(const Arg *arg);
#endif /* end of include guard: _COMMAND_H */
"nmap gu=descent",
"nmap gU=descent!",
"nmap <ctrl-z>=pass-through",
+ "nmap gi=focus-input",
"cmap <tab>=next",
"cmap <shift-tab>=prev",
"cmap <up>=hist-prev",
}
}
+/**
+ * Set focus to the first found editable element and returns if a element was
+ * found to focus.
+ */
+gboolean dom_focus_input(WebKitWebView *view)
+{
+ gboolean found = false;
+ gulong count;
+ WebKitDOMDocument *doc = webkit_web_view_get_dom_document(view);
+ WebKitDOMNodeList *elems = webkit_dom_document_get_elements_by_tag_name(doc, "*");
+ Element *elem;
+
+ count = webkit_dom_node_list_get_length(elems);
+ for (int i = 0; i < count; i++) {
+ elem = WEBKIT_DOM_ELEMENT(webkit_dom_node_list_item(elems, i));
+
+ if (dom_is_editable(elem)) {
+ webkit_dom_element_focus(elem);
+ found = true;
+ break;
+ }
+ }
+ g_object_unref(elems);
+
+ return found;
+}
+
/**
* Indicates if the given dom element is an editable element like text input,
* password or textarea.
void dom_check_auto_insert(WebKitWebView *view);
void dom_clear_focus(WebKitWebView *view);
+gboolean dom_focus_input(WebKitWebView *view);
gboolean dom_is_editable(Element *element);
Element *dom_get_active_element(WebKitWebView *view);
const char *dom_editable_element_get_value(Element *element);