Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2020-01-28 12:01:28 +00:00
commit 60ab714451
5 changed files with 37 additions and 33 deletions

View File

@ -1302,6 +1302,7 @@ input_csi_dispatch(struct input_ctx *ictx)
struct input_table_entry *entry; struct input_table_entry *entry;
int i, n, m; int i, n, m;
u_int cx, bg = ictx->cell.cell.bg; u_int cx, bg = ictx->cell.cell.bg;
char *copy, *cp;
if (ictx->flags & INPUT_DISCARD) if (ictx->flags & INPUT_DISCARD)
return (0); return (0);
@ -1433,6 +1434,13 @@ input_csi_dispatch(struct input_ctx *ictx)
case 6: case 6:
input_reply(ictx, "\033[%u;%uR", s->cy + 1, s->cx + 1); input_reply(ictx, "\033[%u;%uR", s->cy + 1, s->cx + 1);
break; break;
case 1337: /* Terminal version, from iTerm2. */
copy = xstrdup(getversion());
for (cp = copy; *cp != '\0'; cp++)
*cp = toupper((u_char)*cp);
input_reply(ictx, "\033[TMUX %sn", copy);
free(copy);
break;
default: default:
log_debug("%s: unknown '%c'", __func__, ictx->ch); log_debug("%s: unknown '%c'", __func__, ictx->ch);
break; break;

1
tmux.h
View File

