Term-ReadLine-Perl
view release on metacpan or search on metacpan
ReadLine/readline.pm view on Meta::CPAN
#sub F_ReReadInitFile;
#sub rl_getc;
sub F_ForwardChar;
sub F_BackwardChar;
sub F_BeginningOfLine;
sub F_EndOfLine;
sub F_ForwardWord;
sub F_BackwardWord;
sub F_RedrawCurrentLine;
sub F_ClearScreen;
# sub F_SelfInsert;
sub F_QuotedInsert;
sub F_TabInsert;
#sub F_AcceptLine;
sub F_OperateAndGetNext;
sub F_BackwardDeleteChar;
sub F_DeleteChar;
sub F_UnixWordRubout;
sub F_UnixLineDiscard;
sub F_UpcaseWord;
sub F_DownCaseWord;
sub F_CapitalizeWord;
sub F_TransposeWords;
sub F_TransposeChars;
sub F_PreviousHistory;
sub F_NextHistory;
sub F_BeginningOfHistory;
sub F_EndOfHistory;
sub F_ReverseSearchHistory;
sub F_ForwardSearchHistory;
sub F_HistorySearchBackward;
sub F_HistorySearchForward;
sub F_KillLine;
sub F_BackwardKillLine;
sub F_Yank;
sub F_YankPop;
sub F_YankNthArg;
sub F_KillWord;
sub F_BackwardKillWord;
sub F_Abort;
sub F_DoLowercaseVersion;
sub F_DoMetaVersion;
sub F_DoControlVersion;
sub F_Undo;
sub F_RevertLine;
sub F_EmacsEditingMode;
sub F_Interrupt;
sub F_PrefixMeta;
sub F_UniversalArgument;
sub F_DigitArgument;
sub F_OverwriteMode;
sub F_InsertMode;
sub F_ToggleInsertMode;
sub F_Suspend;
sub F_Ding;
sub F_PossibleCompletions;
sub F_Complete;
sub F_YankClipboard;
sub F_CopyRegionAsKillClipboard;
sub F_KillRegionClipboard;
sub clipboard_set;
sub F_BeginUndoGroup;
sub F_EndUndoGroup;
sub F_DoNothing;
sub F_ForceMemorizeDigitArgument;
sub F_MemorizeDigitArgument;
sub F_UnmemorizeDigitArgument;
sub F_ResetDigitArgument;
sub F_MergeInserts;
sub F_MemorizePos;
sub F_BeginPasteGroup;
sub F_EndPasteGroup;
sub F_BeginEditGroup;
sub F_EndEditGroup;
# Comment next line and __DATA__ line below to disable the selfloader.
use SelfLoader;
1;
__DATA__
# From here on anything may be autoloaded
sub max { $_[0] > $_[1] ? $_[0] : $_[1]; }
sub isupper { ord($_[0]) >= ord('A') && ord($_[0]) <= ord('Z'); }
sub islower { ord($_[0]) >= ord('a') && ord($_[0]) <= ord('z'); }
sub toupper { &islower ? pack('c', ord($_[0])-ord('a')+ord('A')) : $_[0];}
sub tolower { &isupper ? pack('c', ord($_[0])-ord('A')+ord('a')) : $_[0];}
##
## rl_set(var_name, value_string)
##
## Sets the named variable as per the given value, if both are appropriate.
## Allows the user of the package to set such things as HorizontalScrollMode
## and EditingMode. Value_string may be of the form
## HorizontalScrollMode
## horizontal-scroll-mode
##
## Also called during the parsing of ~/.inputrc for "set var value" lines.
##
## The previous value is returned, or undef on error.
###########################################################################
## Consider the following example for how to add additional variables
## accessible via rl_set (and hence via ~/.inputrc).
##
## Want:
## We want an external variable called "FooTime" (or "foo-time").
## It may have values "January", "Monday", or "Noon".
## Internally, we'll want those values to translate to 1, 2, and 12.
##
## How:
## Have an internal variable $var_FooTime that will represent the current
## internal value, and initialize it to the default value.
## Make an array %var_FooTime whose keys and values are are the external
## (January, Monday, Noon) and internal (1, 2, 12) values:
##
## $var_FooTime = $var_FooTime{'January'} = 1; #default
## $var_FooTime{'Monday'} = 2;
## $var_FooTime{'Noon'} = 12;
ReadLine/readline.pm view on Meta::CPAN
}
unshift(@Pending, $ch); # Unget the lookahead keystroke
# Successful completion - enter input mode with cursor beyond end of word.
&vi_input_mode;
}
sub F_ViInsertPossibleCompletions {
$Dot_state = savestate(); # Completion is undo-able
undef $Dot_buf; # but not redo-able
&complete_internal('*') or return;
# Successful completion - enter input mode with cursor beyond end of word.
&F_ForwardChar(1);
&vi_input_mode;
}
sub F_ViPossibleCompletions {
# List possible completions
&complete_internal('?');
# Enter input mode with cursor where we left off.
&F_ForwardChar(1);
&vi_input_mode;
}
sub F_SetMark {
$rl_mark = $D;
pos $line = $rl_mark;
$line_rl_mark = $rl_HistoryIndex;
$force_redraw = 1;
}
sub F_ExchangePointAndMark {
return F_Ding unless $line_rl_mark == $rl_HistoryIndex;
($rl_mark, $D) = ($D, $rl_mark);
pos $line = $rl_mark;
$D = length $line if $D > length $line;
$force_redraw = 1;
}
sub F_KillRegion {
return F_Ding unless $line_rl_mark == $rl_HistoryIndex;
$rl_mark = length $line if $rl_mark > length $line;
kill_text($rl_mark, $D, 1);
$line_rl_mark = -1; # Disable mark
}
sub F_CopyRegionAsKill {
return F_Ding unless $line_rl_mark == $rl_HistoryIndex;
$rl_mark = length $line if $rl_mark > length $line;
my ($s, $e) = ($rl_mark, $D);
($s, $e) = ($e, $s) if $s > $e;
$ThisCommandKilledText = 1 + $s;
$KillBuffer = '' if !$LastCommandKilledText;
$KillBuffer .= substr($line, $s, $e - $s);
}
sub clipboard_set {
my $in = shift;
if ($^O eq 'os2') {
eval {
require OS2::Process;
OS2::Process::ClipbrdText_set($in); # Do not disable \r\n-conversion
1
} and return;
} elsif ($^O eq 'MSWin32') {
eval {
require Win32::Clipboard;
Win32::Clipboard::Set($in);
1
} and return;
}
my $mess;
if ($ENV{RL_CLCOPY_CMD}) {
$mess = "Writing to pipe `$ENV{RL_CLCOPY_CMD}'";
open COPY, "| $ENV{RL_CLCOPY_CMD}" or warn("$mess: $!"), return;
} elsif (defined $ENV{HOME}) {
$mess = "Writing to file `$ENV{HOME}/.rl_cutandpaste'";
open COPY, "> $ENV{HOME}/.rl_cutandpaste" or warn("$mess: $!"), return;
} else {
return;
}
print COPY $in;
close COPY or warn("$mess: closing $!");
}
sub F_CopyRegionAsKillClipboard {
return clipboard_set($line) unless $line_rl_mark == $rl_HistoryIndex;
&F_CopyRegionAsKill;
clipboard_set($KillBuffer);
}
sub F_KillRegionClipboard {
&F_KillRegion;
clipboard_set($KillBuffer);
}
sub F_YankClipboard
{
remove_selection();
my $in;
if ($^O eq 'os2') {
eval {
require OS2::Process;
$in = OS2::Process::ClipbrdText();
$in =~ s/\r\n/\n/g; # With old versions, or what?
}
} elsif ($^O eq 'MSWin32') {
eval {
require Win32::Clipboard;
$in = Win32::Clipboard::GetText();
$in =~ s/\r\n/\n/g; # is this needed?
}
} else {
my $mess;
if ($ENV{RL_PASTE_CMD}) {
$mess = "Reading from pipe `$ENV{RL_PASTE_CMD}'";
open PASTE, "$ENV{RL_PASTE_CMD} |" or warn("$mess: $!"), return;
} elsif (defined $ENV{HOME}) {
$mess = "Reading from file `$ENV{HOME}/.rl_cutandpaste'";
open PASTE, "< $ENV{HOME}/.rl_cutandpaste" or warn("$mess: $!"), return;
}
if ($mess) {
local $/;
$in = <PASTE>;
close PASTE or warn("$mess, closing: $!");
}
}
if (defined $in) {
$in =~ s/\n+$//;
return &TextInsert($_[0], $in);
}
&TextInsert($_[0], $KillBuffer);
}
sub F_BeginUndoGroup {
push @undoGroupS, $#undo;
}
sub F_EndUndoGroup {
return F_Ding unless @undoGroupS;
my $last = pop @undoGroupS;
return unless $#undo > $last + 1;
my $now = pop @undo;
$#undo = $last;
push @undo, $now;
}
sub F_DoNothing { # E.g., reset digit-argument
1;
}
sub F_ForceMemorizeDigitArgument {
$memorizedArg = shift;
}
( run in 1.419 second using v1.01-cache-2.11-cpan-2398b32b56e )