NAME

Zaphod::Editor::Action - encapsulate a change in the editor

CLASSDATA

verbs

Lists all the verbs that this package exports. Every verb should be a constructor that returns an instance of this class which performs and undoes the action.

No constructor should modify the document. The editor will call the apply method on the action to change the document.

$action->apply EDITOR

$action->revert EDITOR

$action->copy

Returns a (semi-shallow) copy of the action

Copied entities are:

  * offset
  * text_before
  * text_after

$action->as_js_string

Returns the action as a Javascript serialized string. Currently this doesn't handle escaping properly - the strings are simply passed through quotemeta, which might run afoul of newlines or HTML chars.

The cursor status of the action is not carried over, as this is uninteresting.

$action->args

A convenience method that returns the three vital elements of the action. Equivalent to the following code:

    local $_ = $action;
    return
        $_->offset,
        $_->text_before,
        $_->text_after
    ;

Zaphod::Editor::Action->from_string

Decodes a list of actions from a string

%unquote

Mapping of quoted chars to their unquoted internal representation.

Currently maps:

  \r \t \n \" \' \0 \\

unquote ELEMS

Unquotes a string according to %unquote. Modifies its arguments in-place.

decode STR

Decodes all actions from STR. If an action is syntactically invalid it is skipped.

AUTHOR

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.

SEE ALSO

Zaphod