diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-06-14 19:23:57 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-06-14 19:23:57 +0200 |
commit | a540f8aa3b2570f1d903b63413301ec3d48b27d5 (patch) | |
tree | f9b38804f41d99da0febd16344d3ac554d3d7ed2 /src/screen.c | |
parent | 37df9a4401f6737d6216306ea77a7e080c942aea (diff) | |
download | vim-git-a540f8aa3b2570f1d903b63413301ec3d48b27d5.tar.gz |
patch 8.1.1527: when moving popup window over the cmdline it is not redrawnv8.1.1527
Problem: When moving a popup window over the command line it is not
redrawn.
Solution: Redraw the command line. Move popup redrawing code to the popupwin
file.
Diffstat (limited to 'src/screen.c')
-rw-r--r-- | src/screen.c | 309 |
1 files changed, 3 insertions, 306 deletions
diff --git a/src/screen.c b/src/screen.c index 7248ca221..8708fd7c2 100644 --- a/src/screen.c +++ b/src/screen.c @@ -121,10 +121,6 @@ static int redrawing_for_callback = 0; */ static schar_T *current_ScreenLine; -#ifdef FEAT_TEXT_PROP -static void may_update_popup_mask(int type); -static void update_popups(void); -#endif static void win_update(win_T *wp); static void win_redr_status(win_T *wp, int ignore_pum); static void win_draw_end(win_T *wp, int c1, int c2, int draw_margin, int row, int endrow, hlf_T hl); @@ -826,7 +822,7 @@ update_screen(int type_arg) #ifdef FEAT_TEXT_PROP // Display popup windows on top of the windows. - update_popups(); + update_popups(win_update); #endif #ifdef FEAT_GUI @@ -1001,7 +997,7 @@ update_debug_sign(buf_T *buf, linenr_T lnum) * Get 'wincolor' attribute for window "wp". If not set and "wp" is a popup * window then get the "Pmenu" highlight attribute. */ - static int + int get_wcr_attr(win_T *wp) { int wcr_attr = 0; @@ -1015,305 +1011,6 @@ get_wcr_attr(win_T *wp) return wcr_attr; } -#ifdef FEAT_TEXT_PROP - -/* - * Update "popup_mask" if needed. - * Also recomputes the popup size and positions. - * Also updates "popup_visible". - * Also marks window lines for redrawing. - */ - static void -may_update_popup_mask(int type) -{ - win_T *wp; - short *mask; - int line, col; - int redraw_all = FALSE; - - // Need to recompute when switching tabs. - // Also recompute when the type is CLEAR or NOT_VALID, something basic - // (such as the screen size) must have changed. - if (popup_mask_tab != curtab || type >= NOT_VALID) - { - popup_mask_refresh = TRUE; - redraw_all = TRUE; - } - if (!popup_mask_refresh) - { - // Check if any buffer has changed. - for (wp = first_popupwin; wp != NULL; wp = wp->w_next) - if (wp->w_popup_last_changedtick != CHANGEDTICK(wp->w_buffer)) - popup_mask_refresh = TRUE; - for (wp = curtab->tp_first_popupwin; wp != NULL; wp = wp->w_next) - if (wp->w_popup_last_changedtick != CHANGEDTICK(wp->w_buffer)) - popup_mask_refresh = TRUE; - if (!popup_mask_refresh) - return; - } - - // Need to update the mask, something has changed. - popup_mask_refresh = FALSE; - popup_mask_tab = curtab; - popup_visible = FALSE; - - // If redrawing everything, just update "popup_mask". - // If redrawing only what is needed, update "popup_mask_next" and then - // compare with "popup_mask" to see what changed. - if (type >= SOME_VALID) - mask = popup_mask; - else - mask = popup_mask_next; - vim_memset(mask, 0, screen_Rows * screen_Columns * sizeof(short)); - - // Find the window with the lowest zindex that hasn't been handled yet, - // so that the window with a higher zindex overwrites the value in - // popup_mask. - popup_reset_handled(); - while ((wp = find_next_popup(TRUE)) != NULL) - { - popup_visible = TRUE; - - // Recompute the position if the text changed. - if (redraw_all - || wp->w_popup_last_changedtick != CHANGEDTICK(wp->w_buffer)) - popup_adjust_position(wp); - - for (line = wp->w_winrow; - line < wp->w_winrow + popup_height(wp) - && line < screen_Rows; ++line) - for (col = wp->w_wincol; - col < wp->w_wincol + popup_width(wp) - && col < screen_Columns; ++col) - mask[line * screen_Columns + col] = wp->w_zindex; - } - - // Only check which lines are to be updated if not already - // updating all lines. - if (mask == popup_mask_next) - for (line = 0; line < screen_Rows; ++line) - { - int col_done = 0; - - for (col = 0; col < screen_Columns; ++col) - { - int off = line * screen_Columns + col; - - if (popup_mask[off] != popup_mask_next[off]) - { - popup_mask[off] = popup_mask_next[off]; - - // The screen position "line" / "col" needs to be redrawn. - // Figure out what window that is and update w_redraw_top - // and w_redr_bot. Only needs to be done for each window - // line. - if (col >= col_done) - { - linenr_T lnum; - int line_cp = line; - int col_cp = col; - - // find the window where the row is in - wp = mouse_find_win(&line_cp, &col_cp, IGNORE_POPUP); - if (wp != NULL) - { - if (line_cp >= wp->w_height) - // In (or below) status line - wp->w_redr_status = TRUE; - // compute the position in the buffer line from the - // position on the screen - else if (mouse_comp_pos(wp, &line_cp, &col_cp, - &lnum)) - // past bottom - wp->w_redr_status = TRUE; - else - redrawWinline(wp, lnum); - - // This line is going to be redrawn, no need to - // check until the right side of the window. - col_done = wp->w_wincol + wp->w_width - 1; - } - } - } - } - } -} - -/* - * Return a string of "len" spaces in IObuff. - */ - static char_u * -get_spaces(int len) -{ - vim_memset(IObuff, ' ', (size_t)len); - IObuff[len] = NUL; - return IObuff; -} - - static void -update_popups(void) -{ - win_T *wp; - int top_off; - int left_off; - int total_width; - int total_height; - int popup_attr; - int border_attr[4]; - int border_char[8]; - char_u buf[MB_MAXBYTES]; - int row; - int i; - - // Find the window with the lowest zindex that hasn't been updated yet, - // so that the window with a higher zindex is drawn later, thus goes on - // top. - popup_reset_handled(); - while ((wp = find_next_popup(TRUE)) != NULL) - { - // This drawing uses the zindex of the popup window, so that it's on - // top of the text but doesn't draw when another popup with higher - // zindex is on top of the character. - screen_zindex = wp->w_zindex; - - // adjust w_winrow and w_wincol for border and padding, since - // win_update() doesn't handle them. - top_off = wp->w_popup_padding[0] + wp->w_popup_border[0]; - left_off = wp->w_popup_padding[3] + wp->w_popup_border[3]; - wp->w_winrow += top_off; - wp->w_wincol += left_off; - - // Draw the popup text. - win_update(wp); - - wp->w_winrow -= top_off; - wp->w_wincol -= left_off; - - total_width = wp->w_popup_border[3] + wp->w_popup_padding[3] - + wp->w_width + wp->w_popup_padding[1] + wp->w_popup_border[1]; - total_height = wp->w_popup_border[0] + wp->w_popup_padding[0] - + wp->w_height + wp->w_popup_padding[2] + wp->w_popup_border[2]; - popup_attr = get_wcr_attr(wp); - - // We can only use these line drawing characters when 'encoding' is - // "utf-8" and 'ambiwidth' is "single". - if (enc_utf8 && *p_ambw == 's') - { - border_char[0] = border_char[2] = 0x2550; - border_char[1] = border_char[3] = 0x2551; - border_char[4] = 0x2554; - border_char[5] = 0x2557; - border_char[6] = 0x255d; - border_char[7] = 0x255a; - } - else - { - border_char[0] = border_char[2] = '-'; - border_char[1] = border_char[3] = '|'; - for (i = 4; i < 8; ++i) - border_char[i] = '+'; - } - for (i = 0; i < 8; ++i) - if (wp->w_border_char[i] != 0) - border_char[i] = wp->w_border_char[i]; - - for (i = 0; i < 4; ++i) - { - border_attr[i] = popup_attr; - if (wp->w_border_highlight[i] != NULL) - border_attr[i] = syn_name2attr(wp->w_border_highlight[i]); - } - - if (wp->w_popup_border[0] > 0) - { - // top border - screen_fill(wp->w_winrow, wp->w_winrow + 1, - wp->w_wincol, - wp->w_wincol + total_width, - wp->w_popup_border[3] != 0 - ? border_char[4] : border_char[0], - border_char[0], border_attr[0]); - if (wp->w_popup_border[1] > 0) - { - buf[mb_char2bytes(border_char[5], buf)] = NUL; - screen_puts(buf, wp->w_winrow, - wp->w_wincol + total_width - 1, border_attr[1]); - } - } - - if (wp->w_popup_padding[0] > 0) - { - // top padding - row = wp->w_winrow + wp->w_popup_border[0]; - screen_fill(row, row + wp->w_popup_padding[0], - wp->w_wincol + wp->w_popup_border[3], - wp->w_wincol + total_width - wp->w_popup_border[1], - ' ', ' ', popup_attr); - } - - for (row = wp->w_winrow + wp->w_popup_border[0]; - row < wp->w_winrow + total_height - wp->w_popup_border[2]; - ++row) - { - // left border - if (wp->w_popup_border[3] > 0) - { - buf[mb_char2bytes(border_char[3], buf)] = NUL; - screen_puts(buf, row, wp->w_wincol, border_attr[3]); - } - // left padding - if (wp->w_popup_padding[3] > 0) - screen_puts(get_spaces(wp->w_popup_padding[3]), row, - wp->w_wincol + wp->w_popup_border[3], popup_attr); - // right border - if (wp->w_popup_border[1] > 0) - { - buf[mb_char2bytes(border_char[1], buf)] = NUL; - screen_puts(buf, row, - wp->w_wincol + total_width - 1, border_attr[1]); - } - // right padding - if (wp->w_popup_padding[1] > 0) - screen_puts(get_spaces(wp->w_popup_padding[1]), row, - wp->w_wincol + wp->w_popup_border[3] - + wp->w_popup_padding[3] + wp->w_width, popup_attr); - } - - if (wp->w_popup_padding[2] > 0) - { - // bottom padding - row = wp->w_winrow + wp->w_popup_border[0] - + wp->w_popup_padding[0] + wp->w_height; - screen_fill(row, row + wp->w_popup_padding[2], - wp->w_wincol + wp->w_popup_border[3], - wp->w_wincol + total_width - wp->w_popup_border[1], - ' ', ' ', popup_attr); - } - - if (wp->w_popup_border[2] > 0) - { - // bottom border - row = wp->w_winrow + total_height - 1; - screen_fill(row , row + 1, - wp->w_wincol, - wp->w_wincol + total_width, - wp->w_popup_border[3] != 0 - ? border_char[7] : border_char[2], - border_char[2], border_attr[2]); - if (wp->w_popup_border[1] > 0) - { - buf[mb_char2bytes(border_char[6], buf)] = NUL; - screen_puts(buf, row, - wp->w_wincol + total_width - 1, border_attr[2]); - } - } - - // Back to the normal zindex. - screen_zindex = 0; - } -} -#endif - #if defined(FEAT_GUI) || defined(PROTO) /* * Update a single window, its status line and maybe the command line msg. @@ -1354,7 +1051,7 @@ updateWindow(win_T *wp) #ifdef FEAT_TEXT_PROP // Display popup windows on top of everything. - update_popups(); + update_popups(win_update); #endif update_finish(); |