From eabf4b2b5786c1d196cb36711d5a4fb38e980940 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 29 Mar 2019 14:40:01 +0100 Subject: vi: code shrink, proper printf formatting for strlen() function old new delta yank_delete 98 99 +1 what_reg 34 33 -1 text_yank 56 54 -2 end_cmd_q 17 14 -3 do_cmd 4718 4705 -13 colon 2875 2861 -14 edit_file 668 648 -20 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/6 up/down: 1/-53) Total: -52 bytes Signed-off-by: Denys Vlasenko --- editors/vi.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'editors/vi.c') diff --git a/editors/vi.c b/editors/vi.c index 065a1068e..5e5e13111 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -345,7 +345,8 @@ struct globals { /* a few references only */ #if ENABLE_FEATURE_VI_YANKMARK - int YDreg, Ureg; // default delete register and orig line for "U" + smalluint YDreg;//,Ureg;// default delete register and orig line for "U" +#define Ureg 27 char *reg[28]; // named register a-z, "D", and "U" 0-25,26,27 char *mark[28]; // user marks points somewhere in text[]- a-z and previous context '' char *context_start, *context_end; @@ -455,7 +456,7 @@ struct globals { #define format_edit_status__tot (G.format_edit_status__tot) #define YDreg (G.YDreg ) -#define Ureg (G.Ureg ) +//#define Ureg (G.Ureg ) #define mark (G.mark ) #define context_start (G.context_start ) #define context_end (G.context_end ) @@ -794,7 +795,7 @@ static void edit_file(char *fn) #if ENABLE_FEATURE_VI_YANKMARK YDreg = 26; // default Yank/Delete reg - Ureg = 27; // hold orig line for "U" cmd +// Ureg = 27; - const // hold orig line for "U" cmd mark[26] = mark[27] = text; // init "previous context" #endif @@ -4174,8 +4175,8 @@ static void do_cmd(int c) if (*p == '\n') cnt++; } - status_line("%s %d lines (%d chars) using [%c]", - buf, cnt, strlen(reg[YDreg]), what_reg()); + status_line("%s %u lines (%u chars) using [%c]", + buf, cnt, (unsigned)strlen(reg[YDreg]), what_reg()); #endif end_cmd_q(); // stop adding to q } -- cgit v1.2.3-55-g6feb From a2fd1aaf86e2adc16101bdf95770a2783830727a Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Wed, 20 Mar 2019 11:00:28 +0000 Subject: vi: allow manual screen update if SIGWINCH isn't supported On platforms that don't support SIGWINCH vi can be configured with FEATURE_VI_USE_SIGNALS disabled and FEATURE_VI_WIN_RESIZE enabled. This allows the user to force an update with ^L when the screen is resized. However, because the SIGWINCH handler hasn't run the virtual screen buffer won't have been updated and the display becomes corrupted. Fix this by calling new_screen() if necessary. Signed-off-by: Ron Yorston Signed-off-by: Denys Vlasenko --- editors/vi.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'editors/vi.c') diff --git a/editors/vi.c b/editors/vi.c index 5e5e13111..425d14c9c 100644 --- a/editors/vi.c +++ b/editors/vi.c @@ -3349,7 +3349,15 @@ static void refresh(int full_screen) if (ENABLE_FEATURE_VI_WIN_RESIZE IF_FEATURE_VI_ASK_TERMINAL(&& !G.get_rowcol_error) ) { unsigned c = columns, r = rows; query_screen_dimensions(); +#if ENABLE_FEATURE_VI_USE_SIGNALS full_screen |= (c - columns) | (r - rows); +#else + if (c != columns || r != rows) { + full_screen = TRUE; + /* update screen memory since SIGWINCH won't have done it */ + new_screen(rows, columns); + } +#endif } sync_cursor(dot, &crow, &ccol); // where cursor will be (on "dot") tp = screenbegin; // index into text[] of top line -- cgit v1.2.3-55-g6feb