diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-07-27 19:29:36 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-07-27 19:29:36 +0000 |
commit | e9fc29f09dee89cd16dde63a4fc0a25daebf9a16 (patch) | |
tree | 272f9f02bc1c308b53cb7f5728132bea580c66c0 /usr.bin/tmux/tmux.h | |
parent | 6d02c48047443558125905bd77882aa9391c8a9a (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/tmux.h')
-rw-r--r-- | usr.bin/tmux/tmux.h | 102 |
1 files changed, 70 insertions, 32 deletions
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index dc8871ae716..454b9a3d0f8 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.58 2009/07/27 18:51:46 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.59 2009/07/27 19:29:35 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -358,40 +358,71 @@ struct msg_unlock_data { /* Editing keys. */ enum mode_key_cmd { - MODEKEYCMD_BACKSPACE = 0x1000, - MODEKEYCMD_BACKTOINDENTATION, - MODEKEYCMD_CHOOSE, - MODEKEYCMD_CLEARSELECTION, - MODEKEYCMD_COMPLETE, - MODEKEYCMD_COPYSELECTION, - MODEKEYCMD_DELETE, - MODEKEYCMD_DELETETOENDOFLINE, - MODEKEYCMD_DOWN, - MODEKEYCMD_ENDOFLINE, - MODEKEYCMD_LEFT, - MODEKEYCMD_NEXTPAGE, - MODEKEYCMD_NEXTWORD, - MODEKEYCMD_NONE, - MODEKEYCMD_OTHERKEY, - MODEKEYCMD_PASTE, - MODEKEYCMD_PREVIOUSPAGE, - MODEKEYCMD_PREVIOUSWORD, - MODEKEYCMD_QUIT, - MODEKEYCMD_RIGHT, - MODEKEYCMD_STARTOFLINE, - MODEKEYCMD_STARTSELECTION, - MODEKEYCMD_UP, + MODEKEY_NONE, + MODEKEY_OTHER, + + /* Editing keys. */ + MODEKEYEDIT_BACKSPACE, + MODEKEYEDIT_CANCEL, + MODEKEYEDIT_COMPLETE, + MODEKEYEDIT_CURSORLEFT, + MODEKEYEDIT_CURSORRIGHT, + MODEKEYEDIT_DELETE, + MODEKEYEDIT_DELETETOENDOFLINE, + MODEKEYEDIT_ENDOFLINE, + MODEKEYEDIT_ENTER, + MODEKEYEDIT_HISTORYDOWN, + MODEKEYEDIT_HISTORYUP, + MODEKEYEDIT_PASTE, + MODEKEYEDIT_STARTOFLINE, + MODEKEYEDIT_SWITCHMODE, + MODEKEYEDIT_SWITCHMODEAPPEND, + + /* Menu (choice) keys. */ + MODEKEYCHOICE_CANCEL, + MODEKEYCHOICE_CHOOSE, + MODEKEYCHOICE_DOWN, + MODEKEYCHOICE_PAGEDOWN, + MODEKEYCHOICE_PAGEUP, + MODEKEYCHOICE_UP, + + /* Copy keys. */ + MODEKEYCOPY_CANCEL, + MODEKEYCOPY_BACKTOINDENTATION, + MODEKEYCOPY_CLEARSELECTION, + MODEKEYCOPY_COPYSELECTION, + MODEKEYCOPY_DOWN, + MODEKEYCOPY_ENDOFLINE, + MODEKEYCOPY_LEFT, + MODEKEYCOPY_NEXTPAGE, + MODEKEYCOPY_NEXTWORD, + MODEKEYCOPY_NONE, + MODEKEYCOPY_PREVIOUSPAGE, + MODEKEYCOPY_PREVIOUSWORD, + MODEKEYCOPY_QUIT, + MODEKEYCOPY_RIGHT, + MODEKEYCOPY_STARTOFLINE, + MODEKEYCOPY_STARTSELECTION, + MODEKEYCOPY_UP, }; -struct mode_key_data { - int type; +struct mode_key_entry { + int key; - int flags; -#define MODEKEY_EDITMODE 0x1 -#define MODEKEY_CANEDIT 0x2 -#define MODEKEY_CHOOSEMODE 0x4 -}; + /* + * Editing mode for vi: 0 is edit mode, keys not in the table are + * returned as MODEKEY_OTHER; 1 is command mode, keys not in the table + * are returned as MODEKEY_NONE. This is also matched on, allowing some + * keys to be bound in edit mode. + */ + int mode; + enum mode_key_cmd cmd; +}; +struct mode_key_data { + const struct mode_key_entry *table; + int mode; +}; #define MODEKEY_EMACS 0 #define MODEKEY_VI 1 @@ -1032,7 +1063,14 @@ void sighandler(int); int load_cfg(const char *, char **x); /* mode-key.c */ -void mode_key_init(struct mode_key_data *, int, int); +extern const struct mode_key_entry mode_key_vi_edit[]; +extern const struct mode_key_entry mode_key_vi_choice[]; +extern const struct mode_key_entry mode_key_vi_copy[]; +extern const struct mode_key_entry mode_key_emacs_edit[]; +extern const struct mode_key_entry mode_key_emacs_choice[]; +extern const struct mode_key_entry mode_key_emacs_copy[]; +void mode_key_init( + struct mode_key_data *, const struct mode_key_entry *); enum mode_key_cmd mode_key_lookup(struct mode_key_data *, int); /* options.c */ |