mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-01 07:15:32 -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
|
|
@ -80,17 +80,17 @@ urls_input(struct seat *seat, struct terminal *term, uint32_t key,
|
|||
{
|
||||
/* Key bindings */
|
||||
tll_foreach(seat->kbd.bindings.url, it) {
|
||||
if (it->item.bind.mods != mods)
|
||||
if (it->item.mods != mods)
|
||||
continue;
|
||||
|
||||
/* Match symbol */
|
||||
if (it->item.bind.sym == sym) {
|
||||
if (it->item.sym == sym) {
|
||||
execute_binding(seat, term, it->item.action, serial);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Match raw key code */
|
||||
tll_foreach(it->item.bind.key_codes, code) {
|
||||
tll_foreach(it->item.key_codes, code) {
|
||||
if (code->item == key) {
|
||||
execute_binding(seat, term, it->item.action, serial);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue