comparison src/terminal.c @ 19542:9e428147e4ee v8.2.0328

patch 8.2.0328: no redraw when leaving term-normal mode in popup terminal Commit: https://github.com/vim/vim/commit/e52e0c89d1a6305beca3c01f89a4892dcb43bc71 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Feb 28 22:20:10 2020 +0100 patch 8.2.0328: no redraw when leaving term-normal mode in popup terminal Problem: No redraw when leaving terminal-normal mode in a terminal popup window. Solution: Redraw the popup window. (closes #5708)
author Bram Moolenaar <Bram@vim.org>
date Fri, 28 Feb 2020 22:30:09 +0100
parents 274052873790
children 804322d6c6ba
comparison
equal deleted inserted replaced
19541:80dd4d7df929 19542:9e428147e4ee
1794 term->tl_timer_set = FALSE; 1794 term->tl_timer_set = FALSE;
1795 #endif 1795 #endif
1796 } 1796 }
1797 1797
1798 /* 1798 /*
1799 * Loop over all windows in the current tab, and also curwin, which is not
1800 * encountered when using a terminal in a popup window.
1801 * Return TRUE if "*wp" was set to the next window.
1802 */
1803 static int
1804 for_all_windows_and_curwin(win_T **wp, int *did_curwin)
1805 {
1806 if (*wp == NULL)
1807 *wp = firstwin;
1808 else if ((*wp)->w_next != NULL)
1809 *wp = (*wp)->w_next;
1810 else if (!*did_curwin)
1811 *wp = curwin;
1812 else
1813 return FALSE;
1814 if (*wp == curwin)
1815 *did_curwin = TRUE;
1816 return TRUE;
1817 }
1818
1819 /*
1799 * If needed, add the current lines of the terminal to scrollback and to the 1820 * If needed, add the current lines of the terminal to scrollback and to the
1800 * buffer. Called after the job has ended and when switching to 1821 * buffer. Called after the job has ended and when switching to
1801 * Terminal-Normal mode. 1822 * Terminal-Normal mode.
1802 * When "redraw" is TRUE redraw the windows that show the terminal. 1823 * When "redraw" is TRUE redraw the windows that show the terminal.
1803 */ 1824 */
1804 static void 1825 static void
1805 may_move_terminal_to_buffer(term_T *term, int redraw) 1826 may_move_terminal_to_buffer(term_T *term, int redraw)
1806 { 1827 {
1807 win_T *wp;
1808
1809 if (term->tl_vterm == NULL) 1828 if (term->tl_vterm == NULL)
1810 return; 1829 return;
1811 1830
1812 // Update the snapshot only if something changes or the buffer does not 1831 // Update the snapshot only if something changes or the buffer does not
1813 // have all the lines. 1832 // have all the lines.
1818 // Obtain the current background color. 1837 // Obtain the current background color.
1819 vterm_state_get_default_colors(vterm_obtain_state(term->tl_vterm), 1838 vterm_state_get_default_colors(vterm_obtain_state(term->tl_vterm),
1820 &term->tl_default_color.fg, &term->tl_default_color.bg); 1839 &term->tl_default_color.fg, &term->tl_default_color.bg);
1821 1840
1822 if (redraw) 1841 if (redraw)
1823 FOR_ALL_WINDOWS(wp) 1842 {
1843 win_T *wp = NULL;
1844 int did_curwin = FALSE;
1845
1846 while (for_all_windows_and_curwin(&wp, &did_curwin))
1824 { 1847 {
1825 if (wp->w_buffer == term->tl_buffer) 1848 if (wp->w_buffer == term->tl_buffer)
1826 { 1849 {
1827 wp->w_cursor.lnum = term->tl_buffer->b_ml.ml_line_count; 1850 wp->w_cursor.lnum = term->tl_buffer->b_ml.ml_line_count;
1828 wp->w_cursor.col = 0; 1851 wp->w_cursor.col = 0;
1835 wp->w_topline = min_topline; 1858 wp->w_topline = min_topline;
1836 } 1859 }
1837 redraw_win_later(wp, NOT_VALID); 1860 redraw_win_later(wp, NOT_VALID);
1838 } 1861 }
1839 } 1862 }
1863 }
1840 } 1864 }
1841 1865
1842 #if defined(FEAT_TIMERS) || defined(PROTO) 1866 #if defined(FEAT_TIMERS) || defined(PROTO)
1843 /* 1867 /*
1844 * Check if any terminal timer expired. If so, copy text from the terminal to 1868 * Check if any terminal timer expired. If so, copy text from the terminal to
1918 curwin->w_cursor.lnum = term->tl_scrollback_scrolled 1942 curwin->w_cursor.lnum = term->tl_scrollback_scrolled
1919 + term->tl_cursor_pos.row + 1; 1943 + term->tl_cursor_pos.row + 1;
1920 check_cursor(); 1944 check_cursor();
1921 if (coladvance(term->tl_cursor_pos.col) == FAIL) 1945 if (coladvance(term->tl_cursor_pos.col) == FAIL)
1922 coladvance(MAXCOL); 1946 coladvance(MAXCOL);
1947 curwin->w_set_curswant = TRUE;
1923 1948
1924 // Display the same lines as in the terminal. 1949 // Display the same lines as in the terminal.
1925 curwin->w_topline = term->tl_scrollback_scrolled + 1; 1950 curwin->w_topline = term->tl_scrollback_scrolled + 1;
1926 } 1951 }
1927 1952
1949 set_terminal_mode(term, FALSE); 1974 set_terminal_mode(term, FALSE);
1950 1975
1951 if (term->tl_channel_closed) 1976 if (term->tl_channel_closed)
1952 cleanup_vterm(term); 1977 cleanup_vterm(term);
1953 redraw_buf_and_status_later(curbuf, NOT_VALID); 1978 redraw_buf_and_status_later(curbuf, NOT_VALID);
1979 #ifdef FEAT_PROP_POPUP
1980 if (WIN_IS_POPUP(curwin))
1981 redraw_win_later(curwin, NOT_VALID);
1982 #endif
1954 } 1983 }
1955 1984
1956 /* 1985 /*
1957 * Get a key from the user with terminal mode mappings. 1986 * Get a key from the user with terminal mode mappings.
1958 * Note: while waiting a terminal may be closed and freed if the channel is 1987 * Note: while waiting a terminal may be closed and freed if the channel is
2799 } 2828 }
2800 2829
2801 static void 2830 static void
2802 term_scroll_up(term_T *term, int start_row, int count) 2831 term_scroll_up(term_T *term, int start_row, int count)
2803 { 2832 {
2804 win_T *wp; 2833 win_T *wp = NULL;
2834 int did_curwin = FALSE;
2805 VTermColor fg, bg; 2835 VTermColor fg, bg;
2806 VTermScreenCellAttrs attr; 2836 VTermScreenCellAttrs attr;
2807 int clear_attr; 2837 int clear_attr;
2808 2838
2809 vim_memset(&attr, 0, sizeof(attr)); 2839 vim_memset(&attr, 0, sizeof(attr));
2810 2840
2811 FOR_ALL_WINDOWS(wp) 2841 while (for_all_windows_and_curwin(&wp, &did_curwin))
2812 { 2842 {
2813 if (wp->w_buffer == term->tl_buffer) 2843 if (wp->w_buffer == term->tl_buffer)
2814 { 2844 {
2815 // Set the color to clear lines with. 2845 // Set the color to clear lines with.
2816 vterm_state_get_default_colors(vterm_obtain_state(term->tl_vterm), 2846 vterm_state_get_default_colors(vterm_obtain_state(term->tl_vterm),
2856 VTermPos oldpos UNUSED, 2886 VTermPos oldpos UNUSED,
2857 int visible, 2887 int visible,
2858 void *user) 2888 void *user)
2859 { 2889 {
2860 term_T *term = (term_T *)user; 2890 term_T *term = (term_T *)user;
2861 win_T *wp; 2891 win_T *wp = NULL;
2892 int did_curwin = FALSE;
2862 2893
2863 term->tl_cursor_pos = pos; 2894 term->tl_cursor_pos = pos;
2864 term->tl_cursor_visible = visible; 2895 term->tl_cursor_visible = visible;
2865 2896
2866 FOR_ALL_WINDOWS(wp) 2897 while (for_all_windows_and_curwin(&wp, &did_curwin))
2867 { 2898 {
2868 if (wp->w_buffer == term->tl_buffer) 2899 if (wp->w_buffer == term->tl_buffer)
2869 position_cursor(wp, &pos, FALSE); 2900 position_cursor(wp, &pos, FALSE);
2870 } 2901 }
2871 if (term->tl_buffer == curbuf && !term->tl_normal_mode) 2902 if (term->tl_buffer == curbuf && !term->tl_normal_mode)