sync with OpenBSD -current

This commit is contained in:
purplerain 2024-06-24 17:59:29 +00:00
parent 7bc640af07
commit 4a6edb3688
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
61 changed files with 680 additions and 286 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: tty-keys.c,v 1.173 2024/03/21 11:47:55 nicm Exp $ */
/* $OpenBSD: tty-keys.c,v 1.174 2024/06/24 08:30:50 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@ -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);