From: Daniel Carl Date: Fri, 1 Mar 2013 15:50:22 +0000 (+0100) Subject: Added hinting mode to open images. X-Git-Url: https://git.owens.tech/projects.html/projects.html/git?a=commitdiff_plain;h=63051a62e0a300e949e2bd05f071bb28bd6ae734;p=vimb.git Added hinting mode to open images. With the ;i or ;I hinting mode images can be hinted end opened. --- diff --git a/doc/vimp.1.txt b/doc/vimp.1.txt index 2307574..3f9b501 100644 --- a/doc/vimp.1.txt +++ b/doc/vimp.1.txt @@ -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 diff --git a/src/command.c b/src/command.c index 22ae839..7679185 100644 --- a/src/command.c +++ b/src/command.c @@ -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}}, diff --git a/src/config.h b/src/config.h index cbe478c..85a4fb1 100644 --- a/src/config.h +++ b/src/config.h @@ -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"}, diff --git a/src/hints.c b/src/hints.c index 09ece4f..97b18f3 100644 --- a/src/hints.c +++ b/src/hints.c @@ -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); diff --git a/src/hints.h b/src/hints.h index a9131c6..0955b08 100644 --- a/src/hints.h +++ b/src/hints.h @@ -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 { diff --git a/src/hints.js b/src/hints.js index c734e47..23e47be 100644 --- a/src/hints.js +++ b/src/hints.js @@ -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;