From 0c374868ca34cef826e15e7984300f0292b314d8 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 21 Mar 2024 11:26:28 +0000 Subject: Do not consider a selection present if it is empty, from Michael Grant (GitHub issue 3869). Also a typo fix from GitHub issue 3877. --- screen.c | 2 +- window-copy.c | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/screen.c b/screen.c index 267a50b9..de072d1a 100644 --- a/screen.c +++ b/screen.c @@ -384,7 +384,7 @@ screen_resize_y(struct screen *s, u_int sy, int eat_empty, u_int *cy) /* * Try to pull as much as possible out of scrolled history, if - * is is enabled. + * it is enabled. */ available = gd->hscrolled; if (gd->flags & GRID_HISTORY && available > 0) { diff --git a/window-copy.c b/window-copy.c index bc3713b0..2ca5d961 100644 --- a/window-copy.c +++ b/window-copy.c @@ -795,16 +795,24 @@ window_copy_formats(struct window_mode_entry *wme, struct format_tree *ft) format_add(ft, "copy_cursor_x", "%d", data->cx); format_add(ft, "copy_cursor_y", "%d", data->cy); - format_add(ft, "selection_present", "%d", data->screen.sel != NULL); if (data->screen.sel != NULL) { format_add(ft, "selection_start_x", "%d", data->selx); format_add(ft, "selection_start_y", "%d", data->sely); format_add(ft, "selection_end_x", "%d", data->endselx); format_add(ft, "selection_end_y", "%d", data->endsely); - format_add(ft, "selection_active", "%d", - data->cursordrag != CURSORDRAG_NONE); - } else - format_add(ft, "selection_active", "%d", 0); + + if (data->cursordrag != CURSORDRAG_NONE) + format_add(ft, "selection_active", "1"); + else + format_add(ft, "selection_active", "0"); + if (data->endselx != data->selx && data->endsely != data->sely) + format_add(ft, "selection_present", "1"); + else + format_add(ft, "selection_present", "0"); + } else { + format_add(ft, "selection_active", "0"); + format_add(ft, "selection_present", "0"); + } format_add(ft, "search_present", "%d", data->searchmark != NULL); format_add_cb(ft, "search_match", window_copy_search_match_cb); -- cgit v1.2.3 -- cgit v1.2.3 From 6c0067c10360880334afa50815b880d04edcbf42 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 21 Mar 2024 11:30:42 +0000 Subject: Do not notify window-layout-changed if the window is about to be destroyed (since it may have been freed by the time the notify happens), from Romain Francoise in GitHub issue 3860. --- cmd-display-panes.c | 2 +- cmd-resize-pane.c | 2 +- popup.c | 2 +- resize.c | 2 +- server-fn.c | 2 +- tmux.h | 2 +- window.c | 10 ++++++---- 7 files changed, 12 insertions(+), 10 deletions(-) diff --git a/cmd-display-panes.c b/cmd-display-panes.c index 06f6dc27..25556f3d 100644 --- a/cmd-display-panes.c +++ b/cmd-display-panes.c @@ -246,7 +246,7 @@ cmd_display_panes_key(struct client *c, void *data, struct key_event *event) wp = window_pane_at_index(w, index); if (wp == NULL) return (1); - window_unzoom(w); + window_unzoom(w, 1); xasprintf(&expanded, "%%%u", wp->id); diff --git a/cmd-resize-pane.c b/cmd-resize-pane.c index c9439441..b2c167f5 100644 --- a/cmd-resize-pane.c +++ b/cmd-resize-pane.c @@ -87,7 +87,7 @@ cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item) if (args_has(args, 'Z')) { if (w->flags & WINDOW_ZOOMED) - window_unzoom(w); + window_unzoom(w, 1); else window_zoom(wp); server_redraw_window(w); diff --git a/popup.c b/popup.c index 38a4c17f..804dd6ef 100644 --- a/popup.c +++ b/popup.c @@ -346,7 +346,7 @@ popup_make_pane(struct popup_data *pd, enum layout_type type) u_int hlimit; const char *shell; - window_unzoom(w); + window_unzoom(w, 1); lc = layout_split_pane(wp, type, -1, 0); hlimit = options_get_number(s->options, "history-limit"); diff --git a/resize.c b/resize.c index 457fee0a..dff95712 100644 --- a/resize.c +++ b/resize.c @@ -40,7 +40,7 @@ resize_window(struct window *w, u_int sx, u_int sy, int xpixel, int ypixel) /* If the window is zoomed, unzoom. */ zoomed = w->flags & WINDOW_ZOOMED; if (zoomed) - window_unzoom(w); + window_unzoom(w, 1); /* Resize the layout first. */ layout_resize(w, sx, sy); diff --git a/server-fn.c b/server-fn.c index 8d66bce9..05216956 100644 --- a/server-fn.c +++ b/server-fn.c @@ -487,6 +487,6 @@ server_check_unattached(void) void server_unzoom_window(struct window *w) { - if (window_unzoom(w) == 0) + if (window_unzoom(w, 1) == 0) server_redraw_window(w); } diff --git a/tmux.h b/tmux.h index e6516a72..f61d1032 100644 --- a/tmux.h +++ b/tmux.h @@ -3021,7 +3021,7 @@ struct window_pane *window_add_pane(struct window *, struct window_pane *, void window_resize(struct window *, u_int, u_int, int, int); void window_pane_send_resize(struct window_pane *, u_int, u_int); int window_zoom(struct window_pane *); -int window_unzoom(struct window *); +int window_unzoom(struct window *, int); int window_push_zoom(struct window *, int, int); int window_pop_zoom(struct window *); void window_lost_pane(struct window *, struct window_pane *); diff --git a/window.c b/window.c index c5d00e29..43c272bc 100644 --- a/window.c +++ b/window.c @@ -340,7 +340,7 @@ window_destroy(struct window *w) { log_debug("window @%u destroyed (%d references)", w->id, w->references); - window_unzoom(w); + window_unzoom(w, 0); RB_REMOVE(windows, &windows, w); if (w->layout_root != NULL) @@ -666,7 +666,7 @@ window_zoom(struct window_pane *wp) } int -window_unzoom(struct window *w) +window_unzoom(struct window *w, int notify) { struct window_pane *wp; @@ -683,7 +683,9 @@ window_unzoom(struct window *w) wp->saved_layout_cell = NULL; } layout_fix_panes(w, NULL); - notify_window("window-layout-changed", w); + + if (notify) + notify_window("window-layout-changed", w); return (0); } @@ -697,7 +699,7 @@ window_push_zoom(struct window *w, int always, int flag) w->flags |= WINDOW_WASZOOMED; else w->flags &= ~WINDOW_WASZOOMED; - return (window_unzoom(w) == 0); + return (window_unzoom(w, 1) == 0); } int -- cgit v1.2.3 From 0ae8b681b22aec6a45a38fd286117154957134ff Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 21 Mar 2024 11:32:49 +0000 Subject: Use -p for default paste-buffer command in buffer mode, it will only do anything if the application asked for it. From Gregory Anders. --- window-buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window-buffer.c b/window-buffer.c index aac0bc40..8ad31e4b 100644 --- a/window-buffer.c +++ b/window-buffer.c @@ -36,7 +36,7 @@ static void window_buffer_key(struct window_mode_entry *, struct client *, struct session *, struct winlink *, key_code, struct mouse_event *); -#define WINDOW_BUFFER_DEFAULT_COMMAND "paste-buffer -b '%%'" +#define WINDOW_BUFFER_DEFAULT_COMMAND "paste-buffer -p -b '%%'" #define WINDOW_BUFFER_DEFAULT_FORMAT \ "#{t/p:buffer_created}: #{buffer_sample}" -- cgit v1.2.3 From 6f0254e6a88ee5e66c8ea5d8723c7adfb7181585 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 21 Mar 2024 11:47:55 +0000 Subject: Look for feature code 21 for DECSLRM and 28 for DECFRA in the device attributes and also accept level 1 (there is no hardware with this but some emulators may use it). Pointed out by James Holderness. --- tty-keys.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/tty-keys.c b/tty-keys.c index ef80abc4..9f8ff67c 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -1314,26 +1314,21 @@ tty_keys_device_attributes(struct tty *tty, const char *buf, size_t len, break; } - /* - * Add terminal features. Hardware level 5 does not offer SIXEL but - * some terminal emulators report it anyway and it does not harm - * to check it here. - * - * DECSLRM and DECFRA should be supported by level 5 as well as level - * 4, but VTE has rather ruined it by advertising level 5 despite not - * supporting them. - */ + /* Add terminal features. */ switch (p[0]) { - case 64: /* level 4 */ - tty_add_features(features, "margins,rectfill", ","); - /* FALLTHROUGH */ + case 61: /* level 1 */ case 62: /* level 2 */ case 63: /* level 3 */ + case 64: /* level 4 */ case 65: /* level 5 */ for (i = 1; i < n; i++) { log_debug("%s: DA feature: %d", c->name, p[i]); if (p[i] == 4) tty_add_features(features, "sixel", ","); + if (p[i] == 21) + tty_add_features(features, "margins", ","); + if (p[i] == 28) + tty_add_features(features, "rectfill", ","); } break; } @@ -1405,11 +1400,6 @@ tty_keys_device_attributes2(struct tty *tty, const char *buf, size_t len, * we can't use level 5 from DA because of VTE. */ switch (p[0]) { - case 41: /* VT420 */ - case 61: /* VT510 */ - case 64: /* VT520 */ - tty_add_features(features, "margins,rectfill", ","); - break; case 'M': /* mintty */ tty_default_features(features, "mintty", 0); break; -- cgit v1.2.3 From d8ddeec7db6955434a32acedf7079031c2d8d212 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 21 Mar 2024 11:51:32 +0000 Subject: Add -M to always turn mouse on in a menu, GitHub issue 3779. --- cmd-display-menu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd-display-menu.c b/cmd-display-menu.c index 7d0d3e59..73728b91 100644 --- a/cmd-display-menu.c +++ b/cmd-display-menu.c @@ -39,8 +39,8 @@ const struct cmd_entry cmd_display_menu_entry = { .name = "display-menu", .alias = "menu", - .args = { "b:c:C:H:s:S:Ot:T:x:y:", 1, -1, cmd_display_menu_args_parse }, - .usage = "[-O] [-b border-lines] [-c target-client] " + .args = { "b:c:C:H:s:S:MOt:T:x:y:", 1, -1, cmd_display_menu_args_parse }, + .usage = "[-MO] [-b border-lines] [-c target-client] " "[-C starting-choice] [-H selected-style] [-s style] " "[-S border-style] " CMD_TARGET_PANE_USAGE "[-T title] " "[-x position] [-y position] name key command ...", @@ -374,7 +374,7 @@ cmd_display_menu_exec(struct cmd *self, struct cmdq_item *item) if (args_has(args, 'O')) flags |= MENU_STAYOPEN; - if (!event->m.valid) + if (!event->m.valid && !args_has(args, 'M')) flags |= MENU_NOMOUSE; if (menu_display(menu, flags, starting_choice, item, px, py, tc, lines, style, selected_style, border_style, target, NULL, NULL) != 0) -- cgit v1.2.3 From 2e9d7ebf15615b51b014a12de03b0e5483aadf99 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 21 Mar 2024 11:53:11 +0000 Subject: Reduce escape-time default to 10 milliseconds, 500 is far too long for modern terminals and networks. Case made by Kurtis Rader in GitHub issue 3844. --- options-table.c | 2 +- tmux.1 | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/options-table.c b/options-table.c index df36f1f0..8187ad08 100644 --- a/options-table.c +++ b/options-table.c @@ -286,7 +286,7 @@ const struct options_table_entry options_table[] = { .scope = OPTIONS_TABLE_SERVER, .minimum = 0, .maximum = INT_MAX, - .default_num = 500, + .default_num = 10, .unit = "milliseconds", .text = "Time to wait before assuming a key is Escape." }, diff --git a/tmux.1 b/tmux.1 index 32215371..186ffee0 100644 --- a/tmux.1 +++ b/tmux.1 @@ -3745,7 +3745,6 @@ Set the time in milliseconds for which .Nm waits after an escape is input to determine if it is part of a function or meta key sequences. -The default is 500 milliseconds. .It Ic editor Ar shell-command Set the command used when .Nm @@ -6116,7 +6115,7 @@ the default is .Ql y . .Tg menu .It Xo Ic display-menu -.Op Fl O +.Op Fl OM .Op Fl b Ar border-lines .Op Fl c Ar target-client .Op Fl C Ar starting-choice @@ -6223,7 +6222,13 @@ changes this behaviour so that the menu does not close when the mouse button is released without an item selected the menu is not closed and a mouse button must be clicked to choose an item. .Pp -The following keys are also available: +.Fl M +tells +.Nm +the menu should handle mouse events; by default only menus opened from mouse +key bindings do so. +.Pp +The following keys are available in menus: .Bl -column "Key" "Function" -offset indent .It Sy "Key" Ta Sy "Function" .It Li "Enter" Ta "Choose selected item" @@ -6469,7 +6474,7 @@ is replaced by the buffer name in and the result executed as a command. If .Ar template -is not given, "paste-buffer -b \[aq]%%\[aq]" is used. +is not given, "paste-buffer -p -b \[aq]%%\[aq]" is used. .Pp .Fl O specifies the initial sort field: one of -- cgit v1.2.3 From 89c1c43ef96d805d8fcb987c024ef85f994f11fa Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 21 Mar 2024 12:10:57 +0000 Subject: Write padding character into the right position. --- screen-write.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/screen-write.c b/screen-write.c index ff758a17..554232eb 100644 --- a/screen-write.c +++ b/screen-write.c @@ -2051,7 +2051,7 @@ screen_write_combine(struct screen_write_ctx *ctx, const struct grid_cell *gc) /* Set the new cell. */ grid_view_set_cell(gd, cx - n, cy, &last); if (force_wide) - grid_view_set_padding(gd, cx, cy); + grid_view_set_padding(gd, cx - 1, cy); /* * Redraw the combined cell. If forcing the cell to width 2, reset the -- cgit v1.2.3