mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-04 07:15:29 -04:00
key-bindings: refactor: use a single type for all key bindings
Up until now, the various key binding modes (“normal”, “search” and “url”) have used their own struct definitions for their key bindings. The only reason for this was to have a properly typed “action” (using the appropriate “action” enum). This caused lots of duplicated code. This patch refactors this to use a single struct definition for the “unparsed” key bindings handled by the configuration, and another single definition for “parsed” bindings used while handling input. This allows us to implement configuration parsing, keymap translation and so on using one set of functions, regardless of key binding mode.
This commit is contained in:
parent
63a50afc8e
commit
03bac9dada
7 changed files with 145 additions and 331 deletions
37
config.h
37
config.h
|
|
@ -25,39 +25,26 @@ struct config_key_modifiers {
|
|||
bool meta;
|
||||
};
|
||||
|
||||
struct config_key_binding_normal {
|
||||
enum bind_action_normal action;
|
||||
struct config_key_modifiers modifiers;
|
||||
xkb_keysym_t sym;
|
||||
struct {
|
||||
char *cmd;
|
||||
char **argv;
|
||||
bool master_copy;
|
||||
} pipe;
|
||||
struct config_binding_pipe {
|
||||
char *cmd;
|
||||
char **argv;
|
||||
bool master_copy;
|
||||
};
|
||||
|
||||
struct config_key_binding_search {
|
||||
enum bind_action_search action;
|
||||
struct config_key_modifiers modifiers;
|
||||
xkb_keysym_t sym;
|
||||
};
|
||||
|
||||
struct config_key_binding_url {
|
||||
enum bind_action_url action;
|
||||
struct config_key_binding {
|
||||
int action; /* One of the varios bind_action_* enums from wayland.h */
|
||||
struct config_key_modifiers modifiers;
|
||||
xkb_keysym_t sym;
|
||||
struct config_binding_pipe pipe;
|
||||
};
|
||||
typedef tll(struct config_key_binding) config_key_binding_list_t;
|
||||
|
||||
struct config_mouse_binding {
|
||||
enum bind_action_normal action;
|
||||
struct config_key_modifiers modifiers;
|
||||
int button;
|
||||
int count;
|
||||
struct {
|
||||
char *cmd;
|
||||
char **argv;
|
||||
bool master_copy;
|
||||
} pipe;
|
||||
struct config_binding_pipe pipe;
|
||||
};
|
||||
|
||||
/* If px != 0 then px is valid, otherwise pt is valid */
|
||||
|
|
@ -169,7 +156,7 @@ struct config {
|
|||
|
||||
struct {
|
||||
/* Bindings for "normal" mode */
|
||||
tll(struct config_key_binding_normal) key;
|
||||
config_key_binding_list_t key;
|
||||
tll(struct config_mouse_binding) mouse;
|
||||
|
||||
/*
|
||||
|
|
@ -178,10 +165,10 @@ struct config {
|
|||
|
||||
/* While searching (not - action to *start* a search is in the
|
||||
* 'key' bindings above */
|
||||
tll(struct config_key_binding_search) search;
|
||||
config_key_binding_list_t search;
|
||||
|
||||
/* While showing URL jump labels */
|
||||
tll(struct config_key_binding_url) url;
|
||||
config_key_binding_list_t url;
|
||||
} bindings;
|
||||
|
||||
struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue