From: Daniel Carl Date: Wed, 19 Nov 2014 22:27:27 +0000 (+0100) Subject: Add :reg[ister] command to show register contents. X-Git-Url: https://git.owens.tech///git?a=commitdiff_plain;h=6a526f1cd472087f43bd41331fc8ca6b5ffe983a;p=vimb.git Add :reg[ister] command to show register contents. --- diff --git a/doc/vimb.1 b/doc/vimb.1 index 447f29f..dca3b84 100644 --- a/doc/vimb.1 +++ b/doc/vimb.1 @@ -755,6 +755,31 @@ Close the browser. This will be refused if there are running downloads. .B :q[uit]! Close the browser independent from an running download. .TP +.B :reg[ister] +Display the contents of all registers. +.RS +.PP +.PD 0 +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. +.TP +.B \[char34]; +Contains the last hinted URL. This can be used in `x-hint-command' to get the +URL of the hint. +.PD +.RE +.TP .BI :e[val] " javascript" Runs the given \fIjavascript\fP in the current page and display the evaluated value. @@ -800,24 +825,6 @@ Pass the next key press directly to gtk. .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. -.TP -.B \[char34]; -Contains the last hinted URL. This can be used in `x-hint-command' to get the -URL of the hint. .SH COMPLETIONS The completions are triggered by pressing `` or `` in the activated inputbox. Depending of the current inserted content different diff --git a/src/ex.c b/src/ex.c index 4a34c5a..c2786b7 100644 --- a/src/ex.c +++ b/src/ex.c @@ -72,6 +72,7 @@ typedef enum { EX_QUNSHIFT, #endif EX_QUIT, + EX_REG, EX_SAVE, EX_SCA, EX_SCD, @@ -142,6 +143,7 @@ static gboolean ex_open(const ExArg *arg); #ifdef FEATURE_QUEUE static gboolean ex_queue(const ExArg *arg); #endif +static gboolean ex_register(const ExArg *arg); static gboolean ex_quit(const ExArg *arg); static gboolean ex_save(const ExArg *arg); static gboolean ex_set(const ExArg *arg); @@ -190,6 +192,7 @@ static ExInfo commands[] = { {"qpop", EX_QPOP, ex_queue, EX_FLAG_NONE}, {"qpush", EX_QPUSH, ex_queue, EX_FLAG_RHS}, #endif + {"register", EX_REG, ex_register, EX_FLAG_NONE}, {"save", EX_SAVE, ex_save, EX_FLAG_RHS|EX_FLAG_EXP}, {"set", EX_SET, ex_set, EX_FLAG_RHS}, {"shellcmd", EX_SHELLCMD, ex_shellcmd, EX_FLAG_RHS|EX_FLAG_EXP|EX_FLAG_BANG}, @@ -863,6 +866,32 @@ static gboolean ex_queue(const ExArg *arg) } #endif +/** + * Show the contents of the registers :reg. + */ +static gboolean ex_register(const ExArg *arg) +{ + int idx; + char *reg; + const char *regchars = VB_REG_CHARS; + GString *str = g_string_new("-- Register --"); + + for (idx = 0; idx < VB_REG_SIZE; idx++) { + /* show only filled registers */ + if (vb.state.reg[idx]) { + /* replace all newlines */ + reg = util_str_replace("\n", "^J", vb.state.reg[idx]); + g_string_append_printf(str, "\n\"%c %s", regchars[idx], reg); + g_free(reg); + } + } + + vb_echo(VB_MSG_NORMAL, false, "%s", str->str); + g_string_free(str, true); + + return true; +} + static gboolean ex_quit(const ExArg *arg) { vb_quit(arg->bang);