From: nicm Date: Tue, 8 Aug 2023 08:21:29 +0000 (+0000) Subject: Add flag to next-prompt/previous-prompt to go to command output instead, X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=e49f856682359d0ed329d7ddeed406cd19fe0680;p=openbsd Add flag to next-prompt/previous-prompt to go to command output instead, from Magnus Gross. --- diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c index 2157dac284f..a00a340f4e6 100644 --- a/usr.bin/tmux/input.c +++ b/usr.bin/tmux/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.218 2023/07/13 06:03:48 nicm Exp $ */ +/* $OpenBSD: input.c,v 1.219 2023/08/08 08:21:29 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -2756,6 +2756,9 @@ input_osc_133(struct input_ctx *ictx, const char *p) case 'A': gl->flags |= GRID_LINE_START_PROMPT; break; + case 'C': + gl->flags |= GRID_LINE_START_OUTPUT; + break; } } diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index 35c6a1187aa..6a22779177f 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.925 2023/08/08 08:08:47 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.926 2023/08/08 08:21:30 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -1782,29 +1782,35 @@ Exit copy mode. .Xc Clear the current selection. .It Xo -.Ic copy-end-of-line [] +.Ic copy-end-of-line +.Op Ar prefix .Xc Copy from the cursor position to the end of the line. .Ar prefix is used to name the new paste buffer. .It Xo -.Ic copy-end-of-line-and-cancel [] +.Ic copy-end-of-line-and-cancel +.Op Ar prefix .Xc Copy from the cursor position and exit copy mode. .It Xo -.Ic copy-line [] +.Ic copy-line +.Op Ar prefix .Xc Copy the entire line. .It Xo -.Ic copy-line-and-cancel [] +.Ic copy-line-and-cancel +.Op Ar prefix .Xc Copy the entire line and exit copy mode. .It Xo -.Ic copy-selection [] +.Ic copy-selection +.Op Ar prefix .Xc Copies the current selection. .It Xo -.Ic copy-selection-and-cancel [] +.Ic copy-selection-and-cancel +.Op Ar prefix (vi: Enter) (emacs: M-w) .Xc @@ -1840,7 +1846,8 @@ Move the cursor up. .Xc Move the cursor to the end of the line. .It Xo -.Ic goto-line +.Ic goto-line +.Ar line (vi: :) (emacs: g) .Xc @@ -1864,13 +1871,15 @@ Scroll to the top of the history. .Xc Repeat the last jump. .It Xo -.Ic jump-backward +.Ic jump-backward +.Ar to (vi: F) (emacs: F) .Xc Jump backwards to the specified text. .It Xo -.Ic jump-forward +.Ic jump-forward +.Ar to (vi: f) (emacs: f) .Xc @@ -1901,6 +1910,7 @@ Move to the next matching bracket. Move to the next paragraph. .It Xo .Ic next-prompt +.Op Fl o .Xc Move to the next prompt. .It Xo @@ -1933,6 +1943,7 @@ Move to the previous matching bracket. Move to the previous paragraph. .It Xo .Ic previous-prompt +.Op Fl o .Xc Move to the previous prompt. .It Xo @@ -1960,12 +1971,14 @@ Refresh the content from the pane. .Xc Repeat the last search. .It Xo -.Ic search-backward +.Ic search-backward +.Ar text (vi: ?) .Xc Search backwards for the specified text. .It Xo -.Ic search-forward +.Ic search-forward +.Ar text (vi: /) .Xc Search forward for the specified text. @@ -2033,6 +2046,9 @@ move between shell prompts, but require the shell to emit an escape sequence .Nm where the prompts are located; if the shell does not do this, these commands will do nothing. +The +.Fl o +flag jumps to the beginning of the command output instead of the shell prompt. .Pp Copy commands may take an optional buffer prefix argument which is used to generate the buffer name (the default is diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index b2616b63692..78df276b237 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1203 2023/08/08 08:08:47 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.1204 2023/08/08 08:21:30 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -672,6 +672,7 @@ struct colour_palette { #define GRID_LINE_EXTENDED 0x2 #define GRID_LINE_DEAD 0x4 #define GRID_LINE_START_PROMPT 0x8 +#define GRID_LINE_START_OUTPUT 0x10 /* Grid string flags. */ #define GRID_STRING_WITH_SEQUENCES 0x1 diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index fba3c05b938..bae0e083a79 100644 --- a/usr.bin/tmux/window-copy.c +++ b/usr.bin/tmux/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.341 2023/07/03 16:47:43 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.342 2023/08/08 08:21:30 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -131,7 +131,8 @@ static void window_copy_cursor_previous_word_pos(struct window_mode_entry *, const char *, u_int *, u_int *); static void window_copy_cursor_previous_word(struct window_mode_entry *, const char *, int); -static void window_copy_cursor_prompt(struct window_mode_entry *, int); +static void window_copy_cursor_prompt(struct window_mode_entry *, int, + const char *); static void window_copy_scroll_up(struct window_mode_entry *, u_int); static void window_copy_scroll_down(struct window_mode_entry *, u_int); static void window_copy_rectangle_set(struct window_mode_entry *, int); @@ -2245,8 +2246,9 @@ static enum window_copy_cmd_action window_copy_cmd_next_prompt(struct window_copy_cmd_state *cs) { struct window_mode_entry *wme = cs->wme; + const char *arg1 = args_string(cs->args, 1); - window_copy_cursor_prompt(wme, 1); + window_copy_cursor_prompt(wme, 1, arg1); return (WINDOW_COPY_CMD_NOTHING); } @@ -2254,8 +2256,9 @@ static enum window_copy_cmd_action window_copy_cmd_previous_prompt(struct window_copy_cmd_state *cs) { struct window_mode_entry *wme = cs->wme; + const char *arg1 = args_string(cs->args, 1); - window_copy_cursor_prompt(wme, 0); + window_copy_cursor_prompt(wme, 0, arg1); return (WINDOW_COPY_CMD_NOTHING); } @@ -2721,7 +2724,7 @@ static const struct { }, { .command = "previous-prompt", .minargs = 0, - .maxargs = 0, + .maxargs = 1, .clear = WINDOW_COPY_CMD_CLEAR_ALWAYS, .f = window_copy_cmd_previous_prompt }, @@ -5389,14 +5392,20 @@ window_copy_cursor_previous_word(struct window_mode_entry *wme, } static void -window_copy_cursor_prompt(struct window_mode_entry *wme, int direction) +window_copy_cursor_prompt(struct window_mode_entry *wme, int direction, + const char *args) { struct window_copy_mode_data *data = wme->data; struct screen *s = data->backing; struct grid *gd = s->grid; u_int end_line; u_int line = gd->hsize - data->oy + data->cy; - int add; + int add, line_flag; + + if (args != NULL && strcmp(args, "-o") == 0) + line_flag = GRID_LINE_START_OUTPUT; + else + line_flag = GRID_LINE_START_PROMPT; if (direction == 0) { /* up */ add = -1; @@ -5413,7 +5422,7 @@ window_copy_cursor_prompt(struct window_mode_entry *wme, int direction) return; line += add; - if (grid_get_line(gd, line)->flags & GRID_LINE_START_PROMPT) + if (grid_get_line(gd, line)->flags & line_flag) break; }