Text::Editor::Vip::Buffer::Indenter - Default indentiation plugin and documentation for indentation plugins.


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

Index


Code Index:

NAME

Top

Text::Editor::Vip::Buffer::Indenter - Default indentiation plugin and documentation for indentation plugins.

SYNOPSIS

Top

Nothing need to be done for using the default indenter. Read on to learn how to define your own indenters.

If you have an indenter for any "standard" indentation, please contribute it to VIP.

DESCRIPTION

Top

If Vip::Buffer::Insert() or InsertNewLine() is called with a SMART_INDENTATION argument, IndentNewLine is called. This lets you define your own indentation strategy.

To define you own indenter, Create a perl module, preferably under Text::Editor::Vip::Buffer::Plugins::Indent::.

The module needs a single function IndentNewLine

  package Text::Editor::Vip::Buffer::Plugins::Indent::MyIndenter ;

  sub IndentNewLine
  {
  # modification position is set at the line to indent

  my $buffer = shift ; # the buffer
  my $line_index = shift ; # usefull if we indent depending on previous lines

  # code to implement you indenter
  }

USING THE INDENTER

Top

  use Text::Editor::Vip::Buffer ;
  my $buffer = new Text::Editor::Vip::Buffer() ;

  $buffer->LoadAndExpandWith('Text::Editor::Vip::Buffer::Plugins::Indent::MyIndenter') ;

INLINED INDENTERS

Top

if you want to play with an indenter but don't want to bother creating a separate file and package.

  use Text::Editor::Vip::Buffer ;
  my $buffer = new Text::Editor::Vip::Buffer() ;

  sub my_indenter
  {
  # modification position is set at the line to indent

  my $buffer = shift ; # the buffer
  my $line_index = shift ; # usefull if we indent depending on previous lines

  $buffer->Insert('   ') ;  # silly indentation
  $buffer->MarkBufferAsEdited() ;
  }

  $buffer->ExpandWith('IndentNewLine', \&my_indenter) ;
  $buffer->Insert("hi\nThere\nWhats\nYour\nName\n") ;

  is($buffer->GetLineText(1), "   There", "Same text") ;

AUTHOR

Top

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

COPYRIGHT

Top

IndentNewLine

Default Line indenter for Vip::Buffer. Does nothing.


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

use strict;
use warnings ;
use Carp qw(cluck) ;

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 IndentNewLine
{

}


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

1;