diff options
author | 2019-11-28 09:05:34 +0000 | |
---|---|---|
committer | 2019-11-28 09:05:34 +0000 | |
commit | 8002856b9657c90af9e24fa94db5bbb43d82b4bc (patch) | |
tree | 29f7a707a70dabec6d6819d7d524bf8e3b9c3674 | |
parent | status-left and status-right need push-default also, reported by Eric (diff) | |
download | wireguard-openbsd-8002856b9657c90af9e24fa94db5bbb43d82b4bc.tar.xz wireguard-openbsd-8002856b9657c90af9e24fa94db5bbb43d82b4bc.zip |
Store xpixel/ypixel from TIOCGWINSZ and add formats.
-rw-r--r-- | usr.bin/tmux/cmd-refresh-client.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/format.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.1 | 8 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 6 | ||||
-rw-r--r-- | usr.bin/tmux/tty.c | 25 |
5 files changed, 32 insertions, 15 deletions
diff --git a/usr.bin/tmux/cmd-refresh-client.c b/usr.bin/tmux/cmd-refresh-client.c index 4de9e62c72c..9e6ada6340b 100644 --- a/usr.bin/tmux/cmd-refresh-client.c +++ b/usr.bin/tmux/cmd-refresh-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-refresh-client.c,v 1.29 2019/07/10 11:20:10 nicm Exp $ */ +/* $OpenBSD: cmd-refresh-client.c,v 1.30 2019/11/28 09:05:34 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -130,7 +130,7 @@ cmd_refresh_client_exec(struct cmd *self, struct cmdq_item *item) cmdq_error(item, "size too small or too big"); return (CMD_RETURN_ERROR); } - tty_set_size(&c->tty, x, y); + tty_set_size(&c->tty, x, y, 0, 0); c->flags |= CLIENT_SIZECHANGED; recalculate_sizes(); } diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index 7adb92a22d4..5bb73e5e43f 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.217 2019/11/25 15:04:15 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.218 2019/11/28 09:05:34 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -2158,6 +2158,8 @@ format_defaults_client(struct format_tree *ft, struct client *c) format_add(ft, "client_pid", "%ld", (long) c->pid); format_add(ft, "client_height", "%u", tty->sy); format_add(ft, "client_width", "%u", tty->sx); + format_add(ft, "client_cell_width", "%u", tty->xpixel); + format_add(ft, "client_cell_height", "%u", tty->ypixel); format_add(ft, "client_tty", "%s", c->ttyname); format_add(ft, "client_control_mode", "%d", !!(c->flags & CLIENT_CONTROL)); diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index dc9e4307fb9..985eba304c2 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.698 2019/11/25 15:04:15 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.699 2019/11/28 09:05:34 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> .\" @@ -14,7 +14,7 @@ .\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING .\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: November 25 2019 $ +.Dd $Mdocdate: November 28 2019 $ .Dt TMUX 1 .Os .Sh NAME @@ -4209,6 +4209,8 @@ The following variables are available, where appropriate: .It Li "buffer_sample" Ta "" Ta "Sample of start of buffer" .It Li "buffer_size" Ta "" Ta "Size of the specified buffer in bytes" .It Li "client_activity" Ta "" Ta "Time client last had activity" +.It Li "client_cell_height" Ta "" Ta "Height of each client cell in pixels" +.It Li "client_cell_width" Ta "" Ta "Width of each client cell in pixels" .It Li "client_control_mode" Ta "" Ta "1 if client is in control mode" .It Li "client_created" Ta "" Ta "Time client created" .It Li "client_discarded" Ta "" Ta "Bytes discarded when client behind" @@ -4223,7 +4225,7 @@ The following variables are available, where appropriate: .It Li "client_termname" Ta "" Ta "Terminal name of client" .It Li "client_termtype" Ta "" Ta "Terminal type of client" .It Li "client_tty" Ta "" Ta "Pseudo terminal of client" -.It Li "client_utf8" Ta "" Ta "1 if client supports utf8" +.It Li "client_utf8" Ta "" Ta "1 if client supports UTF-8" .It Li "client_width" Ta "" Ta "Width of client" .It Li "client_written" Ta "" Ta "Bytes written to client" .It Li "command" Ta "" Ta "Name of command in use, if any" diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 45d8e08d623..04d7c55ffc4 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.933 2019/11/25 15:04:15 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.934 2019/11/28 09:05:34 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1148,6 +1148,8 @@ struct tty { u_int sx; u_int sy; + u_int xpixel; + u_int ypixel; u_int cx; u_int cy; @@ -1927,7 +1929,7 @@ void tty_putc(struct tty *, u_char); void tty_putn(struct tty *, const void *, size_t, u_int); int tty_init(struct tty *, struct client *, int, char *); void tty_resize(struct tty *); -void tty_set_size(struct tty *, u_int, u_int); +void tty_set_size(struct tty *, u_int, u_int, u_int, u_int); void tty_start_tty(struct tty *); void tty_stop_tty(struct tty *); void tty_set_title(struct tty *, const char *); diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c index 81d29e0036b..d81e7ea5e0b 100644 --- a/usr.bin/tmux/tty.c +++ b/usr.bin/tmux/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.333 2019/11/14 07:56:32 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.334 2019/11/28 09:05:34 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -127,29 +127,40 @@ tty_resize(struct tty *tty) { struct client *c = tty->client; struct winsize ws; - u_int sx, sy; + u_int sx, sy, xpixel, ypixel; if (ioctl(tty->fd, TIOCGWINSZ, &ws) != -1) { sx = ws.ws_col; - if (sx == 0) + if (sx == 0) { sx = 80; + xpixel = 0; + } else + xpixel = ws.ws_xpixel / sx; sy = ws.ws_row; - if (sy == 0) + if (sy == 0) { sy = 24; + ypixel = 0; + } else + ypixel = ws.ws_ypixel / sy; } else { sx = 80; sy = 24; + xpixel = 0; + ypixel = 0; } - log_debug("%s: %s now %ux%u", __func__, c->name, sx, sy); - tty_set_size(tty, sx, sy); + log_debug("%s: %s now %ux%u (%ux%u)", __func__, c->name, sx, sy, + xpixel, ypixel); + tty_set_size(tty, sx, sy, xpixel, ypixel); tty_invalidate(tty); } void -tty_set_size(struct tty *tty, u_int sx, u_int sy) +tty_set_size(struct tty *tty, u_int sx, u_int sy, u_int xpixel, u_int ypixel) { tty->sx = sx; tty->sy = sy; + tty->xpixel = xpixel; + tty->ypixel = ypixel; } static void |