correct error checking for keymaps

This commit is contained in:
Robby Findler 2016-07-21 21:42:17 -05:00
parent 8272f99035
commit 943582763e
2 changed files with 11 additions and 1 deletions

View File

@ -284,7 +284,7 @@
(if (caps . < . 0) "~l:" "")
(if (altgr . > . 0) "g:" "")
(if (altgr . < . 0) "~g:" "")
(or (hash-ref rev-keylist code)
(or (hash-ref rev-keylist code #f)
(format "~c" code)))])
(error (method-name 'keymap% 'map-function)
"~s is already mapped as a ~aprefix key"

View File

@ -1212,6 +1212,16 @@
(expect (send km handle-key-event 'obj kevt) #t)
(expect hit #\t)
(let ()
(define k (new keymap%))
(send k add-function "swap if branches" void)
(send k map-function "c:x;r" "swap if branches")
(send k add-function "rectangle" void)
(expect (regexp-match? (regexp-quote "map-function in keymap%: \"r\" is already mapped as a non-prefix key")
(with-handlers ([exn:fail? exn-message])
(send k map-function "c:x;r;a" "rectangle")))
#t))
;; Chained keymap non-prefixed overrides prefixed
(send km2 add-function "letter-d" (lambda (obj evt) (set! hit #\d)))
(send km2 map-function "d" "letter-d")