From 46128219462b44d4a5ae964b41812f6953753fed Mon Sep 17 00:00:00 2001 From: watiko Date: Mon, 15 Feb 2016 22:40:55 +0900 Subject: vim-patch:7.4.925 Problem: User may yank or put using the register being recorded in. Solution: Add the recording register in the message. (Christian Brabandt, closes vim/vim#470) https://github.com/vim/vim/commit/a0ed84a26897c994512873a895b9fc54e90c6845 --- src/nvim/ops.c | 11 ++++++----- src/nvim/option_defs.h | 3 ++- src/nvim/screen.c | 39 +++++++++++++++++++++++---------------- src/nvim/version.c | 2 +- 4 files changed, 32 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index b1adc85e1d..0efce8c4c0 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -835,12 +835,13 @@ int do_record(int c) yankreg_T *old_y_previous; int retval; - if (Recording == FALSE) { /* start recording */ - /* registers 0-9, a-z and " are allowed */ - if (c < 0 || (!ASCII_ISALNUM(c) && c != '"')) + if (Recording == false) { + // start recording + // registers 0-9, a-z and " are allowed + if (c < 0 || (!ASCII_ISALNUM(c) && c != '"')) { retval = FAIL; - else { - Recording = TRUE; + } else { + Recording = c; showmode(); regname = c; retval = OK; diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 10706a0753..19edc14ed6 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -170,7 +170,8 @@ #define SHM_ATTENTION 'A' /* no ATTENTION messages */ #define SHM_INTRO 'I' /* intro messages */ #define SHM_COMPLETIONMENU 'c' // completion menu messages -#define SHM_ALL "rmfixlnwaWtToOsAIc" /* all possible flags for 'shm' */ +#define SHM_RECORDING 'q' ///< short recording message +#define SHM_ALL "rmfixlnwaWtToOsAIcq" ///< all possible flags for 'shm' /* characters for p_go: */ #define GO_ASEL 'a' /* autoselect */ diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 3b5836f0b5..382fcbac25 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -6760,8 +6760,8 @@ int showmode(void) if (Recording && edit_submode == NULL /* otherwise it gets too long */ ) { - MSG_PUTS_ATTR(_("recording"), attr); - need_clear = TRUE; + recording_mode(attr); + need_clear = true; } mode_displayed = TRUE; @@ -6800,26 +6800,33 @@ static void msg_pos_mode(void) msg_row = Rows - 1; } -/* - * Delete mode message. Used when ESC is typed which is expected to end - * Insert mode (but Insert mode didn't end yet!). - * Caller should check "mode_displayed". - */ -void unshowmode(int force) +/// Delete mode message. Used when ESC is typed which is expected to end +/// Insert mode (but Insert mode didn't end yet!). +/// Caller should check "mode_displayed". +void unshowmode(bool force) { - /* - * Don't delete it right now, when not redrawing or inside a mapping. - */ - if (!redrawing() || (!force && char_avail() && !KeyTyped)) - redraw_cmdline = TRUE; /* delete mode later */ - else { + // Don't delete it right now, when not redrawing or inside a mapping. + if (!redrawing() || (!force && char_avail() && !KeyTyped)) { + redraw_cmdline = true; // delete mode later + } else { msg_pos_mode(); - if (Recording) - MSG_PUTS_ATTR(_("recording"), hl_attr(HLF_CM)); + if (Recording) { + recording_mode(hl_attr(HLF_CM)); + } msg_clr_eos(); } } +static void recording_mode(int attr) +{ + MSG_PUTS_ATTR(_("recording"), attr); + if (!shortmess(SHM_RECORDING)) { + char_u s[4]; + vim_snprintf((char *)s, ARRAY_SIZE(s), " @%c", Recording); + MSG_PUTS_ATTR(s, attr); + } +} + /* * Draw the tab pages line at the top of the Vim window. */ diff --git a/src/nvim/version.c b/src/nvim/version.c index 39b8e3db84..874d10a44a 100644 --- a/src/nvim/version.c +++ b/src/nvim/version.c @@ -363,7 +363,7 @@ static int included_patches[] = { // 928 NA // 927 NA // 926, - // 925, + 925, // 924 NA // 923 NA // 922, -- cgit From 0b67bb8c25781205e7404ba9541124ffa0c0a0e4 Mon Sep 17 00:00:00 2001 From: watiko Date: Mon, 15 Feb 2016 23:22:24 +0900 Subject: option_defs.h: Improve coding style --- src/nvim/option_defs.h | 54 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 19edc14ed6..85068dfb69 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -151,27 +151,39 @@ #define COCU_ALL "nvic" /* flags for 'concealcursor' */ -/* characters for p_shm option: */ -#define SHM_RO 'r' /* readonly */ -#define SHM_MOD 'm' /* modified */ -#define SHM_FILE 'f' /* (file 1 of 2) */ -#define SHM_LAST 'i' /* last line incomplete */ -#define SHM_TEXT 'x' /* tx instead of textmode */ -#define SHM_LINES 'l' /* "L" instead of "lines" */ -#define SHM_NEW 'n' /* "[New]" instead of "[New file]" */ -#define SHM_WRI 'w' /* "[w]" instead of "written" */ -#define SHM_A "rmfixlnw" /* represented by 'a' flag */ -#define SHM_WRITE 'W' /* don't use "written" at all */ -#define SHM_TRUNC 't' /* trunctate file messages */ -#define SHM_TRUNCALL 'T' /* trunctate all messages */ -#define SHM_OVER 'o' /* overwrite file messages */ -#define SHM_OVERALL 'O' /* overwrite more messages */ -#define SHM_SEARCH 's' /* no search hit bottom messages */ -#define SHM_ATTENTION 'A' /* no ATTENTION messages */ -#define SHM_INTRO 'I' /* intro messages */ -#define SHM_COMPLETIONMENU 'c' // completion menu messages -#define SHM_RECORDING 'q' ///< short recording message -#define SHM_ALL "rmfixlnwaWtToOsAIcq" ///< all possible flags for 'shm' +/// characters for p_shm option: +enum { + SHM_RO = 'r', ///< Readonly. + SHM_MOD = 'm', ///< Modified. + SHM_FILE = 'f', ///< (file 1 of 2) + SHM_LAST = 'i', ///< Last line incomplete. + SHM_TEXT = 'x', ///< Tx instead of textmode. + SHM_LINES = 'l', ///< "L" instead of "lines". + SHM_NEW = 'n', ///< "[New]" instead of "[New file]". + SHM_WRI = 'w', ///< "[w]" instead of "written". + SHM_WRITE = 'W', ///< Don't use "written" at all. + SHM_TRUNC = 't', ///< Trunctate file messages. + SHM_TRUNCALL = 'T', ///< Trunctate all messages. + SHM_OVER = 'o', ///< Overwrite file messages. + SHM_OVERALL = 'O', ///< Overwrite more messages. + SHM_SEARCH = 's', ///< No search hit bottom messages. + SHM_ATTENTION = 'A', ///< No ATTENTION messages. + SHM_INTRO = 'I', ///< Intro messages. + SHM_COMPLETIONMENU = 'c', ///< Completion menu messages. + SHM_RECORDING = 'q', ///< Short recording message. +}; +/// Represented by 'a' flag. +#define SHM_A ((char_u[]) { \ + SHM_RO, SHM_MOD, SHM_FILE, SHM_LAST, SHM_TEXT, SHM_LINES, SHM_NEW, SHM_WRI, \ + 0, \ +}) +/// All possible flags for 'shm'. +#define SHM_ALL ((char_u[]) { \ + SHM_RO, SHM_MOD, SHM_FILE, SHM_LAST, SHM_TEXT, SHM_LINES, SHM_NEW, SHM_WRI, \ + SHM_WRITE, SHM_TRUNC, SHM_TRUNCALL, SHM_OVER, SHM_OVERALL, SHM_SEARCH, \ + SHM_ATTENTION, SHM_INTRO, SHM_COMPLETIONMENU, SHM_RECORDING, \ + 0, \ +}) /* characters for p_go: */ #define GO_ASEL 'a' /* autoselect */ -- cgit From 5b63488c25493a2f5a0734ad43ea422dab1c550b Mon Sep 17 00:00:00 2001 From: watiko Date: Tue, 16 Feb 2016 02:08:25 +0900 Subject: option_defs.h: Fix "set shm+=a" --- src/nvim/option_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 85068dfb69..688ed7d939 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -180,7 +180,7 @@ enum { /// All possible flags for 'shm'. #define SHM_ALL ((char_u[]) { \ SHM_RO, SHM_MOD, SHM_FILE, SHM_LAST, SHM_TEXT, SHM_LINES, SHM_NEW, SHM_WRI, \ - SHM_WRITE, SHM_TRUNC, SHM_TRUNCALL, SHM_OVER, SHM_OVERALL, SHM_SEARCH, \ + 'a', SHM_WRITE, SHM_TRUNC, SHM_TRUNCALL, SHM_OVER, SHM_OVERALL, SHM_SEARCH, \ SHM_ATTENTION, SHM_INTRO, SHM_COMPLETIONMENU, SHM_RECORDING, \ 0, \ }) -- cgit From 0d6cd2b8087d9ae7fdb2b70fcc40ecaf378b0af7 Mon Sep 17 00:00:00 2001 From: watiko Date: Tue, 16 Feb 2016 02:26:06 +0900 Subject: option_defs.h: Introduce SHM_ABBREVIATIONS Helped-by: ZyX --- src/nvim/option.c | 14 ++++++-------- src/nvim/option_defs.h | 8 +++++--- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/nvim/option.c b/src/nvim/option.c index 4bf7ec5405..9aa2b145e8 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -6163,16 +6163,14 @@ int has_format_option(int x) return vim_strchr(curbuf->b_p_fo, x) != NULL; } -/* - * Return TRUE if "x" is present in 'shortmess' option, or - * 'shortmess' contains 'a' and "x" is present in SHM_A. - */ -int shortmess(int x) +/// @returns true if "x" is present in 'shortmess' option, or +/// 'shortmess' contains 'a' and "x" is present in SHM_ALL_ABBREVIATIONS. +bool shortmess(int x) { return p_shm != NULL && - ( vim_strchr(p_shm, x) != NULL - || (vim_strchr(p_shm, 'a') != NULL - && vim_strchr((char_u *)SHM_A, x) != NULL)); + (vim_strchr(p_shm, x) != NULL + || (vim_strchr(p_shm, 'a') != NULL + && vim_strchr((char_u *)SHM_ALL_ABBREVIATIONS, x) != NULL)); } /* diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h index 688ed7d939..547bd9442c 100644 --- a/src/nvim/option_defs.h +++ b/src/nvim/option_defs.h @@ -161,6 +161,7 @@ enum { SHM_LINES = 'l', ///< "L" instead of "lines". SHM_NEW = 'n', ///< "[New]" instead of "[New file]". SHM_WRI = 'w', ///< "[w]" instead of "written". + SHM_ABBREVIATIONS = 'a', ///< Use abbreviations from #SHM_ALL_ABBREVIATIONS. SHM_WRITE = 'W', ///< Don't use "written" at all. SHM_TRUNC = 't', ///< Trunctate file messages. SHM_TRUNCALL = 'T', ///< Trunctate all messages. @@ -173,15 +174,16 @@ enum { SHM_RECORDING = 'q', ///< Short recording message. }; /// Represented by 'a' flag. -#define SHM_A ((char_u[]) { \ +#define SHM_ALL_ABBREVIATIONS ((char_u[]) { \ SHM_RO, SHM_MOD, SHM_FILE, SHM_LAST, SHM_TEXT, SHM_LINES, SHM_NEW, SHM_WRI, \ 0, \ }) /// All possible flags for 'shm'. #define SHM_ALL ((char_u[]) { \ SHM_RO, SHM_MOD, SHM_FILE, SHM_LAST, SHM_TEXT, SHM_LINES, SHM_NEW, SHM_WRI, \ - 'a', SHM_WRITE, SHM_TRUNC, SHM_TRUNCALL, SHM_OVER, SHM_OVERALL, SHM_SEARCH, \ - SHM_ATTENTION, SHM_INTRO, SHM_COMPLETIONMENU, SHM_RECORDING, \ + SHM_ABBREVIATIONS, SHM_WRITE, SHM_TRUNC, SHM_TRUNCALL, SHM_OVER, \ + SHM_OVERALL, SHM_SEARCH, SHM_ATTENTION, SHM_INTRO, SHM_COMPLETIONMENU, \ + SHM_RECORDING, \ 0, \ }) -- cgit