Improve logging of screen mode changes.

This commit is contained in:
nicm 2021-06-10 07:43:44 +00:00
parent f02a6c34e0
commit 02a6b39db7
5 changed files with 67 additions and 5 deletions

View File

@ -769,6 +769,9 @@ screen_write_mode_set(struct screen_write_ctx *ctx, int mode)
struct screen *s = ctx->s;
s->mode |= mode;
if (log_get_level() != 0)
log_debug("%s: %s", __func__, screen_mode_to_string(mode));
}
/* Clear a mode. */
@ -778,6 +781,9 @@ screen_write_mode_clear(struct screen_write_ctx *ctx, int mode)
struct screen *s = ctx->s;
s->mode &= ~mode;
if (log_get_level() != 0)
log_debug("%s: %s", __func__, screen_mode_to_string(mode));
}
/* Cursor up by ny. */

View File

@ -156,8 +156,8 @@ screen_reset_tabs(struct screen *s)
void
screen_set_cursor_style(struct screen *s, u_int style)
{
switch (style)
{
log_debug("%s: new %u, was %u", __func__, style, s->cstyle);
switch (style) {
case 0:
s->cstyle = SCREEN_CURSOR_DEFAULT;
break;
@ -653,3 +653,51 @@ screen_alternate_off(struct screen *s, struct grid_cell *gc, int cursor)
if (s->cy > screen_size_y(s) - 1)
s->cy = screen_size_y(s) - 1;
}
/* Get mode as a string. */
const char *
screen_mode_to_string(int mode)
{
static char tmp[1024];
if (mode == 0)
return "NONE";
if (mode == ALL_MODES)
return "ALL";
*tmp = '\0';
if (mode & MODE_CURSOR)
strlcat(tmp, "CURSOR,", sizeof tmp);
if (mode & MODE_INSERT)
strlcat(tmp, "INSERT,", sizeof tmp);
if (mode & MODE_KCURSOR)
strlcat(tmp, "KCURSOR,", sizeof tmp);
if (mode & MODE_KKEYPAD)
strlcat(tmp, "KKEYPAD,", sizeof tmp);
if (mode & MODE_WRAP)
strlcat(tmp, "WRAP,", sizeof tmp);
if (mode & MODE_MOUSE_STANDARD)
strlcat(tmp, "STANDARD,", sizeof tmp);
if (mode & MODE_MOUSE_BUTTON)
strlcat(tmp, "BUTTON,", sizeof tmp);
if (mode & MODE_BLINKING)
strlcat(tmp, "BLINKING,", sizeof tmp);
if (mode & MODE_MOUSE_UTF8)
strlcat(tmp, "UTF8,", sizeof tmp);
if (mode & MODE_MOUSE_SGR)
strlcat(tmp, "SGR,", sizeof tmp);
if (mode & MODE_BRACKETPASTE)
strlcat(tmp, "BRACKETPASTE,", sizeof tmp);
if (mode & MODE_FOCUSON)
strlcat(tmp, "FOCUSON,", sizeof tmp);
if (mode & MODE_MOUSE_ALL)
strlcat(tmp, "ALL,", sizeof tmp);
if (mode & MODE_ORIGIN)
strlcat(tmp, "ORIGIN,", sizeof tmp);
if (mode & MODE_CRLF)
strlcat(tmp, "CRLF,", sizeof tmp);
if (mode & MODE_KEXTENDED)
strlcat(tmp, "KEXTENDED,", sizeof tmp);
tmp[strlen (tmp) - 1] = '\0';
return (tmp);
}

View File

@ -1694,7 +1694,10 @@ server_client_reset_state(struct client *c)
s = wp->screen;
if (s != NULL)
mode = s->mode;
log_debug("%s: client %s mode %x", __func__, c->name, mode);
if (log_get_level() != 0) {
log_debug("%s: client %s mode %s", __func__, c->name,
screen_mode_to_string(mode));
}
/* Reset region and margin. */
tty_region_off(tty);

1
tmux.h
View File

@ -2749,6 +2749,7 @@ void screen_select_cell(struct screen *, struct grid_cell *,
const struct grid_cell *);
void screen_alternate_on(struct screen *, struct grid_cell *, int);
void screen_alternate_off(struct screen *, struct grid_cell *, int);
const char *screen_mode_to_string(int);
/* window.c */
extern struct windows windows;

8
tty.c
View File

@ -665,8 +665,12 @@ tty_update_mode(struct tty *tty, int mode, struct screen *s)
mode &= ~MODE_CURSOR;
changed = mode ^ tty->mode;
if (changed != 0)
log_debug("%s: update mode %x to %x", c->name, tty->mode, mode);
if (log_get_level() != 0 && changed != 0) {
log_debug("%s: current mode %s", c->name,
screen_mode_to_string(tty->mode));
log_debug("%s: setting mode %s", c->name,
screen_mode_to_string(mode));
}
if (s != NULL) {
if (strcmp(s->ccolour, tty->ccolour) != 0)