comparison 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
comparison
equal deleted inserted replaced
12081:318726cc2e48 12082:504df4aa84c6
1049 int clear_selection)/* clear selection under cursor */ 1049 int clear_selection)/* clear selection under cursor */
1050 { 1050 {
1051 int cur_width = 0; 1051 int cur_width = 0;
1052 int cur_height = 0; 1052 int cur_height = 0;
1053 int old_hl_mask; 1053 int old_hl_mask;
1054 int idx; 1054 cursorentry_T *shape;
1055 int id; 1055 int id;
1056 #ifdef FEAT_TERMINAL
1057 guicolor_T shape_fg = INVALCOLOR;
1058 guicolor_T shape_bg = INVALCOLOR;
1059 #endif
1056 guicolor_T cfg, cbg, cc; /* cursor fore-/background color */ 1060 guicolor_T cfg, cbg, cc; /* cursor fore-/background color */
1057 int cattr; /* cursor attributes */ 1061 int cattr; /* cursor attributes */
1058 int attr; 1062 int attr;
1059 attrentry_T *aep = NULL; 1063 attrentry_T *aep = NULL;
1060 1064
1092 1096
1093 gui.cursor_is_valid = TRUE; 1097 gui.cursor_is_valid = TRUE;
1094 1098
1095 /* 1099 /*
1096 * How the cursor is drawn depends on the current mode. 1100 * How the cursor is drawn depends on the current mode.
1101 * When in a terminal window use the shape/color specified there.
1097 */ 1102 */
1098 idx = get_shape_idx(FALSE); 1103 #ifdef FEAT_TERMINAL
1104 if (use_terminal_cursor())
1105 shape = term_get_cursor_shape(&shape_fg, &shape_bg);
1106 else
1107 #endif
1108 shape = &shape_table[get_shape_idx(FALSE)];
1099 if (State & LANGMAP) 1109 if (State & LANGMAP)
1100 id = shape_table[idx].id_lm; 1110 id = shape->id_lm;
1101 else 1111 else
1102 id = shape_table[idx].id; 1112 id = shape->id;
1103 1113
1104 /* get the colors and attributes for the cursor. Default is inverted */ 1114 /* get the colors and attributes for the cursor. Default is inverted */
1105 cfg = INVALCOLOR; 1115 cfg = INVALCOLOR;
1106 cbg = INVALCOLOR; 1116 cbg = INVALCOLOR;
1107 cattr = HL_INVERSE; 1117 cattr = HL_INVERSE;
1108 gui_mch_set_blinking(shape_table[idx].blinkwait, 1118 gui_mch_set_blinking(shape->blinkwait,
1109 shape_table[idx].blinkon, 1119 shape->blinkon,
1110 shape_table[idx].blinkoff); 1120 shape->blinkoff);
1121 #ifdef FEAT_TERMINAL
1122 if (shape_bg != INVALCOLOR)
1123 {
1124 cattr = 0;
1125 cfg = shape_fg;
1126 cbg = shape_bg;
1127 }
1128 else
1129 #endif
1111 if (id > 0) 1130 if (id > 0)
1112 { 1131 {
1113 cattr = syn_id2colors(id, &cfg, &cbg); 1132 cattr = syn_id2colors(id, &cfg, &cbg);
1114 #if defined(USE_IM_CONTROL) || defined(FEAT_HANGULIN) 1133 #if defined(USE_IM_CONTROL) || defined(FEAT_HANGULIN)
1115 { 1134 {
1200 gui_mch_draw_hollow_cursor(cbg); 1219 gui_mch_draw_hollow_cursor(cbg);
1201 return; 1220 return;
1202 } 1221 }
1203 1222
1204 old_hl_mask = gui.highlight_mask; 1223 old_hl_mask = gui.highlight_mask;
1205 if (shape_table[idx].shape == SHAPE_BLOCK 1224 if (shape->shape == SHAPE_BLOCK
1206 #ifdef FEAT_HANGULIN 1225 #ifdef FEAT_HANGULIN
1207 || composing_hangul 1226 || composing_hangul
1208 #endif 1227 #endif
1209 ) 1228 )
1210 { 1229 {
1240 #endif 1259 #endif
1241 /* 1260 /*
1242 * First draw the partial cursor, then overwrite with the text 1261 * First draw the partial cursor, then overwrite with the text
1243 * character, using a transparent background. 1262 * character, using a transparent background.
1244 */ 1263 */
1245 if (shape_table[idx].shape == SHAPE_VER) 1264 if (shape->shape == SHAPE_VER)
1246 { 1265 {
1247 cur_height = gui.char_height; 1266 cur_height = gui.char_height;
1248 cur_width = (gui.char_width * shape_table[idx].percentage 1267 cur_width = (gui.char_width * shape->percentage + 99) / 100;
1249 + 99) / 100;
1250 } 1268 }
1251 else 1269 else
1252 { 1270 {
1253 cur_height = (gui.char_height * shape_table[idx].percentage 1271 cur_height = (gui.char_height * shape->percentage + 99) / 100;
1254 + 99) / 100;
1255 cur_width = gui.char_width; 1272 cur_width = gui.char_width;
1256 } 1273 }
1257 #ifdef FEAT_MBYTE 1274 #ifdef FEAT_MBYTE
1258 if (has_mbyte && (*mb_off2cells)(LineOffset[gui.row] + gui.col, 1275 if (has_mbyte && (*mb_off2cells)(LineOffset[gui.row] + gui.col,
1259 LineOffset[gui.row] + screen_Columns) > 1) 1276 LineOffset[gui.row] + screen_Columns) > 1)
1260 { 1277 {
1261 /* Double wide character. */ 1278 /* Double wide character. */
1262 if (shape_table[idx].shape != SHAPE_VER) 1279 if (shape->shape != SHAPE_VER)
1263 cur_width += gui.char_width; 1280 cur_width += gui.char_width;
1264 # ifdef FEAT_RIGHTLEFT 1281 # ifdef FEAT_RIGHTLEFT
1265 if (CURSOR_BAR_RIGHT) 1282 if (CURSOR_BAR_RIGHT)
1266 { 1283 {
1267 /* gui.col points to the left halve of the character but 1284 /* gui.col points to the left halve of the character but
1726 * output buffer before calling gui_update_cursor(). 1743 * output buffer before calling gui_update_cursor().
1727 */ 1744 */
1728 void 1745 void
1729 gui_update_cursor_later(void) 1746 gui_update_cursor_later(void)
1730 { 1747 {
1731 OUT_STR(IF_EB("\033|s", ESC_STR "|s")); 1748 OUT_STR(IF_EB("\033|s", ESC_STR "|s"));
1732 } 1749 }
1733 1750
1734 void 1751 void
1735 gui_write( 1752 gui_write(
1736 char_u *s, 1753 char_u *s,