App-Prima-REPL
view release on metacpan or search on metacpan
lib/PrimaX/InputHistory.pm view on Meta::CPAN
# PrimaX::InputHistory #
###########################
# a history-tracking input line.
package PrimaX::InputHistory;
use base 'Prima::InputLine';
# This has the standard profile of an InputLine widget, except that it knows
# about navigation keys and other things useful for the History.
sub profile_default
{
my %def = %{$_[ 0]-> SUPER::profile_default};
# These lines are somewhat patterned from the Prima example called 'editor'
my @acc = (
# Navigation scrolls through the command history
['Previous Line', 'Up', kb::Up, sub {$_[0]->move_line(-1)}]
, ['Next Line', 'Down', kb::Down, sub {$_[0]->move_line(1)}]
# Note that the values of 10 here are purely symbolic; the function
# actually refers to self's pageLines property when it sees +-10
, ['Earlier Lines', 'Page Up', kb::PageUp, sub {$_[0]->move_line(-10)}]
, ['Later Lines', 'Page Down', kb::PageDown, sub {$_[0]->move_line(10)}]
lib/PrimaX/InputHistory.pm view on Meta::CPAN
currentLine => 0,
storeType => ih::All,
}
}
# This stage initializes the inputline. I believe this is the appropriate stage
# for (1) setting the properties above (2) loading the history file data, and
# (3) connecting to the output widget.
sub init {
my $self = shift;
my %profile = $self->SUPER::init(@_);
foreach ( qw(pageLines promptFormat currentLine outputWidget storeType) ) {
$self->{$_} = $profile{$_};
}
# Store the history and revisions:
$self->currentRevisions([]);
$self->history([]);
# history calls currentLine, so this doesn't need to be called:
# $self->currentLine(0);
( run in 0.408 second using v1.01-cache-2.11-cpan-26ccb49234f )