Patch 8.2.3647

6 views
Skip to first unread message

Bram Moolenaar

unread,
Nov 22, 2021, 12:19:38 PM11/22/21
to vim...@googlegroups.com

Patch 8.2.3647
Problem: GTK: when using ligatures the cursor is drawn wrong.
Solution: Clear more characters when ligatures are used. (Dusan Popovic,
closes #9190)
Files: src/gui.c


*** ../vim-8.2.3646/src/gui.c 2021-10-24 20:34:01.430895189 +0100
--- src/gui.c 2021-11-22 17:14:18.707414957 +0000
***************
*** 1097,1102 ****
--- 1097,1127 ----
else
CLEAR_FIELD(gui.ligatures_map);
}
+
+ /*
+ * Adjust the columns to undraw for when the cursor is on ligatures.
+ */
+ static void
+ gui_adjust_undraw_cursor_for_ligatures(int *startcol, int *endcol)
+ {
+ int off;
+
+ if (ScreenLines == NULL || *p_guiligatures == NUL)
+ return;
+
+ // expand before the cursor for all the chars in gui.ligatures_map
+ off = LineOffset[gui.cursor_row] + *startcol;
+ if (gui.ligatures_map[ScreenLines[off]])
+ while (*startcol > 0 && gui.ligatures_map[ScreenLines[--off]])
+ (*startcol)--;
+
+ // expand after the cursor for all the chars in gui.ligatures_map
+ off = LineOffset[gui.cursor_row] + *endcol;
+ if (gui.ligatures_map[ScreenLines[off]])
+ while (*endcol < ((int)screen_Columns - 1)
+ && gui.ligatures_map[ScreenLines[++off]])
+ (*endcol)++;
+ }
#endif

static void
***************
*** 2673,2691 ****
}

/*
! * Un-draw the cursor. Actually this just redraws the character at the given
! * position.
*/
void
gui_undraw_cursor(void)
{
if (gui.cursor_is_valid)
{
! // Redraw the character just before too, if there is one, because with
! // some fonts and characters there can be a one pixel overlap.
! gui_redraw_block(gui.cursor_row,
! gui.cursor_col > 0 ? gui.cursor_col - 1 : gui.cursor_col,
! gui.cursor_row, gui.cursor_col, GUI_MON_NOCLEAR);

// Cursor_is_valid is reset when the cursor is undrawn, also reset it
// here in case it wasn't needed to undraw it.
--- 2698,2721 ----
}

/*
! * Undraw the cursor. This actually redraws the character at the cursor
! * position, plus some more characters when needed.
*/
void
gui_undraw_cursor(void)
{
if (gui.cursor_is_valid)
{
! // Always redraw the character just before if there is one, because
! // with some fonts and characters there can be a one pixel overlap.
! int startcol = gui.cursor_col > 0 ? gui.cursor_col - 1 : gui.cursor_col;
! int endcol = gui.cursor_col;
!
! #ifdef FEAT_GUI_GTK
! gui_adjust_undraw_cursor_for_ligatures(&startcol, &endcol);
! #endif
! gui_redraw_block(gui.cursor_row, startcol,
! gui.cursor_row, endcol, GUI_MON_NOCLEAR);

// Cursor_is_valid is reset when the cursor is undrawn, also reset it
// here in case it wasn't needed to undraw it.
*** ../vim-8.2.3646/src/version.c 2021-11-22 15:37:11.752625328 +0000
--- src/version.c 2021-11-22 17:04:13.927106049 +0000
***************
*** 759,760 ****
--- 759,762 ----
{ /* Add new patch number below this line */
+ /**/
+ 3647,
/**/

--
To the optimist, the glass is half full.
To the pessimist, the glass is half empty.
To the engineer, the glass is twice as big as it needs to be.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages