vim like editing optional in a TextView
For simple editing inside a TextView, I’ve mapped various editing functions to vi keys. I’ve done this as a module so it can be included at runtime in a TextView instance rather than extending the TextView class.
This editable version of TextView does editing only through keystrokes – there is no edit mode. On pressing C to change a line, or o or O etc a box is displayed at the bottom for editing or entering text which is then updated. Unlimited undo and redo, of course. I am also using the emacs like kill-ring here, so deletes and copies can be cycled through using M-y. C-y works for the current (last) copy. P and p are also usable. For an example, see examples/testscrollp.rb. You can test with a “dd”, “4dd”, “5dw”, “p”, “u” (undo) or C-_ (undo), C-r (redo), “x”, “5x”, “X”, df (char), “yy”, C (change line), o (open a line).
For a full proper editor, you would continue to use TextArea. However, being an edit mode editor, TextArea is unable to provide mapping for most vim keys which are single keys, thus i’ve used some emacs keys in TextArea. Since TextView is non-editable one can put it into “command-mode” and use most vim keys.
rbcurse is for geeks anyway, or atleast keyboard lovers, so lets make rbcurse a keyboard friendly ncurses library.
I’ve now started adding all key binding functionality to proper key bindings (instead of hard-coding them in the key checking loop of a component). Soon, when I’ve organized my thoughts, we should be able to use something like emacs’s “M-x” which (I think) allows a user to see what all functions he can use for an object and execute them, or bind them to a key.