Text-Snippet

This module provides TextMate-like snippet functionality via an
editor-agnostic API.  The snippet syntax is modeled after the
snippets provided by TextMate.

    use Text::Snippet;

    my $snippet = Text::Snippet->parse($snippet_content);

	my @tabstops = $snippet->tab_stops;
	foreach my $t (@tabstops) {
		my $replacement = get_user_input();    # get user input somehow
		$t->replace($replacement) if ($user_input);
	}
	print $snippet;                           # stringify and write to STDOUT
	
	# alternate "cursor" interface

	my $cursor = $snippet->cursor;
	while ( my $direction = get_user_tab_direction() ) {    # forward or backward
		my $t;
		if ( $direction == 1 ) {          # tab
			$t = $cursor->next;
		} elsif ( $direction == -1 ) {    # shift-tab
			$t = $cursor->prev;
		} else {
			last;                         # bail
		}
		next if ( !$t );

		# get (zero-based) cursor position relative to the beginning of the snippet
		my($line, $column) = $cursor->current_position;

		my $replacement = get_user_input();
		$t->replace($replacement);
	}
	print $snippet; # stringify snippet and write to STDOUT

INSTALLATION

To install this module, run the following commands:

	perl Makefile.PL
	make
	make test
	make install

SUPPORT AND DOCUMENTATION

After installing, you can find documentation for this module with the
perldoc command.

    perldoc Text::Snippet

You can also look for information at:

    RT, CPAN's request tracker
        http://rt.cpan.org/NoAuth/Bugs.html?Dist=Text-Snippet

    AnnoCPAN, Annotated CPAN documentation
        http://annocpan.org/dist/Text-Snippet

    CPAN Ratings
        http://cpanratings.perl.org/d/Text-Snippet

    Search CPAN
        http://search.cpan.org/dist/Text-Snippet/


COPYRIGHT AND LICENCE

Copyright (C) 2008 Brian Phillips

This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.