Skip to content

Instantly share code, notes, and snippets.

@lsparrish
Created December 2, 2009 03:28
Show Gist options
  • Save lsparrish/246905 to your computer and use it in GitHub Desktop.
Save lsparrish/246905 to your computer and use it in GitHub Desktop.
: :: ( -a ) here ] ;
: stub create 0 , 0 , 9 , ['] .word last @ d->class ! ;
: stubs for stub next ;
stub cursor
stub scan-for-esc
4 stubs up down left right
: default: ( "- )
' drop which @ d->xt @ 2 + compile ; immediate
:: ( -c )
default: key dup 27 =if dup ['] cursor ['] key :is then ;
is scan-for-esc
' scan-for-esc is key
: char key literal, ; immediate
:: default: key
dup s" h" @ =if left drop 32 then
dup s" j" @ =if down drop 32 then
dup s" k" @ =if up drop 32 then
dup s" l" @ =if right drop 32 then
dup 27 =if ['] scan-for-esc ['] key :is then ;
is cursor
:: ." left" ; is left
:: ." right" ; is right
:: ." up" ; is up
:: ." down" ; is down
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment