summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDusan Popovic <dpx@binaryapparatus.com>2021-11-22 17:18:44 +0000
committerBram Moolenaar <Bram@vim.org>2021-11-22 17:18:44 +0000
commitce59b9f29244d98e55e3ec6be341c4d521159e8f (patch)
tree3ac72880c86f0e3e63eee2d71170ddc2f6d5033e
parentc449271f4efa44725c40116a95b213813040312f (diff)
downloadvim-git-ce59b9f29244d98e55e3ec6be341c4d521159e8f.tar.gz
patch 8.2.3647: GTK: when using ligatures the cursor is drawn wrongv8.2.3647
Problem: GTK: when using ligatures the cursor is drawn wrong. Solution: Clear more characters when ligatures are used. (Dusan Popovic, closes #9190)
-rw-r--r--src/gui.c44
-rw-r--r--src/version.c2
2 files changed, 39 insertions, 7 deletions
diff --git a/src/gui.c b/src/gui.c
index 68754b3bc..39f69e104 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -1097,6 +1097,31 @@ gui_set_ligatures(void)
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,19 +2698,24 @@ gui_outstr_nowrap(
}
/*
- * Un-draw the cursor. Actually this just redraws the character at the given
- * position.
+ * 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)
{
- // 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);
+ // 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.
diff --git a/src/version.c b/src/version.c
index c76ce0281..1871c7fc4 100644
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 3647,
+/**/
3646,
/**/
3645,