From 5080acc12714862ef7a66286d7c3bce538c6d74f Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 3 Feb 2022 07:26:43 +0000 Subject: [PATCH 1/3] Add a key in copy mode to toggle position indicator. --- key-bindings.c | 2 ++ tmux.1 | 1 + window-copy.c | 16 ++++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/key-bindings.c b/key-bindings.c index 9f7e734a..95171966 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -492,6 +492,7 @@ key_bindings_init(void) "bind -Tcopy-mode \\; { send -X jump-again }", "bind -Tcopy-mode F { command-prompt -1p'(jump backward)' { send -X jump-backward '%%' } }", "bind -Tcopy-mode N { send -X search-reverse }", + "bind -Tcopy-mode P { send -X toggle-position }", "bind -Tcopy-mode R { send -X rectangle-toggle }", "bind -Tcopy-mode T { command-prompt -1p'(jump to backward)' { send -X jump-to-backward '%%' } }", "bind -Tcopy-mode X { send -X set-mark }", @@ -588,6 +589,7 @@ key_bindings_init(void) "bind -Tcopy-mode-vi L { send -X bottom-line }", "bind -Tcopy-mode-vi M { send -X middle-line }", "bind -Tcopy-mode-vi N { send -X search-reverse }", + "bind -Tcopy-mode-vi P { send -X toggle-position }", "bind -Tcopy-mode-vi T { command-prompt -1p'(jump to backward)' { send -X jump-to-backward '%%' } }", "bind -Tcopy-mode-vi V { send -X select-line }", "bind -Tcopy-mode-vi W { send -X next-space }", diff --git a/tmux.1 b/tmux.1 index 7a8b9f24..255f10a9 100644 --- a/tmux.1 +++ b/tmux.1 @@ -1773,6 +1773,7 @@ The following commands are supported in copy mode: .It Li "set-mark" Ta "X" Ta "X" .It Li "start-of-line" Ta "0" Ta "C-a" .It Li "stop-selection" Ta "" Ta "" +.It Li "toggle-position" Ta "P" Ta "P" .It Li "top-line" Ta "H" Ta "M-R" .El .Pp diff --git a/window-copy.c b/window-copy.c index 9a0179a4..7c55b0f2 100644 --- a/window-copy.c +++ b/window-copy.c @@ -1272,6 +1272,16 @@ window_copy_cmd_halfpage_up(struct window_copy_cmd_state *cs) return (WINDOW_COPY_CMD_NOTHING); } +static enum window_copy_cmd_action +window_copy_cmd_toggle_position(struct window_copy_cmd_state *cs) +{ + struct window_mode_entry *wme = cs->wme; + struct window_copy_mode_data *data = wme->data; + + data->hide_position = !data->hide_position; + return (WINDOW_COPY_CMD_REDRAW); +} + static enum window_copy_cmd_action window_copy_cmd_history_bottom(struct window_copy_cmd_state *cs) { @@ -2817,6 +2827,12 @@ static const struct { .clear = WINDOW_COPY_CMD_CLEAR_ALWAYS, .f = window_copy_cmd_stop_selection }, + { .command = "toggle-position", + .minargs = 0, + .maxargs = 0, + .clear = WINDOW_COPY_CMD_CLEAR_NEVER, + .f = window_copy_cmd_toggle_position + }, { .command = "top-line", .minargs = 0, .maxargs = 0, From c401c91ad9f1ef8ea50b11762856a458de525bf9 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 3 Feb 2022 07:38:17 +0000 Subject: [PATCH 2/3] Update focus when active pane changes after pane destroyed. --- window.c | 1 + 1 file changed, 1 insertion(+) diff --git a/window.c b/window.c index d7fc3bf4..2ca3833c 100644 --- a/window.c +++ b/window.c @@ -754,6 +754,7 @@ window_lost_pane(struct window *w, struct window_pane *wp) if (w->active != NULL) { w->active->flags |= PANE_CHANGED; notify_window("window-pane-changed", w); + window_update_focus(w); } } else if (wp == w->last) w->last = NULL; From 948d2fad0ae9723263554115164c412aa095fe7a Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 3 Feb 2022 10:07:11 +0000 Subject: [PATCH 3/3] Use format_draw for command prompt prefix to allow styles, GitHub issue 3054. --- status.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/status.c b/status.c index bb57b3d6..79033242 100644 --- a/status.c +++ b/status.c @@ -718,7 +718,7 @@ status_prompt_redraw(struct client *c) memcpy(&cursorgc, &gc, sizeof cursorgc); cursorgc.attr ^= GRID_ATTR_REVERSE; - start = screen_write_strlen("%s", c->prompt_string); + start = format_width(c->prompt_string); if (start > c->tty.sx) start = c->tty.sx; @@ -728,7 +728,7 @@ status_prompt_redraw(struct client *c) for (offset = 0; offset < c->tty.sx; offset++) screen_write_putc(&ctx, &gc, ' '); screen_write_cursormove(&ctx, 0, lines - 1, 0); - screen_write_nputs(&ctx, start, &gc, "%s", c->prompt_string); + format_draw(&ctx, &gc, start, c->prompt_string, NULL, 0); screen_write_cursormove(&ctx, start, lines - 1, 0); left = c->tty.sx - start;