Permalink
Browse files

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.
  • Loading branch information...
brammool committed Aug 12, 2017
1 parent 893029a commit 3d9bdfebf1a8c1eec1c3e1cff6fbb60b3d98f02a
Showing with 94 additions and 18 deletions.
  1. +32 −15 src/gui.c
  2. +1 −0 src/proto/syntax.pro
  3. +2 −0 src/proto/terminal.pro
  4. +1 −2 src/syntax.c
  5. +56 −1 src/terminal.c
  6. +2 −0 src/version.c
View
@@ -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,24 +1261,22 @@ 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
if (has_mbyte && (*mb_off2cells)(LineOffset[gui.row] + gui.col,
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
View
@@ -32,6 +32,7 @@ char_u *hl_get_font_name(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);
View
@@ -6,6 +6,8 @@ int term_job_running(term_T *term);
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);
View
@@ -103,7 +103,6 @@ static void highlight_clear(int idx);
#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);
@@ -8622,7 +8621,7 @@ hl_do_font(
* 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)
View
@@ -1163,11 +1163,57 @@ term_paste_register(int prev_c UNUSED)
}
}
#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;
@@ -1184,6 +1230,10 @@ may_set_cursor_props(term_T *term)
static void
may_restore_cursor_props(void)
{
#ifdef FEAT_GUI
if (gui.in_use)
return;
#endif
if (did_change_cursor)
{
did_change_cursor = FALSE;
@@ -1241,6 +1291,8 @@ terminal_loop(void)
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);
@@ -1447,7 +1499,10 @@ handle_settermprop(
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;
View
@@ -769,6 +769,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
921,
/**/
920,
/**/

0 comments on commit 3d9bdfe

Please sign in to comment.