NAME

Term::EditLine - Perl interface to the NetBSD editline library

SYNOPSIS

use Term::EditLine qw(CC_EOF);

my $el = Term::EditLine->new('progname');
$el->set_prompt ( '# ' );

$el->add_fun ('bye','desc',sub { print "\nbye\n"; return CC_EOF; });

$el->parse('bind','-e');
$el->parse('bind','^D','bye');

while (defined($_ = $el->gets())) {
  $el->history_enter($_);
  print $_;
}

DESCRIPTION

Term::EditLine is a compiled module, which provides an object oriented interface to the NetBSD editline library. Since editline supports readline and history functions this module is almost a full replacement for the Term::ReadLine module even though it is much smaller than any existing Term::ReadLine interface.

Functions

new ( PROGNAME, [ IN, OUT, ERR ] )

Creates a new Term::EditLine object. Argument is the name of the application. Optionally can be followed by three arguments for the input, output, and error filehandles. These arguments should be globs. See also el_init(3).

gets

Read a line from the tty. If successful returns the line read, or undef if no characters where read or if an error occured.

set_prompt ( PROMPT )

Define the prompt. Argument may either be a perl sub, which has to return a string that contains the prompt, or a string.

set_rprompt ( PROMPT )

Define the right side prompt. Argument may either be a perl sub, which has to return a string that contains the prompt, or a string.

set_editor ( MODE )

Set editing mode to mode, which must be one of "emacs" or "vi".

add_fun ( NAME, HELP, FUN )

See el_set(3). This functions performs an el_set( editline, EL_ADDFN, NAME, HELP, FUN ) call. FUN is to be a reference to a perl subroutine.

history_set_size ( SIZE )

Set size of history to SIZE elements.

history_get_size

Return the number of events currently in history.

history_clear

Clear the history.

history_get_first

Return the first element in the history.

history_get_last

Return the last element in the history.

history_get_prev

Return the previous element in the history.

history_get_next

Return the next element in the history.

history_get_curr

Return the current element in the history.

history_add ( STR )

Append STR to the current element of the history, or create an element with.

history_append ( STR )

Append STR to the last new element of the history.

history_enter ( STR )

Add STR as a new element to the history, and, if necessary, removing the oldest entry to keep the list to the created size.

history_get_prev_str ( STR )

Return the closest previous event that starts with STR.

history_get_next_str ( STR )

Return the closest next event that starts with STR.

history_load ( FILENAME )

Load the history list stored in FILENAME.

history_save ( FILENAME )

Save the history list to FILENAME.

Additional functions

The following functions are simply perl wrappers of the C functions documented in editline(3):

reset
getc
push
resize
line
insertstr
deletestr

EXPORT

None by default.

Exportable constants

CC_ARGHACK
CC_CURSOR
CC_EOF
CC_ERROR
CC_FATAL
CC_NEWLINE
CC_NORM
CC_REDISPLAY
CC_REFRESH
CC_REFRESH_BEEP

SEE ALSO

editline(3), editrc(5)

AUTHOR

Ulrich Burgbacher, <ulrich@burgbacher.net>

COPYRIGHT AND LICENSE

Copyright 2003 by Ulrich Burgbacher

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

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 254:

You forgot a '=back' before '=head2'

Around line 275:

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