version 1.409, 2021/10/28 18:57:06 |
version 1.410, 2021/11/01 09:34:49 |
|
|
|
|
static void tty_set_italics(struct tty *); |
static void tty_set_italics(struct tty *); |
static int tty_try_colour(struct tty *, int, const char *); |
static int tty_try_colour(struct tty *, int, const char *); |
static void tty_force_cursor_colour(struct tty *, const char *); |
static void tty_force_cursor_colour(struct tty *, int); |
static void tty_cursor_pane(struct tty *, const struct tty_ctx *, u_int, |
static void tty_cursor_pane(struct tty *, const struct tty_ctx *, u_int, |
u_int); |
u_int); |
static void tty_cursor_pane_unless_wrap(struct tty *, |
static void tty_cursor_pane_unless_wrap(struct tty *, |
|
|
tty->client = c; |
tty->client = c; |
|
|
tty->cstyle = SCREEN_CURSOR_DEFAULT; |
tty->cstyle = SCREEN_CURSOR_DEFAULT; |
tty->ccolour = xstrdup(""); |
tty->ccolour = -1; |
|
|
if (tcgetattr(c->fd, &tty->tio) != 0) |
if (tcgetattr(c->fd, &tty->tio) != 0) |
return (-1); |
return (-1); |
|
|
tty->flags |= TTY_STARTED; |
tty->flags |= TTY_STARTED; |
tty_invalidate(tty); |
tty_invalidate(tty); |
|
|
if (*tty->ccolour != '\0') |
if (tty->ccolour != -1) |
tty_force_cursor_colour(tty, ""); |
tty_force_cursor_colour(tty, -1); |
|
|
tty->mouse_drag_flag = 0; |
tty->mouse_drag_flag = 0; |
tty->mouse_drag_update = NULL; |
tty->mouse_drag_update = NULL; |
|
|
} |
} |
if (tty->mode & MODE_BRACKETPASTE) |
if (tty->mode & MODE_BRACKETPASTE) |
tty_raw(tty, tty_term_string(tty->term, TTYC_DSBP)); |
tty_raw(tty, tty_term_string(tty->term, TTYC_DSBP)); |
if (*tty->ccolour != '\0') |
if (tty->ccolour != -1) |
tty_raw(tty, tty_term_string(tty->term, TTYC_CR)); |
tty_raw(tty, tty_term_string(tty->term, TTYC_CR)); |
|
|
tty_raw(tty, tty_term_string(tty->term, TTYC_CNORM)); |
tty_raw(tty, tty_term_string(tty->term, TTYC_CNORM)); |
|
|
tty_free(struct tty *tty) |
tty_free(struct tty *tty) |
{ |
{ |
tty_close(tty); |
tty_close(tty); |
free(tty->ccolour); |
|
} |
} |
|
|
void |
void |
|
|
} |
} |
|
|
static void |
static void |
tty_force_cursor_colour(struct tty *tty, const char *ccolour) |
tty_force_cursor_colour(struct tty *tty, int c) |
{ |
{ |
if (*ccolour == '\0') |
u_char r, g, b; |
|
char s[13] = ""; |
|
|
|
if (c != -1) |
|
c = colour_force_rgb(c); |
|
if (c == tty->ccolour) |
|
return; |
|
if (c == -1) |
tty_putcode(tty, TTYC_CR); |
tty_putcode(tty, TTYC_CR); |
else |
else { |
tty_putcode_ptr1(tty, TTYC_CS, ccolour); |
colour_split_rgb(c, &r, &g, &b); |
free(tty->ccolour); |
xsnprintf(s, sizeof s, "rgb:%02hhx/%02hhx/%02hhx", r, g, b); |
tty->ccolour = xstrdup(ccolour); |
tty_putcode_ptr1(tty, TTYC_CS, s); |
|
} |
|
tty->ccolour = c; |
} |
} |
|
|
static void |
static void |
tty_update_cursor(struct tty *tty, int mode, int changed, struct screen *s) |
tty_update_cursor(struct tty *tty, int mode, int changed, struct screen *s) |
{ |
{ |
enum screen_cursor_style cstyle; |
enum screen_cursor_style cstyle; |
|
int ccolour; |
|
|
/* Set cursor colour if changed. */ |
/* Set cursor colour if changed. */ |
if (s != NULL && strcmp(s->ccolour, tty->ccolour) != 0) |
if (s != NULL) { |
tty_force_cursor_colour(tty, s->ccolour); |
ccolour = s->ccolour; |
|
if (s->ccolour == -1) |
|
ccolour = s->default_ccolour; |
|
tty_force_cursor_colour(tty, ccolour); |
|
} |
|
|
/* If cursor is off, set as invisible. */ |
/* If cursor is off, set as invisible. */ |
if (~mode & MODE_CURSOR) { |
if (~mode & MODE_CURSOR) { |