diff src/gui.c @ 12082:504df4aa84c6 v8.0.0921

patch 8.0.0921: terminal window cursor shape not supported in the GUI commit https://github.com/vim/vim/commit/3d9bdfebf1a8c1eec1c3e1cff6fbb60b3d98f02a Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 12 22:55:58 2017 +0200 patch 8.0.0921: terminal window cursor shape not supported in the GUI Problem: Terminal window cursor shape not supported in the GUI. Solution: Use the terminal window cursor shape in the GUI.
author Christian Brabandt <cb@256bit.org>
date Sat, 12 Aug 2017 23:00:04 +0200
parents 578df034735d
children 60cf03e59402
line wrap: on
line diff
--- a/src/gui.c
+++ b/src/gui.c
@@ -1051,8 +1051,12 @@ gui_update_cursor(
     int		cur_width = 0;
     int		cur_height = 0;
     int		old_hl_mask;
-    int		idx;
+    cursorentry_T *shape;
     int		id;
+#ifdef FEAT_TERMINAL
+    guicolor_T	shape_fg = INVALCOLOR;
+    guicolor_T	shape_bg = INVALCOLOR;
+#endif
     guicolor_T	cfg, cbg, cc;	/* cursor fore-/background color */
     int		cattr;		/* cursor attributes */
     int		attr;
@@ -1094,20 +1098,35 @@ gui_update_cursor(
 
 	/*
 	 * How the cursor is drawn depends on the current mode.
+	 * When in a terminal window use the shape/color specified there.
 	 */
-	idx = get_shape_idx(FALSE);
+#ifdef FEAT_TERMINAL
+	if (use_terminal_cursor())
+	    shape = term_get_cursor_shape(&shape_fg, &shape_bg);
+	else
+#endif
+	    shape = &shape_table[get_shape_idx(FALSE)];
 	if (State & LANGMAP)
-	    id = shape_table[idx].id_lm;
+	    id = shape->id_lm;
 	else
-	    id = shape_table[idx].id;
+	    id = shape->id;
 
 	/* get the colors and attributes for the cursor.  Default is inverted */
 	cfg = INVALCOLOR;
 	cbg = INVALCOLOR;
 	cattr = HL_INVERSE;
-	gui_mch_set_blinking(shape_table[idx].blinkwait,
-			     shape_table[idx].blinkon,
-			     shape_table[idx].blinkoff);
+	gui_mch_set_blinking(shape->blinkwait,
+			     shape->blinkon,
+			     shape->blinkoff);
+#ifdef FEAT_TERMINAL
+	if (shape_bg != INVALCOLOR)
+	{
+	    cattr = 0;
+	    cfg = shape_fg;
+	    cbg = shape_bg;
+	}
+	else
+#endif
 	if (id > 0)
 	{
 	    cattr = syn_id2colors(id, &cfg, &cbg);
@@ -1202,7 +1221,7 @@ gui_update_cursor(
 	}
 
 	old_hl_mask = gui.highlight_mask;
-	if (shape_table[idx].shape == SHAPE_BLOCK
+	if (shape->shape == SHAPE_BLOCK
 #ifdef FEAT_HANGULIN
 		|| composing_hangul
 #endif
@@ -1242,16 +1261,14 @@ gui_update_cursor(
 	     * First draw the partial cursor, then overwrite with the text
 	     * character, using a transparent background.
 	     */
-	    if (shape_table[idx].shape == SHAPE_VER)
+	    if (shape->shape == SHAPE_VER)
 	    {
 		cur_height = gui.char_height;
-		cur_width = (gui.char_width * shape_table[idx].percentage
-								  + 99) / 100;
+		cur_width = (gui.char_width * shape->percentage + 99) / 100;
 	    }
 	    else
 	    {
-		cur_height = (gui.char_height * shape_table[idx].percentage
-								  + 99) / 100;
+		cur_height = (gui.char_height * shape->percentage + 99) / 100;
 		cur_width = gui.char_width;
 	    }
 #ifdef FEAT_MBYTE
@@ -1259,7 +1276,7 @@ gui_update_cursor(
 				    LineOffset[gui.row] + screen_Columns) > 1)
 	    {
 		/* Double wide character. */
-		if (shape_table[idx].shape != SHAPE_VER)
+		if (shape->shape != SHAPE_VER)
 		    cur_width += gui.char_width;
 # ifdef FEAT_RIGHTLEFT
 		if (CURSOR_BAR_RIGHT)
@@ -1728,7 +1745,7 @@ gui_clear_block(
     void
 gui_update_cursor_later(void)
 {
- OUT_STR(IF_EB("\033|s", ESC_STR "|s"));
+    OUT_STR(IF_EB("\033|s", ESC_STR "|s"));
 }
 
     void