mirror of
https://github.com/tmux/tmux.git
synced 2024-12-12 17:38:48 +00:00
Make C-Up and C-Down in copy mode scroll the screen up and down one line
without moving the cursor, like Up and Down in scroll mode (which will shortly disappear).
This commit is contained in:
parent
4ca2200d83
commit
9400fdac77
@ -89,6 +89,8 @@ struct mode_key_cmdstr mode_key_cmdstr_copy[] = {
|
||||
{ MODEKEYCOPY_PREVIOUSPAGE, "page-up" },
|
||||
{ MODEKEYCOPY_PREVIOUSWORD, "previous-word" },
|
||||
{ MODEKEYCOPY_RIGHT, "cursor-right" },
|
||||
{ MODEKEYCOPY_SCROLLDOWN, "scroll-down" },
|
||||
{ MODEKEYCOPY_SCROLLUP, "scroll-up" },
|
||||
{ MODEKEYCOPY_SEARCHAGAIN, "search-again" },
|
||||
{ MODEKEYCOPY_SEARCHDOWN, "search-forward" },
|
||||
{ MODEKEYCOPY_SEARCHUP, "search-backward" },
|
||||
@ -177,11 +179,13 @@ const struct mode_key_entry mode_key_vi_copy[] = {
|
||||
{ 'q', 0, MODEKEYCOPY_CANCEL },
|
||||
{ 'w', 0, MODEKEYCOPY_NEXTWORD },
|
||||
{ KEYC_BSPACE, 0, MODEKEYCOPY_LEFT },
|
||||
{ KEYC_DOWN | KEYC_CTRL,0, MODEKEYCOPY_SCROLLDOWN },
|
||||
{ KEYC_DOWN, 0, MODEKEYCOPY_DOWN },
|
||||
{ KEYC_LEFT, 0, MODEKEYCOPY_LEFT },
|
||||
{ KEYC_NPAGE, 0, MODEKEYCOPY_NEXTPAGE },
|
||||
{ KEYC_PPAGE, 0, MODEKEYCOPY_PREVIOUSPAGE },
|
||||
{ KEYC_RIGHT, 0, MODEKEYCOPY_RIGHT },
|
||||
{ KEYC_UP | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLUP },
|
||||
{ KEYC_UP, 0, MODEKEYCOPY_UP },
|
||||
|
||||
{ 0, -1, 0 }
|
||||
@ -262,12 +266,14 @@ const struct mode_key_entry mode_key_emacs_copy[] = {
|
||||
{ 'q', 0, MODEKEYCOPY_CANCEL },
|
||||
{ 'v' | KEYC_ESCAPE, 0, MODEKEYCOPY_PREVIOUSPAGE },
|
||||
{ 'w' | KEYC_ESCAPE, 0, MODEKEYCOPY_COPYSELECTION },
|
||||
{ KEYC_DOWN | KEYC_CTRL,0, MODEKEYCOPY_SCROLLDOWN },
|
||||
{ KEYC_DOWN | KEYC_ESCAPE, 0, MODEKEYCOPY_HALFPAGEDOWN },
|
||||
{ KEYC_DOWN, 0, MODEKEYCOPY_DOWN },
|
||||
{ KEYC_LEFT, 0, MODEKEYCOPY_LEFT },
|
||||
{ KEYC_NPAGE, 0, MODEKEYCOPY_NEXTPAGE },
|
||||
{ KEYC_PPAGE, 0, MODEKEYCOPY_PREVIOUSPAGE },
|
||||
{ KEYC_RIGHT, 0, MODEKEYCOPY_RIGHT },
|
||||
{ KEYC_UP | KEYC_CTRL, 0, MODEKEYCOPY_SCROLLUP },
|
||||
{ KEYC_UP | KEYC_ESCAPE, 0, MODEKEYCOPY_HALFPAGEUP },
|
||||
{ KEYC_UP, 0, MODEKEYCOPY_UP },
|
||||
|
||||
|
2
tmux.1
2
tmux.1
@ -515,6 +515,8 @@ The following keys are supported as appropriate for the mode:
|
||||
.It Li "Previous page" Ta "C-u" Ta "Page up"
|
||||
.It Li "Previous word" Ta "b" Ta "M-b"
|
||||
.It Li "Quit mode" Ta "q" Ta "Escape"
|
||||
.It Li "Scroll down" Ta "C-Down" Ta "C-Down"
|
||||
.It Li "Scroll up" Ta "C-Up" Ta "C-Up"
|
||||
.It Li "Search again" Ta "n" Ta "n"
|
||||
.It Li "Search backward" Ta "?" Ta "C-r"
|
||||
.It Li "Search forward" Ta "/" Ta "C-s"
|
||||
|
2
tmux.h
2
tmux.h
@ -402,6 +402,8 @@ enum mode_key_cmd {
|
||||
MODEKEYCOPY_PREVIOUSPAGE,
|
||||
MODEKEYCOPY_PREVIOUSWORD,
|
||||
MODEKEYCOPY_RIGHT,
|
||||
MODEKEYCOPY_SCROLLDOWN,
|
||||
MODEKEYCOPY_SCROLLUP,
|
||||
MODEKEYCOPY_SEARCHAGAIN,
|
||||
MODEKEYCOPY_SEARCHDOWN,
|
||||
MODEKEYCOPY_SEARCHUP,
|
||||
|
@ -61,8 +61,8 @@ void window_copy_cursor_back_to_indentation(struct window_pane *);
|
||||
void window_copy_cursor_end_of_line(struct window_pane *);
|
||||
void window_copy_cursor_left(struct window_pane *);
|
||||
void window_copy_cursor_right(struct window_pane *);
|
||||
void window_copy_cursor_up(struct window_pane *);
|
||||
void window_copy_cursor_down(struct window_pane *);
|
||||
void window_copy_cursor_up(struct window_pane *, int);
|
||||
void window_copy_cursor_down(struct window_pane *, int);
|
||||
void window_copy_cursor_next_word(struct window_pane *);
|
||||
void window_copy_cursor_previous_word(struct window_pane *);
|
||||
void window_copy_scroll_up(struct window_pane *, u_int);
|
||||
@ -235,11 +235,17 @@ window_copy_key(struct window_pane *wp, struct client *c, int key)
|
||||
window_copy_cursor_right(wp);
|
||||
return;
|
||||
case MODEKEYCOPY_UP:
|
||||
window_copy_cursor_up(wp);
|
||||
window_copy_cursor_up(wp, 0);
|
||||
return;
|
||||
case MODEKEYCOPY_DOWN:
|
||||
window_copy_cursor_down(wp);
|
||||
window_copy_cursor_down(wp, 0);
|
||||
return;
|
||||
case MODEKEYCOPY_SCROLLUP:
|
||||
window_copy_cursor_up(wp, 1);
|
||||
break;
|
||||
case MODEKEYCOPY_SCROLLDOWN:
|
||||
window_copy_cursor_down(wp, 1);
|
||||
break;
|
||||
case MODEKEYCOPY_PREVIOUSPAGE:
|
||||
window_copy_pageup(wp);
|
||||
break;
|
||||
@ -1020,7 +1026,7 @@ window_copy_cursor_left(struct window_pane *wp)
|
||||
struct window_copy_mode_data *data = wp->modedata;
|
||||
|
||||
if (data->cx == 0) {
|
||||
window_copy_cursor_up(wp);
|
||||
window_copy_cursor_up(wp, 0);
|
||||
window_copy_cursor_end_of_line(wp);
|
||||
} else {
|
||||
window_copy_update_cursor(wp, data->cx - 1, data->cy);
|
||||
@ -1040,7 +1046,7 @@ window_copy_cursor_right(struct window_pane *wp)
|
||||
|
||||
if (data->cx >= px) {
|
||||
window_copy_cursor_start_of_line(wp);
|
||||
window_copy_cursor_down(wp);
|
||||
window_copy_cursor_down(wp, 0);
|
||||
} else {
|
||||
window_copy_update_cursor(wp, data->cx + 1, data->cy);
|
||||
if (window_copy_update_selection(wp))
|
||||
@ -1049,7 +1055,7 @@ window_copy_cursor_right(struct window_pane *wp)
|
||||
}
|
||||
|
||||
void
|
||||
window_copy_cursor_up(struct window_pane *wp)
|
||||
window_copy_cursor_up(struct window_pane *wp, int scroll_only)
|
||||
{
|
||||
struct window_copy_mode_data *data = wp->modedata;
|
||||
u_int ox, oy, px, py;
|
||||
@ -1062,9 +1068,11 @@ window_copy_cursor_up(struct window_pane *wp)
|
||||
}
|
||||
|
||||
data->cx = data->lastcx;
|
||||
if (data->cy == 0)
|
||||
if (scroll_only || data->cy == 0) {
|
||||
window_copy_scroll_down(wp, 1);
|
||||
else {
|
||||
if (scroll_only && window_copy_update_selection(wp))
|
||||
window_copy_redraw_lines(wp, data->cy, 2);
|
||||
} else {
|
||||
window_copy_update_cursor(wp, data->cx, data->cy - 1);
|
||||
if (window_copy_update_selection(wp))
|
||||
window_copy_redraw_lines(wp, data->cy, 2);
|
||||
@ -1077,7 +1085,7 @@ window_copy_cursor_up(struct window_pane *wp)
|
||||
}
|
||||
|
||||
void
|
||||
window_copy_cursor_down(struct window_pane *wp)
|
||||
window_copy_cursor_down(struct window_pane *wp, int scroll_only)
|
||||
{
|
||||
struct window_copy_mode_data *data = wp->modedata;
|
||||
struct screen *s = &data->screen;
|
||||
@ -1091,9 +1099,11 @@ window_copy_cursor_down(struct window_pane *wp)
|
||||
}
|
||||
|
||||
data->cx = data->lastcx;
|
||||
if (data->cy == screen_size_y(s) - 1)
|
||||
if (scroll_only || data->cy == screen_size_y(s) - 1) {
|
||||
window_copy_scroll_up(wp, 1);
|
||||
else {
|
||||
if (scroll_only && window_copy_update_selection(wp))
|
||||
window_copy_redraw_lines(wp, data->cy - 1, 2);
|
||||
} else {
|
||||
window_copy_update_cursor(wp, data->cx, data->cy + 1);
|
||||
if (window_copy_update_selection(wp))
|
||||
window_copy_redraw_lines(wp, data->cy - 1, 2);
|
||||
@ -1137,7 +1147,7 @@ window_copy_cursor_next_word(struct window_pane *wp)
|
||||
}
|
||||
|
||||
px = 0;
|
||||
window_copy_cursor_down(wp);
|
||||
window_copy_cursor_down(wp, 0);
|
||||
|
||||
py =screen_hsize(
|
||||
&wp->base) + data->cy - data->oy;
|
||||
@ -1185,7 +1195,7 @@ window_copy_cursor_previous_word(struct window_pane *wp)
|
||||
(screen_hsize(&wp->base) == 0 ||
|
||||
data->oy >= screen_hsize(&wp->base) - 1))
|
||||
goto out;
|
||||
window_copy_cursor_up(wp);
|
||||
window_copy_cursor_up(wp, 0);
|
||||
|
||||
py = screen_hsize(
|
||||
&wp->base) + data->cy - data->oy;
|
||||
|
Loading…
Reference in New Issue
Block a user