wip
This commit is contained in:
parent
625f5aed51
commit
00770d5723
|
@ -3,8 +3,7 @@
|
|||
#:use-module (gri3 hooks)
|
||||
#:use-module (srfi srfi-1)
|
||||
#:use-module (ice-9 match)
|
||||
#:export
|
||||
(define-mode-map add-key-binding kbd key-press-hook clear-bindings))
|
||||
#:export (define-mode-map add-key-binding kbd key-press-hook clear-bindings))
|
||||
|
||||
(define *bindings* '())
|
||||
(define *mode-map* '())
|
||||
|
@ -31,33 +30,35 @@
|
|||
#t)
|
||||
#f))))
|
||||
|
||||
(define (notify-exceptions exc)
|
||||
(system (format #f "notify-send exception ~A" exc)))
|
||||
|
||||
(define (key-press-hook param)
|
||||
(with-exception-handler notify-exceptions key-press-hook-real #:unwind? #t))
|
||||
|
||||
(define (clear-bindings) (set! *bindings* '()))
|
||||
|
||||
(define (add-key-binding key func)
|
||||
(match-let (((mode (press mod keysym)) key))
|
||||
;; (format #t "Binding key ~A\n" keysym)
|
||||
;; get notified for key with all mods
|
||||
(for-each
|
||||
(lambda (mod)
|
||||
(bind-key keysym mod))
|
||||
(list #x8 #x10 #x26 #x40))
|
||||
(for-each (lambda (mod) (bind-key keysym mod)) (list #x8 #x10 #x26 #x40))
|
||||
;; Store the key+func couple in the list of hooks
|
||||
(set! *bindings*
|
||||
(assoc-set! *bindings* `("default" (,press ,mod ,keysym)) func))))
|
||||
(set! *bindings* (assoc-set! *bindings* `("default" (,press ,mod ,keysym)) func))))
|
||||
|
||||
(define (special->keysym name)
|
||||
(or (assoc-ref '( ;; ("NUL")
|
||||
;; ("REM")
|
||||
("RET" . "Return")
|
||||
("TAB" . "Tab")
|
||||
("LFD" . "Linefeed")
|
||||
("ESC" . "Escape")
|
||||
("SPC" . "space")
|
||||
("DEL" . "Delete"))
|
||||
name)
|
||||
(or (assoc-ref
|
||||
'( ;; ("NUL")
|
||||
;; ("REM")
|
||||
("RET" . "Return")
|
||||
("TAB" . "Tab")
|
||||
("LFD" . "Linefeed")
|
||||
("ESC" . "Escape")
|
||||
("SPC" . "space")
|
||||
("DEL" . "Delete"))
|
||||
name)
|
||||
name))
|
||||
|
||||
|
||||
(define (define-mode-map map mode)
|
||||
(set! *mode-map* (append *mode-map* `((,map . ,mode)))))
|
||||
|
||||
|
|
Loading…
Reference in New Issue