osric.uk

TextArea has selectionStart and selectionEnd.

In normal mode movement cancels the current selection (sets end = start). Visual mode changes it, needs thought. Insert mode has fewer movements, but otherwise works like normal mode.

Maybe a hash table per mode mapping keys to commands? Need to match chords (e.g. ctrl-x).

Or swap out key handlers?

Probably need to wait for command before doing movement, so add in at least delete (and then can compose e.g. change is delete + insert mode).

Don't forget clipboard, yank and paste should be fairly simple, and then can extend to named buffers if I can think through parsing arguments.

Lets have a state type to keep track of current mode, named buffer (mostly null except between a " and a yank/paste command), and a proxy through to the textarea to handle cursor position.