Allow to set query string for hint commands.
authorDaniel Carl <danielcarl@gmx.de>
Mon, 17 Jun 2013 19:28:06 +0000 (21:28 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Mon, 17 Jun 2013 20:46:17 +0000 (22:46 +0200)
The feature to define only the prefix to be shown in the inputbox to show
which hinting mode is active, we now replace this by a static text in favor to
call the hinting command with a initial query like `:hint-link foo`.

doc/vimb.1.txt
src/command.c

index ec85efa..2eb8aec 100644 (file)
@@ -204,31 +204,40 @@ Remove a Input Mode keybinding.
 Remove a Command Mode keybinding.
 
 .SS Hints
-.TP
-.BI "hint-link [" PREFIX "], hint-link-new [" PREFIX ]
-Start hinting to open link into current or new window. If \fIPREFIX\fP is given,
-print this into the inputbox, default '.' and ','.
-.TP
-.BI "hint-input-open [" PREFIX "], hint-input-tabopen [" PREFIX ]
+The hinting is the way to do what you would do with the mouse in common
+mouse-driven browsers. Open url, yank uri, save page and so on. If the hinting
+is started, the relevant elements on the page will be marked by numbered
+labels. Hints can be selected by using <tab> or <ctrl-tab>, by typing the
+number of the label, or filtering the elements by some text that is part of
+the hinted element (like url, link text, button label) and any combination of
+this methods. If <enter> is pressed, the current active hint will be fired. If
+only one possible hint remains, this will be fired automatically.
+.TP
+Syntax: ":hint-{TYPE} [\fIQUERY\fP]"
+If \fIQUERY\fP is given, this is used to filter hints contents initially. Note
+that the \fIQUERY\fP can only be used to filter the hints by their content and
+not by their numeric hint label. On the other hand \fIQUERY\fP is the only way
+to match hints with numeric content.
+.TP
+.BI "hint-link [" QUERY "], hint-link-new [" QUERY ]
+Start hinting to open link into current or new window.
+.TP
+.BI "hint-input-open [" QUERY "], hint-input-tabopen [" QUERY ]
 Start hinting to fill the inputbox with ":open {hintedLinkUrl}" or ":tabopen
-{hintedLinkUrl}". If \fIPREFIX\fP is given, print this into the inputbox,
-default ';o' and ';t'.
+{hintedLinkUrl}".
 .TP
-.BI "hint-yank [" PREFIX ]
+.BI "hint-yank [" QUERY ]
 Start hinting to yank the hinted link url into the primary and secondary
-clipboard. If \fIPREFIX\fP is given, print this into the inputbox, default ';y'.
+clipboard.
 .TP
-.BI "hint-image-open [" PREFIX "], hint-image-tabopen [" PREFIX ]
-Start hinting to open images into current or new window. If \fIPREFIX\fP is
-given, print this into the inputbox, default ';i' and ';I'.
+.BI "hint-image-open [" QUERY "], hint-image-tabopen [" QUERY ]
+Start hinting to open images into current or new window.
 .TP
-.BI "hint-editor [" PREFIX "]"
-Start hinting to open inputboxes or textareas with external editor. If
-\fIPREFIX\fP is given, print this into the inputbox, default ';e'.
+.BI "hint-editor [" QUERY "]"
+Start hinting to open inputboxes or textareas with external editor.
 .TP
-.BI "hint-save [" PREFIX "]"
-Start hinting to download hinted links into configured download directory. If
-\fIPREFIX\fP is given, print this into the inputbox, default ';s'.
+.BI "hint-save [" QUERY "]"
+Start hinting to download hinted links into configured download directory.
 
 .SS Yank
 .TP
