Created
December 20, 2009 15:54
-
-
Save crcx/260533 to your computer and use it in GitHub Desktop.
start of new rem
This file contains hidden or 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
| This is the start of a re-implementation of REM, intended to eliminate the huge conditional block and make adding new commands easier. (The existing REM works well, but suffers from a lack of visibility since everything is literally enclosed in a single scoped block. This core should be easier to factor and makes adding new commands possible after REM is loaded.) | |
| variable rem:l ( line ) | |
| variable rem:c ( column ) | |
| : $$i rem:l -- ; ( i = up ) | |
| : $$j rem:c -- ; ( j = left ) | |
| : $$k rem:l ++ ; ( k = down ) | |
| : $$l rem:c ++ ; ( l = right ) | |
| : $$z pop pop 2drop ; ( z = exit REM ) | |
| : $$q rem:c @ rem:l @ ia ; ( q = enter code at current loc ) | |
| ( This is the new replacement for the big conditional loop. ) | |
| ( It maps each key to a word "$$c" where c = key code. ) | |
| : match ( c- ) s" $$_" dup push 2 + ! pop find if d->xt @ execute then ; | |
| : edit ( - ) repeat v key match again ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment