marionette: Fix typing of capital letters.

Previously we'd use "sendkey P" instead of "sendkey shift-p", which had
no effect.

* gnu/build/marionette.scm (character->keystroke): New procedure.
(string->keystroke-commands): Use it.
This commit is contained in:
Ludovic Courtès 2017-08-27 22:00:19 +02:00
parent 8bd5231485
commit 0a80981178
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 11 additions and 3 deletions

View File

@ -264,6 +264,14 @@ PREDICATE, whichever comes first. Raise an error when TIMEOUT is exceeded."
(#\bs . "backspace") (#\bs . "backspace")
(#\tab . "tab"))) (#\tab . "tab")))
(define (character->keystroke chr keystrokes)
"Return the keystroke for CHR according to the keyboard layout defined by
KEYSTROKES."
(if (char-set-contains? char-set:upper-case chr)
(string-append "shift-" (string (char-downcase chr)))
(or (assoc-ref keystrokes chr)
(string chr))))
(define* (string->keystroke-commands str (define* (string->keystroke-commands str
#:optional #:optional
(keystrokes (keystrokes
@ -272,9 +280,9 @@ PREDICATE, whichever comes first. Raise an error when TIMEOUT is exceeded."
to STR. KEYSTROKES is an alist specifying a mapping from characters to to STR. KEYSTROKES is an alist specifying a mapping from characters to
keystrokes." keystrokes."
(string-fold-right (lambda (chr result) (string-fold-right (lambda (chr result)
(cons (string-append "sendkey " (cons (string-append
(or (assoc-ref keystrokes chr) "sendkey "
(string chr))) (character->keystroke chr keystrokes))
result)) result))
'() '()
str)) str))