Added hinting mode to open images.
authorDaniel Carl <danielcarl@gmx.de>
Fri, 1 Mar 2013 15:50:22 +0000 (16:50 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Fri, 1 Mar 2013 16:02:41 +0000 (17:02 +0100)
With the ;i or ;I hinting mode images can be hinted end opened.

doc/vimp.1.txt
src/command.c
src/config.h
src/hints.c
src/hints.h
src/hints.js

index 2307574..3f9b501 100644 (file)
@@ -214,32 +214,25 @@ complation is already started, switch to the next completion item.
 If complation is already started, switch to the previous completion item.
 .SS Hints
 .TP
-.BI "hint-link [" PREFIX ]
-Start hinting to open link into current window. If \fIPREFIX\fP is given,
-print this into the inputbox, default '.'.
+.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-link-new [" PREFIX ]
-Start hinting to open link into a new window. If \fIPREFIX\fP is given,
-print this into the inputbox, default ','.
-.TP
-.BI "hint-input-open [" PREFIX ]
-Start hinting to fill the inputbox with ":open {hintedLinkUrl}". If
-\fIPREFIX\fP is given, print this into the inputbox, default ';o'.
-.TP
-.BI "hint-input-tabopen [" PREFIX ]
-Start hinting to fill the inputbox with ":tabopen {hintedLinkUrl}". If
-\fIPREFIX\fP is given, print this into the inputbox, default ';t'.
+.BI "hint-input-open [" PREFIX "], hint-input-tabopen [" PREFIX ]
+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'.
 .TP
 .BI "hint-yank [" PREFIX ]
 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. If \fIPREFIX\fP is given, print this into the inputbox, default ';y'.
 .TP
-.B hint-focus-next
-Focus next hint.
+.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'.
 .TP
-.B hint-focus-prev
-Foxus previous hint.
+.B hint-focus-nex, hint-focus-prevt
+Focus next or previous hint.
 .SS Yank
 .TP
 .B yank-uri
index 22ae839..7679185 100644 (file)
@@ -73,6 +73,8 @@ static CommandInfo cmd_list[] = {
     {"hint-input-open",     command_hints,       {HINTS_TYPE_LINK | HINTS_PROCESS | HINTS_PROCESS_INPUT, ";o"}},
     {"hint-input-tabopen",  command_hints,       {HINTS_TYPE_LINK | HINTS_TARGET_BLANK | HINTS_PROCESS | HINTS_PROCESS_INPUT, ";t"}},
     {"hint-yank",           command_hints,       {HINTS_TYPE_LINK | HINTS_PROCESS | HINTS_PROCESS_YANK, ";y"}},
+    {"hint-image-open",     command_hints,       {HINTS_TYPE_IMAGE, ";i"}},
+    {"hint-image-tabopen",  command_hints,       {HINTS_TYPE_IMAGE | HINTS_TARGET_BLANK, ";I"}},
     {"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}},
index cbe478c..85a4fb1 100644 (file)
@@ -71,6 +71,8 @@ const struct {
     {"nmap ;o=hint-input-open"},
     {"nmap ;t=hint-input-tabopen"},
     {"nmap ;y=hint-yank"},
+    {"nmap ;i=hint-image-open"},
+    {"nmap ;I=hint-image-tabopen"},
     {"nmap y=yank-uri"},
     {"nmap Y=yank-selection"},
     {"nmap p=open-clipboard"},
index 09ece4f..97b18f3 100644 (file)
@@ -133,6 +133,7 @@ static void hints_run_script(char* js)
     if (!value) {
         return;
     }
+
     if (!strncmp(value, "DONE:", 5)) {
         hints_observe_input(FALSE);
         vp_set_mode(VP_MODE_NORMAL, TRUE);
@@ -141,21 +142,22 @@ static void hints_run_script(char* js)
         vp_set_mode(VP_MODE_INSERT, TRUE);
     } else if (!strncmp(value, "DATA:", 5)) {
         hints_observe_input(FALSE);
-        HintsProcess type = HINTS_GET_PROCESSING(mode);
         Arg a = {0};
-        switch (type) {
-            case HINTS_PROCESS_INPUT:
+        if (mode & HINTS_TYPE_IMAGE) {
+            a.s = (value + 5);
+            a.i = (mode & HINTS_TARGET_BLANK) ? VP_TARGET_NEW : VP_TARGET_CURRENT;
+            command_open(&a);
+        } else {
+            HintsProcess type = HINTS_GET_PROCESSING(mode);
+            if (type == HINTS_PROCESS_INPUT) {
                 a.s = g_strconcat((mode & HINTS_TARGET_BLANK) ? ":tabopen " : ":open ", (value + 5), NULL);
                 command_input(&a);
                 g_free(a.s);
-                break;
-
-            case HINTS_PROCESS_YANK:
+            } else if (type == HINTS_PROCESS_YANK) {
                 a.i = COMMAND_YANK_PRIMARY | COMMAND_YANK_SECONDARY;
-                a.s = g_strdup((value + 5));
+                a.s = (value + 5);
                 command_yank(&a);
-                g_free(a.s);
-                break;
+            }
         }
     }
     g_free(value);
index a9131c6..0955b08 100644 (file)
@@ -22,7 +22,6 @@
 
 #include "main.h"
 
-#define HINTS_GET_TYPE(type)       ((type) & (HINTS_TYPE_LINK | HINTS_TYPE_IMAGE))
 #define HINTS_GET_PROCESSING(type) ((type) & ~(HINTS_TYPE_LINK | HINTS_TYPE_IMAGE | HINTS_PROCESS | HINTS_TARGET_BLANK))
 
 typedef enum {
index c734e47..23e47be 100644 (file)
@@ -200,10 +200,10 @@ VimpHints = function Hints(bg, bgf, fg, style) {
     this.fire = function(n)
     {
         n = n ? n : curFocusNum;
-        var result;
+        var result = "DONE:";
         var hint = _getHintByNumber(n);
         if (typeof(hint.elem) == "undefined") {
-            return "DONE:";
+            return result;
         }
 
         var el  = hint.elem;
@@ -211,7 +211,9 @@ VimpHints = function Hints(bg, bgf, fg, style) {
 
         this.clear();
 
-        if (tag === "iframe" || tag === "frame" || tag === "textarea" || tag === "input" && (el.type === "text" || el.type === "password" || el.type === "checkbox" || el.type === "radio") || tag === "select") {
+        if (tag === "iframe" || tag === "frame" || tag === "textarea" || tag === "select" || tag === "input"
+            && (el.type != "image" && el.type != "submit")
+        ) {
             el.focus();
             if (tag === "input" || tag === "textarea") {
                 return "INSERT:";
@@ -219,7 +221,6 @@ VimpHints = function Hints(bg, bgf, fg, style) {
             return "DONE:";
         }
 
-        result = "DONE:";
         switch (mode) {
             case "f":
                 _open(el);
@@ -227,12 +228,6 @@ VimpHints = function Hints(bg, bgf, fg, style) {
             case "F":
                 _openNewWindow(el);
                 break;
-            case "i":
-                _open(el);
-                break;
-            case "I":
-                _openNewWindow(el);
-                break;
             default:
                 result = "DATA:" + _getElemtSource(el);
                 break;