diff options
author | nicm <nicm> | 2019-11-28 09:05:34 +0000 |
---|---|---|
committer | nicm <nicm> | 2019-11-28 09:05:34 +0000 |
commit | 067604bf8cb23c1a208d26d94dbae7c2ab46dabf (patch) | |
tree | d8692a46c84f0bb155282f9208311f8f8646f9cd | |
parent | 7fb8eec8f13bf54b3a6c06763d2cf0b29df51281 (diff) | |
download | rtmux-067604bf8cb23c1a208d26d94dbae7c2ab46dabf.tar.gz rtmux-067604bf8cb23c1a208d26d94dbae7c2ab46dabf.tar.bz2 rtmux-067604bf8cb23c1a208d26d94dbae7c2ab46dabf.zip |
Store xpixel/ypixel from TIOCGWINSZ and add formats.
-rw-r--r-- | cmd-refresh-client.c | 2 | ||||
-rw-r--r-- | format.c | 2 | ||||
-rw-r--r-- | tmux.1 | 4 | ||||
-rw-r--r-- | tmux.h | 4 | ||||
-rw-r--r-- | tty.c | 23 |
5 files changed, 26 insertions, 9 deletions
diff --git a/cmd-refresh-client.c b/cmd-refresh-client.c index 49921a74..b4c5e844 100644 --- a/cmd-refresh-client.c +++ b/cmd-refresh-client.c @@ -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(); } @@ -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)); @@ -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" @@ -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 *); @@ -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 |