summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2021-06-10 07:43:45 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2021-06-10 07:43:45 +0000
commit64601c98a6167dc9a2de301d33a28fbf3c518f4f (patch)
tree2857e182651c1351c8f1bfc20723444029072b3f
parenta246e1daf61c080c928f555cef3245c5dadaaa2a (diff)
Improve logging of screen mode changes.
-rw-r--r--usr.bin/tmux/screen-write.c8
-rw-r--r--usr.bin/tmux/screen.c54
-rw-r--r--usr.bin/tmux/server-client.c7
-rw-r--r--usr.bin/tmux/tmux.h3
-rw-r--r--usr.bin/tmux/tty.c10
5 files changed, 72 insertions, 10 deletions
diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c
index db9c89250a9..b83cce19c6d 100644
--- a/usr.bin/tmux/screen-write.c
+++ b/usr.bin/tmux/screen-write.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen-write.c,v 1.193 2021/01/29 09:48:43 nicm Exp $ */
+/* $OpenBSD: screen-write.c,v 1.194 2021/06/10 07:43:44 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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. */
diff --git a/usr.bin/tmux/screen.c b/usr.bin/tmux/screen.c
index b578902bd92..d81011765cf 100644
--- a/usr.bin/tmux/screen.c
+++ b/usr.bin/tmux/screen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: screen.c,v 1.72 2021/06/10 07:36:47 nicm Exp $ */
+/* $OpenBSD: screen.c,v 1.73 2021/06/10 07:43:44 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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);
+}
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index 5e512216174..ea50b55dfb1 100644
--- a/usr.bin/tmux/server-client.c
+++ b/usr.bin/tmux/server-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.374 2021/06/10 07:33:41 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.375 2021/06/10 07:43:44 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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);
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 93992171bbf..6b023f2a8cf 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.1107 2021/06/10 07:38:28 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.1108 2021/06/10 07:43:44 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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;
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index 58c4792ba61..ba099ad3135 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.391 2021/06/10 07:36:47 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.392 2021/06/10 07:43:44 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -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)