Make keyspec parsing/printing properly use byte-strings in unknown-escape-sequence.

This commit is contained in:
Tony Garnock-Jones 2014-12-27 17:22:59 -05:00
parent 5fae56dc78
commit 04f7da73e2
2 changed files with 4 additions and 6 deletions

View File

@ -9,8 +9,5 @@ command handler have everything it needs even in the face of change
Need line wrap of some kind. Need line wrap of some kind.
unknown-escape-sequence contents are byte strings, and keyseq parsing
and printing should reflect that.
Catch and handle SIGWINCH. Catch and handle SIGWINCH.
See http://man7.org/tlpi/code/online/dist/tty/demo_SIGWINCH.c.html See http://man7.org/tlpi/code/online/dist/tty/demo_SIGWINCH.c.html

View File

@ -48,7 +48,7 @@
(cons '#:default (parse-key-sequence rest))] (cons '#:default (parse-key-sequence rest))]
[(pregexp "^ *(([cCsSmM]-)*)\"([^\"]*)\"(.*)" (list lexeme modifiers _ stringspec rest)) [(pregexp "^ *(([cCsSmM]-)*)\"([^\"]*)\"(.*)" (list lexeme modifiers _ stringspec rest))
(define mods (parse-modifiers modifiers lexeme)) (define mods (parse-modifiers modifiers lexeme))
(define seq (unknown-escape-sequence (or (read-string-to-end (format "\"~a\"" stringspec)) (define seq (unknown-escape-sequence (or (read-string-to-end (format "#\"~a\"" stringspec))
(bad-key lexeme "Bad raw input sequence")))) (bad-key lexeme "Bad raw input sequence"))))
(cons (key seq mods) (parse-key-sequence rest))] (cons (key seq mods) (parse-key-sequence rest))]
[(pregexp "^ *(([cCsSmM]-)*)<([^>]+)>(( +.*)|$)" (list lexeme modifiers _ symname rest _)) [(pregexp "^ *(([cCsSmM]-)*)<([^>]+)>(( +.*)|$)" (list lexeme modifiers _ symname rest _))
@ -99,8 +99,9 @@
[(key value modifiers) [(key value modifiers)
(define-values (str updated-modifiers) (define-values (str updated-modifiers)
(match value (match value
[(unknown-escape-sequence s) [(unknown-escape-sequence bs)
(values (format "~v" s) modifiers)] (define s (format "~v" bs))
(values (substring s 1 (string-length s)) modifiers)]
[(? symbol? s) [(? symbol? s)
(values (format "<~a>" s) modifiers)] (values (format "<~a>" s) modifiers)]
[#\[ #:when (set-member? modifiers 'control) [#\[ #:when (set-member? modifiers 'control)