ActiveState::Indenter - Keep track of indentation levels

NAME

ActiveState::Indenter - Keep track of indentation levels

SYNOPSIS

 use ActiveState::Indenter;
 
 my $fh = ActiveState::Indenter->new(*STDOUT);
 $fh->print("if (foo()) {\n")
 $fh->over;
 $fh->print("# do something\n");
 $fh->back;
 $fh->print("}\n");

DESCRIPTION

The ActiveState::Indenter works like an output file handle but will insert whitespace in the printed stream reflecting the current indentation level. It is useful for printing out nicely formatted programs.

The following methods are available:

$fh = ActiveState::Indenter->new( $filehandle )

The object constructor takes a file handle as argument. It will create a new indenter object that prints to the given file handle.

The $filehandle can actually be any object that implement a print() method.

$fh->handle

Returns back the filehandle passed to the constructor.

$fh->line_width
$fh->line_width( $new_width )

This get/set the current line width. The line width is used by the soft_space() method. The default is 70.

$fh->indent_offset
$fh->indent_offset( $new_offset )

This get/set the standard indentation offset. The default is 4.

$fh->print( $string )

The print() will print the string given as argument to the wrapped file handle but with suitable additional leading space added. The indenter object will never buffer output, so all content of the string will have reached the file when print returns.

$fh->soft_space

This will print a space character " " if there is more room on the line, or a newline otherwise.

$col = $fh->indent

This returns the current indentation column.

$fh->over
$fh->over( $offset )

This increase the indentation column with the given amount. Without argument the standard amount is used.

$fh->over_cur

This sets the indentation column the same as the current column.

$fh->over_abs( $col )

This set the indentation column to the number given.

$fh->back

Returns to the previous indentation column.

$col = $fh->column

Returns the current column position.

$line = $fh->line
$fh->line( $new_line )

This get/set the current line number.

$n = $fh->depth

Returns the current indentation depth.

COPYRIGHT

Copyright (C) 2003 ActiveState Corp. All rights reserved.

POD ERRORS

Hey! The above document had some coding errors, which are explained below:

Around line 220:

You forgot a '=back' before '=head1'