summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/window-more.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-07-27 19:29:36 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-07-27 19:29:36 +0000
commite9fc29f09dee89cd16dde63a4fc0a25daebf9a16 (patch)
tree272f9f02bc1c308b53cb7f5728132bea580c66c0 /usr.bin/tmux/window-more.c
parent6d02c48047443558125905bd77882aa9391c8a9a (diff)
Change mode key bindings from big switches into a set of tables. Rather than
lumping them all together, split editing keys from those used in choice/more mode and those for copy/scroll mode. Tidier and clearer, and the first step towards customisable mode keys.
Diffstat (limited to 'usr.bin/tmux/window-more.c')
-rw-r--r--usr.bin/tmux/window-more.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/usr.bin/tmux/window-more.c b/usr.bin/tmux/window-more.c
index 990d000abd4..79e8dc8c814 100644
--- a/usr.bin/tmux/window-more.c
+++ b/usr.bin/tmux/window-more.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-more.c,v 1.4 2009/07/27 18:51:46 nicm Exp $ */
+/* $OpenBSD: window-more.c,v 1.5 2009/07/27 19:29:35 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -80,6 +80,7 @@ window_more_init(struct window_pane *wp)
{
struct window_more_mode_data *data;
struct screen *s;
+ int keys;
wp->modedata = data = xmalloc(sizeof *data);
ARRAY_INIT(&data->list);
@@ -89,8 +90,11 @@ window_more_init(struct window_pane *wp)
screen_init(s, screen_size_x(&wp->base), screen_size_y(&wp->base), 0);
s->mode &= ~MODE_CURSOR;
- mode_key_init(&data->mdata,
- options_get_number(&wp->window->options, "mode-keys"), 0);
+ keys = options_get_number(&wp->window->options, "mode-keys");
+ if (keys == MODEKEY_EMACS)
+ mode_key_init(&data->mdata, mode_key_emacs_choice);
+ else
+ mode_key_init(&data->mdata, mode_key_vi_choice);
return (s);
}
@@ -126,23 +130,23 @@ window_more_key(struct window_pane *wp, unused struct client *c, int key)
struct screen *s = &data->screen;
switch (mode_key_lookup(&data->mdata, key)) {
- case MODEKEYCMD_QUIT:
+ case MODEKEYCHOICE_CANCEL:
window_pane_reset_mode(wp);
break;
- case MODEKEYCMD_UP:
+ case MODEKEYCHOICE_UP:
window_more_scroll_up(wp);
break;
- case MODEKEYCMD_DOWN:
+ case MODEKEYCHOICE_DOWN:
window_more_scroll_down(wp);
break;
- case MODEKEYCMD_PREVIOUSPAGE:
+ case MODEKEYCHOICE_PAGEUP:
if (data->top < screen_size_y(s))
data->top = 0;
else
data->top -= screen_size_y(s);
window_more_redraw_screen(wp);
break;
- case MODEKEYCMD_NEXTPAGE:
+ case MODEKEYCHOICE_PAGEDOWN:
if (data->top + screen_size_y(s) > ARRAY_LENGTH(&data->list))
data->top = ARRAY_LENGTH(&data->list);
else