diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-12-29 17:58:00 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-12-29 17:58:00 +0100 |
| commit | eda4ab0e8e2f97225e4c0470318e9427e09bbfb9 (patch) | |
| tree | bd988ad26c4dd7825cb5ab7635d16c81c82b6edb /vis.h | |
| parent | a8116c57341f87b293d35ef7e1d140ceb01ed8b1 (diff) | |
| download | vis-eda4ab0e8e2f97225e4c0470318e9427e09bbfb9.tar.gz vis-eda4ab0e8e2f97225e4c0470318e9427e09bbfb9.tar.xz | |
vis: cleanup key action lifetime management
Diffstat (limited to 'vis.h')
| -rw-r--r-- | vis.h | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -53,15 +53,17 @@ typedef union { /* various types of arguments passed to key action functions */ void (*f)(Vis*); } Arg; +/* action handling function, keys refers to the next characters found in the input queue + * (an empty string "" indicates an empty queue). The return value of func has to point to + * the first non consumed key. Returning NULL indicates that not enough keys were available + * to complete the action. In this case the function will be called again when more input + * becomes available */ +typedef const char *KeyActionFunction(Vis*, const char *keys, const Arg*); + typedef struct { /* a KeyAction can be bound to a key binding */ const char *name; /* aliases can refer to this action by means of a pseudo key <name> */ const char *help; /* short (one line) human readable description, displayed by :help */ - /* action handling function, keys refers to the next characters found in the input queue - * (an empty string "" indicates an empty queue). The return value of func has to point to - * the first non consumed key. Returning NULL indicates that not enough keys were available - * to complete the action. In this case the function will be called again when more input - * becomes available */ - const char* (*func)(Vis*, const char *keys, const Arg*); + KeyActionFunction *func; /* action implementation */ Arg arg; /* additional arguments which will be passed as to func */ } KeyAction; @@ -175,6 +177,9 @@ bool vis_window_mode_map(Win*, enum VisMode, bool force, const char *key, const /* in the specified mode: unmap a given key, fails if the key is not currently mapped */ bool vis_mode_unmap(Vis*, enum VisMode, const char *key); bool vis_window_mode_unmap(Win*, enum VisMode, const char *key); + +KeyAction *vis_action_new(Vis*, const char *name, const char *help, KeyActionFunction*, Arg); +void vis_action_free(Vis*, KeyAction*); /* associates the special pseudo key <keyaction->name> with the given key action. * after successfull registration the pseudo key can be used key binding aliases */ bool vis_action_register(Vis*, const KeyAction*); |