index 2eed611..8a70775 100644 (file)
@@ -86,15 +86,15 @@ static CommandInfo cmd_list[] = {
     {"cunmap",               NULL,    command_unmap,                {VB_MODE_COMMAND}},
     {"set",                  NULL,    command_set,                  {0}},
     {"inspect",              NULL,    command_inspect,              {0}},
-    {"hint-link",            NULL,    command_hints,                {HINTS_TYPE_LINK | HINTS_PROCESS_OPEN, "."}},
-    {"hint-link-new",        NULL,    command_hints,                {HINTS_TYPE_LINK | HINTS_PROCESS_OPEN | HINTS_OPEN_NEW, ","}},
-    {"hint-input-open",      NULL,    command_hints,                {HINTS_TYPE_LINK | HINTS_PROCESS_INPUT, ";o"}},
-    {"hint-input-tabopen",   NULL,    command_hints,                {HINTS_TYPE_LINK | HINTS_PROCESS_INPUT | HINTS_OPEN_NEW, ";t"}},
-    {"hint-yank",            NULL,    command_hints,                {HINTS_TYPE_LINK | HINTS_PROCESS_YANK, ";y"}},
-    {"hint-image-open",      NULL,    command_hints,                {HINTS_TYPE_IMAGE | HINTS_PROCESS_OPEN, ";i"}},
-    {"hint-image-tabopen",   NULL,    command_hints,                {HINTS_TYPE_IMAGE | HINTS_PROCESS_OPEN | HINTS_OPEN_NEW, ";I"}},
-    {"hint-editor",          NULL,    command_hints,                {HINTS_TYPE_EDITABLE, ";e"}},
-    {"hint-save",            NULL,    command_hints,                {HINTS_TYPE_LINK | HINTS_PROCESS_SAVE, ";s"}},
+    {"hint-link",            NULL,    command_hints,                {HINTS_TYPE_LINK | HINTS_PROCESS_OPEN}},
+    {"hint-link-new",        NULL,    command_hints,                {HINTS_TYPE_LINK | HINTS_PROCESS_OPEN | HINTS_OPEN_NEW}},
+    {"hint-input-open",      NULL,    command_hints,                {HINTS_TYPE_LINK | HINTS_PROCESS_INPUT}},
+    {"hint-input-tabopen",   NULL,    command_hints,                {HINTS_TYPE_LINK | HINTS_PROCESS_INPUT | HINTS_OPEN_NEW}},
+    {"hint-yank",            NULL,    command_hints,                {HINTS_TYPE_LINK | HINTS_PROCESS_YANK}},
+    {"hint-image-open",      NULL,    command_hints,                {HINTS_TYPE_IMAGE | HINTS_PROCESS_OPEN}},
+    {"hint-image-tabopen",   NULL,    command_hints,                {HINTS_TYPE_IMAGE | HINTS_PROCESS_OPEN | HINTS_OPEN_NEW}},
+    {"hint-editor",          NULL,    command_hints,                {HINTS_TYPE_EDITABLE}},
+    {"hint-save",            NULL,    command_hints,                {HINTS_TYPE_LINK | HINTS_PROCESS_SAVE}},
     {"yank-uri",             "yu",    command_yank,                 {VB_CLIPBOARD_PRIMARY | VB_CLIPBOARD_SECONDARY | COMMAND_YANK_URI}},
     {"yank-selection",       "ys",    command_yank,                 {VB_CLIPBOARD_PRIMARY | VB_CLIPBOARD_SECONDARY | COMMAND_YANK_SELECTION}},
     {"search-forward",       NULL,    command_search,               {VB_SEARCH_FORWARD}},
@@ -462,9 +462,37 @@ gboolean command_inspect(const Arg *arg)
 
 gboolean command_hints(const Arg *arg)
 {
-    vb_echo_force(VB_MSG_NORMAL, false, "%s", arg->s);
+    int mode = arg->i;
+    char *prefix = "";
+    /* set prefix string according to hint type */
+    switch (HINTS_GET_TYPE(mode)) {
+        case HINTS_TYPE_LINK:
+            if (mode & HINTS_PROCESS_OPEN) {
+                prefix = mode & HINTS_OPEN_NEW ? "," : ".";
+            } else if (mode & HINTS_PROCESS_INPUT) {
+                prefix = mode & HINTS_OPEN_NEW ? ";t" : ";o";
+            } else if (mode & HINTS_PROCESS_YANK) {
+                prefix = ";y";
+            } else if (mode & HINTS_PROCESS_SAVE) {
+                prefix = ";s";
+            }
+            break;
+
+        case HINTS_TYPE_IMAGE:
+            if (mode & HINTS_PROCESS_OPEN) {
+                prefix = mode & HINTS_OPEN_NEW ? ";I" : ";i";
+            }
+            break;
+
+        case HINTS_TYPE_EDITABLE:
+            prefix = ";e";
+            break;
+    }
+
+    vb_echo_force(VB_MSG_NORMAL, false, "%s%s", prefix, arg->s ? arg->s : "");
+
     /* mode will be set in hints_create - so we don't neet to do it here */
-    hints_create(NULL, arg->i, (arg->s ? strlen(arg->s) : 0));
+    hints_create(arg->s, arg->i, strlen(prefix));
 
     return true;
 }