Skip to content

Commit 7c003aa

Browse files
committed
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)
1 parent 33fa29c commit 7c003aa

4 files changed

Lines changed: 17 additions & 22 deletions

File tree

src/gui.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2630,18 +2630,19 @@ gui_outstr_nowrap(
26302630

26312631
/*
26322632
* 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.
26342634
*/
26352635
void
26362636
gui_undraw_cursor(void)
26372637
{
26382638
if (gui.cursor_is_valid)
26392639
{
2640-
if (gui_redraw_block(gui.cursor_row, gui.cursor_col,
2641-
gui.cursor_row, gui.cursor_col, GUI_MON_NOCLEAR)
2642-
&& gui.cursor_col > 0)
2643-
(void)gui_redraw_block(gui.cursor_row, gui.cursor_col - 1,
2644-
gui.cursor_row, gui.cursor_col - 1, GUI_MON_NOCLEAR);
2640+
// Redraw the character just before too, if there is one, because with
2641+
// some fonts and characters there can be a one pixel overlap.
2642+
gui_redraw_block(gui.cursor_row,
2643+
gui.cursor_col > 0 ? gui.cursor_col - 1 : gui.cursor_col,
2644+
gui.cursor_row, gui.cursor_col, GUI_MON_NOCLEAR);
2645+
26452646
// Cursor_is_valid is reset when the cursor is undrawn, also reset it
26462647
// here in case it wasn't needed to undraw it.
26472648
gui.cursor_is_valid = FALSE;
@@ -2662,7 +2663,7 @@ gui_redraw(
26622663
row2 = Y_2_ROW(y + h - 1);
26632664
col2 = X_2_COL(x + w - 1);
26642665

2665-
(void)gui_redraw_block(row1, col1, row2, col2, GUI_MON_NOCLEAR);
2666+
gui_redraw_block(row1, col1, row2, col2, GUI_MON_NOCLEAR);
26662667

26672668
/*
26682669
* We may need to redraw the cursor, but don't take it upon us to change
@@ -2678,10 +2679,8 @@ gui_redraw(
26782679
/*
26792680
* Draw a rectangular block of characters, from row1 to row2 (inclusive) and
26802681
* from col1 to col2 (inclusive).
2681-
* Return TRUE when the character before the first drawn character has
2682-
* different attributes (may have to be redrawn too).
26832682
*/
2684-
int
2683+
void
26852684
gui_redraw_block(
26862685
int row1,
26872686
int col1,
@@ -2695,12 +2694,11 @@ gui_redraw_block(
26952694
sattr_T first_attr;
26962695
int idx, len;
26972696
int back, nback;
2698-
int retval = FALSE;
26992697
int orig_col1, orig_col2;
27002698

27012699
// Don't try to update when ScreenLines is not valid
27022700
if (!screen_cleared || ScreenLines == NULL)
2703-
return retval;
2701+
return;
27042702

27052703
// Don't try to draw outside the shell!
27062704
// Check everything, strange values may be caused by a big border width
@@ -2762,8 +2760,6 @@ gui_redraw_block(
27622760
if (ScreenAttrs[off - 1 - back] != ScreenAttrs[off]
27632761
|| ScreenLines[off - 1 - back] == ' ')
27642762
break;
2765-
retval = (col1 > 0 && ScreenAttrs[off - 1] != 0 && back == 0
2766-
&& ScreenLines[off - 1] != ' ');
27672763

27682764
// Break it up in strings of characters with the same attributes.
27692765
// Print UTF-8 characters individually.
@@ -2845,8 +2841,6 @@ gui_redraw_block(
28452841
gui.row = old_row;
28462842
gui.col = old_col;
28472843
gui.highlight_mask = (int)old_hl_mask;
2848-
2849-
return retval;
28502844
}
28512845

28522846
static void

src/proto/gui.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void gui_enable_flush(void);
2727
void gui_may_flush(void);
2828
void gui_undraw_cursor(void);
2929
void gui_redraw(int x, int y, int w, int h);
30-
int gui_redraw_block(int row1, int col1, int row2, int col2, int flags);
30+
void gui_redraw_block(int row1, int col1, int row2, int col2, int flags);
3131
int gui_wait_for_chars(long wtime, int tb_change_cnt);
3232
int gui_inchar(char_u *buf, int maxlen, long wtime, int tb_change_cnt);
3333
void gui_send_mouse_event(int button, int x, int y, int repeated_click, int_u modifiers);

src/screen.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2788,11 +2788,10 @@ screenalloc(int doclear)
27882788
&& ScreenLines != NULL
27892789
&& old_Rows != Rows)
27902790
{
2791-
(void)gui_redraw_block(0, 0, (int)Rows - 1, (int)Columns - 1, 0);
2792-
/*
2793-
* Adjust the position of the cursor, for when executing an external
2794-
* command.
2795-
*/
2791+
gui_redraw_block(0, 0, (int)Rows - 1, (int)Columns - 1, 0);
2792+
2793+
// Adjust the position of the cursor, for when executing an external
2794+
// command.
27962795
if (msg_row >= Rows) // Rows got smaller
27972796
msg_row = Rows - 1; // put cursor at last row
27982797
else if (Rows > old_Rows) // Rows got bigger

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ static char *(features[]) =
738738

739739
static int included_patches[] =
740740
{ /* Add new patch number below this line */
741+
/**/
742+
468,
741743
/**/
742744
467,
743745
/**/

0 commit comments

Comments
 (0)