From e5d8b2bbe0688523dbe20e4f6519674daea1183f Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Thu, 20 Nov 2014 00:02:48 +0100 Subject: [PATCH] Allow select of yank buffer for ;y hinting (#151). --- doc/vimb.1 | 9 +++++---- src/hints.c | 2 +- src/main.h | 1 + src/normal.c | 6 ++++++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/doc/vimb.1 b/doc/vimb.1 index dca3b84..4e4647d 100644 --- a/doc/vimb.1 +++ b/doc/vimb.1 @@ -311,12 +311,13 @@ feature. Hints like ;o, but instead of opening the hinted URI, the `x-hint-command' is run in vimb. .TP -.B ;y -Yank hint's destination location into primary and secondary clipboard. +.BI [ \[char34]x ];y +Yank hint's destination location into primary and secondary clipboard and into +the register \fIx\fP. .TP -.B ;Y +.BI [ \[char34]x ];Y Yank hint's text description or form text into primary and secondary -clipboard. +clipboard and into the register \fIx\fP. .PD .RE .TP diff --git a/src/hints.c b/src/hints.c index 0917d97..516f204 100644 --- a/src/hints.c +++ b/src/hints.c @@ -353,7 +353,7 @@ static gboolean call_hints_function(const char *func, int count, JSValueRef para case 'Y': a.i = COMMAND_YANK_ARG; a.s = v; - command_yank(&a, '\0'); + command_yank(&a, vb.state.current_register); break; #ifdef FEATURE_QUEUE diff --git a/src/main.h b/src/main.h index 0144a54..4c1e284 100644 --- a/src/main.h +++ b/src/main.h @@ -300,6 +300,7 @@ typedef struct { char *linkhover; /* the uri of the curret hovered link */ char *reg[VB_REG_SIZE]; /* holds the yank buffer */ gboolean enable_register; /* indicates if registers are filled */ + char current_register; /* holds char for current register to be used */ gboolean enable_history; /* indicates if history entries are written */ #ifdef FEATURE_SEARCH_HIGHLIGHT int search_matches; /* number of matches search results */ diff --git a/src/normal.c b/src/normal.c index 9d78f63..2e9d507 100644 --- a/src/normal.c +++ b/src/normal.c @@ -438,6 +438,12 @@ static VbResult normal_hint(const NormalCmdInfo *info) { const char prompt[3] = {info->key, info->key2, 0}; + /* Save the current cutbuf char to make it available in case of ;y + * hinting. This is only a hack, because we don't need this state variable + * somewhere else - it's only use is for hinting. It might be better to + * allow to set various data to the mode itself to avoid toggling + * variables in global skope. */ + vb.state.current_register = info->cutbuf; return normal_do_hint(prompt); } -- 2.20.1