remove hardcoded keyvals
This commit is contained in:
+23
-13
@@ -2,19 +2,26 @@
|
||||
(local { : view } (require :fennel))
|
||||
|
||||
(local modifier-keyvals
|
||||
{
|
||||
;; These aren't canonical or official, this is just the
|
||||
;; result of pressing keys on my keyboard. If Gtk/Gdk/GI
|
||||
;; implemented KeyEvent.is_modifier we wouldn't have to
|
||||
;; do this
|
||||
65507 :control_l
|
||||
65505 :shift_l
|
||||
269025067 :fn
|
||||
65515 :windows
|
||||
65513 :alt_l
|
||||
65027 :alt_gr
|
||||
65508 :control_r
|
||||
})
|
||||
;; we need to detect and discard modifier-only key events when
|
||||
;; looking for the next key in a key sequence. Gtk/Gdk
|
||||
;; allegedly has KeyEvent.is_modifier to do this but it's always
|
||||
;; 0 because GI doesn't expose it.
|
||||
(let [names
|
||||
[
|
||||
:Control_L
|
||||
:Control_R
|
||||
:Control
|
||||
:Shift_L
|
||||
:Shift_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]
|
||||
(. modifier-keyvals keyval))
|
||||
@@ -85,6 +92,9 @@
|
||||
|
||||
|
||||
{ : recogniser
|
||||
:keyval {
|
||||
:Escape (Gdk.keyval_from_name "Escape")
|
||||
}
|
||||
:_ {
|
||||
;; symbols in _ are exported only for testing
|
||||
: keychord->spec
|
||||
|
||||
Reference in New Issue
Block a user