mirror of
https://github.com/tmux/tmux.git
synced 2024-10-31 22:58:49 +00:00
Separate "very visible" flag from blinking flag, it should not affect
DECSCUSR. GitHub issue 2891.
This commit is contained in:
parent
3d5a02bf45
commit
9b1fdb291e
8
input.c
8
input.c
@ -1646,7 +1646,7 @@ input_csi_dispatch_rm(struct input_ctx *ictx)
|
|||||||
screen_write_mode_clear(sctx, MODE_INSERT);
|
screen_write_mode_clear(sctx, MODE_INSERT);
|
||||||
break;
|
break;
|
||||||
case 34:
|
case 34:
|
||||||
screen_write_mode_set(sctx, MODE_BLINKING);
|
screen_write_mode_set(sctx, MODE_CURSOR_VERY_VISIBLE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_debug("%s: unknown '%c'", __func__, ictx->ch);
|
log_debug("%s: unknown '%c'", __func__, ictx->ch);
|
||||||
@ -1682,7 +1682,7 @@ input_csi_dispatch_rm_private(struct input_ctx *ictx)
|
|||||||
screen_write_mode_clear(sctx, MODE_WRAP);
|
screen_write_mode_clear(sctx, MODE_WRAP);
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
screen_write_mode_clear(sctx, MODE_BLINKING);
|
screen_write_mode_clear(sctx, MODE_CURSOR_BLINKING);
|
||||||
break;
|
break;
|
||||||
case 25: /* TCEM */
|
case 25: /* TCEM */
|
||||||
screen_write_mode_clear(sctx, MODE_CURSOR);
|
screen_write_mode_clear(sctx, MODE_CURSOR);
|
||||||
@ -1734,7 +1734,7 @@ input_csi_dispatch_sm(struct input_ctx *ictx)
|
|||||||
screen_write_mode_set(sctx, MODE_INSERT);
|
screen_write_mode_set(sctx, MODE_INSERT);
|
||||||
break;
|
break;
|
||||||
case 34:
|
case 34:
|
||||||
screen_write_mode_clear(sctx, MODE_BLINKING);
|
screen_write_mode_clear(sctx, MODE_CURSOR_VERY_VISIBLE);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_debug("%s: unknown '%c'", __func__, ictx->ch);
|
log_debug("%s: unknown '%c'", __func__, ictx->ch);
|
||||||
@ -1771,7 +1771,7 @@ input_csi_dispatch_sm_private(struct input_ctx *ictx)
|
|||||||
screen_write_mode_set(sctx, MODE_WRAP);
|
screen_write_mode_set(sctx, MODE_WRAP);
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
screen_write_mode_set(sctx, MODE_BLINKING);
|
screen_write_mode_set(sctx, MODE_CURSOR_BLINKING);
|
||||||
break;
|
break;
|
||||||
case 25: /* TCEM */
|
case 25: /* TCEM */
|
||||||
screen_write_mode_set(sctx, MODE_CURSOR);
|
screen_write_mode_set(sctx, MODE_CURSOR);
|
||||||
|
18
screen.c
18
screen.c
@ -163,27 +163,27 @@ screen_set_cursor_style(struct screen *s, u_int style)
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
s->cstyle = SCREEN_CURSOR_BLOCK;
|
s->cstyle = SCREEN_CURSOR_BLOCK;
|
||||||
s->mode |= MODE_BLINKING;
|
s->mode |= MODE_CURSOR_BLINKING;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
s->cstyle = SCREEN_CURSOR_BLOCK;
|
s->cstyle = SCREEN_CURSOR_BLOCK;
|
||||||
s->mode &= ~MODE_BLINKING;
|
s->mode &= ~MODE_CURSOR_BLINKING;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
s->cstyle = SCREEN_CURSOR_UNDERLINE;
|
s->cstyle = SCREEN_CURSOR_UNDERLINE;
|
||||||
s->mode |= MODE_BLINKING;
|
s->mode |= MODE_CURSOR_BLINKING;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
s->cstyle = SCREEN_CURSOR_UNDERLINE;
|
s->cstyle = SCREEN_CURSOR_UNDERLINE;
|
||||||
s->mode &= ~MODE_BLINKING;
|
s->mode &= ~MODE_CURSOR_BLINKING;
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
s->cstyle = SCREEN_CURSOR_BAR;
|
s->cstyle = SCREEN_CURSOR_BAR;
|
||||||
s->mode |= MODE_BLINKING;
|
s->mode |= MODE_CURSOR_BLINKING;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
s->cstyle = SCREEN_CURSOR_BAR;
|
s->cstyle = SCREEN_CURSOR_BAR;
|
||||||
s->mode &= ~MODE_BLINKING;
|
s->mode &= ~MODE_CURSOR_BLINKING;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -680,8 +680,10 @@ screen_mode_to_string(int mode)
|
|||||||
strlcat(tmp, "MOUSE_STANDARD,", sizeof tmp);
|
strlcat(tmp, "MOUSE_STANDARD,", sizeof tmp);
|
||||||
if (mode & MODE_MOUSE_BUTTON)
|
if (mode & MODE_MOUSE_BUTTON)
|
||||||
strlcat(tmp, "MOUSE_BUTTON,", sizeof tmp);
|
strlcat(tmp, "MOUSE_BUTTON,", sizeof tmp);
|
||||||
if (mode & MODE_BLINKING)
|
if (mode & MODE_CURSOR_BLINKING)
|
||||||
strlcat(tmp, "BLINKING,", sizeof tmp);
|
strlcat(tmp, "CURSOR_BLINKING,", sizeof tmp);
|
||||||
|
if (mode & MODE_CURSOR_VERY_VISIBLE)
|
||||||
|
strlcat(tmp, "CURSOR_VERY_VISIBLE,", sizeof tmp);
|
||||||
if (mode & MODE_MOUSE_UTF8)
|
if (mode & MODE_MOUSE_UTF8)
|
||||||
strlcat(tmp, "UTF8,", sizeof tmp);
|
strlcat(tmp, "UTF8,", sizeof tmp);
|
||||||
if (mode & MODE_MOUSE_SGR)
|
if (mode & MODE_MOUSE_SGR)
|
||||||
|
4
tmux.h
4
tmux.h
@ -520,7 +520,7 @@ enum tty_code_code {
|
|||||||
#define MODE_WRAP 0x10
|
#define MODE_WRAP 0x10
|
||||||
#define MODE_MOUSE_STANDARD 0x20
|
#define MODE_MOUSE_STANDARD 0x20
|
||||||
#define MODE_MOUSE_BUTTON 0x40
|
#define MODE_MOUSE_BUTTON 0x40
|
||||||
#define MODE_BLINKING 0x80
|
#define MODE_CURSOR_BLINKING 0x80
|
||||||
#define MODE_MOUSE_UTF8 0x100
|
#define MODE_MOUSE_UTF8 0x100
|
||||||
#define MODE_MOUSE_SGR 0x200
|
#define MODE_MOUSE_SGR 0x200
|
||||||
#define MODE_BRACKETPASTE 0x400
|
#define MODE_BRACKETPASTE 0x400
|
||||||
@ -529,10 +529,12 @@ enum tty_code_code {
|
|||||||
#define MODE_ORIGIN 0x2000
|
#define MODE_ORIGIN 0x2000
|
||||||
#define MODE_CRLF 0x4000
|
#define MODE_CRLF 0x4000
|
||||||
#define MODE_KEXTENDED 0x8000
|
#define MODE_KEXTENDED 0x8000
|
||||||
|
#define MODE_CURSOR_VERY_VISIBLE 0x10000
|
||||||
|
|
||||||
#define ALL_MODES 0xffffff
|
#define ALL_MODES 0xffffff
|
||||||
#define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON|MODE_MOUSE_ALL)
|
#define ALL_MOUSE_MODES (MODE_MOUSE_STANDARD|MODE_MOUSE_BUTTON|MODE_MOUSE_ALL)
|
||||||
#define MOTION_MOUSE_MODES (MODE_MOUSE_BUTTON|MODE_MOUSE_ALL)
|
#define MOTION_MOUSE_MODES (MODE_MOUSE_BUTTON|MODE_MOUSE_ALL)
|
||||||
|
#define CURSOR_MODES (MODE_CURSOR|MODE_CURSOR_BLINKING|MODE_CURSOR_VERY_VISIBLE)
|
||||||
|
|
||||||
/* A single UTF-8 character. */
|
/* A single UTF-8 character. */
|
||||||
typedef u_int utf8_char;
|
typedef u_int utf8_char;
|
||||||
|
159
tty.c
159
tty.c
@ -314,7 +314,7 @@ tty_start_tty(struct tty *tty)
|
|||||||
tio.c_cc[VMIN] = 1;
|
tio.c_cc[VMIN] = 1;
|
||||||
tio.c_cc[VTIME] = 0;
|
tio.c_cc[VTIME] = 0;
|
||||||
if (tcsetattr(c->fd, TCSANOW, &tio) == 0)
|
if (tcsetattr(c->fd, TCSANOW, &tio) == 0)
|
||||||
tcflush(c->fd, TCIOFLUSH);
|
tcflush(c->fd, TCOFLUSH);
|
||||||
|
|
||||||
tty_putcode(tty, TTYC_SMCUP);
|
tty_putcode(tty, TTYC_SMCUP);
|
||||||
|
|
||||||
@ -658,12 +658,83 @@ tty_force_cursor_colour(struct tty *tty, const char *ccolour)
|
|||||||
tty->ccolour = xstrdup(ccolour);
|
tty->ccolour = xstrdup(ccolour);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
tty_update_cursor(struct tty *tty, int mode, int changed, struct screen *s)
|
||||||
|
{
|
||||||
|
enum screen_cursor_style cstyle;
|
||||||
|
|
||||||
|
/* Set cursor colour if changed. */
|
||||||
|
if (s != NULL && strcmp(s->ccolour, tty->ccolour) != 0)
|
||||||
|
tty_force_cursor_colour(tty, s->ccolour);
|
||||||
|
|
||||||
|
/* If cursor is off, set as invisible. */
|
||||||
|
if (~mode & MODE_CURSOR) {
|
||||||
|
if (changed & MODE_CURSOR)
|
||||||
|
tty_putcode(tty, TTYC_CIVIS);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if blinking or very visible flag changed or style changed. */
|
||||||
|
if (s == NULL)
|
||||||
|
cstyle = tty->cstyle;
|
||||||
|
else
|
||||||
|
cstyle = s->cstyle;
|
||||||
|
if ((changed & CURSOR_MODES) == 0 && cstyle == tty->cstyle)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set cursor style. If an explicit style has been set with DECSCUSR,
|
||||||
|
* set it if supported, otherwise send cvvis for blinking styles.
|
||||||
|
*
|
||||||
|
* If no style, has been set (SCREEN_CURSOR_DEFAULT), then send cvvis
|
||||||
|
* if either the blinking or very visible flags are set.
|
||||||
|
*/
|
||||||
|
tty_putcode(tty, TTYC_CNORM);
|
||||||
|
switch (cstyle) {
|
||||||
|
case SCREEN_CURSOR_DEFAULT:
|
||||||
|
if (tty_term_has(tty->term, TTYC_SE))
|
||||||
|
tty_putcode(tty, TTYC_SE);
|
||||||
|
else
|
||||||
|
tty_putcode1(tty, TTYC_SS, 0);
|
||||||
|
if (mode & (MODE_CURSOR_BLINKING|MODE_CURSOR_VERY_VISIBLE))
|
||||||
|
tty_putcode(tty, TTYC_CVVIS);
|
||||||
|
break;
|
||||||
|
case SCREEN_CURSOR_BLOCK:
|
||||||
|
if (tty_term_has(tty->term, TTYC_SS)) {
|
||||||
|
if (mode & MODE_CURSOR_BLINKING)
|
||||||
|
tty_putcode1(tty, TTYC_SS, 1);
|
||||||
|
else
|
||||||
|
tty_putcode1(tty, TTYC_SS, 2);
|
||||||
|
} else if (mode & MODE_CURSOR_BLINKING)
|
||||||
|
tty_putcode(tty, TTYC_CVVIS);
|
||||||
|
break;
|
||||||
|
case SCREEN_CURSOR_UNDERLINE:
|
||||||
|
if (tty_term_has(tty->term, TTYC_SS)) {
|
||||||
|
if (mode & MODE_CURSOR_BLINKING)
|
||||||
|
tty_putcode1(tty, TTYC_SS, 3);
|
||||||
|
else
|
||||||
|
tty_putcode1(tty, TTYC_SS, 4);
|
||||||
|
} else if (mode & MODE_CURSOR_BLINKING)
|
||||||
|
tty_putcode(tty, TTYC_CVVIS);
|
||||||
|
break;
|
||||||
|
case SCREEN_CURSOR_BAR:
|
||||||
|
if (tty_term_has(tty->term, TTYC_SS)) {
|
||||||
|
if (mode & MODE_CURSOR_BLINKING)
|
||||||
|
tty_putcode1(tty, TTYC_SS, 5);
|
||||||
|
else
|
||||||
|
tty_putcode1(tty, TTYC_SS, 6);
|
||||||
|
} else if (mode & MODE_CURSOR_BLINKING)
|
||||||
|
tty_putcode(tty, TTYC_CVVIS);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tty->cstyle = cstyle;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_update_mode(struct tty *tty, int mode, struct screen *s)
|
tty_update_mode(struct tty *tty, int mode, struct screen *s)
|
||||||
{
|
{
|
||||||
struct client *c = tty->client;
|
struct client *c = tty->client;
|
||||||
int changed;
|
int changed;
|
||||||
enum screen_cursor_style cstyle = tty->cstyle;
|
|
||||||
|
|
||||||
if (tty->flags & TTY_NOCURSOR)
|
if (tty->flags & TTY_NOCURSOR)
|
||||||
mode &= ~MODE_CURSOR;
|
mode &= ~MODE_CURSOR;
|
||||||
@ -676,85 +747,7 @@ tty_update_mode(struct tty *tty, int mode, struct screen *s)
|
|||||||
screen_mode_to_string(mode));
|
screen_mode_to_string(mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s != NULL) {
|
tty_update_cursor(tty, mode, changed, s);
|
||||||
if (strcmp(s->ccolour, tty->ccolour) != 0)
|
|
||||||
tty_force_cursor_colour(tty, s->ccolour);
|
|
||||||
cstyle = s->cstyle;
|
|
||||||
}
|
|
||||||
if (~mode & MODE_CURSOR) {
|
|
||||||
/* Cursor now off - set as invisible. */
|
|
||||||
if (changed & MODE_CURSOR)
|
|
||||||
tty_putcode(tty, TTYC_CIVIS);
|
|
||||||
} else if ((changed & (MODE_CURSOR|MODE_BLINKING)) ||
|
|
||||||
cstyle != tty->cstyle) {
|
|
||||||
/*
|
|
||||||
* Cursor now on, blinking flag changed or style changed. Start
|
|
||||||
* by setting the cursor to normal.
|
|
||||||
*/
|
|
||||||
tty_putcode(tty, TTYC_CNORM);
|
|
||||||
switch (cstyle) {
|
|
||||||
case SCREEN_CURSOR_DEFAULT:
|
|
||||||
/*
|
|
||||||
* If the old style wasn't default, then reset it to
|
|
||||||
* default.
|
|
||||||
*/
|
|
||||||
if (tty->cstyle != SCREEN_CURSOR_DEFAULT) {
|
|
||||||
if (tty_term_has(tty->term, TTYC_SE))
|
|
||||||
tty_putcode(tty, TTYC_SE);
|
|
||||||
else
|
|
||||||
tty_putcode1(tty, TTYC_SS, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the cursor as very visible if necessary. */
|
|
||||||
if (mode & MODE_BLINKING)
|
|
||||||
tty_putcode(tty, TTYC_CVVIS);
|
|
||||||
break;
|
|
||||||
case SCREEN_CURSOR_BLOCK:
|
|
||||||
/*
|
|
||||||
* Set style to either block blinking (1) or steady (2)
|
|
||||||
* if supported, otherwise just check the blinking
|
|
||||||
* flag.
|
|
||||||
*/
|
|
||||||
if (tty_term_has(tty->term, TTYC_SS)) {
|
|
||||||
if (mode & MODE_BLINKING)
|
|
||||||
tty_putcode1(tty, TTYC_SS, 1);
|
|
||||||
else
|
|
||||||
tty_putcode1(tty, TTYC_SS, 2);
|
|
||||||
} else if (mode & MODE_BLINKING)
|
|
||||||
tty_putcode(tty, TTYC_CVVIS);
|
|
||||||
break;
|
|
||||||
case SCREEN_CURSOR_UNDERLINE:
|
|
||||||
/*
|
|
||||||
* Set style to either underline blinking (3) or steady
|
|
||||||
* (4) if supported, otherwise just check the blinking
|
|
||||||
* flag.
|
|
||||||
*/
|
|
||||||
if (tty_term_has(tty->term, TTYC_SS)) {
|
|
||||||
if (mode & MODE_BLINKING)
|
|
||||||
tty_putcode1(tty, TTYC_SS, 3);
|
|
||||||
else
|
|
||||||
tty_putcode1(tty, TTYC_SS, 4);
|
|
||||||
} else if (mode & MODE_BLINKING)
|
|
||||||
tty_putcode(tty, TTYC_CVVIS);
|
|
||||||
break;
|
|
||||||
case SCREEN_CURSOR_BAR:
|
|
||||||
/*
|
|
||||||
* Set style to either bar blinking (5) or steady (6)
|
|
||||||
* if supported, otherwise just check the blinking
|
|
||||||
* flag.
|
|
||||||
*/
|
|
||||||
if (tty_term_has(tty->term, TTYC_SS)) {
|
|
||||||
if (mode & MODE_BLINKING)
|
|
||||||
tty_putcode1(tty, TTYC_SS, 5);
|
|
||||||
else
|
|
||||||
tty_putcode1(tty, TTYC_SS, 6);
|
|
||||||
} else if (mode & MODE_BLINKING)
|
|
||||||
tty_putcode(tty, TTYC_CVVIS);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
tty->cstyle = cstyle;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((changed & ALL_MOUSE_MODES) &&
|
if ((changed & ALL_MOUSE_MODES) &&
|
||||||
tty_term_has(tty->term, TTYC_KMOUS)) {
|
tty_term_has(tty->term, TTYC_KMOUS)) {
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user