30 lines
653 B
Scheme
30 lines
653 B
Scheme
|
(define-module (oni kbd)
|
||
|
#:use-module (ice-9 match)
|
||
|
#:use-module (srfi srfi-1)
|
||
|
|
||
|
#:export (kbd))
|
||
|
|
||
|
(define (convert-modifier mod)
|
||
|
(match mod
|
||
|
("C" "Ctrl")
|
||
|
("M" "Mod1")
|
||
|
("S" "Shift")
|
||
|
("s" "Mod4")))
|
||
|
|
||
|
(define (convert-key key)
|
||
|
(match key
|
||
|
("RET" "Return")
|
||
|
("SPC" "space")
|
||
|
("<backspace>" "BackSpace")
|
||
|
(_ key)))
|
||
|
|
||
|
(define (kbd str)
|
||
|
(let ((parts (string-split str #\-)))
|
||
|
(string-join
|
||
|
(fold-right (lambda (key previous)
|
||
|
(if (null? previous)
|
||
|
(list (convert-key key))
|
||
|
(cons (convert-modifier key) previous)))
|
||
|
'() parts)
|
||
|
"-")))
|