From b22bb3097634206956392929795fd2902f08faa7 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 8 Mar 2020 12:08:46 +0100 Subject: wip: initial framework for dealing with key/mouse bindings in different modes This adds initial support for defining key and mouse bindings that are applied in different terminal modes/states. For example, there are two arrays dealing with key and mouse bindings in the "normal" mode. Most bindings will go here. There's also an array for "search" mode. These bindings will be used when the user has started a scrollback search. In the future, there may be a model selection mode as well. Or maybe "search" and "modal selection" will be combined into a single "keyboard" mode. We'll see. Since the keyboard bindings depend on the current XKB keymap, translation from the user specified key combination string cannot be done when loading the configuration, but must be done when we've received a keymap from the wayland server. We should explore if it's possible to load some kind of default keymap just to be able to verify the validity of the key combination strings at configuration load time, to be able to reject the configuration at startup. A couple of key bindings have been added as proof of concept. Mouse bindings aren't handled at all yet, and is likely to be re-written. For example, we can probably translate the configuration strings at configuration load time. --- config.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'config.c') diff --git a/config.c b/config.c index 46056567..0baa5eb5 100644 --- a/config.c +++ b/config.c @@ -619,6 +619,19 @@ config_load(struct config *conf, const char *conf_path) }, }, + .bindings = { + .key = { + [BIND_ACTION_CLIPBOARD_COPY] = strdup("Control+Shift+C"), + [BIND_ACTION_CLIPBOARD_PASTE] = strdup("Control+Shift+V"), + [BIND_ACTION_SEARCH_START] = strdup("Control+Shift+R"), + }, + .mouse = { + [BIND_ACTION_PRIMARY_PASTE] = strdup("BTN_MIDDLE"), + }, + .search = { + }, + }, + .csd = { .preferred = CONF_CSD_PREFER_SERVER, .title_height = 26, @@ -671,4 +684,10 @@ config_free(struct config conf) free(conf.shell); tll_free_and_free(conf.fonts, free); free(conf.server_socket_path); + + for (size_t i = 0; i < BIND_ACTION_COUNT; i++) { + free(conf.bindings.key[i]); + free(conf.bindings.mouse[i]); + free(conf.bindings.search[i]); + } } -- cgit v1.3