From 7fb8eec8f13bf54b3a6c06763d2cf0b29df51281 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 28 Nov 2019 08:38:04 +0000 Subject: status-left and status-right need push-default also, reported by Eric Pruitt in GitHub issue 1989. --- options-table.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/options-table.c b/options-table.c index 6e2db178..1d22b662 100644 --- a/options-table.c +++ b/options-table.c @@ -70,7 +70,10 @@ static const char *options_table_window_size_list[] = { /* Status line format. */ #define OPTIONS_TABLE_STATUS_FORMAT1 \ "#[align=left range=left #{status-left-style}]" \ - "#{T;=/#{status-left-length}:status-left}#[norange default]" \ + "#[push-default]" \ + "#{T;=/#{status-left-length}:status-left}" \ + "#[pop-default]" \ + "#[norange default]" \ "#[list=on align=#{status-justify}]" \ "#[list=left-marker]<#[list=right-marker]>#[list=on]" \ "#{W:" \ @@ -126,7 +129,10 @@ static const char *options_table_window_size_list[] = { "#{?window_end_flag,,#{window-status-separator}}" \ "}" \ "#[nolist align=right range=right #{status-right-style}]" \ - "#{T;=/#{status-right-length}:status-right}#[norange default]" + "#[push-default]" \ + "#{T;=/#{status-right-length}:status-right}" \ + "#[pop-default]" \ + "#[norange default]" #define OPTIONS_TABLE_STATUS_FORMAT2 \ "#[align=centre]#{P:#{?pane_active,#[reverse],}" \ "#{pane_index}[#{pane_width}x#{pane_height}]#[default] }" -- cgit From 067604bf8cb23c1a208d26d94dbae7c2ab46dabf Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 28 Nov 2019 09:05:34 +0000 Subject: Store xpixel/ypixel from TIOCGWINSZ and add formats. --- cmd-refresh-client.c | 2 +- format.c | 2 ++ tmux.1 | 4 +++- tmux.h | 4 +++- 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(); } diff --git a/format.c b/format.c index ffa9b8d5..45320bf5 100644 --- a/format.c +++ b/format.c @@ -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/tmux.1 b/tmux.1 index 6cf8df24..fc42b393 100644 --- a/tmux.1 +++ b/tmux.1 @@ -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/tmux.h b/tmux.h index 5b6a1716..d2a4196a 100644 --- a/tmux.h +++ b/tmux.h @@ -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/tty.c b/tty.c index d77bb440..9efd78a0 100644 --- a/tty.c +++ b/tty.c @@ -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 -- cgit From 2349b1dbef7cd0b4a165cd234d6757c34d5e02e6 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 28 Nov 2019 09:45:15 +0000 Subject: Make a best effort to set xpixel and ypixel for each pane and add formats for them. --- cmd-break-pane.c | 2 +- cmd-resize-window.c | 14 +++++++++----- format.c | 2 ++ layout-custom.c | 2 +- layout-set.c | 8 ++++---- resize.c | 51 +++++++++++++++++++++++++++++++++++++++++++++------ server-client.c | 15 ++------------- spawn.c | 9 ++++++--- tmux.1 | 2 ++ tmux.h | 15 +++++++++++---- window.c | 42 +++++++++++++++++++++++++++++++++++++++--- 11 files changed, 122 insertions(+), 40 deletions(-) diff --git a/cmd-break-pane.c b/cmd-break-pane.c index 8b430ff7..6c638103 100644 --- a/cmd-break-pane.c +++ b/cmd-break-pane.c @@ -76,7 +76,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item) window_lost_pane(w, wp); layout_close_pane(wp); - w = wp->window = window_create(w->sx, w->sy); + w = wp->window = window_create(w->sx, w->sy, w->xpixel, w->ypixel); options_set_parent(wp->options, w->options); wp->flags |= PANE_STYLECHANGED; TAILQ_INSERT_HEAD(&w->panes, wp, entry); diff --git a/cmd-resize-window.c b/cmd-resize-window.c index c5a7c5a1..9cc74e82 100644 --- a/cmd-resize-window.c +++ b/cmd-resize-window.c @@ -53,6 +53,7 @@ cmd_resize_window_exec(struct cmd *self, struct cmdq_item *item) const char *errstr; char *cause; u_int adjust, sx, sy; + int xpixel = -1, ypixel = -1; if (args->argc == 0) adjust = 1; @@ -97,13 +98,16 @@ cmd_resize_window_exec(struct cmd *self, struct cmdq_item *item) } else if (args_has(args, 'D')) sy += adjust; - if (args_has(args, 'A')) - default_window_size(NULL, s, w, &sx, &sy, WINDOW_SIZE_LARGEST); - else if (args_has(args, 'a')) - default_window_size(NULL, s, w, &sx, &sy, WINDOW_SIZE_SMALLEST); + if (args_has(args, 'A')) { + default_window_size(NULL, s, w, &sx, &sy, &xpixel, &ypixel, + WINDOW_SIZE_LARGEST); + } else if (args_has(args, 'a')) { + default_window_size(NULL, s, w, &sx, &sy, &xpixel, &ypixel, + WINDOW_SIZE_SMALLEST); + } options_set_number(w->options, "window-size", WINDOW_SIZE_MANUAL); - resize_window(w, sx, sy); + resize_window(w, sx, sy, xpixel, ypixel); return (CMD_RETURN_NORMAL); } diff --git a/format.c b/format.c index 45320bf5..86878cda 100644 --- a/format.c +++ b/format.c @@ -2211,6 +2211,8 @@ format_defaults_window(struct format_tree *ft, struct window *w) format_add(ft, "window_name", "%s", w->name); format_add(ft, "window_width", "%u", w->sx); format_add(ft, "window_height", "%u", w->sy); + format_add(ft, "window_cell_width", "%u", w->xpixel); + format_add(ft, "window_cell_height", "%u", w->ypixel); format_add_cb(ft, "window_layout", format_cb_window_layout); format_add_cb(ft, "window_visible_layout", format_cb_window_visible_layout); diff --git a/layout-custom.c b/layout-custom.c index d7371292..097dabe6 100644 --- a/layout-custom.c +++ b/layout-custom.c @@ -221,7 +221,7 @@ layout_parse(struct window *w, const char *layout) return (-1); /* Resize to the layout size. */ - window_resize(w, lc->sx, lc->sy); + window_resize(w, lc->sx, lc->sy, -1, -1); /* Destroy the old layout and swap to the new. */ layout_free_cell(w->layout_root); diff --git a/layout-set.c b/layout-set.c index 82247149..f712b059 100644 --- a/layout-set.c +++ b/layout-set.c @@ -163,7 +163,7 @@ layout_set_even(struct window *w, enum layout_type type) layout_print_cell(w->layout_root, __func__, 1); - window_resize(w, lc->sx, lc->sy); + window_resize(w, lc->sx, lc->sy, -1, -1); notify_window("window-layout-changed", w); server_redraw_window(w); } @@ -262,7 +262,7 @@ layout_set_main_h(struct window *w) layout_print_cell(w->layout_root, __func__, 1); - window_resize(w, lc->sx, lc->sy); + window_resize(w, lc->sx, lc->sy, -1, -1); notify_window("window-layout-changed", w); server_redraw_window(w); } @@ -349,7 +349,7 @@ layout_set_main_v(struct window *w) layout_print_cell(w->layout_root, __func__, 1); - window_resize(w, lc->sx, lc->sy); + window_resize(w, lc->sx, lc->sy, -1, -1); notify_window("window-layout-changed", w); server_redraw_window(w); } @@ -458,7 +458,7 @@ layout_set_tiled(struct window *w) layout_print_cell(w->layout_root, __func__, 1); - window_resize(w, lc->sx, lc->sy); + window_resize(w, lc->sx, lc->sy, -1, -1); notify_window("window-layout-changed", w); server_redraw_window(w); } diff --git a/resize.c b/resize.c index 6432f003..9f74b33e 100644 --- a/resize.c +++ b/resize.c @@ -23,7 +23,7 @@ #include "tmux.h" void -resize_window(struct window *w, u_int sx, u_int sy) +resize_window(struct window *w, u_int sx, u_int sy, int xpixel, int ypixel) { int zoomed; @@ -50,7 +50,7 @@ resize_window(struct window *w, u_int sx, u_int sy) sx = w->layout_root->sx; if (sy < w->layout_root->sy) sy = w->layout_root->sy; - window_resize(w, sx, sy); + window_resize(w, sx, sy, xpixel, ypixel); log_debug("%s: @%u resized to %u,%u; layout %u,%u", __func__, w->id, sx, sy, w->layout_root->sx, w->layout_root->sy); @@ -77,7 +77,7 @@ ignore_client_size(struct client *c) void default_window_size(struct client *c, struct session *s, struct window *w, - u_int *sx, u_int *sy, int type) + u_int *sx, u_int *sy, u_int *xpixel, u_int *ypixel, int type) { struct client *loop; u_int cx, cy; @@ -88,6 +88,7 @@ default_window_size(struct client *c, struct session *s, struct window *w, switch (type) { case WINDOW_SIZE_LARGEST: *sx = *sy = 0; + *xpixel = *ypixel = 0; TAILQ_FOREACH(loop, &clients, entry) { if (ignore_client_size(loop)) continue; @@ -103,12 +104,19 @@ default_window_size(struct client *c, struct session *s, struct window *w, *sx = cx; if (cy > *sy) *sy = cy; + + if (loop->tty.xpixel > *xpixel && + loop->tty.ypixel > *ypixel) { + *xpixel = loop->tty.xpixel; + *ypixel = loop->tty.ypixel; + } } if (*sx == 0 || *sy == 0) goto manual; break; case WINDOW_SIZE_SMALLEST: *sx = *sy = UINT_MAX; + *xpixel = *ypixel = 0; TAILQ_FOREACH(loop, &clients, entry) { if (ignore_client_size(loop)) continue; @@ -124,6 +132,12 @@ default_window_size(struct client *c, struct session *s, struct window *w, *sx = cx; if (cy < *sy) *sy = cy; + + if (loop->tty.xpixel > *xpixel && + loop->tty.ypixel > *ypixel) { + *xpixel = loop->tty.xpixel; + *ypixel = loop->tty.ypixel; + } } if (*sx == UINT_MAX || *sy == UINT_MAX) goto manual; @@ -132,8 +146,11 @@ default_window_size(struct client *c, struct session *s, struct window *w, if (c != NULL && !ignore_client_size(c)) { *sx = c->tty.sx; *sy = c->tty.sy - status_line_size(c); + *xpixel = c->tty.xpixel; + *ypixel = c->tty.ypixel; } else { *sx = *sy = UINT_MAX; + *xpixel = *ypixel = 0; TAILQ_FOREACH(loop, &clients, entry) { if (ignore_client_size(loop)) continue; @@ -148,6 +165,12 @@ default_window_size(struct client *c, struct session *s, struct window *w, *sx = cx; if (cy < *sy) *sy = cy; + + if (loop->tty.xpixel > *xpixel && + loop->tty.ypixel > *ypixel) { + *xpixel = loop->tty.xpixel; + *ypixel = loop->tty.ypixel; + } } if (*sx == UINT_MAX || *sy == UINT_MAX) goto manual; @@ -181,7 +204,7 @@ recalculate_size(struct window *w) { struct session *s; struct client *c; - u_int sx, sy, cx, cy; + u_int sx, sy, cx, cy, xpixel = 0, ypixel = 0; int type, current, has, changed; if (w->active == NULL) @@ -214,6 +237,11 @@ recalculate_size(struct window *w) sx = cx; if (cy > sy) sy = cy; + + if (c->tty.xpixel > xpixel && c->tty.ypixel > ypixel) { + xpixel = c->tty.xpixel; + ypixel = c->tty.ypixel; + } } if (sx == 0 || sy == 0) changed = 0; @@ -239,6 +267,11 @@ recalculate_size(struct window *w) sx = cx; if (cy < sy) sy = cy; + + if (c->tty.xpixel > xpixel && c->tty.ypixel > ypixel) { + xpixel = c->tty.xpixel; + ypixel = c->tty.ypixel; + } } if (sx == UINT_MAX || sy == UINT_MAX) changed = 0; @@ -266,6 +299,11 @@ recalculate_size(struct window *w) sx = cx; if (cy < sy) sy = cy; + + if (c->tty.xpixel > xpixel && c->tty.ypixel > ypixel) { + xpixel = c->tty.xpixel; + ypixel = c->tty.ypixel; + } } if (sx == UINT_MAX || sy == UINT_MAX) changed = 0; @@ -281,8 +319,9 @@ recalculate_size(struct window *w) tty_update_window_offset(w); return; } - log_debug("%s: @%u changed to %u,%u", __func__, w->id, sx, sy); - resize_window(w, sx, sy); + log_debug("%s: @%u changed to %u,%u (%ux%u)", __func__, w->id, sx, sy, + xpixel, ypixel); + resize_window(w, sx, sy, xpixel, ypixel); } void diff --git a/server-client.c b/server-client.c index 26b246c1..27173ef1 100644 --- a/server-client.c +++ b/server-client.c @@ -1321,7 +1321,6 @@ static int server_client_resize_force(struct window_pane *wp) { struct timeval tv = { .tv_usec = 100000 }; - struct winsize ws; /* * If we are resizing to the same size as when we entered the loop @@ -1342,12 +1341,8 @@ server_client_resize_force(struct window_pane *wp) wp->sy <= 1) return (0); - memset(&ws, 0, sizeof ws); - ws.ws_col = wp->sx; - ws.ws_row = wp->sy - 1; - if (wp->fd != -1 && ioctl(wp->fd, TIOCSWINSZ, &ws) == -1) - fatal("ioctl failed"); log_debug("%s: %%%u forcing resize", __func__, wp->id); + window_pane_send_resize(wp, -1); evtimer_add(&wp->resize_timer, &tv); wp->flags |= PANE_RESIZEFORCE; @@ -1358,14 +1353,8 @@ server_client_resize_force(struct window_pane *wp) static void server_client_resize_pane(struct window_pane *wp) { - struct winsize ws; - - memset(&ws, 0, sizeof ws); - ws.ws_col = wp->sx; - ws.ws_row = wp->sy; - if (wp->fd != -1 && ioctl(wp->fd, TIOCSWINSZ, &ws) == -1) - fatal("ioctl failed"); log_debug("%s: %%%u resize to %u,%u", __func__, wp->id, wp->sx, wp->sy); + window_pane_send_resize(wp, 0); wp->flags &= ~PANE_RESIZE; diff --git a/spawn.c b/spawn.c index dfa39ad7..6cf7c73b 100644 --- a/spawn.c +++ b/spawn.c @@ -85,7 +85,7 @@ spawn_window(struct spawn_context *sc, char **cause) struct window_pane *wp; struct winlink *wl; int idx = sc->idx; - u_int sx, sy; + u_int sx, sy, xpixel, ypixel; spawn_log(__func__, sc); @@ -155,8 +155,9 @@ spawn_window(struct spawn_context *sc, char **cause) xasprintf(cause, "couldn't add window %d", idx); return (NULL); } - default_window_size(sc->c, s, NULL, &sx, &sy, -1); - if ((w = window_create(sx, sy)) == NULL) { + default_window_size(sc->c, s, NULL, &sx, &sy, &xpixel, &ypixel, + -1); + if ((w = window_create(sx, sy, xpixel, ypixel)) == NULL) { winlink_remove(&s->windows, sc->wl); xasprintf(cause, "couldn't create window %d", idx); return (NULL); @@ -338,6 +339,8 @@ spawn_pane(struct spawn_context *sc, char **cause) memset(&ws, 0, sizeof ws); ws.ws_col = screen_size_x(&new_wp->base); ws.ws_row = screen_size_y(&new_wp->base); + ws.ws_xpixel = w->xpixel * ws.ws_col; + ws.ws_ypixel = w->ypixel * ws.ws_row; /* Block signals until fork has completed. */ sigfillset(&set); diff --git a/tmux.1 b/tmux.1 index fc42b393..56ebeb87 100644 --- a/tmux.1 +++ b/tmux.1 @@ -4329,6 +4329,8 @@ The following variables are available, where appropriate: .It Li "window_activity_flag" Ta "" Ta "1 if window has activity" .It Li "window_bell_flag" Ta "" Ta "1 if window has bell" .It Li "window_bigger" Ta "" Ta "1 if window is larger than client" +.It Li "window_cell_height" Ta "" Ta "Height of each cell in pixels" +.It Li "window_cell_width" Ta "" Ta "Width of each cell in pixels" .It Li "window_end_flag" Ta "" Ta "1 if window has the highest index" .It Li "window_flags" Ta "#F" Ta "Window flags" .It Li "window_format" Ta "" Ta "1 if format is for a window" diff --git a/tmux.h b/tmux.h index d2a4196a..6d142ab9 100644 --- a/tmux.h +++ b/tmux.h @@ -78,6 +78,10 @@ struct winlink; /* Maximum size of data to hold from a pane. */ #define READ_SIZE 4096 +/* Default pixel cell sizes. */ +#define DEFAULT_XPIXEL 16 +#define DEFAULT_YPIXEL 32 + /* Attribute to make GCC check printf-like arguments. */ #define printflike(a, b) __attribute__ ((format (printf, a, b))) @@ -928,6 +932,8 @@ struct window { u_int sx; u_int sy; + u_int xpixel; + u_int ypixel; int flags; #define WINDOW_BELL 0x1 @@ -2208,9 +2214,9 @@ void status_prompt_load_history(void); void status_prompt_save_history(void); /* resize.c */ -void resize_window(struct window *, u_int, u_int); +void resize_window(struct window *, u_int, u_int, int, int); void default_window_size(struct client *, struct session *, struct window *, - u_int *, u_int *, int); + u_int *, u_int *, u_int *, u_int *, int); void recalculate_size(struct window *); void recalculate_sizes(void); @@ -2402,7 +2408,7 @@ void winlink_stack_remove(struct winlink_stack *, struct winlink *); struct window *window_find_by_id_str(const char *); struct window *window_find_by_id(u_int); void window_update_activity(struct window *); -struct window *window_create(u_int, u_int); +struct window *window_create(u_int, u_int, u_int, u_int); void window_pane_set_event(struct window_pane *); struct window_pane *window_get_active_at(struct window *, u_int, u_int); struct window_pane *window_find_string(struct window *, const char *); @@ -2413,7 +2419,8 @@ void window_redraw_active_switch(struct window *, struct window_pane *); struct window_pane *window_add_pane(struct window *, struct window_pane *, u_int, int); -void window_resize(struct window *, u_int, u_int); +void window_resize(struct window *, u_int, u_int, int, int); +void window_pane_send_resize(struct window_pane *, int); int window_zoom(struct window_pane *); int window_unzoom(struct window *); int window_push_zoom(struct window *, int); diff --git a/window.c b/window.c index 21bf366f..bde9693b 100644 --- a/window.c +++ b/window.c @@ -308,10 +308,15 @@ window_update_activity(struct window *w) } struct window * -window_create(u_int sx, u_int sy) +window_create(u_int sx, u_int sy, u_int xpixel, u_int ypixel) { struct window *w; + if (xpixel == 0) + xpixel = DEFAULT_XPIXEL; + if (ypixel == 0) + ypixel = DEFAULT_YPIXEL; + w = xcalloc(1, sizeof *w); w->name = xstrdup(""); w->flags = 0; @@ -324,6 +329,8 @@ window_create(u_int sx, u_int sy) w->sx = sx; w->sy = sy; + w->xpixel = xpixel; + w->ypixel = ypixel; w->options = options_create(global_w_options); @@ -410,11 +417,40 @@ window_set_name(struct window *w, const char *new_name) } void -window_resize(struct window *w, u_int sx, u_int sy) +window_resize(struct window *w, u_int sx, u_int sy, int xpixel, int ypixel) { - log_debug("%s: @%u resize %ux%u", __func__, w->id, sx, sy); + if (xpixel == 0) + xpixel = DEFAULT_XPIXEL; + if (ypixel == 0) + ypixel = DEFAULT_YPIXEL; + + log_debug("%s: @%u resize %ux%u (%ux%u)", __func__, w->id, sx, sy, + xpixel == -1 ? w->xpixel : xpixel, + ypixel == -1 ? w->ypixel : ypixel); w->sx = sx; w->sy = sy; + if (xpixel != -1) + w->xpixel = xpixel; + if (ypixel != -1) + w->ypixel = ypixel; +} + +void +window_pane_send_resize(struct window_pane *wp, int yadjust) +{ + struct window *w = wp->window; + struct winsize ws; + + if (wp->fd == -1) + return; + + memset(&ws, 0, sizeof ws); + ws.ws_col = wp->sx; + ws.ws_row = wp->sy + yadjust; + ws.ws_xpixel = w->xpixel * ws.ws_col; + ws.ws_ypixel = w->ypixel * ws.ws_row; + if (ioctl(wp->fd, TIOCSWINSZ, &ws) == -1) + fatal("ioctl failed"); } int -- cgit From 9ea05b2fb32395d717ead5d7904acdfaa852b068 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 28 Nov 2019 09:50:09 +0000 Subject: Bump the escape sequence timeout to five seconds to allow for longer legitimate sequences. --- input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input.c b/input.c index 96fd5d33..452eac7f 100644 --- a/input.c +++ b/input.c @@ -740,7 +740,7 @@ input_timer_callback(__unused int fd, __unused short events, void *arg) static void input_start_timer(struct input_ctx *ictx) { - struct timeval tv = { .tv_usec = 100000 }; + struct timeval tv = { .tv_sec = 5, .tv_usec = 0 }; event_del(&ictx->timer); event_add(&ictx->timer, &tv); -- cgit From c416fe0da43f9caffd8b5f6c1a627c8f7a16f881 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 28 Nov 2019 09:51:58 +0000 Subject: Add xrecallocarray. --- xmalloc.c | 14 ++++++++++++++ xmalloc.h | 1 + 2 files changed, 15 insertions(+) diff --git a/xmalloc.c b/xmalloc.c index f249e397..d11d8dc7 100644 --- a/xmalloc.c +++ b/xmalloc.c @@ -71,6 +71,20 @@ xreallocarray(void *ptr, size_t nmemb, size_t size) return new_ptr; } +void * +xrecallocarray(void *ptr, size_t oldnmemb, size_t nmemb, size_t size) +{ + void *new_ptr; + + if (nmemb == 0 || size == 0) + fatalx("xrecallocarray: zero size"); + new_ptr = recallocarray(ptr, oldnmemb, nmemb, size); + if (new_ptr == NULL) + fatalx("xrecallocarray: allocating %zu * %zu bytes: %s", + nmemb, size, strerror(errno)); + return new_ptr; +} + char * xstrdup(const char *str) { diff --git a/xmalloc.h b/xmalloc.h index a3ee486f..3fe4f1cc 100644 --- a/xmalloc.h +++ b/xmalloc.h @@ -23,6 +23,7 @@ void *xmalloc(size_t); void *xcalloc(size_t, size_t); void *xrealloc(void *, size_t); void *xreallocarray(void *, size_t, size_t); +void *xrecallocarray(void *, size_t, size_t, size_t); char *xstrdup(const char *); char *xstrndup(const char *, size_t); int xasprintf(char **, const char *, ...) -- cgit From bc5881c4d2fe0d9172636cfb2d756372995c8359 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 28 Nov 2019 09:56:25 +0000 Subject: Long lines and spacing fixes. --- server-client.c | 3 ++- tmux.h | 4 ++-- tty-term.c | 3 ++- tty.c | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/server-client.c b/server-client.c index 27173ef1..c644bb01 100644 --- a/server-client.c +++ b/server-client.c @@ -543,7 +543,8 @@ have_event: where = STATUS_RIGHT; break; case STYLE_RANGE_WINDOW: - wl = winlink_find_by_index(&s->windows, sr->argument); + wl = winlink_find_by_index(&s->windows, + sr->argument); if (wl == NULL) return (KEYC_UNKNOWN); m->w = wl->window->id; diff --git a/tmux.h b/tmux.h index 6d142ab9..bcdc99a4 100644 --- a/tmux.h +++ b/tmux.h @@ -1244,8 +1244,8 @@ struct tty_ctx { const struct grid_cell *cell; int wrapped; - u_int num; - void *ptr; + u_int num; + void *ptr; /* * Cursor and region position before the screen was updated - this is diff --git a/tty-term.c b/tty-term.c index c408d968..52468faf 100644 --- a/tty-term.c +++ b/tty-term.c @@ -636,7 +636,8 @@ tty_term_string2(struct tty_term *term, enum tty_code_code code, int a, int b) } const char * -tty_term_string3(struct tty_term *term, enum tty_code_code code, int a, int b, int c) +tty_term_string3(struct tty_term *term, enum tty_code_code code, int a, int b, + int c) { return (tparm((char *) tty_term_string(term, code), a, b, c)); } diff --git a/tty.c b/tty.c index 9efd78a0..594f02fa 100644 --- a/tty.c +++ b/tty.c @@ -2454,7 +2454,8 @@ tty_check_bg(struct tty *tty, struct window_pane *wp, struct grid_cell *gc) } static void -tty_check_us(__unused struct tty *tty, struct window_pane *wp, struct grid_cell *gc) +tty_check_us(__unused struct tty *tty, struct window_pane *wp, + struct grid_cell *gc) { int c; -- cgit From 08e28285923cb87168ba383011b42aac76925e07 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 28 Nov 2019 10:17:22 +0000 Subject: Parse out DA features. --- screen-write.c | 3 ++- tty-keys.c | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/screen-write.c b/screen-write.c index 34d16ee8..43cb42b4 100644 --- a/screen-write.c +++ b/screen-write.c @@ -1636,7 +1636,8 @@ screen_write_overwrite(struct screen_write_ctx *ctx, struct grid_cell *gc, grid_view_get_cell(gd, xx, s->cy, &tmp_gc); if (~tmp_gc.flags & GRID_FLAG_PADDING) break; - log_debug("%s: overwrite at %u,%u", __func__, xx, s->cy); + log_debug("%s: overwrite at %u,%u", __func__, xx, + s->cy); grid_view_set_cell(gd, xx, s->cy, &grid_default_cell); done = 1; } diff --git a/tty-keys.c b/tty-keys.c index 66f0201a..6be40d0e 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -1002,8 +1002,8 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len, size_t *size) { struct client *c = tty->client; - u_int i, a, b; - char tmp[64], *endptr; + u_int i, n = 0; + char tmp[64], *endptr, p[32] = { 0 }, *cp, *next; static const char *types[] = TTY_TYPES; int type; @@ -1035,23 +1035,21 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len, *size = 4 + i; /* Convert version numbers. */ - a = strtoul(tmp, &endptr, 10); - if (*endptr == ';') { - b = strtoul(endptr + 1, &endptr, 10); + cp = tmp; + while ((next = strsep(&cp, ";")) != NULL) { + p[n] = strtoul(next, &endptr, 10); if (*endptr != '\0' && *endptr != ';') - b = 0; - } else if (*endptr == '\0') - b = 0; - else - a = b = 0; + p[n] = 0; + n++; + } /* Store terminal type. */ type = TTY_UNKNOWN; - switch (a) { + switch (p[0]) { case 1: - if (b == 2) + if (p[1] == 2) type = TTY_VT100; - else if (b == 0) + else if (p[1] == 0) type = TTY_VT101; break; case 6: @@ -1070,6 +1068,8 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len, type = TTY_VT520; break; } + for (i = 2; i < n; i++) + log_debug("%s: DA feature: %d", c->name, p[i]); tty_set_type(tty, type); log_debug("%s: received DA %.*s (%s)", c->name, (int)*size, buf, -- cgit From fa409194d3dfe0095bf6572a253772f2825f5dec Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 28 Nov 2019 10:55:45 +0000 Subject: Missing after-kill-pane option. --- options-table.c | 1 + 1 file changed, 1 insertion(+) diff --git a/options-table.c b/options-table.c index 1d22b662..d8612ff2 100644 --- a/options-table.c +++ b/options-table.c @@ -811,6 +811,7 @@ const struct options_table_entry options_table[] = { OPTIONS_TABLE_HOOK("after-copy-mode", ""), OPTIONS_TABLE_HOOK("after-display-message", ""), OPTIONS_TABLE_HOOK("after-display-panes", ""), + OPTIONS_TABLE_HOOK("after-kill-pane", ""), OPTIONS_TABLE_HOOK("after-list-buffers", ""), OPTIONS_TABLE_HOOK("after-list-clients", ""), OPTIONS_TABLE_HOOK("after-list-keys", ""), -- cgit