io/input: implement key.Filter.Name special case for matching every key

The empty key.Filter.Name now means matching every key name. This is a
replacement for the previous special case where the top-level key.InputOp
handler would get all unmatched events.

Add special case for system events such as focus switch shortcuts.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2023-11-28 19:11:22 -06:00
parent 77ff21605c
commit c3f2abebca
4 changed files with 87 additions and 54 deletions
+4 -4
View File
@@ -250,20 +250,20 @@ func (q *keyQueue) AreaFor(k *keyHandler) int {
return q.dirOrder[order].area
}
func (k *keyFilter) Matches(focus event.Tag, e key.Event) bool {
func (k *keyFilter) Matches(focus event.Tag, e key.Event, system bool) bool {
for _, f := range *k {
if keyFilterMatch(focus, f, e) {
if keyFilterMatch(focus, f, e, system) {
return true
}
}
return false
}
func keyFilterMatch(focus event.Tag, f key.Filter, e key.Event) bool {
func keyFilterMatch(focus event.Tag, f key.Filter, e key.Event, system bool) bool {
if f.Focus != nil && f.Focus != focus {
return false
}
if f.Name != e.Name {
if (f.Name != "" || system) && f.Name != e.Name {
return false
}
if e.Modifiers&f.Required != f.Required {