remove hardcoded keyvals

main
Daniel Barlow 2023-01-01 11:27:33 +00:00
parent 3fac6a2601
commit a81d9d4d4c
2 changed files with 24 additions and 14 deletions

View File

@ -46,7 +46,7 @@
[name params] (commander:invoke-interactively name params) [name params] (commander:invoke-interactively name params)
(nil prompt) (print "prompted" prompt))) (nil prompt) (print "prompted" prompt)))
(when (and (commander:active?) (when (and (commander:active?)
(= (Gdk.keyval_name event.keyval) "Escape")) (= keymap.keyval.Escape event.keyval))
(commander:deactivate)) (commander:deactivate))
(when (and event.state.MOD1_MASK (when (and event.state.MOD1_MASK

View File

@ -2,19 +2,26 @@
(local { : view } (require :fennel)) (local { : view } (require :fennel))
(local modifier-keyvals (local modifier-keyvals
{ ;; we need to detect and discard modifier-only key events when
;; These aren't canonical or official, this is just the ;; looking for the next key in a key sequence. Gtk/Gdk
;; result of pressing keys on my keyboard. If Gtk/Gdk/GI ;; allegedly has KeyEvent.is_modifier to do this but it's always
;; implemented KeyEvent.is_modifier we wouldn't have to ;; 0 because GI doesn't expose it.
;; do this (let [names
65507 :control_l [
65505 :shift_l :Control_L
269025067 :fn :Control_R
65515 :windows :Control
65513 :alt_l :Shift_L
65027 :alt_gr :Shift_R
65508 :control_r :WakeUp ; labelled "Fn"
}) :Super_L ; labelled with Windows logo
:Super_R ; menu key? not on my keyboard
:Alt_L
:Alt_R
:ISO_Level3_Shift ; AltGr
]]
(collect [_ n (ipairs names)]
(values (Gdk.keyval_from_name n) n))))
(fn modifier? [keyval] (fn modifier? [keyval]
(. modifier-keyvals keyval)) (. modifier-keyvals keyval))
@ -85,6 +92,9 @@
{ : recogniser { : recogniser
:keyval {
:Escape (Gdk.keyval_from_name "Escape")
}
:_ { :_ {
;; symbols in _ are exported only for testing ;; symbols in _ are exported only for testing
: keychord->spec : keychord->spec