To: vim_dev@googlegroups.com Subject: Patch 8.2.0328 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0328 Problem: No redraw when leaving terminal-normal mode in a terminal popup window. Solution: Redraw the popup window. (closes #5708) Files: src/macros.h, src/vim.h, src/terminal.c, src/drawscreen.c, src/move.c, src/popupwin.c, src/testdir/test_terminal.vim, src/testdir/dumps/Test_terminal_popup_7.dump, src/testdir/dumps/Test_terminal_popup_8.dump *** ../vim-8.2.0327/src/macros.h 2020-02-01 23:04:20.120422629 +0100 --- src/macros.h 2020-02-28 19:47:20.411458095 +0100 *************** *** 344,352 **** --- 344,354 ---- // Give an error in curwin is a popup window and evaluate to TRUE. #ifdef FEAT_PROP_POPUP + # define WIN_IS_POPUP(wp) ((wp)->w_popup_flags != 0) # define ERROR_IF_POPUP_WINDOW error_if_popup_window(FALSE) # define ERROR_IF_ANY_POPUP_WINDOW error_if_popup_window(TRUE) #else + # define WIN_IS_POPUP(wp) 0 # define ERROR_IF_POPUP_WINDOW 0 # define ERROR_IF_ANY_POPUP_WINDOW 0 #endif *** ../vim-8.2.0327/src/vim.h 2020-02-26 16:15:31.076386941 +0100 --- src/vim.h 2020-02-28 19:45:43.639790163 +0100 *************** *** 640,651 **** #define POPUP_HANDLED_4 0x08 // used by may_update_popup_mask() #define POPUP_HANDLED_5 0x10 // used by update_popups() - #ifdef FEAT_PROP_POPUP - # define WIN_IS_POPUP(wp) ((wp)->w_popup_flags != 0) - #else - # define WIN_IS_POPUP(wp) 0 - #endif - /* * Terminal highlighting attribute bits. * Attributes above HL_ALL are used for syntax highlighting. --- 640,645 ---- *** ../vim-8.2.0327/src/terminal.c 2020-02-24 21:37:50.950593397 +0100 --- src/terminal.c 2020-02-28 21:35:01.627411295 +0100 *************** *** 1796,1801 **** --- 1796,1822 ---- } /* + * Loop over all windows in the current tab, and also curwin, which is not + * encountered when using a terminal in a popup window. + * Return TRUE if "*wp" was set to the next window. + */ + static int + for_all_windows_and_curwin(win_T **wp, int *did_curwin) + { + if (*wp == NULL) + *wp = firstwin; + else if ((*wp)->w_next != NULL) + *wp = (*wp)->w_next; + else if (!*did_curwin) + *wp = curwin; + else + return FALSE; + if (*wp == curwin) + *did_curwin = TRUE; + return TRUE; + } + + /* * If needed, add the current lines of the terminal to scrollback and to the * buffer. Called after the job has ended and when switching to * Terminal-Normal mode. *************** *** 1804,1811 **** static void may_move_terminal_to_buffer(term_T *term, int redraw) { - win_T *wp; - if (term->tl_vterm == NULL) return; --- 1825,1830 ---- *************** *** 1820,1826 **** &term->tl_default_color.fg, &term->tl_default_color.bg); if (redraw) ! FOR_ALL_WINDOWS(wp) { if (wp->w_buffer == term->tl_buffer) { --- 1839,1849 ---- &term->tl_default_color.fg, &term->tl_default_color.bg); if (redraw) ! { ! win_T *wp = NULL; ! int did_curwin = FALSE; ! ! while (for_all_windows_and_curwin(&wp, &did_curwin)) { if (wp->w_buffer == term->tl_buffer) { *************** *** 1837,1842 **** --- 1860,1866 ---- redraw_win_later(wp, NOT_VALID); } } + } } #if defined(FEAT_TIMERS) || defined(PROTO) *************** *** 1920,1925 **** --- 1944,1950 ---- check_cursor(); if (coladvance(term->tl_cursor_pos.col) == FAIL) coladvance(MAXCOL); + curwin->w_set_curswant = TRUE; // Display the same lines as in the terminal. curwin->w_topline = term->tl_scrollback_scrolled + 1; *************** *** 1951,1956 **** --- 1976,1985 ---- if (term->tl_channel_closed) cleanup_vterm(term); redraw_buf_and_status_later(curbuf, NOT_VALID); + #ifdef FEAT_PROP_POPUP + if (WIN_IS_POPUP(curwin)) + redraw_win_later(curwin, NOT_VALID); + #endif } /* *************** *** 2801,2814 **** static void term_scroll_up(term_T *term, int start_row, int count) { ! win_T *wp; VTermColor fg, bg; VTermScreenCellAttrs attr; int clear_attr; vim_memset(&attr, 0, sizeof(attr)); ! FOR_ALL_WINDOWS(wp) { if (wp->w_buffer == term->tl_buffer) { --- 2830,2844 ---- static void term_scroll_up(term_T *term, int start_row, int count) { ! win_T *wp = NULL; ! int did_curwin = FALSE; VTermColor fg, bg; VTermScreenCellAttrs attr; int clear_attr; vim_memset(&attr, 0, sizeof(attr)); ! while (for_all_windows_and_curwin(&wp, &did_curwin)) { if (wp->w_buffer == term->tl_buffer) { *************** *** 2858,2869 **** void *user) { term_T *term = (term_T *)user; ! win_T *wp; term->tl_cursor_pos = pos; term->tl_cursor_visible = visible; ! FOR_ALL_WINDOWS(wp) { if (wp->w_buffer == term->tl_buffer) position_cursor(wp, &pos, FALSE); --- 2888,2900 ---- void *user) { term_T *term = (term_T *)user; ! win_T *wp = NULL; ! int did_curwin = FALSE; term->tl_cursor_pos = pos; term->tl_cursor_visible = visible; ! while (for_all_windows_and_curwin(&wp, &did_curwin)) { if (wp->w_buffer == term->tl_buffer) position_cursor(wp, &pos, FALSE); *** ../vim-8.2.0327/src/drawscreen.c 2019-12-23 22:59:14.260820709 +0100 --- src/drawscreen.c 2020-02-28 22:15:13.650946151 +0100 *************** *** 69,74 **** --- 69,77 ---- #ifdef FEAT_STL_OPT static void redraw_custom_statusline(win_T *wp); #endif + #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD) + static int did_update_one_window; + #endif /* * Based on the current value of curwin->w_topline, transfer a screenfull *************** *** 81,90 **** int type = type_arg; win_T *wp; static int did_intro = FALSE; - #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD) - int did_one; - #endif #ifdef FEAT_GUI int did_undraw = FALSE; int gui_cursor_col = 0; int gui_cursor_row = 0; --- 84,91 ---- int type = type_arg; win_T *wp; static int did_intro = FALSE; #ifdef FEAT_GUI + int did_one = FALSE; int did_undraw = FALSE; int gui_cursor_col = 0; int gui_cursor_row = 0; *************** *** 276,282 **** // Go from top to bottom through the windows, redrawing the ones that need // it. #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD) ! did_one = FALSE; #endif #ifdef FEAT_SEARCH_EXTRA screen_search_hl.rm.regprog = NULL; --- 277,283 ---- // Go from top to bottom through the windows, redrawing the ones that need // it. #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD) ! did_update_one_window = FALSE; #endif #ifdef FEAT_SEARCH_EXTRA screen_search_hl.rm.regprog = NULL; *************** *** 286,306 **** if (wp->w_redr_type != 0) { cursor_off(); ! #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD) if (!did_one) { did_one = TRUE; ! # ifdef FEAT_SEARCH_EXTRA ! start_search_hl(); ! # endif ! # ifdef FEAT_CLIPBOARD ! // When Visual area changed, may have to update selection. ! if (clip_star.available && clip_isautosel_star()) ! clip_update_selection(&clip_star); ! if (clip_plus.available && clip_isautosel_plus()) ! clip_update_selection(&clip_plus); ! # endif ! #ifdef FEAT_GUI // Remove the cursor before starting to do anything, because // scrolling may make it difficult to redraw the text under // it. --- 287,297 ---- if (wp->w_redr_type != 0) { cursor_off(); ! #ifdef FEAT_GUI if (!did_one) { did_one = TRUE; ! // Remove the cursor before starting to do anything, because // scrolling may make it difficult to redraw the text under // it. *************** *** 311,319 **** gui_undraw_cursor(); did_undraw = TRUE; } - #endif } #endif win_update(wp); } --- 302,310 ---- gui_undraw_cursor(); did_undraw = TRUE; } } #endif + win_update(wp); } *************** *** 1422,1427 **** --- 1413,1437 ---- proftime_T syntax_tm; #endif + #if defined(FEAT_SEARCH_EXTRA) || defined(FEAT_CLIPBOARD) + // This needs to be done only for the first window when update_screen() is + // called. + if (!did_update_one_window) + { + did_update_one_window = TRUE; + # ifdef FEAT_SEARCH_EXTRA + start_search_hl(); + # endif + # ifdef FEAT_CLIPBOARD + // When Visual area changed, may have to update selection. + if (clip_star.available && clip_isautosel_star()) + clip_update_selection(&clip_star); + if (clip_plus.available && clip_isautosel_plus()) + clip_update_selection(&clip_plus); + # endif + } + #endif + type = wp->w_redr_type; if (type == NOT_VALID) *************** *** 3025,3030 **** --- 3035,3045 ---- if (wp->w_buffer == buf) redraw_win_later(wp, type); } + #if defined(FEAT_TERMINAL) && defined(FEAT_PROP_POPUP) + // terminal in popup window is not in list of windows + if (curwin->w_buffer == buf) + redraw_win_later(curwin, type); + #endif } #if defined(FEAT_SIGNS) || defined(PROTO) *** ../vim-8.2.0327/src/move.c 2019-12-21 18:25:50.453560468 +0100 --- src/move.c 2020-02-28 21:26:10.136830770 +0100 *************** *** 1174,1179 **** --- 1174,1186 ---- && !pum_visible()) redraw_later(SOME_VALID); #endif + #if defined(FEAT_PROP_POPUP) && defined(FEAT_TERMINAL) + if (popup_is_popup(curwin) && curbuf->b_term != NULL) + { + curwin->w_wrow += popup_top_extra(curwin); + curwin->w_wcol += popup_left_extra(curwin); + } + #endif // now w_leftcol is valid, avoid check_cursor_moved() thinking otherwise curwin->w_valid_leftcol = curwin->w_leftcol; *** ../vim-8.2.0327/src/popupwin.c 2020-02-28 19:11:09.870348295 +0100 --- src/popupwin.c 2020-02-28 21:31:49.799950553 +0100 *************** *** 3505,3513 **** wp->w_winrow -= top_off; wp->w_wincol -= left_extra; ! // cursor position matters in terminal ! wp->w_wrow += top_off; ! wp->w_wcol += left_extra; total_width = popup_width(wp); total_height = popup_height(wp); --- 3505,3516 ---- wp->w_winrow -= top_off; wp->w_wincol -= left_extra; ! // cursor position matters in terminal in job mode ! if (wp != curwin || !term_in_normal_mode()) ! { ! wp->w_wrow += top_off; ! wp->w_wcol += left_extra; ! } total_width = popup_width(wp); total_height = popup_height(wp); *** ../vim-8.2.0327/src/testdir/test_terminal.vim 2020-02-28 19:11:09.870348295 +0100 --- src/testdir/test_terminal.vim 2020-02-28 20:50:48.755671239 +0100 *************** *** 2382,2389 **** call term_sendkeys(buf, "\:call ReopenPopup()\") call VerifyScreenDump(buf, 'Test_terminal_popup_6', {}) - call term_wait(buf, 100) call term_sendkeys(buf, ":q\") call term_wait(buf, 100) " wait for terminal to vanish --- 2382,2397 ---- call term_sendkeys(buf, "\:call ReopenPopup()\") call VerifyScreenDump(buf, 'Test_terminal_popup_6', {}) + " Go to terminal-Normal mode and visually select text. + call term_sendkeys(buf, "\Ngg/in\vww") + call VerifyScreenDump(buf, 'Test_terminal_popup_7', {}) + + " Back to job mode, redraws + call term_sendkeys(buf, "A") + call VerifyScreenDump(buf, 'Test_terminal_popup_8', {}) + + call term_wait(buf, 100) call term_sendkeys(buf, ":q\") call term_wait(buf, 100) " wait for terminal to vanish *** ../vim-8.2.0327/src/testdir/dumps/Test_terminal_popup_7.dump 2020-02-28 22:17:37.662442460 +0100 --- src/testdir/dumps/Test_terminal_popup_7.dump 2020-02-28 22:16:17.702721621 +0100 *************** *** 0 **** --- 1,15 ---- + |0+0&#ffffff0| @73 + |1| @73 + |2| @73 + |3| @12|╔+0#0000001#ffd7ff255|═@44|╗| +0#0000000#ffffff0@13 + |4| @12|║+0#0000001#ffd7ff255|s|o|m|e| |t|e|x|t| @35|║| +0#0000000#ffffff0@13 + |5| @12|║+0#0000001#ffd7ff255|t|o| |e+0&#ffff4012|d|i|t| +0&#ffd7ff255@37|║| +0#0000000#ffffff0@13 + |6| @12|║+0#0000001#ffd7ff255|i+0&#e0e0e08|n| |a| >p+0&#ffd7ff255|o|p|u|p| |w|i|n|d|o|w| @27|║| +0#0000000#ffffff0@13 + |7| @12|║+0#0000001#ffd7ff255|~+0#4040ff13&| @43|║+0#0000001&| +0#0000000#ffffff0@13 + |8| @12|║+0#0000001#ffd7ff255|~+0#4040ff13&| @43|║+0#0000001&| +0#0000000#ffffff0@13 + |9| @12|║+0#0000001#ffd7ff255|~+0#4040ff13&| @43|║+0#0000001&| +0#0000000#ffffff0@13 + |1|0| @11|║+0#0000001#ffd7ff255|/|e|d|i|t| @21|2|,|4| @10|A|l@1| |║| +0#0000000#ffffff0@13 + |1@1| @11|╚+0#0000001#ffd7ff255|═@44|╝| +0#0000000#ffffff0@13 + |1|2| @72 + |1|3| @72 + |-+2&&@1| |V|I|S|U|A|L| |-@1| +0&&@34|6| @8|3|,|6| @10|A|l@1| *** ../vim-8.2.0327/src/testdir/dumps/Test_terminal_popup_8.dump 2020-02-28 22:17:37.666442448 +0100 --- src/testdir/dumps/Test_terminal_popup_8.dump 2020-02-28 20:15:36.498144835 +0100 *************** *** 0 **** --- 1,15 ---- + |0+0&#ffffff0| @73 + |1| @73 + |2| @73 + |3| @12|╔+0#0000001#ffd7ff255|═@44|╗| +0#0000000#ffffff0@13 + |4| @12|║+0#0000001#ffd7ff255|s+0#0000000#ffffff0|o|m|e| |t|e|x|t| @35|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13 + |5| @12|║+0#0000001#ffd7ff255|t+0#0000000#ffffff0|o| >e+0&#ffff4012|d|i|t| +0&#ffffff0@37|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13 + |6| @12|║+0#0000001#ffd7ff255|i+0#0000000#ffffff0|n| |a| |p|o|p|u|p| |w|i|n|d|o|w| @27|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13 + |7| @12|║+0#0000001#ffd7ff255|~+0#4040ff13#ffffff0| @43|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13 + |8| @12|║+0#0000001#ffd7ff255|~+0#4040ff13#ffffff0| @43|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13 + |9| @12|║+0#0000001#ffd7ff255|~+0#4040ff13#ffffff0| @43|║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13 + |1|0| @11|║+0#0000001#ffd7ff255|/+0#0000000#ffffff0|e|d|i|t| @21|2|,|4| @10|A|l@1| |║+0#0000001#ffd7ff255| +0#0000000#ffffff0@13 + |1@1| @11|╚+0#0000001#ffd7ff255|═@44|╝| +0#0000000#ffffff0@13 + |1|2| @72 + |1|3| @72 + @57|1|,|1| @10|T|o|p| *** ../vim-8.2.0327/src/version.c 2020-02-28 19:11:09.870348295 +0100 --- src/version.c 2020-02-28 20:17:53.189852166 +0100 *************** *** 740,741 **** --- 740,743 ---- { /* Add new patch number below this line */ + /**/ + 328, /**/ -- hundred-and-one symptoms of being an internet addict: 130. You can't get out of your desk even if it's time to eat or time to go to the bathroom. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///