« blib/lib/Text/Editor/Vip/Buffer/Plugins/GetWord.pm
↑ Summary
blib/lib/Text/Editor/Vip/Selection.pm »
| 1 | |||||||||||||||||||||
| 2 | package Text::Editor::Vip::CommandBlock; | ||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 18 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 18 | ▶ | use warnings ; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 18 | ▶ | use Text::Editor::Vip::Buffer::DoUndoRedo ; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | BEGIN | ||||||||||||||||||||
| 10 | 18 | ▶ | { | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 18 | ▶ | use Exporter (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 18 | ▶ | use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 18 | $VERSION = 0.01; | |||||||||||||||||||
| 14 | 18 | @ISA = qw (Exporter); | |||||||||||||||||||
| 15 | 18 | @EXPORT = qw (); | |||||||||||||||||||
| 16 | 18 | @EXPORT_OK = qw (); | |||||||||||||||||||
| 17 | 18 | %EXPORT_TAGS = (); | |||||||||||||||||||
| 18 | } | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | #------------------------------------------------------------------------------- | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | =head1 NAME | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | Text::Editor::Vip::CommandBlock - Allows grouping of do and undo commands | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | =head1 SYNOPSIS | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | use Text::Editor::Vip::CommandBlock | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | my $undo_block = new Text::Editor::Vip::CommandBlock | ||||||||||||||||||||
| 31 | ( | ||||||||||||||||||||
| 32 | $buffer | ||||||||||||||||||||
| 33 | , "\$buffer->Insert(\"$stringified_text_to_insert\", $use_smart_indentation) ;", ' #' | ||||||||||||||||||||
| 34 | , "# undo for \$buffer->Insert(\"$stringified_text_to_insert\", $use_smart_indentation)", ' ' | ||||||||||||||||||||
| 35 | ) ; | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | =head1 DESCRIPTION | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | Text::Editor::Vip::CommandBlock allows grouping of undo blocks by automatically manipulating | ||||||||||||||||||||
| 40 | and decrementing the do and undo stack prefix. See L<DoUndoRedo.pm> | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | =cut | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | #---------------------------------------------------------------------------- | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | sub new | ||||||||||||||||||||
| 47 | 10839 | ▶ | { | ||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=19.4
Pod
documented
| |||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | =head2 new | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | Creates a new instance of Text::Editor::Vip::CommandBlock. See L<SYNOPSIS> for and example. | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | B<new> takes five arguments: | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | =over 2 | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | =item * A buffer object | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | =item * A do command | ||||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | =item * An indentation string for the do buffer | ||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | =item * An undo command | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | =item * An indentation string for the undo buffer | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | =back | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | See L<DoUndoRedo.pm> to understand how this is used | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | =cut | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | 10839 | my ($class, $buffer, $do, $do_prefix, $undo, $undo_prefix) = @_; | |||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | 10839 | ▶ | $do ||= '' ; | ||||||||||||||||||
|
Condition50%1/2
$do ||= ""
MC/DC0%0/1
$do ||= ""
$do
Truth table50%1/2
A
A= $do
| |||||||||||||||||||||
| 76 | 10839 | ▶ | $do_prefix ||= '' ; | ||||||||||||||||||
|
Condition50%1/2
$do_prefix ||= ""
MC/DC0%0/1
$do_prefix ||= ""
$do_prefix
Truth table50%1/2
A
A= $do_prefix
| |||||||||||||||||||||
| 77 | 10839 | ▶ | $undo ||= '' ; | ||||||||||||||||||
|
Condition50%1/2
$undo ||= ""
MC/DC0%0/1
$undo ||= ""
$undo
Truth table50%1/2
A
A= $undo
| |||||||||||||||||||||
| 78 | 10839 | ▶ | $undo_prefix ||= '' ; | ||||||||||||||||||
|
Condition50%1/2
$undo_prefix ||= ""
MC/DC0%0/1
$undo_prefix ||= ""
$undo_prefix
Truth table50%1/2
A
A= $undo_prefix
| |||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | 10839 | PushUndoStep($buffer, $do, $undo) ; | |||||||||||||||||||
| 81 | 10839 | IncrementUndoStackLevel($buffer, $do_prefix, $undo_prefix) ; | |||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | 10839 | ▶ | my $this = bless | ||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 84 | ( | ||||||||||||||||||||
| 85 | { BUFFER => $buffer, DO_PREFIX => $do_prefix, UNDO_PREFIX => $undo_prefix} | ||||||||||||||||||||
| 86 | , ref ($class) || $class | ||||||||||||||||||||
| 87 | ); | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | 10839 | return ($this); | |||||||||||||||||||
| 90 | } | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | #------------------------------------------------------------------------------- | ||||||||||||||||||||
| 93 | |||||||||||||||||||||
| 94 | sub DESTROY | ||||||||||||||||||||
| 95 | 10839 | ▶ | { | ||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | =head2 DESTROY | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | This sub is automatically called by perl when a command block goes out of scope. This sub | ||||||||||||||||||||
| 100 | will decrement the do/undo stack level. | ||||||||||||||||||||
| 101 | |||||||||||||||||||||
| 102 | This sub is private and should only be called by perl. | ||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | =cut | ||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | 10839 | my $this = shift ; | |||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | 10839 | DecrementUndoStackLevel($this->{BUFFER}, $this->{DO_PREFIX}, $this->{UNDO_PREFIX}) ; | |||||||||||||||||||
| 109 | } | ||||||||||||||||||||
| 110 | |||||||||||||||||||||
| 111 | #------------------------------------------------------------------------------- | ||||||||||||||||||||
| 112 | |||||||||||||||||||||
| 113 | 18 | 1 ; | |||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | =head1 AUTHOR | ||||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | Khemir Nadim ibn Hamouda | ||||||||||||||||||||
| 118 | CPAN ID: NKH | ||||||||||||||||||||
| 119 | mailto:nadim@khemir.net | ||||||||||||||||||||
| 120 | http:// no web site | ||||||||||||||||||||
| 121 | |||||||||||||||||||||
| 122 | =head1 COPYRIGHT | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | This program is free software; you can redistribute | ||||||||||||||||||||
| 125 | it and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | The full text of the license can be found in the | ||||||||||||||||||||
| 128 | LICENSE file included with this module. | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | =cut | ||||||||||||||||||||