RFC + sanity check, Tk::Text with Vi interface
am 19.04.2008 01:29:06 von j-stromI've been pulling together a module that acts as a replacement for
Tk::Text but handles keyboard input similar to Vi (originally to stop
me from sticking "dd" all over my config files, but it seems like one
of those things silly enough that others might get some use out of
it). This is the first time I've tried something like this, so I'd
appreciate any suggestions or corrections. Is Tk::TextVi a reasonable
name? Does my interface have any serious flaws? Am I missing and
features that have to be there? etc.
A few excerpts from the POD is below or the full archive can be found
here: http://omega0.xepher.net/stuff/Tk-TextVi-0.01.tar.gz
use Tk::TextVi;
$textvi = $window->TextVi( -option => value, ... );
Tk::TextVi is a Tk::Text widget that replaces InsertKeypress() to
handle user input similar to vi. All other methods remain the same
(and most code should be using $text->insert( ... ) rather than $text-
>InsertKeypress()). This only implements the text widget and key
press logic; the status bar must be drawn by the application (see
TextViDemo.pl for an example of this).
Functions in Vi that require interaction with the system (such as
reading or writing files) are not (currently) handled by this module
(This is a feature since you probably don't want :quit to do exactly
that).
OPTIONS
-statuscommand
Callback invoked when the mode or the keys in the pending command
change. The current mode and pending keys will be passed to this
function.
-messagecommand
Callback invoked when messages need to be displayed.
-systemcommand
Callback invoked when the parent application needs to take action. If
you return 'undef' the widget will pretend that command doesn't exist
and do nothing. Currently, the argument can be:
'quit' The :quit command has been entered
SUPPORTED COMMANDS
Normal: a d f ga gg h i j k l m n o p q r t v x y D G O V 0 @ ` $ % /
Command: :quit :nohlsearch :split :map