From: Daniel Carl Date: Fri, 30 May 2014 21:52:32 +0000 (+0200) Subject: Added support of read only registers ":, "/ and "%. X-Git-Url: https://git.owens.tech/about.html/about.html/git?a=commitdiff_plain;h=69c8d0251ac9b0246e7feeb58506fc6013cd7dbb;p=vimb.git Added support of read only registers ":, "/ and "%. --- diff --git a/doc/vimb.1 b/doc/vimb.1 index 296c5db..d72d4c9 100644 --- a/doc/vimb.1 +++ b/doc/vimb.1 @@ -357,8 +357,9 @@ Moves the cursor after the char in inputbox. .B CTRL\-V Pass the next key press directly to gtk. .TP -.B CTRL\-R {0-9a-z} -Insert the content of given buffer at cursor position. +.B CTRL\-R {a-z%:/} +Insert the content of given buffer at cursor position. See also section +REGISTERS. .SS Command Line History .TP .B @@ -580,6 +581,20 @@ Open configured editor with content of current form field. .TP .B CTRL\-Z Enter the pass-through mode. +.SH REGISTERS +There are different types of registers. +.TP +.BR \[char34]a " - " \[char34]z +26 named registers "a to "z. Vimb fills these registers only when you say so. +.TP +.B \[char34]% +Contains the curent opened URI. +.TP +.B \[char34]: +Contains the most recent executed ex command. +.TP +.B \[char34]/ +Contains the most recent search-pattern. .SH COMPLETIONS The completions are triggered by pressing `` or `` in the activated inputbox. Depending of the current inserted content different diff --git a/src/command.c b/src/command.c index de32cbb..4de2279 100644 --- a/src/command.c +++ b/src/command.c @@ -96,7 +96,9 @@ gboolean command_yank(const Arg *arg, char buf) } if (text) { /* put the text into the yank buffer */ - vb_register_add(buf, text); + if (strchr(VB_USER_REG, buf)) { + vb_register_add(buf, text); + } vb_echo(VB_MSG_NORMAL, false, tmpl, text); g_free(text); @@ -117,7 +119,9 @@ gboolean command_yank(const Arg *arg, char buf) if (a.s) { /* put the text into the yank buffer */ vb_set_clipboard(&a); - vb_register_add(buf, a.s); + if (strchr(VB_USER_REG, buf)) { + vb_register_add(buf, a.s); + } vb_echo(VB_MSG_NORMAL, false, tmpl, a.s); return true; diff --git a/src/ex.c b/src/ex.c index 5cc44b6..243c069 100644 --- a/src/ex.c +++ b/src/ex.c @@ -427,9 +427,10 @@ static void input_activate(void) switch (*text) { case '/': count = 1; /* fall through */ case '?': - history_add(HISTORY_SEARCH, cmd, NULL); mode_enter('n'); command_search(&((Arg){count, cmd})); + vb_register_add('/', cmd); + history_add(HISTORY_SEARCH, cmd, NULL); break; case ';': /* fall through */ @@ -438,9 +439,10 @@ static void input_activate(void) break; case ':': - history_add(HISTORY_COMMAND, cmd, NULL); mode_enter('n'); ex_run_string(cmd); + vb_register_add(':', cmd); + history_add(HISTORY_COMMAND, cmd, NULL); break; } diff --git a/src/main.c b/src/main.c index 6efbb51..9dfb702 100644 --- a/src/main.c +++ b/src/main.c @@ -513,6 +513,8 @@ static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec) vb_update_statusbar(); vb_update_urlbar(uri); + /* save the current URI in register % */ + vb_register_add('%', uri); /* clear possible set marks */ marks_clear(); diff --git a/src/main.h b/src/main.h index e9fd42e..690e30b 100644 --- a/src/main.h +++ b/src/main.h @@ -115,7 +115,8 @@ #define VB_MARK_TICK 0 #define VB_MARK_SIZE (sizeof(VB_MARK_CHARS) - 1) -#define VB_REG_CHARS "0123456789abcdefghijklmnopqrstuvwxyz" +#define VB_USER_REG "abcdefghijklmnopqrstuvwxyz" +#define VB_REG_CHARS VB_USER_REG "%:/" #define VB_REG_SIZE (sizeof(VB_REG_CHARS) - 1) /* enums */ diff --git a/src/normal.c b/src/normal.c index efaf469..52e140b 100644 --- a/src/normal.c +++ b/src/normal.c @@ -270,7 +270,7 @@ VbResult normal_keypress(int key) } else if ((char)key == '"') { info.phase = PHASE_CUTBUF; vb.mode->flags |= FLAG_NOMAP; - } else if (info.phase == PHASE_CUTBUF) { + } else if (info.phase == PHASE_CUTBUF && strchr(VB_REG_CHARS, (char)key)) { info.cutbuf = (char)key; info.phase = PHASE_START; } else {