@ -1173,6 +1173,7 @@ struct tty_term {
#define TERM_NOXENL 0x2 #define TERM_NOXENL 0x2
#define TERM_DECSLRM 0x4 #define TERM_DECSLRM 0x4
#define TERM_DECFRA 0x8 #define TERM_DECFRA 0x8
#define TERM_RGBCOLOURS 0x10
int flags; int flags;
LIST_ENTRY(tty_term) entry; LIST_ENTRY(tty_term) entry;

View File

@ -1099,7 +1099,7 @@ tty_keys_device_status_report(struct tty *tty, const char *buf, size_t len,
return (-1); return (-1);
if (len == 2) if (len == 2)
return (1); return (1);
if (buf[2] != 'I') if (buf[2] != 'I' && buf[2] != 'T')
return (-1); return (-1);
if (len == 3) if (len == 3)
return (1); return (1);
@ -1117,7 +1117,9 @@ tty_keys_device_status_report(struct tty *tty, const char *buf, size_t len,
/* Set terminal flags. */ /* Set terminal flags. */
if (strncmp(tmp, "ITERM2 ", 7) == 0) if (strncmp(tmp, "ITERM2 ", 7) == 0)
flags |= TERM_DECSLRM; flags |= (TERM_DECSLRM|TERM_256COLOURS|TERM_RGBCOLOURS);
if (strncmp(tmp, "TMUX ", 5) == 0)
flags |= (TERM_256COLOURS|TERM_RGBCOLOURS);
log_debug("%s: received DSR %.*s", c->name, (int)*size, buf); log_debug("%s: received DSR %.*s", c->name, (int)*size, buf);
tty_set_flags(tty, flags); tty_set_flags(tty, flags);

View File

@ -528,11 +528,16 @@ tty_term_find(char *name, int fd, char **cause)
goto error; goto error;
} }
/* Figure out if we have 256 colours (or more). */ /* Set flag if terminal has 256 colours. */
if (tty_term_number(term, TTYC_COLORS) >= 256 || if (tty_term_number(term, TTYC_COLORS) >= 256)
tty_term_has(term, TTYC_RGB))
term->flags |= TERM_256COLOURS; term->flags |= TERM_256COLOURS;
/* Set flag if terminal has RGB colours. */
if ((tty_term_flag(term, TTYC_TC) || tty_term_has(term, TTYC_RGB)) ||
(tty_term_has(term, TTYC_SETRGBF) &&
tty_term_has(term, TTYC_SETRGBB)))
term->flags |= TERM_RGBCOLOURS;
/* /*
* Terminals without xenl (eat newline glitch) wrap at at $COLUMNS - 1 * Terminals without xenl (eat newline glitch) wrap at at $COLUMNS - 1
* rather than $COLUMNS (the cursor can never be beyond $COLUMNS - 1). * rather than $COLUMNS (the cursor can never be beyond $COLUMNS - 1).
@ -567,22 +572,7 @@ tty_term_find(char *name, int fd, char **cause)
code->type = TTYCODE_STRING; code->type = TTYCODE_STRING;
} }
/* /* Log the capabilities. */
* On terminals with RGB colour (Tc or RGB), fill in setrgbf and
* setrgbb if they are missing.
*/
if ((tty_term_flag(term, TTYC_TC) || tty_term_flag(term, TTYC_RGB)) &&
!tty_term_has(term, TTYC_SETRGBF) &&
!tty_term_has(term, TTYC_SETRGBB)) {
code = &term->codes[TTYC_SETRGBF];
code->value.string = xstrdup("\033[38;2;%p1%d;%p2%d;%p3%dm");
code->type = TTYCODE_STRING;
code = &term->codes[TTYC_SETRGBB];
code->value.string = xstrdup("\033[48;2;%p1%d;%p2%d;%p3%dm");
code->type = TTYCODE_STRING;
}
/* Log it. */
for (i = 0; i < tty_term_ncodes(); i++) for (i = 0; i < tty_term_ncodes(); i++)
log_debug("%s%s", name, tty_term_describe(term, i)); log_debug("%s%s", name, tty_term_describe(term, i));

27
tty.c
View File

@ -2386,11 +2386,10 @@ tty_check_fg(struct tty *tty, struct window_pane *wp, struct grid_cell *gc)
/* Is this a 24-bit colour? */ /* Is this a 24-bit colour? */
if (gc->fg & COLOUR_FLAG_RGB) { if (gc->fg & COLOUR_FLAG_RGB) {
/* Not a 24-bit terminal? Translate to 256-colour palette. */ /* Not a 24-bit terminal? Translate to 256-colour palette. */
if (!tty_term_has(tty->term, TTYC_SETRGBF)) { if ((tty->term->flags|tty->term_flags) & TERM_RGBCOLOURS)
colour_split_rgb(gc->fg, &r, &g, &b);
gc->fg = colour_find_rgb(r, g, b);
} else
return; return;
colour_split_rgb(gc->fg, &r, &g, &b);
gc->fg = colour_find_rgb(r, g, b);
} }
/* How many colours does this terminal have? */ /* How many colours does this terminal have? */
@ -2436,11 +2435,10 @@ tty_check_bg(struct tty *tty, struct window_pane *wp, struct grid_cell *gc)
/* Is this a 24-bit colour? */ /* Is this a 24-bit colour? */
if (gc->bg & COLOUR_FLAG_RGB) { if (gc->bg & COLOUR_FLAG_RGB) {
/* Not a 24-bit terminal? Translate to 256-colour palette. */ /* Not a 24-bit terminal? Translate to 256-colour palette. */
if (!tty_term_has(tty->term, TTYC_SETRGBB)) { if ((tty->term->flags|tty->term_flags) & TERM_RGBCOLOURS)
colour_split_rgb(gc->bg, &r, &g, &b);
gc->bg = colour_find_rgb(r, g, b);
} else
return; return;
colour_split_rgb(gc->bg, &r, &g, &b);
gc->bg = colour_find_rgb(r, g, b);
} }
/* How many colours does this terminal have? */ /* How many colours does this terminal have? */
@ -2617,15 +2615,14 @@ tty_try_colour(struct tty *tty, int colour, const char *type)
} }
if (colour & COLOUR_FLAG_RGB) { if (colour & COLOUR_FLAG_RGB) {
colour_split_rgb(colour & 0xffffff, &r, &g, &b);
if (*type == '3') { if (*type == '3') {
if (!tty_term_has(tty->term, TTYC_SETRGBF)) if (!tty_term_has(tty->term, TTYC_SETRGBF))
return (-1); goto fallback_rgb;
colour_split_rgb(colour & 0xffffff, &r, &g, &b);
tty_putcode3(tty, TTYC_SETRGBF, r, g, b); tty_putcode3(tty, TTYC_SETRGBF, r, g, b);
} else { } else {
if (!tty_term_has(tty->term, TTYC_SETRGBB)) if (!tty_term_has(tty->term, TTYC_SETRGBB))
return (-1); goto fallback_rgb;
colour_split_rgb(colour & 0xffffff, &r, &g, &b);
tty_putcode3(tty, TTYC_SETRGBB, r, g, b); tty_putcode3(tty, TTYC_SETRGBB, r, g, b);
} }
return (0); return (0);
@ -2638,6 +2635,12 @@ fallback_256:
log_debug("%s: 256 colour fallback: %s", tty->client->name, s); log_debug("%s: 256 colour fallback: %s", tty->client->name, s);
tty_puts(tty, s); tty_puts(tty, s);
return (0); return (0);
fallback_rgb:
xsnprintf(s, sizeof s, "\033[%s;2;%d;%d;%dm", type, r, g, b);
log_debug("%s: RGB colour fallback: %s", tty->client->name, s);
tty_puts(tty, s);
return (0);
} }
static void static void