Zaphod::Editor - document framework for an editor
$e->install_verb $verb => $classRegisters a verb and its handling class by creating a subroutine with the name in $verb which delegates to the class $class.
If a subroutine of that name already exists,
the method dies.
__PACKAGE__->install_actionsInstalls all verbs from all plugins into the editor class. Inheritance is not really handled.
$e->current_lineConvenience :lvalue method to get the current line
$e->docrefConvenience method to get a reference to the current document. This should be moved to Data::Alias maybe, to prevent even further copying of data.
$e->record_action ACTIONPuts an action onto the undo-stack so it can be undone later
$e->get_actionsReturns a copy of all undoable actions
$e->apply_actions ACTIONSApply a list of undoable actions
$e->undo COUNTUndoes COUNT items in the undo/redo tree.
Change the undo list into a tree so nested calls of the editor unto itself undo intuitively.
When passed an array reference, should undo exactly these actions.
$e->redo COUNTRedoes COUNT items in the undo/redo tree.
When passed an array reference, should redo exactly these actions.
$e->can_undoReturns true if the undo action is available,
that is,
there are actions that can be undone.
$e->can_redoReturns true if the redo action is available,
that is,
there are actions that can be redone.
$e->is_changedReturns true if the document was changed since it was last saved.
Currently, this is identical to the document having undoable actions.
$e->statusReturns an opaque reference encapsulating the current status of the editor. This is used by the undo facility to record where an action takes place.
Currently, this just means the cursor position.
$e->restore_status STATUSRestores the status from a previously saved status.
$e->vocabularyReturns the list of commands understood and undoable by the editor. Mostly convenient for introspection, but it could be convenient to use for scripting as well.
$e->insert_actions FROM,TO,ACTIONSReplaces the actions in the undo list at the offsets FROM ..
TO with the actions in ACTIONS and performs the necessary changes to the document.
$session->adjustment_map CHANGESCreates the list offset changes that result from applying the given actions.
$e->adjust_change SHIFT_MAP,
CHANGESAdjusts the changes by adjusting their offsets according to the SHIFT_MAP hash reference.
Actions that have no start point anymore are not yet discarded.
$e->adjust_offset SHIFT_MAP,
OFFSETSAdjusts the offsets according to the SHIFT_MAP hash reference.
Offsets that don't exist anymore get moved to their leftmost leftover position.
$e->dumpOutputs the state of the editor to STDOUT
$e->line_indicesReturns a list of all line indices
This is equivalent to
0..$#{ $e->document }
All plugins for adding new verbs to the editor are loaded from the Zaphod::Editor::Action:: namespace and are made available directly in the editor as undoable actions.
Written by Max Maischein <corion@cpan.org>
Copyright Max Maischein 2005,2006; All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.