comparison src/gui.c @ 19824:09a621bdb0bc v8.2.0468

patch 8.2.0468: GUI: pixel dust with some fonts and characters Commit: https://github.com/vim/vim/commit/7c003aa314337ce732e18c541fa93d71cafedf03 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 28 20:44:41 2020 +0100 patch 8.2.0468: GUI: pixel dust with some fonts and characters Problem: GUI: pixel dust with some fonts and characters. Solution: Always redraw the character before the cursor. (Nir Lichtman, closes #5549, closes #5856)
author Bram Moolenaar <Bram@vim.org>
date Sat, 28 Mar 2020 20:45:04 +0100
parents 9daed26b788b
children 435726a03481
comparison
equal deleted inserted replaced
19823:fafab4bec82f 19824:09a621bdb0bc
2628 return OK; 2628 return OK;
2629 } 2629 }
2630 2630
2631 /* 2631 /*
2632 * Un-draw the cursor. Actually this just redraws the character at the given 2632 * Un-draw the cursor. Actually this just redraws the character at the given
2633 * position. The character just before it too, for when it was in bold. 2633 * position.
2634 */ 2634 */
2635 void 2635 void
2636 gui_undraw_cursor(void) 2636 gui_undraw_cursor(void)
2637 { 2637 {
2638 if (gui.cursor_is_valid) 2638 if (gui.cursor_is_valid)
2639 { 2639 {
2640 if (gui_redraw_block(gui.cursor_row, gui.cursor_col, 2640 // Redraw the character just before too, if there is one, because with
2641 gui.cursor_row, gui.cursor_col, GUI_MON_NOCLEAR) 2641 // some fonts and characters there can be a one pixel overlap.
2642 && gui.cursor_col > 0) 2642 gui_redraw_block(gui.cursor_row,
2643 (void)gui_redraw_block(gui.cursor_row, gui.cursor_col - 1, 2643 gui.cursor_col > 0 ? gui.cursor_col - 1 : gui.cursor_col,
2644 gui.cursor_row, gui.cursor_col - 1, GUI_MON_NOCLEAR); 2644 gui.cursor_row, gui.cursor_col, GUI_MON_NOCLEAR);
2645
2645 // Cursor_is_valid is reset when the cursor is undrawn, also reset it 2646 // Cursor_is_valid is reset when the cursor is undrawn, also reset it
2646 // here in case it wasn't needed to undraw it. 2647 // here in case it wasn't needed to undraw it.
2647 gui.cursor_is_valid = FALSE; 2648 gui.cursor_is_valid = FALSE;
2648 } 2649 }
2649 } 2650 }
2660 row1 = Y_2_ROW(y); 2661 row1 = Y_2_ROW(y);
2661 col1 = X_2_COL(x); 2662 col1 = X_2_COL(x);
2662 row2 = Y_2_ROW(y + h - 1); 2663 row2 = Y_2_ROW(y + h - 1);
2663 col2 = X_2_COL(x + w - 1); 2664 col2 = X_2_COL(x + w - 1);
2664 2665
2665 (void)gui_redraw_block(row1, col1, row2, col2, GUI_MON_NOCLEAR); 2666 gui_redraw_block(row1, col1, row2, col2, GUI_MON_NOCLEAR);
2666 2667
2667 /* 2668 /*
2668 * We may need to redraw the cursor, but don't take it upon us to change 2669 * We may need to redraw the cursor, but don't take it upon us to change
2669 * its location after a scroll. 2670 * its location after a scroll.
2670 * (maybe be more strict even and test col too?) 2671 * (maybe be more strict even and test col too?)
2676 } 2677 }
2677 2678
2678 /* 2679 /*
2679 * Draw a rectangular block of characters, from row1 to row2 (inclusive) and 2680 * Draw a rectangular block of characters, from row1 to row2 (inclusive) and
2680 * from col1 to col2 (inclusive). 2681 * from col1 to col2 (inclusive).
2681 * Return TRUE when the character before the first drawn character has 2682 */
2682 * different attributes (may have to be redrawn too). 2683 void
2683 */
2684 int
2685 gui_redraw_block( 2684 gui_redraw_block(
2686 int row1, 2685 int row1,
2687 int col1, 2686 int col1,
2688 int row2, 2687 int row2,
2689 int col2, 2688 int col2,
2693 long_u old_hl_mask; 2692 long_u old_hl_mask;
2694 int off; 2693 int off;
2695 sattr_T first_attr; 2694 sattr_T first_attr;
2696 int idx, len; 2695 int idx, len;
2697 int back, nback; 2696 int back, nback;
2698 int retval = FALSE;
2699 int orig_col1, orig_col2; 2697 int orig_col1, orig_col2;
2700 2698
2701 // Don't try to update when ScreenLines is not valid 2699 // Don't try to update when ScreenLines is not valid
2702 if (!screen_cleared || ScreenLines == NULL) 2700 if (!screen_cleared || ScreenLines == NULL)
2703 return retval; 2701 return;
2704 2702
2705 // Don't try to draw outside the shell! 2703 // Don't try to draw outside the shell!
2706 // Check everything, strange values may be caused by a big border width 2704 // Check everything, strange values may be caused by a big border width
2707 col1 = check_col(col1); 2705 col1 = check_col(col1);
2708 col2 = check_col(col2); 2706 col2 = check_col(col2);
2760 // is. Needed for when the bold trick is used 2758 // is. Needed for when the bold trick is used
2761 for (back = 0; back < col1; ++back) 2759 for (back = 0; back < col1; ++back)
2762 if (ScreenAttrs[off - 1 - back] != ScreenAttrs[off] 2760 if (ScreenAttrs[off - 1 - back] != ScreenAttrs[off]
2763 || ScreenLines[off - 1 - back] == ' ') 2761 || ScreenLines[off - 1 - back] == ' ')
2764 break; 2762 break;
2765 retval = (col1 > 0 && ScreenAttrs[off - 1] != 0 && back == 0
2766 && ScreenLines[off - 1] != ' ');
2767 2763
2768 // Break it up in strings of characters with the same attributes. 2764 // Break it up in strings of characters with the same attributes.
2769 // Print UTF-8 characters individually. 2765 // Print UTF-8 characters individually.
2770 while (len > 0) 2766 while (len > 0)
2771 { 2767 {
2843 2839
2844 // Put the cursor back where it was 2840 // Put the cursor back where it was
2845 gui.row = old_row; 2841 gui.row = old_row;
2846 gui.col = old_col; 2842 gui.col = old_col;
2847 gui.highlight_mask = (int)old_hl_mask; 2843 gui.highlight_mask = (int)old_hl_mask;
2848
2849 return retval;
2850 } 2844 }
2851 2845
2852 static void 2846 static void
2853 gui_delete_lines(int row, int count) 2847 gui_delete_lines(int row, int count)
2854 { 2848 {