diff options
author | Daniel Carl <danielcarl@gmx.de> | 2013-04-14 21:53:12 +0200 |
---|---|---|
committer | Daniel Carl <danielcarl@gmx.de> | 2013-04-14 21:54:28 +0200 |
commit | a0889c549896ea1c1ca541530143e19526023ac4 (patch) | |
tree | 0789aa39699a9b310b81c6abc833d586d51a0c38 /src | |
parent | 07c0a84ec428f6e47226d74db4869d1f0b8b086f (diff) |
Added new hinting mode to open form fields with editor (#15).
Diffstat (limited to 'src')
-rw-r--r-- | src/command.c | 1 | ||||
-rw-r--r-- | src/config.h | 1 | ||||
-rw-r--r-- | src/hints.c | 11 | ||||
-rw-r--r-- | src/hints.h | 3 | ||||
-rw-r--r-- | src/hints.js | 8 |
5 files changed, 21 insertions, 3 deletions
diff --git a/src/command.c b/src/command.c index 48cf36c..df05a23 100644 --- a/src/command.c +++ b/src/command.c @@ -88,6 +88,7 @@ static CommandInfo cmd_list[] = { {"hint-yank", command_hints, {HINTS_TYPE_LINK | HINTS_PROCESS_YANK, ";y"}}, {"hint-image-open", command_hints, {HINTS_TYPE_IMAGE | HINTS_PROCESS_OPEN, ";i"}}, {"hint-image-tabopen", command_hints, {HINTS_TYPE_IMAGE | HINTS_PROCESS_OPEN | HINTS_OPEN_NEW, ";I"}}, + {"hint-editor", command_hints, {HINTS_TYPE_EDITABLE, ";e"}}, {"hint-focus-next", command_hints_focus, {0}}, {"hint-focus-prev", command_hints_focus, {1}}, {"yank-uri", command_yank, {COMMAND_YANK_PRIMARY | COMMAND_YANK_SECONDARY | COMMAND_YANK_URI}}, diff --git a/src/config.h b/src/config.h index 325cf2c..15e0072 100644 --- a/src/config.h +++ b/src/config.h @@ -75,6 +75,7 @@ const char *default_config[] = { "nmap ;y=hint-yank", "nmap ;i=hint-image-open", "nmap ;I=hint-image-tabopen", + "nmap ;e=hint-editor", "nmap y=yank-uri", "nmap Y=yank-selection", "nmap p=open-clipboard", diff --git a/src/hints.c b/src/hints.c index 5ca08fb..bbab0dd 100644 --- a/src/hints.c +++ b/src/hints.c @@ -79,7 +79,13 @@ void hints_create(const char *input, guint mode, const guint prefixLength) char type, usage; /* convert the mode into the type chare used in the hint script */ - type = mode & HINTS_TYPE_LINK ? 'l' : 'i'; + if (HINTS_GET_TYPE(mode) == HINTS_TYPE_LINK) { + type = 'l'; + } else if (HINTS_GET_TYPE(mode) == HINTS_TYPE_EDITABLE) { + type = 'e'; + } else { + type = 'i'; + } if (mode & HINTS_PROCESS_OPEN) { usage = mode & HINTS_OPEN_NEW ? 'T' : 'O'; @@ -148,6 +154,9 @@ static void run_script(char *js) vb_set_mode(VB_MODE_NORMAL, true); } else if (!strncmp(value, "INSERT:", 7)) { vb_set_mode(VB_MODE_INSERT, false); + if (HINTS_GET_TYPE(mode) == HINTS_TYPE_EDITABLE) { + command_editor(NULL); + } } else if (!strncmp(value, "DATA:", 5)) { Arg a = {0}; char *v = (value + 5); diff --git a/src/hints.h b/src/hints.h index 17ef146..5146036 100644 --- a/src/hints.h +++ b/src/hints.h @@ -22,11 +22,12 @@ #include "main.h" -#define HINTS_GET_TYPE(n) ((n) & (HINTS_TYPE_LINK | HINTS_TYPE_IMAGE)) +#define HINTS_GET_TYPE(n) ((n) & (HINTS_TYPE_LINK | HINTS_TYPE_IMAGE | HINTS_TYPE_EDITABLE)) enum { HINTS_TYPE_LINK = 1, HINTS_TYPE_IMAGE = 2, + HINTS_TYPE_EDITABLE = 3, HINTS_PROCESS_INPUT = (1 << 2), HINTS_PROCESS_YANK = (1 << 3), HINTS_PROCESS_OPEN = (1 << 4), diff --git a/src/hints.js b/src/hints.js index b00aebb..224426f 100644 --- a/src/hints.js +++ b/src/hints.js @@ -1,4 +1,4 @@ -/* mode: l - links, i - images */ +/* mode: l - links, i - images, e - editables */ /* usage: O - open, T - open in new window, U - use source */ function VimbHints(mode, usage, bg, bgf, fg, style, maxHints) { @@ -334,6 +334,12 @@ function VimbHints(mode, usage, bg, bgf, fg, style, maxHints) } else { return "//*[(@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @role='link' or @href) and contains(., '" + s + "')] | //input[not(@type='hidden') and contains(., '" + s + "')] | //a[@href and contains(., '" + s + "')] | //area[contains(., '" + s + "')] | //textarea[contains(., '" + s + "')] | //button[contains(@value, '" + s + "')] | //select[contains(., '" + s + "')]"; } + case "e": + if (s === "") { + return "//input[@type='text'] | //textarea"; + } else { + return "//input[@type='text' and contains(., '" + s + "')] | //textarea[contains(., '" + s + "')]"; + } case "i": if (s === "") { return "//img[@src]"; |