mirror of
https://github.com/tmux/tmux.git
synced 2025-11-03 16:46:18 +00:00
Add a way (refresh-client -r) for control mode clients to provide OSC 10
and 11 responses to tmux so they can set the default foreground and background colours, from George Nachman in GitHub issue 4014.
This commit is contained in:
22
tty-keys.c
22
tty-keys.c
@@ -59,7 +59,6 @@ static int tty_keys_device_attributes2(struct tty *, const char *, size_t,
|
||||
size_t *);
|
||||
static int tty_keys_extended_device_attributes(struct tty *, const char *,
|
||||
size_t, size_t *);
|
||||
static int tty_keys_colours(struct tty *, const char *, size_t, size_t *);
|
||||
|
||||
/* A key tree entry. */
|
||||
struct tty_key {
|
||||
@@ -721,7 +720,7 @@ tty_keys_next(struct tty *tty)
|
||||
}
|
||||
|
||||
/* Is this a colours response? */
|
||||
switch (tty_keys_colours(tty, buf, len, &size)) {
|
||||
switch (tty_keys_colours(tty, buf, len, &size, &tty->fg, &tty->bg)) {
|
||||
case 0: /* yes */
|
||||
key = KEYC_UNKNOWN;
|
||||
goto complete_key;
|
||||
@@ -1490,8 +1489,9 @@ tty_keys_extended_device_attributes(struct tty *tty, const char *buf,
|
||||
* Handle foreground or background input. Returns 0 for success, -1 for
|
||||
* failure, 1 for partial.
|
||||
*/
|
||||
static int
|
||||
tty_keys_colours(struct tty *tty, const char *buf, size_t len, size_t *size)
|
||||
int
|
||||
tty_keys_colours(struct tty *tty, const char *buf, size_t len, size_t *size,
|
||||
int *fg, int *bg)
|
||||
{
|
||||
struct client *c = tty->client;
|
||||
u_int i;
|
||||
@@ -1542,11 +1542,17 @@ tty_keys_colours(struct tty *tty, const char *buf, size_t len, size_t *size)
|
||||
|
||||
n = colour_parseX11(tmp);
|
||||
if (n != -1 && buf[3] == '0') {
|
||||
log_debug("%s: foreground is %s", c->name, colour_tostring(n));
|
||||
tty->fg = n;
|
||||
if (c != NULL)
|
||||
log_debug("%s fg is %s", c->name, colour_tostring(n));
|
||||
else
|
||||
log_debug("fg is %s", colour_tostring(n));
|
||||
*fg = n;
|
||||
} else if (n != -1) {
|
||||
log_debug("%s: background is %s", c->name, colour_tostring(n));
|
||||
tty->bg = n;
|
||||
if (c != NULL)
|
||||
log_debug("%s bg is %s", c->name, colour_tostring(n));
|
||||
else
|
||||
log_debug("bg is %s", colour_tostring(n));
|
||||
*bg = n;
|
||||
}
|
||||
|
||||
return (0);
|
||||
|
||||
Reference in New Issue
Block a user