inexorabletash/jslogo — pull request #25 by ianb (2013-12-06 17:08:06+00:00)
Title: Fix #24, getstate/setstate; add arrow commands

First change is pretty obvious.

Second change is to allow unicode arrows, ← ↑ → ↓ commands. This extends the pattern for identifiers. Note that I've only included these four characters, and they are all only allowed to be one character (`↓↓` is not a distinct command, it's the same as `↓ ↓`).

The goal (not yet implemented) is to allow for the traditional entry to Logo where you can "program" the turtle with the arrow keys, which creates a script. I thought about having the input field translate this to `FD`, `RT` etc, but the hack of allowing unicode commands somehow seemed more awesome.

I then want to make the composer capture arrow keys until you press enter, all the while showing a preview of what will happen – using canvas save/restore and turtle getstate/setstate to run commands and then revert when finished, putting the commands in the normal editor (though the commands may be immediately executed, depending on context).

Though thinking about it, the whole pattern makes me want to use a live coding pattern – then you could edit internal bits of a program, like:

REPEAT 10 [ ↑↑→↓ ]

so if you opened the arrow editor on that inner expression, you'd see how the entire program was interpreted given your new set of commands. Hmm...