Text::Editor::Vip::CommandBlock - Allows grouping of do and undo commands


Text-Editor-Vip documentation Contained in the Text-Editor-Vip distribution.

Index


Code Index:

NAME

Top

Text::Editor::Vip::CommandBlock - Allows grouping of do and undo commands

SYNOPSIS

Top

  use Text::Editor::Vip::CommandBlock

  my $undo_block = new Text::Editor::Vip::CommandBlock
  			(
  			$buffer
  			, "\$buffer->Insert(\"$stringified_text_to_insert\", $use_smart_indentation) ;", '   #'
  			, "# undo for \$buffer->Insert(\"$stringified_text_to_insert\", $use_smart_indentation)", '   '
  			) ;

DESCRIPTION

Top

Text::Editor::Vip::CommandBlock allows grouping of undo blocks by automatically manipulating and decrementing the do and undo stack prefix. See DoUndoRedo.pm

new

Creates a new instance of Text::Editor::Vip::CommandBlock. See SYNOPSIS for and example.

new takes five arguments:

* A buffer object
* A do command
* An indentation string for the do buffer
* An undo command
* An indentation string for the undo buffer

See DoUndoRedo.pm to understand how this is used

DESTROY

This sub is automatically called by perl when a command block goes out of scope. This sub will decrement the do/undo stack level.

This sub is private and should only be called by perl.

AUTHOR

Top

	Khemir Nadim ibn Hamouda
	CPAN ID: NKH
	mailto:nadim@khemir.net
	http:// no web site

COPYRIGHT

Top


Text-Editor-Vip documentation Contained in the Text-Editor-Vip distribution.
package Text::Editor::Vip::CommandBlock;

use strict;
use warnings ;

use Text::Editor::Vip::Buffer::DoUndoRedo ;

BEGIN 
{
use Exporter ();
use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
$VERSION     = 0.01;
@ISA         = qw (Exporter);
@EXPORT      = qw ();
@EXPORT_OK   = qw ();
%EXPORT_TAGS = ();
}

#-------------------------------------------------------------------------------

#----------------------------------------------------------------------------

sub new
{

my ($class, $buffer, $do, $do_prefix, $undo, $undo_prefix) = @_;

$do ||= '' ;
$do_prefix ||= '' ;
$undo ||= '' ;
$undo_prefix ||= '' ;

PushUndoStep($buffer, $do, $undo) ;
IncrementUndoStackLevel($buffer, $do_prefix, $undo_prefix) ;

my $this = bless 
		(
		{ BUFFER => $buffer, DO_PREFIX => $do_prefix, UNDO_PREFIX => $undo_prefix}
		, ref ($class) || $class
		);

return ($this);
}

#-------------------------------------------------------------------------------

sub DESTROY
{

my $this = shift ;

DecrementUndoStackLevel($this->{BUFFER}, $this->{DO_PREFIX}, $this->{UNDO_PREFIX}) ;
}

#-------------------------------------------------------------------------------

1 ;