mirror of
https://github.com/tmux/tmux.git
synced 2024-11-07 19:58:51 +00:00
Sync OpenBSD patchset 629:
Add scroll-up/scroll-down for choose/more mode, from Micah Cowan.
This commit is contained in:
parent
998d76c6b4
commit
c4724c7861
12
mode-key.c
12
mode-key.c
@ -1,4 +1,4 @@
|
||||
/* $Id: mode-key.c,v 1.40 2010-01-28 22:47:21 tcunha Exp $ */
|
||||
/* $Id: mode-key.c,v 1.41 2010-02-02 23:55:21 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -69,6 +69,8 @@ struct mode_key_cmdstr mode_key_cmdstr_choice[] = {
|
||||
{ MODEKEYCHOICE_DOWN, "down" },
|
||||
{ MODEKEYCHOICE_PAGEDOWN, "page-down" },
|
||||
{ MODEKEYCHOICE_PAGEUP, "page-up" },
|
||||
{ MODEKEYCHOICE_SCROLLDOWN, "scroll-down" },
|
||||
{ MODEKEYCHOICE_SCROLLUP, "scroll-up" },
|
||||
{ MODEKEYCHOICE_UP, "up" },
|
||||
|
||||
{ 0, NULL }
|
||||
@ -145,14 +147,20 @@ struct mode_key_tree mode_key_tree_vi_edit;
|
||||
|
||||
/* vi choice selection keys. */
|
||||
const struct mode_key_entry mode_key_vi_choice[] = {
|
||||
{ '\002' /* C-b */, 0, MODEKEYCHOICE_PAGEUP },
|
||||
{ '\003' /* C-c */, 0, MODEKEYCHOICE_CANCEL },
|
||||
{ '\005' /* C-e */, 0, MODEKEYCHOICE_SCROLLDOWN },
|
||||
{ '\006' /* C-f */, 0, MODEKEYCHOICE_PAGEDOWN },
|
||||
{ '\031' /* C-y */, 0, MODEKEYCHOICE_SCROLLUP },
|
||||
{ '\r', 0, MODEKEYCHOICE_CHOOSE },
|
||||
{ 'j', 0, MODEKEYCHOICE_DOWN },
|
||||
{ 'k', 0, MODEKEYCHOICE_UP },
|
||||
{ 'q', 0, MODEKEYCHOICE_CANCEL },
|
||||
{ KEYC_DOWN | KEYC_CTRL,0, MODEKEYCHOICE_SCROLLDOWN },
|
||||
{ KEYC_DOWN, 0, MODEKEYCHOICE_DOWN },
|
||||
{ KEYC_NPAGE, 0, MODEKEYCHOICE_PAGEDOWN },
|
||||
{ KEYC_PPAGE, 0, MODEKEYCHOICE_PAGEUP },
|
||||
{ KEYC_UP | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLUP },
|
||||
{ KEYC_UP, 0, MODEKEYCHOICE_UP },
|
||||
|
||||
{ 0, -1, 0 }
|
||||
@ -248,9 +256,11 @@ const struct mode_key_entry mode_key_emacs_choice[] = {
|
||||
{ '\r', 0, MODEKEYCHOICE_CHOOSE },
|
||||
{ 'q', 0, MODEKEYCHOICE_CANCEL },
|
||||
{ 'v' | KEYC_ESCAPE, 0, MODEKEYCHOICE_PAGEUP },
|
||||
{ KEYC_DOWN | KEYC_CTRL,0, MODEKEYCHOICE_SCROLLDOWN },
|
||||
{ KEYC_DOWN, 0, MODEKEYCHOICE_DOWN },
|
||||
{ KEYC_NPAGE, 0, MODEKEYCHOICE_PAGEDOWN },
|
||||
{ KEYC_PPAGE, 0, MODEKEYCHOICE_PAGEUP },
|
||||
{ KEYC_UP | KEYC_CTRL, 0, MODEKEYCHOICE_SCROLLUP },
|
||||
{ KEYC_UP, 0, MODEKEYCHOICE_UP },
|
||||
|
||||
{ 0, -1, 0 }
|
||||
|
4
tmux.h
4
tmux.h
@ -1,4 +1,4 @@
|
||||
/* $Id: tmux.h,v 1.538 2010-01-28 22:45:57 tcunha Exp $ */
|
||||
/* $Id: tmux.h,v 1.539 2010-02-02 23:55:21 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -441,6 +441,8 @@ enum mode_key_cmd {
|
||||
MODEKEYCHOICE_DOWN,
|
||||
MODEKEYCHOICE_PAGEDOWN,
|
||||
MODEKEYCHOICE_PAGEUP,
|
||||
MODEKEYCHOICE_SCROLLDOWN,
|
||||
MODEKEYCHOICE_SCROLLUP,
|
||||
MODEKEYCHOICE_UP,
|
||||
|
||||
/* Copy keys. */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: window-choose.c,v 1.28 2010-01-17 19:00:05 tcunha Exp $ */
|
||||
/* $Id: window-choose.c,v 1.29 2010-02-02 23:55:21 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -225,16 +225,41 @@ window_choose_key(struct window_pane *wp, unused struct client *c, int key)
|
||||
}
|
||||
data->selected++;
|
||||
|
||||
if (data->selected >= data->top + screen_size_y(&data->screen))
|
||||
window_choose_scroll_down(wp);
|
||||
else {
|
||||
if (data->selected < data->top + screen_size_y(s)) {
|
||||
screen_write_start(&ctx, wp, NULL);
|
||||
window_choose_write_line(
|
||||
wp, &ctx, data->selected - data->top);
|
||||
window_choose_write_line(
|
||||
wp, &ctx, data->selected - 1 - data->top);
|
||||
screen_write_stop(&ctx);
|
||||
}
|
||||
} else
|
||||
window_choose_scroll_down(wp);
|
||||
break;
|
||||
case MODEKEYCHOICE_SCROLLUP:
|
||||
if (items == 0 || data->top == 0)
|
||||
break;
|
||||
if (data->selected == data->top + screen_size_y(s) - 1) {
|
||||
data->selected--;
|
||||
window_choose_scroll_up(wp);
|
||||
screen_write_start(&ctx, wp, NULL);
|
||||
window_choose_write_line(
|
||||
wp, &ctx, screen_size_y(s) - 1);
|
||||
screen_write_stop(&ctx);
|
||||
} else
|
||||
window_choose_scroll_up(wp);
|
||||
break;
|
||||
case MODEKEYCHOICE_SCROLLDOWN:
|
||||
if (items == 0 ||
|
||||
data->top + screen_size_y(&data->screen) >= items)
|
||||
break;
|
||||
if (data->selected == data->top) {
|
||||
data->selected++;
|
||||
window_choose_scroll_down(wp);
|
||||
screen_write_start(&ctx, wp, NULL);
|
||||
window_choose_write_line(wp, &ctx, 0);
|
||||
screen_write_stop(&ctx);
|
||||
} else
|
||||
window_choose_scroll_down(wp);
|
||||
break;
|
||||
case MODEKEYCHOICE_PAGEUP:
|
||||
if (data->selected < screen_size_y(s)) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: window-more.c,v 1.40 2009-12-04 22:14:47 tcunha Exp $ */
|
||||
/* $Id: window-more.c,v 1.41 2010-02-02 23:55:21 tcunha Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -135,9 +135,11 @@ window_more_key(struct window_pane *wp, unused struct client *c, int key)
|
||||
window_pane_reset_mode(wp);
|
||||
break;
|
||||
case MODEKEYCHOICE_UP:
|
||||
case MODEKEYCHOICE_SCROLLUP:
|
||||
window_more_scroll_up(wp);
|
||||
break;
|
||||
case MODEKEYCHOICE_DOWN:
|
||||
case MODEKEYCHOICE_SCROLLDOWN:
|
||||
window_more_scroll_down(wp);
|
||||
break;
|
||||
case MODEKEYCHOICE_PAGEUP:
|
||||
|
Loading…
Reference in New Issue
Block a user