To: vim_dev@googlegroups.com Subject: Patch 9.0.0592 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0592 Problem: Display not cleared when scrolling back in messages, a background color is set and t_ut is empty. Solution: Clear to the end of the display if needed. (closes #8973) Files: src/message.c, src/screen.c, src/proto/screen.pro, src/testdir/test_messages.vim, src/testdir/dumps/Test_more_scrollback_1.dump, src/testdir/dumps/Test_more_scrollback_2.dump *** ../vim-9.0.0591/src/message.c 2022-09-20 12:45:11.848336408 +0100 --- src/message.c 2022-09-26 14:48:44.530597200 +0100 *************** *** 2913,2922 **** /* * Display a screen line from previously displayed text at row "row". * Returns a pointer to the text for the next line (can be NULL). */ static msgchunk_T * ! disp_sb_line(int row, msgchunk_T *smp) { msgchunk_T *mp = smp; char_u *p; --- 2913,2923 ---- /* * Display a screen line from previously displayed text at row "row". + * When "clear_to_eol" is set clear the rest of the screen line. * Returns a pointer to the text for the next line (can be NULL). */ static msgchunk_T * ! disp_sb_line(int row, msgchunk_T *smp, int clear_to_eol) { msgchunk_T *mp = smp; char_u *p; *************** *** 2929,2934 **** --- 2930,2941 ---- if (*p == '\n') // don't display the line break ++p; msg_puts_display(p, -1, mp->sb_attr, TRUE); + + // If clearing the screen did not work (e.g. because of a background + // color and t_ut isn't set) clear until the last column here. + if (clear_to_eol) + screen_fill(row, row + 1, msg_col, (int)Columns, ' ', ' ', 0); + if (mp->sb_eol || mp->sb_next == NULL) break; mp = mp->sb_next; *************** *** 3279,3293 **** (int)Rows, 0, NULL) == OK) { // display line at top ! (void)disp_sb_line(0, mp); } else { // redisplay all lines - screenclear(); for (i = 0; mp != NULL && i < Rows - 1; ++i) { ! mp = disp_sb_line(i, mp); ++msg_scrolled; } } --- 3286,3301 ---- (int)Rows, 0, NULL) == OK) { // display line at top ! (void)disp_sb_line(0, mp, FALSE); } else { + int did_clear = screenclear(); + // redisplay all lines for (i = 0; mp != NULL && i < Rows - 1; ++i) { ! mp = disp_sb_line(i, mp, !did_clear); ++msg_scrolled; } } *************** *** 3304,3310 **** inc_msg_scrolled(); screen_fill((int)Rows - 2, (int)Rows - 1, 0, (int)Columns, ' ', ' ', 0); ! mp_last = disp_sb_line((int)Rows - 2, mp_last); --toscroll; } } --- 3312,3318 ---- inc_msg_scrolled(); screen_fill((int)Rows - 2, (int)Rows - 1, 0, (int)Columns, ' ', ' ', 0); ! mp_last = disp_sb_line((int)Rows - 2, mp_last, FALSE); --toscroll; } } *** ../vim-9.0.0591/src/screen.c 2022-09-19 11:44:07.782992213 +0100 --- src/screen.c 2022-09-26 15:14:18.183498798 +0100 *************** *** 49,55 **** static int screen_attr = 0; static void screen_char_2(unsigned off, int row, int col); ! static void screenclear2(int doclear); static void lineclear(unsigned off, int width, int attr); static void lineinvalid(unsigned off, int width); static int win_do_lines(win_T *wp, int row, int line_count, int mayclear, int del, int clear_attr); --- 49,55 ---- static int screen_attr = 0; static void screen_char_2(unsigned off, int row, int col); ! static int screenclear2(int doclear); static void lineclear(unsigned off, int width, int attr); static void lineinvalid(unsigned off, int width); static int win_do_lines(win_T *wp, int row, int line_count, int mayclear, int del, int clear_attr); *************** *** 2473,2478 **** --- 2473,2479 ---- || (enc_utf8 && (int)ScreenLinesUC[off] != (c >= 0x80 ? c : 0)) || ScreenAttrs[off] != attr + || must_redraw == UPD_CLEAR // screen clear pending #if defined(FEAT_GUI) || defined(UNIX) || force_next #endif *************** *** 2975,2987 **** * Clear the screen. * May delay if there is something the user should read. * Allocated the screen for resizing if needed. */ ! void screenclear(void) { check_for_delay(FALSE); ! screenalloc(FALSE); // allocate screen buffers if size changed ! screenclear2(TRUE); // clear the screen } /* --- 2976,2990 ---- * Clear the screen. * May delay if there is something the user should read. * Allocated the screen for resizing if needed. + * Returns TRUE when the screen was actually claared, FALSE if all display + * cells were marked for updating. */ ! int screenclear(void) { check_for_delay(FALSE); ! screenalloc(FALSE); // allocate screen buffers if size changed ! return screenclear2(TRUE); // clear the screen } /* *************** *** 2993,3009 **** screenclear2(FALSE); } ! static void screenclear2(int doclear) { int i; if (starting == NO_SCREEN || ScreenLines == NULL #ifdef FEAT_GUI || (gui.in_use && gui.starting) #endif ) ! return; #ifdef FEAT_GUI if (!gui.in_use) --- 2996,3013 ---- screenclear2(FALSE); } ! static int screenclear2(int doclear) { int i; + int did_clear = FALSE; if (starting == NO_SCREEN || ScreenLines == NULL #ifdef FEAT_GUI || (gui.in_use && gui.starting) #endif ) ! return FALSE; #ifdef FEAT_GUI if (!gui.in_use) *************** *** 3026,3031 **** --- 3030,3036 ---- if (doclear && can_clear(T_CL)) { out_str(T_CL); // clear the display + did_clear = TRUE; clear_cmdline = FALSE; mode_displayed = FALSE; } *************** *** 3054,3059 **** --- 3059,3066 ---- screen_start(); // don't know where cursor is now msg_didany = FALSE; msg_didout = FALSE; + + return did_clear; } /* *** ../vim-9.0.0591/src/proto/screen.pro 2022-08-29 13:44:24.166897355 +0100 --- src/proto/screen.pro 2022-09-26 14:46:52.590791750 +0100 *************** *** 30,36 **** int screen_valid(int doclear); void screenalloc(int doclear); void free_screenlines(void); ! void screenclear(void); void redraw_as_cleared(void); void line_was_clobbered(int screen_lnum); int can_clear(char_u *p); --- 30,36 ---- int screen_valid(int doclear); void screenalloc(int doclear); void free_screenlines(void); ! int screenclear(void); void redraw_as_cleared(void); void line_was_clobbered(int screen_lnum); int can_clear(char_u *p); *** ../vim-9.0.0591/src/testdir/test_messages.vim 2022-09-26 12:56:49.662896909 +0100 --- src/testdir/test_messages.vim 2022-09-26 15:02:33.112972981 +0100 *************** *** 311,316 **** --- 311,342 ---- call StopVimInTerminal(buf) endfunc + " Test more-prompt scrollback + func Test_message_more_scrollback() + CheckRunVimInTerminal + + let lines =<< trim END + set t_ut= + hi Normal ctermfg=15 ctermbg=0 + for i in range(100) + echo i + endfor + END + call writefile(lines, 'XmoreScrollback', 'D') + let buf = RunVimInTerminal('-S XmoreScrollback', {'rows': 10}) + call VerifyScreenDump(buf, 'Test_more_scrollback_1', {}) + + call term_sendkeys(buf, 'f') + call TermWait(buf) + call term_sendkeys(buf, 'b') + call VerifyScreenDump(buf, 'Test_more_scrollback_2', {}) + + call term_sendkeys(buf, 'q') + call TermWait(buf) + call StopVimInTerminal(buf) + endfunc + + func Test_ask_yesno() CheckRunVimInTerminal let buf = RunVimInTerminal('', {'rows': 6}) *** ../vim-9.0.0591/src/testdir/dumps/Test_more_scrollback_1.dump 2022-09-26 15:16:05.999276868 +0100 --- src/testdir/dumps/Test_more_scrollback_1.dump 2022-09-26 15:14:33.315467628 +0100 *************** *** 0 **** --- 1,10 ---- + |0+0#ffffff16#0000001| @73 + |1| @73 + |2| @73 + |3| @73 + |4| @73 + |5| @73 + |6| @73 + |7| @73 + |8| @73 + |-+0#00e0003&@1| |M|o|r|e| |-@1> +0#ffffff16&@64 *** ../vim-9.0.0591/src/testdir/dumps/Test_more_scrollback_2.dump 2022-09-26 15:16:06.003276859 +0100 --- src/testdir/dumps/Test_more_scrollback_2.dump 2022-09-26 14:55:43.125826000 +0100 *************** *** 0 **** --- 1,10 ---- + |0+0#ffffff16#0000001| @73 + |1| @73 + |2| @73 + |3| @73 + |4| @73 + |5| @73 + |6| @73 + |7| @73 + |8| @73 + |-+0#00e0003&@1| |M|o|r|e| |-@1> +0#ffffff16&@64 *** ../vim-9.0.0591/src/version.c 2022-09-26 12:56:49.662896909 +0100 --- src/version.c 2022-09-26 14:43:04.047164573 +0100 *************** *** 701,702 **** --- 701,704 ---- { /* Add new patch number below this line */ + /**/ + 592, /**/ -- hundred-and-one symptoms of being an internet addict: 178. You look for an icon to double-click to open your bedroom window. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///