Created
October 21, 2012 02:26
-
-
Save lsparrish/3925497 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chain: keymap' | |
{{ | |
( useful things: ) | |
( internal -- ignore the vector on a word ) | |
: internal getToken find [ @d->xt ] ifTrue 2 + , ; compile-only | |
( latest -- use the last defined version of a word with a given name ) | |
: latest getToken keepString 1 , , [ find [ @d->xt ] ifTrue ] , ; compile-only | |
: isPrefix dup latest keymap:PREFIX @ == ; | |
: mkey internal getc dup putc latest keymap:TABLE + ; | |
---reveal--- | |
: new:table "keymap:TABLE" header 256 allot ; | |
: new:prefix "keymap:PREFIX" header , ; | |
: bkey ' mkey ! ; | |
[ isPrefix | |
[ latest onPrefix do mkey @ dup 0 <> [ do ] ifTrue ] ifTrue | |
] is remapKeys | |
}} | |
;chain | |
chain: mykeymap' | |
^keymap'new:table | |
^keymap'bkey words w | |
;chain | |
chain: myprefixes' | |
9 ^keymap'new:prefix | |
: onPrefix "Was prefix!" puts ; | |
;chain | |
with mykeymap' with myprefixes' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment