mirror of
https://github.com/tmate-io/tmate.git
synced 2024-12-24 15:48:58 +01:00
vi(1)-style half page scroll in copy and scroll modes. Move the vi full page
scroll key to C-b instead of C-u and use C-u/C-d for half page scrolling with vi keys. In emacs mode, half page scrolling is bound to M-Up and M-Down. Suggested by merdely (about a year ago :-)).
This commit is contained in:
parent
39154402e5
commit
7a359c00ac
@ -149,10 +149,12 @@ const struct mode_key_entry mode_key_vi_copy[] = {
|
||||
{ ' ', 0, MODEKEYCOPY_STARTSELECTION },
|
||||
{ '$', 0, MODEKEYCOPY_ENDOFLINE },
|
||||
{ '0', 0, MODEKEYCOPY_STARTOFLINE },
|
||||
{ '\002' /* C-b */, 0, MODEKEYCOPY_PREVIOUSPAGE },
|
||||
{ '\003' /* C-c */, 0, MODEKEYCOPY_CANCEL },
|
||||
{ '\004' /* C-d */, 0, MODEKEYCOPY_HALFPAGEDOWN },
|
||||
{ '\006' /* C-f */, 0, MODEKEYCOPY_NEXTPAGE },
|
||||
{ '\010' /* C-h */, 0, MODEKEYCOPY_LEFT },
|
||||
{ '\025' /* C-u */, 0, MODEKEYCOPY_PREVIOUSPAGE },
|
||||
{ '\025' /* C-u */, 0, MODEKEYCOPY_HALFPAGEUP },
|
||||
{ '\033' /* Escape */, 0, MODEKEYCOPY_CLEARSELECTION },
|
||||
{ '\r', 0, MODEKEYCOPY_COPYSELECTION },
|
||||
{ '^', 0, MODEKEYCOPY_BACKTOINDENTATION },
|
||||
@ -237,11 +239,13 @@ 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_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_ESCAPE, 0, MODEKEYCOPY_HALFPAGEUP },
|
||||
{ KEYC_UP, 0, MODEKEYCOPY_UP },
|
||||
|
||||
{ 0, -1, 0 }
|
||||
|
4
tmux.h
4
tmux.h
@ -388,12 +388,14 @@ enum mode_key_cmd {
|
||||
MODEKEYCHOICE_UP,
|
||||
|
||||
/* Copy keys. */
|
||||
MODEKEYCOPY_CANCEL,
|
||||
MODEKEYCOPY_BACKTOINDENTATION,
|
||||
MODEKEYCOPY_CANCEL,
|
||||
MODEKEYCOPY_CLEARSELECTION,
|
||||
MODEKEYCOPY_COPYSELECTION,
|
||||
MODEKEYCOPY_DOWN,
|
||||
MODEKEYCOPY_ENDOFLINE,
|
||||
MODEKEYCOPY_HALFPAGEDOWN,
|
||||
MODEKEYCOPY_HALFPAGEUP,
|
||||
MODEKEYCOPY_LEFT,
|
||||
MODEKEYCOPY_NEXTPAGE,
|
||||
MODEKEYCOPY_NEXTWORD,
|
||||
|
@ -203,6 +203,24 @@ window_copy_key(struct window_pane *wp, struct client *c, int key)
|
||||
window_copy_update_selection(wp);
|
||||
window_copy_redraw_screen(wp);
|
||||
break;
|
||||
case MODEKEYCOPY_HALFPAGEUP:
|
||||
n = screen_size_y(s) / 2;
|
||||
if (data->oy + n > screen_hsize(&wp->base))
|
||||
data->oy = screen_hsize(&wp->base);
|
||||
else
|
||||
data->oy += n;
|
||||
window_copy_update_selection(wp);
|
||||
window_copy_redraw_screen(wp);
|
||||
break;
|
||||
case MODEKEYCOPY_HALFPAGEDOWN:
|
||||
n = screen_size_y(s) / 2;
|
||||
if (data->oy < n)
|
||||
data->oy = 0;
|
||||
else
|
||||
data->oy -= n;
|
||||
window_copy_update_selection(wp);
|
||||
window_copy_redraw_screen(wp);
|
||||
break;
|
||||
case MODEKEYCOPY_STARTSELECTION:
|
||||
window_copy_start_selection(wp);
|
||||
window_copy_redraw_screen(wp);
|
||||
|
@ -165,6 +165,22 @@ window_scroll_key(struct window_pane *wp, unused struct client *c, int key)
|
||||
data->oy -= n;
|
||||
window_scroll_redraw_screen(wp);
|
||||
break;
|
||||
case MODEKEYCOPY_HALFPAGEUP:
|
||||
n = screen_size_y(s) / 2;
|
||||
if (data->oy + n > screen_hsize(&wp->base))
|
||||
data->oy = screen_hsize(&wp->base);
|
||||
else
|
||||
data->oy += n;
|
||||
window_scroll_redraw_screen(wp);
|
||||
break;
|
||||
case MODEKEYCOPY_HALFPAGEDOWN:
|
||||
n = screen_size_y(s) / 2;
|
||||
if (data->oy < n)
|
||||
data->oy = 0;
|
||||
else
|
||||
data->oy -= n;
|
||||
window_scroll_redraw_screen(wp);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user