Problem: Terminal window cursor shape not supported in the GUI.
Solution: Use the terminal window cursor shape in the GUI.
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;
/*
* 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);
}
old_hl_mask = gui.highlight_mask;
- if (shape_table[idx].shape == SHAPE_BLOCK
+ if (shape->shape == SHAPE_BLOCK
#ifdef FEAT_HANGULIN
|| composing_hangul
#endif
* 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
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)
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
void hl_set_font_name(char_u *font_name);
void hl_set_bg_color_name(char_u *name);
void hl_set_fg_color_name(char_u *name);
+guicolor_T color_name2handle(char_u *name);
int get_cterm_attr_idx(int attr, int fg, int bg);
int get_tgc_attr_idx(int attr, guicolor_T fg, guicolor_T bg);
int get_gui_attr_idx(int attr, guicolor_T fg, guicolor_T bg);
int term_in_normal_mode(void);
void term_enter_job_mode(void);
int send_keys_to_term(term_T *term, int c, int typed);
+int use_terminal_cursor(void);
+cursorentry_T *term_get_cursor_shape(guicolor_T *fg, guicolor_T *bg);
int term_use_loop(void);
int terminal_loop(void);
void term_job_ended(job_T *job);
#if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS)
static void gui_do_one_color(int idx, int do_menu, int do_tooltip);
-static guicolor_T color_name2handle(char_u *name);
#endif
#ifdef FEAT_GUI
static int set_group_colors(char_u *name, guicolor_T *fgp, guicolor_T *bgp, int do_menu, int use_norm, int do_tooltip);
* Return the handle for a color name.
* Returns INVALCOLOR when failed.
*/
- static guicolor_T
+ guicolor_T
color_name2handle(char_u *name)
{
if (STRCMP(name, "NONE") == 0)
}
}
+#if defined(FEAT_GUI) || defined(PROTO)
+/*
+ * Return TRUE when the cursor of the terminal should be displayed.
+ */
+ int
+use_terminal_cursor()
+{
+ return in_terminal_loop != NULL;
+}
+
+ cursorentry_T *
+term_get_cursor_shape(guicolor_T *fg, guicolor_T *bg)
+{
+ term_T *term = in_terminal_loop;
+ static cursorentry_T entry;
+
+ vim_memset(&entry, 0, sizeof(entry));
+ entry.shape = entry.mshape =
+ term->tl_cursor_shape == VTERM_PROP_CURSORSHAPE_UNDERLINE ? SHAPE_HOR :
+ term->tl_cursor_shape == VTERM_PROP_CURSORSHAPE_BAR_LEFT ? SHAPE_VER :
+ SHAPE_BLOCK;
+ entry.percentage = 20;
+ if (term->tl_cursor_blink)
+ {
+ entry.blinkwait = 700;
+ entry.blinkon = 400;
+ entry.blinkon = 250;
+ }
+ *fg = gui.back_pixel;
+ if (term->tl_cursor_color == NULL)
+ *bg = gui.norm_pixel;
+ else
+ *bg = color_name2handle(term->tl_cursor_color);
+ entry.name = "n";
+ entry.used_for = SHAPE_CURSOR;
+
+ return &entry;
+}
+#endif
+
static int did_change_cursor = FALSE;
static void
may_set_cursor_props(term_T *term)
{
+#ifdef FEAT_GUI
+ /* For the GUI the cursor properties are obtained with
+ * term_get_cursor_shape(). */
+ if (gui.in_use)
+ return;
+#endif
if (in_terminal_loop == term)
{
did_change_cursor = TRUE;
static void
may_restore_cursor_props(void)
{
+#ifdef FEAT_GUI
+ if (gui.in_use)
+ return;
+#endif
if (did_change_cursor)
{
did_change_cursor = FALSE;
if (!term_use_loop())
/* job finished while waiting for a character */
break;
+ if (c == K_IGNORE)
+ continue;
#ifdef UNIX
may_send_sigint(c, curbuf->b_term->tl_job->jv_pid, 0);
case VTERM_PROP_CURSORCOLOR:
vim_free(term->tl_cursor_color);
- term->tl_cursor_color = vim_strsave((char_u *)value->string);
+ if (*value->string == NUL)
+ term->tl_cursor_color = NULL;
+ else
+ term->tl_cursor_color = vim_strsave((char_u *)value->string);
may_set_cursor_props(term);
break;
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 921,
/**/
920,
/**/