summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/tmux.h
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-07-28 07:03:33 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-07-28 07:03:33 +0000
commit91b609484f4b8d3135cdb26cb6db6f7c4cdc97fc (patch)
tree3d9cf96a6e9085b6170fa11b36c3ae156b3cb12e /usr.bin/tmux/tmux.h
parent8ac01f5403feb01127486cf04aaa8261b2e2725e (diff)
Next step towards customisable mode keys: build each default table of keys into
a named tree on start and use that for lookups. Also add command to string translation tables and modify list-keys to show the the mode key bindings (new -t argument).
Diffstat (limited to 'usr.bin/tmux/tmux.h')
-rw-r--r--usr.bin/tmux/tmux.h58
1 files changed, 45 insertions, 13 deletions
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index d933be1b468..598c6d0dcc5 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.61 2009/07/28 06:48:44 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.62 2009/07/28 07:03:32 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -356,7 +356,7 @@ struct msg_unlock_data {
char pass[PASS_MAX];
};
-/* Editing keys. */
+/* Mode key commands. */
enum mode_key_cmd {
MODEKEY_NONE,
MODEKEY_OTHER,
@@ -404,6 +404,7 @@ enum mode_key_cmd {
MODEKEYCOPY_UP,
};
+/* Entry in the default mode key tables. */
struct mode_key_entry {
int key;
@@ -414,16 +415,42 @@ struct mode_key_entry {
* keys to be bound in edit mode.
*/
int mode;
-
enum mode_key_cmd cmd;
};
+
+/* Data required while mode keys are in use. */
struct mode_key_data {
- const struct mode_key_entry *table;
- int mode;
+ struct mode_key_tree *tree;
+ int mode;
};
#define MODEKEY_EMACS 0
#define MODEKEY_VI 1
+/* Binding between a key and a command. */
+struct mode_key_binding {
+ int key;
+
+ int mode;
+ enum mode_key_cmd cmd;
+
+ SPLAY_ENTRY(mode_key_binding) entry;
+};
+SPLAY_HEAD(mode_key_tree, mode_key_binding);
+
+/* Command to string mapping. */
+struct mode_key_cmdstr {
+ enum mode_key_cmd cmd;
+ const char *name;
+};
+
+/* Named mode key table description. */
+struct mode_key_table {
+ const char *name;
+ struct mode_key_cmdstr *cmdstr;
+ struct mode_key_tree *tree;
+ const struct mode_key_entry *table; /* default entries */
+};
+
/* Modes. */
#define MODE_CURSOR 0x1
#define MODE_INSERT 0x2
@@ -1061,14 +1088,19 @@ void sighandler(int);
int load_cfg(const char *, char **x);
/* mode-key.c */
-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 *);
+extern const struct mode_key_table mode_key_tables[];
+extern struct mode_key_tree mode_key_tree_vi_edit;
+extern struct mode_key_tree mode_key_tree_vi_choice;
+extern struct mode_key_tree mode_key_tree_vi_copy;
+extern struct mode_key_tree mode_key_tree_emacs_edit;
+extern struct mode_key_tree mode_key_tree_emacs_choice;
+extern struct mode_key_tree mode_key_tree_emacs_copy;
+int mode_key_cmp(struct mode_key_binding *, struct mode_key_binding *);
+SPLAY_PROTOTYPE(mode_key_tree, mode_key_binding, entry, mode_key_cmp);
+const char *mode_key_tostring(struct mode_key_cmdstr *r, enum mode_key_cmd);
+void mode_key_init_trees(void);
+void mode_key_free_trees(void);
+void mode_key_init(struct mode_key_data *, struct mode_key_tree *);
enum mode_key_cmd mode_key_lookup(struct mode_key_data *, int);
/* options.c */