extension, from Munif Tanjim in GitHub issue 3596.
-/* $OpenBSD: input.c,v 1.216 2023/06/30 13:19:32 nicm Exp $ */
+/* $OpenBSD: input.c,v 1.217 2023/07/03 16:47:43 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
static void input_osc_110(struct input_ctx *, const char *);
static void input_osc_111(struct input_ctx *, const char *);
static void input_osc_112(struct input_ctx *, const char *);
+static void input_osc_133(struct input_ctx *, const char *);
/* Transition entry/exit handlers. */
static void input_clear(struct input_ctx *);
case 112:
input_osc_112(ictx, p);
break;
+ case 133:
+ input_osc_133(ictx, p);
+ break;
default:
log_debug("%s: unknown '%u'", __func__, option);
break;
screen_set_cursor_colour(ictx->ctx.s, -1);
}
+/* Handle the OSC 133 sequence. */
+static void
+input_osc_133(struct input_ctx *ictx, const char *p)
+{
+ struct grid *gd = ictx->ctx.s->grid;
+ u_int line = ictx->ctx.s->cy + gd->hsize;
+ struct grid_line *gl;
+
+ if (line > gd->hsize + gd->sy - 1)
+ return;
+ gl = grid_get_line(gd, line);
+
+ switch (*p) {
+ case 'A':
+ gl->flags |= GRID_LINE_START_PROMPT;
+ break;
+ }
+}
/* Handle the OSC 52 sequence for setting the clipboard. */
static void
-.\" $OpenBSD: tmux.1,v 1.921 2023/06/26 07:17:40 nicm Exp $
+.\" $OpenBSD: tmux.1,v 1.922 2023/07/03 16:47:43 nicm Exp $
.\"
.\" Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
.\"
.\" IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
.\" OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: June 26 2023 $
+.Dd $Mdocdate: July 3 2023 $
.Dt TMUX 1
.Os
.Sh NAME
.It Li "middle-line" Ta "M" Ta "M-r"
.It Li "next-matching-bracket" Ta "%" Ta "M-C-f"
.It Li "next-paragraph" Ta "}" Ta "M-}"
+.It Li "next-prompt" Ta "" Ta ""
.It Li "next-space" Ta "W" Ta ""
.It Li "next-space-end" Ta "E" Ta ""
.It Li "next-word" Ta "w" Ta ""
.It Li "pipe-and-cancel [<command>] [<prefix>]" Ta "" Ta ""
.It Li "previous-matching-bracket" Ta "" Ta "M-C-b"
.It Li "previous-paragraph" Ta "{" Ta "M-{"
+.It Li "previous-prompt" Ta "" Ta ""
.It Li "previous-space" Ta "B" Ta ""
.It Li "previous-word" Ta "b" Ta "M-b"
.It Li "rectangle-on" Ta "" Ta ""
does the same but reverses the direction (forward becomes backward and backward
becomes forward).
.Pp
+The
+.Ql next-prompt
+and
+.Ql previous-prompt
+move between shell prompts, but require the shell to emit an escape sequence
+(\e033]133;A\e033\e\e) to tell
+.Nm
+where the prompts are located; if the shell does not do this, these commands
+will do nothing.
+.Pp
Copy commands may take an optional buffer prefix argument which is used
to generate the buffer name (the default is
.Ql buffer
-/* $OpenBSD: tmux.h,v 1.1199 2023/06/08 11:17:29 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.1200 2023/07/03 16:47:43 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
#define GRID_LINE_WRAPPED 0x1
#define GRID_LINE_EXTENDED 0x2
#define GRID_LINE_DEAD 0x4
+#define GRID_LINE_START_PROMPT 0x8
/* Grid string flags. */
#define GRID_STRING_WITH_SEQUENCES 0x1
-/* $OpenBSD: window-copy.c,v 1.340 2022/09/28 07:59:50 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.341 2023/07/03 16:47:43 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
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_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);
return (WINDOW_COPY_CMD_NOTHING);
}
+static enum window_copy_cmd_action
+window_copy_cmd_next_prompt(struct window_copy_cmd_state *cs)
+{
+ struct window_mode_entry *wme = cs->wme;
+
+ window_copy_cursor_prompt(wme, 1);
+ return (WINDOW_COPY_CMD_NOTHING);
+}
+
+static enum window_copy_cmd_action
+window_copy_cmd_previous_prompt(struct window_copy_cmd_state *cs)
+{
+ struct window_mode_entry *wme = cs->wme;
+
+ window_copy_cursor_prompt(wme, 0);
+ return (WINDOW_COPY_CMD_NOTHING);
+}
+
static enum window_copy_cmd_action
window_copy_cmd_search_backward(struct window_copy_cmd_state *cs)
{
.clear = WINDOW_COPY_CMD_CLEAR_ALWAYS,
.f = window_copy_cmd_jump_to_mark
},
+ { .command = "next-prompt",
+ .minargs = 0,
+ .maxargs = 0,
+ .clear = WINDOW_COPY_CMD_CLEAR_ALWAYS,
+ .f = window_copy_cmd_next_prompt
+ },
+ { .command = "previous-prompt",
+ .minargs = 0,
+ .maxargs = 0,
+ .clear = WINDOW_COPY_CMD_CLEAR_ALWAYS,
+ .f = window_copy_cmd_previous_prompt
+ },
{ .command = "middle-line",
.minargs = 0,
.maxargs = 0,
window_copy_acquire_cursor_up(wme, hsize, data->oy, oldy, px, py);
}
+static void
+window_copy_cursor_prompt(struct window_mode_entry *wme, int direction)
+{
+ 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;
+
+ if (direction == 0) { /* up */
+ add = -1;
+ end_line = 0;
+ } else { /* down */
+ add = 1;
+ end_line = gd->hsize + gd->sy - 1;
+ }
+
+ if (line == end_line)
+ return;
+ for (;;) {
+ if (line == end_line)
+ return;
+ line += add;
+
+ if (grid_get_line(gd, line)->flags & GRID_LINE_START_PROMPT)
+ break;
+ }
+
+ data->cx = 0;
+ if (line > gd->hsize) {
+ data->cy = line - gd->hsize;
+ data->oy = 0;
+ } else {
+ data->cy = 0;
+ data->oy = gd->hsize - line;
+ }
+
+ window_copy_update_selection(wme, 1, 0);
+ window_copy_redraw_screen(wme);
+}
+
static void
window_copy_scroll_up(struct window_mode_entry *wme, u_int ny)
{