remove hardcoded keyvals
This commit is contained in:
parent
3fac6a2601
commit
a81d9d4d4c
@ -46,7 +46,7 @@
|
||||
[name params] (commander:invoke-interactively name params)
|
||||
(nil prompt) (print "prompted" prompt)))
|
||||
(when (and (commander:active?)
|
||||
(= (Gdk.keyval_name event.keyval) "Escape"))
|
||||
(= keymap.keyval.Escape event.keyval))
|
||||
(commander:deactivate))
|
||||
|
||||
(when (and event.state.MOD1_MASK
|
||||
|
36
keymap.fnl
36
keymap.fnl
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user