2022-07-23 06:12:45 +02:00
|
|
|
(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
|
2023-06-21 08:06:25 +02:00
|
|
|
(fold-right (λ (key previous)
|
2022-07-23 06:12:45 +02:00
|
|
|
(if (null? previous)
|
|
|
|
(list (convert-key key))
|
|
|
|
(cons (convert-modifier key) previous)))
|
|
|
|
'() parts)
|
|
|
|
"-")))
|