Skip to content

Instantly share code, notes, and snippets.

@lsparrish
Forked from crcx/more.rx
Created October 19, 2012 05:19
Show Gist options
  • Save lsparrish/3916373 to your computer and use it in GitHub Desktop.
Save lsparrish/3916373 to your computer and use it in GitHub Desktop.
yet another approach
( useful things )
: dictionary.find/xt ( string:name - xt ) find [ @d->xt ] [ drop #0 ] if ;
: getc:internal ( -c ) &getc 2 + @ do ;
: __$ keepString 1 , , &dictionary.find/xt , ; parsing
( keymap )
9 variable: prefix:CHAR
create prefix:TABLE 256 allot
( We will lookup the keymap by name, to allow for per-application maps )
[ dup prefix:CHAR @ ==
[ drop getc:internal
$prefix:TABLE + @ dup 0 <> [ dip cr ] [ drop ] if 0
] ifTrue
dup '| == push over tib == pop and
[ putc
'| $prefix:TABLE + @ do cr 0
] ifTrue
] is remapKeys
: (matching) ;
: bindTo: ( quote "character" - )
getc:internal $prefix:TABLE + ! ;
[ cr
"? help text\n" puts
"d<word> documentation for word\n" puts
"s show stack contents\n" puts
"p<char> change trigger character to <char>\n" puts ] .s bindTo: ?
[ "display docs for: " puts
getToken find
[ cr @d->doc 0; puts ] [ drop cr "no docs found!" puts ] if
] bindTo: d
[ "display functions matching: " puts
getToken cr (matching) ] bindTo: m
[ getc:internal dup putc !prefix:CHAR ] bindTo: p
[ getc:internal getc:internal
drop $prefix:TABLE +
getToken find [ @d->xt swap ! ] [ drop drop ] if
] bindTo: |
|w|words
|s|.s
|?|help
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment