Refactor key mapping modifier logic

- Consolidate a modifier's "left" and "right" variants to just one
  modifier referred to by its name or mask. E.g. Control_L and Control_R are
  resolved by detecting the mask and are both associated with the name "Ctrl".

- Store string representations of the modified key values as the keys to
  the key entry map (exactly how they appear in the config file). E.g.
  the string "Ctrl-m" would be the key to the map entry for a custom
  Ctrl-m binding (whereas before the key would've only been "m", a
  source of ambiguity and conflict).

- During init, pass through key mapping entry logic twice: once for
  inputting the defaults, and a second time for adding any custom
  mappings as defined by the config file. This allows defaults to stay
  in place unless a user chooses to blow them away. E.g. mapping Ctrl-p
  to key_up shouldn't blow away key_up's default mapping to up arrow,
  and this fixes that use case.

These changes resolve several bugs due to key mapping resolution ambiguity and
conflicts, and generally make key mapping more intuitive. However, a new quirk
is that keys that are obtained using Shift (like "J", aka "capital j") now
require the use of Shift modifier when configuring that binding.
This commit is contained in:
jim jammer
2022-12-11 05:04:34 -08:00
parent ee2bab5d17
commit f4ebbed7a8
3 changed files with 134 additions and 53 deletions

View File

@@ -3,7 +3,7 @@
wofi \- Key names for custom binds
.SH DESCRIPTION
This is a list of the key names that can be used for custom binding, these are taken from gdk/gdkkeysyms.h. Certain keys cannot have the shift modifier attached as holding shift while using these keys causes a completely different key press to be registered. For example Shift_L\-j is invalid as holding shift while pressing j changes the key into J so J should be registered as the key instead of Shift_L\-j. This is the case with all alphanumeric chars as well as Tab which turns into ISO_Left_Tab.
This is a list of the key names that can be used for custom binding. These are taken from gdk/gdkkeysyms.h with exception to modifiers. Certain keys cannot have the shift modifier attached as holding shift while using these keys causes a completely different key press to be registered. For example Shift\-j is invalid as holding shift while pressing j changes the key into J so Shift-J should be registered as the key instead of Shift\-j. This is the case with all alphanumeric chars as well as Tab which turns into ISO_Left_Tab.
.SH KEY NAMES
.B BackSpace
@@ -4543,3 +4543,10 @@ This is a list of the key names that can be used for custom binding, these are t
.B LogWindowTree
.br
.B LogGrabInfo
.SH MODIFIER NAMES
.B Shift
.br
.B Ctrl
.br
.B Alt

View File

@@ -167,7 +167,7 @@ Specifies the key to use in order to expand/contract multi-action entires. There
Specifies the key to use in order to hide/show the search bar. There is no default. See \fBwofi\-keys\fR(7) for the key codes.
.TP
.B key_copy=\fIKEY\fR
Specifies the key to use in order to copy the action text for the current entry. The default is Control_L-c. See \fBwofi\-keys\fR(7) for the key codes.
Specifies the key to use in order to copy the action text for the current entry. The default is Ctrl-c. See \fBwofi\-keys\fR(7) for the key codes.
.TP
.B line_wrap=\fIMODE\fR
Specifies the line wrap mode to use. The options are off, word, char, and word_char. Default is off.