mirror of
https://github.com/tmux/tmux.git
synced 2025-01-07 16:28:48 +00:00
Add copy-mode -e to exit copy mode when scrolling off the bottom, useful
for quick view of history, from Cam Hutchison.
This commit is contained in:
parent
ede0f2f633
commit
901c2eb20a
@ -28,8 +28,8 @@ enum cmd_retval cmd_copy_mode_exec(struct cmd *, struct cmd_q *);
|
|||||||
|
|
||||||
const struct cmd_entry cmd_copy_mode_entry = {
|
const struct cmd_entry cmd_copy_mode_entry = {
|
||||||
"copy-mode", NULL,
|
"copy-mode", NULL,
|
||||||
"Mt:u", 0, 0,
|
"Met:u", 0, 0,
|
||||||
"[-Mu] " CMD_TARGET_PANE_USAGE,
|
"[-Meu] " CMD_TARGET_PANE_USAGE,
|
||||||
0,
|
0,
|
||||||
cmd_copy_mode_exec
|
cmd_copy_mode_exec
|
||||||
};
|
};
|
||||||
@ -66,7 +66,7 @@ cmd_copy_mode_exec(struct cmd *self, struct cmd_q *cmdq)
|
|||||||
if (wp->mode != &window_copy_mode) {
|
if (wp->mode != &window_copy_mode) {
|
||||||
if (window_pane_set_mode(wp, &window_copy_mode) != 0)
|
if (window_pane_set_mode(wp, &window_copy_mode) != 0)
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
window_copy_init_from_pane(wp);
|
window_copy_init_from_pane(wp, args_has(self->args, 'e'));
|
||||||
}
|
}
|
||||||
if (args_has(args, 'M')) {
|
if (args_has(args, 'M')) {
|
||||||
if (wp->mode != NULL && wp->mode != &window_copy_mode)
|
if (wp->mode != NULL && wp->mode != &window_copy_mode)
|
||||||
|
12
tmux.1
12
tmux.1
@ -1133,7 +1133,7 @@ The synopsis for the
|
|||||||
command is:
|
command is:
|
||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Xo Ic copy-mode
|
.It Xo Ic copy-mode
|
||||||
.Op Fl Mu
|
.Op Fl Meu
|
||||||
.Op Fl t Ar target-pane
|
.Op Fl t Ar target-pane
|
||||||
.Xc
|
.Xc
|
||||||
Enter copy mode.
|
Enter copy mode.
|
||||||
@ -1143,6 +1143,16 @@ option scrolls one page up.
|
|||||||
.Fl M
|
.Fl M
|
||||||
begins a mouse drag (only valid if bound to a mouse key binding, see
|
begins a mouse drag (only valid if bound to a mouse key binding, see
|
||||||
.Sx MOUSE SUPPORT ) .
|
.Sx MOUSE SUPPORT ) .
|
||||||
|
.Fl e
|
||||||
|
specifies that scrolling to the bottom of the history (to the visible screen)
|
||||||
|
should exit copy mode.
|
||||||
|
While in copy mode, pressing a key other than those used for scrolling will
|
||||||
|
disable this behaviour.
|
||||||
|
This is intended to allow fast scrolling through a pane's history, for
|
||||||
|
example with:
|
||||||
|
.Bd -literal -offset indent
|
||||||
|
bind PageUp copy-mode -eu
|
||||||
|
.Ed
|
||||||
.El
|
.El
|
||||||
.Pp
|
.Pp
|
||||||
Each window displayed by
|
Each window displayed by
|
||||||
|
2
tmux.h
2
tmux.h
@ -2068,7 +2068,7 @@ extern const char window_clock_table[14][5][5];
|
|||||||
|
|
||||||
/* window-copy.c */
|
/* window-copy.c */
|
||||||
extern const struct window_mode window_copy_mode;
|
extern const struct window_mode window_copy_mode;
|
||||||
void window_copy_init_from_pane(struct window_pane *);
|
void window_copy_init_from_pane(struct window_pane *, u_int);
|
||||||
void window_copy_init_for_output(struct window_pane *);
|
void window_copy_init_for_output(struct window_pane *);
|
||||||
void printflike(2, 3) window_copy_add(struct window_pane *, const char *, ...);
|
void printflike(2, 3) window_copy_add(struct window_pane *, const char *, ...);
|
||||||
void window_copy_vadd(struct window_pane *, const char *, va_list);
|
void window_copy_vadd(struct window_pane *, const char *, va_list);
|
||||||
|
@ -135,7 +135,8 @@ struct window_copy_mode_data {
|
|||||||
u_int selx;
|
u_int selx;
|
||||||
u_int sely;
|
u_int sely;
|
||||||
|
|
||||||
u_int rectflag; /* are we in rectangle copy mode? */
|
int rectflag; /* in rectangle copy mode? */
|
||||||
|
int scroll_exit; /* exit on scroll to end? */
|
||||||
|
|
||||||
u_int cx;
|
u_int cx;
|
||||||
u_int cy;
|
u_int cy;
|
||||||
@ -175,6 +176,7 @@ window_copy_init(struct window_pane *wp)
|
|||||||
data->backing_written = 0;
|
data->backing_written = 0;
|
||||||
|
|
||||||
data->rectflag = 0;
|
data->rectflag = 0;
|
||||||
|
data->scroll_exit = 0;
|
||||||
|
|
||||||
data->inputtype = WINDOW_COPY_OFF;
|
data->inputtype = WINDOW_COPY_OFF;
|
||||||
data->inputprompt = NULL;
|
data->inputprompt = NULL;
|
||||||
@ -206,7 +208,7 @@ window_copy_init(struct window_pane *wp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
window_copy_init_from_pane(struct window_pane *wp)
|
window_copy_init_from_pane(struct window_pane *wp, u_int scroll_exit)
|
||||||
{
|
{
|
||||||
struct window_copy_mode_data *data = wp->modedata;
|
struct window_copy_mode_data *data = wp->modedata;
|
||||||
struct screen *s = &data->screen;
|
struct screen *s = &data->screen;
|
||||||
@ -219,6 +221,7 @@ window_copy_init_from_pane(struct window_pane *wp)
|
|||||||
data->backing = &wp->base;
|
data->backing = &wp->base;
|
||||||
data->cx = data->backing->cx;
|
data->cx = data->backing->cx;
|
||||||
data->cy = data->backing->cy;
|
data->cy = data->backing->cy;
|
||||||
|
data->scroll_exit = scroll_exit;
|
||||||
|
|
||||||
s->cx = data->cx;
|
s->cx = data->cx;
|
||||||
s->cy = data->cy;
|
s->cy = data->cy;
|
||||||
@ -419,6 +422,13 @@ window_copy_key(struct window_pane *wp, struct client *c, struct session *sess,
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd = mode_key_lookup(&data->mdata, key, &arg);
|
cmd = mode_key_lookup(&data->mdata, key, &arg);
|
||||||
|
if (cmd != MODEKEYCOPY_PREVIOUSPAGE &&
|
||||||
|
cmd != MODEKEYCOPY_NEXTPAGE &&
|
||||||
|
cmd != MODEKEYCOPY_SCROLLUP &&
|
||||||
|
cmd != MODEKEYCOPY_SCROLLDOWN &&
|
||||||
|
cmd != MODEKEYCOPY_HALFPAGEUP &&
|
||||||
|
cmd != MODEKEYCOPY_HALFPAGEDOWN)
|
||||||
|
data->scroll_exit = 0;
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case MODEKEYCOPY_APPENDSELECTION:
|
case MODEKEYCOPY_APPENDSELECTION:
|
||||||
if (sess != NULL) {
|
if (sess != NULL) {
|
||||||
@ -461,6 +471,10 @@ window_copy_key(struct window_pane *wp, struct client *c, struct session *sess,
|
|||||||
case MODEKEYCOPY_SCROLLDOWN:
|
case MODEKEYCOPY_SCROLLDOWN:
|
||||||
for (; np != 0; np--)
|
for (; np != 0; np--)
|
||||||
window_copy_cursor_down(wp, 1);
|
window_copy_cursor_down(wp, 1);
|
||||||
|
if (data->scroll_exit && data->oy == 0) {
|
||||||
|
window_pane_reset_mode(wp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case MODEKEYCOPY_PREVIOUSPAGE:
|
case MODEKEYCOPY_PREVIOUSPAGE:
|
||||||
for (; np != 0; np--)
|
for (; np != 0; np--)
|
||||||
@ -476,6 +490,10 @@ window_copy_key(struct window_pane *wp, struct client *c, struct session *sess,
|
|||||||
else
|
else
|
||||||
data->oy -= n;
|
data->oy -= n;
|
||||||
}
|
}
|
||||||
|
if (data->scroll_exit && data->oy == 0) {
|
||||||
|
window_pane_reset_mode(wp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
window_copy_update_selection(wp, 1);
|
window_copy_update_selection(wp, 1);
|
||||||
window_copy_redraw_screen(wp);
|
window_copy_redraw_screen(wp);
|
||||||
break;
|
break;
|
||||||
@ -498,6 +516,10 @@ window_copy_key(struct window_pane *wp, struct client *c, struct session *sess,
|
|||||||
else
|
else
|
||||||
data->oy -= n;
|
data->oy -= n;
|
||||||
}
|
}
|
||||||
|
if (data->scroll_exit && data->oy == 0) {
|
||||||
|
window_pane_reset_mode(wp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
window_copy_update_selection(wp, 1);
|
window_copy_update_selection(wp, 1);
|
||||||
window_copy_redraw_screen(wp);
|
window_copy_redraw_screen(wp);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user