Curses-UI
view release on metacpan or search on metacpan
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
# Pasting more than one char/line is possible. As long
# as you do it at once (no other actions in between are
# allowed).
if (defined $this->{-prevkey} and $this->{-prevkey} ne $key) {
$this->do_new_pastebuffer(1);
} else {
$this->do_new_pastebuffer(0);
}
# Backup, in case illegal input is done.
my %backup = %{$this};
# Process bindings.
my $ret = $this->process_bindings($key);
# Did the widget loose focus, due to the keypress?
return $this unless $this->{-focus};
# To upper or to lower?
if ($this->{-toupper}) {
$this->{-text} = uc $this->{-text};
lib/Curses/UI/TextEditor.pm view on Meta::CPAN
my $lines = $this->split_to_lines($this->{-text});
$is_illegal = 1 if @$lines > $this->{-maxlines};
}
if (not $is_illegal and defined $this->{-regexp}) {
my $e = '$is_illegal = (not $this->{-text} =~ ' . $this->{-regexp} . ')';
eval $e;
}
if ($is_illegal) # Illegal input? Then restore and bail out.
{
while (my ($k,$v) = each %backup) {
$this->{$k} = $v;
}
$this->dobeep();
} else { # Legal input? Redraw the text.
$this->run_event('-onchange');
$this->draw(1);
}
# Save the current key.
$this->{-prevkey} = $key;
( run in 1.053 second using v1.01-cache-2.11-cpan-49f99fa48dc )