1# 2# Gnu.pm --- The GNU Readline/History Library wrapper module 3# 4# Copyright (c) 1996-2021 Hiroo Hayashi. All rights reserved. 5# 6# This program is free software; you can redistribute it and/or 7# modify it under the same terms as Perl itself. 8# 9# Some of documentation strings in this file are cited from the 10# GNU Readline/History Library Manual. 11 12package Term::ReadLine::Gnu; 13 14=head1 NAME 15 16Term::ReadLine::Gnu - Perl extension for the GNU Readline/History Library 17 18=head1 SYNOPSIS 19 20 use Term::ReadLine; # Do not "use Term::ReadLine::Gnu;" 21 $term = new Term::ReadLine 'ProgramName'; 22 while ( defined ($_ = $term->readline('prompt>')) ) { 23 ... 24 } 25 26=head1 DESCRIPTION 27 28=head2 Overview 29 30This is an implementation of 31L<Term::ReadLine|http://search.cpan.org/dist/Term-ReadLine/> using 32L<the GNU ReadlineE<sol>History 33Library|https://tiswww.cwru.edu/php/chet/readline/rltop.html>. 34 35For basic functions object oriented interface is provided. These are 36described in the section L</"Standard Methods"> and 37L</"C<Term::ReadLine::Gnu> Functions">. 38 39This package also has the interface with the almost all functions and 40variables which are documented in the GNU Readline/History Library 41Manual. They are documented in the section 42L</"C<Term::ReadLine::Gnu> Functions"> 43and 44L</"C<Term::ReadLine::Gnu> 45Variables"> briefly. For further details of the GNU Readline/History 46Library, see L<GNU Readline Library 47Manual|https://tiswww.cwru.edu/php/chet/readline/readline.html> and 48L<GNU History Library 49Manual|https://tiswww.cwru.edu/php/chet/readline/history.html>. 50 51There are some C<Term::ReadLine::Gnu> original features. They are 52described in the section L</"C<Term::ReadLine::Gnu> Specific 53Features"> 54 55The sample programs under F<eg/> directory and test programs under 56F<t/> directory in L<the C<Term::ReadLine::Gnu> distribution|http://search.cpan.org/dist/Term-ReadLine-Gnu/> include 57many examples of this module. 58 59=head2 Standard Methods 60 61These are standard methods defined by 62L<Term::ReadLine|http://search.cpan.org/dist/Term-ReadLine/>. 63 64=cut 65 66use strict; 67use warnings; 68use Carp; 69# use version TRG-1.22 for perl 5.7.x, or TRG-1.09 for older Perl 70use 5.8.1; 71 72# This module can't be loaded directly. 73BEGIN { 74 if (not defined $Term::ReadLine::VERSION) { 75 croak <<END; 76It is invalid to load Term::ReadLine::Gnu directly. Please consult 77the Term::ReadLine documentation for more information. 78END 79 } 80} 81# use Term::ReadLine::Stub on a dumb terminal. 82# https://rt.cpan.org/Ticket/Display.html?id=123398 83# Debian Bug Report #99843 84BEGIN { 85 if (!exists($ENV{TERM}) || !defined($ENV{TERM}) || $ENV{TERM} =~ /^(dumb|emacs|unknown|)$/) { 86 croak "dumb terminal."; 87 } 88} 89 90{ 91 use Exporter (); 92 use DynaLoader; 93 94 our $VERSION = '1.42'; # update Gnu::XS::VERSION also. 95 96 # Term::ReadLine::Gnu::AU makes a function in 97 # `Term::ReadLine::Gnu::XS' as a method. 98 # The namespace of Term::ReadLine::Gnu::AU is searched before ones 99 # of other classes 100 101 our @ISA = qw(Term::ReadLine::Gnu::AU Term::ReadLine::Stub 102 Exporter DynaLoader); 103 104 our %EXPORT_TAGS = ( 105 prompt => [qw(RL_PROMPT_START_IGNORE RL_PROMPT_END_IGNORE)], 106 match_type => [qw(NO_MATCH SINGLE_MATCH MULT_MATCH)], 107 keymap_type => [qw(ISFUNC ISKMAP ISMACR)], 108 undo_code => [qw(UNDO_DELETE UNDO_INSERT UNDO_BEGIN UNDO_END)], 109 rl_state => [qw(RL_STATE_NONE RL_STATE_INITIALIZING 110 RL_STATE_INITIALIZED RL_STATE_TERMPREPPED 111 RL_STATE_READCMD RL_STATE_METANEXT 112 RL_STATE_DISPATCHING RL_STATE_MOREINPUT 113 RL_STATE_ISEARCH RL_STATE_NSEARCH 114 RL_STATE_SEARCH RL_STATE_NUMERICARG 115 RL_STATE_MACROINPUT RL_STATE_MACRODEF 116 RL_STATE_OVERWRITE RL_STATE_COMPLETING 117 RL_STATE_SIGHANDLER RL_STATE_UNDOING 118 RL_STATE_INPUTPENDING RL_STATE_TTYCSAVED 119 RL_STATE_CALLBACK RL_STATE_VIMOTION 120 RL_STATE_MULTIKEY RL_STATE_VICMDONCE 121 RL_STATE_CHARSEARCH RL_STATE_REDISPLAYING 122 RL_STATE_DONE)], 123 ); 124 Exporter::export_ok_tags('prompt'); 125 Exporter::export_ok_tags('match_type'); 126 Exporter::export_ok_tags('keymap_type'); 127 Exporter::export_ok_tags('undo_code'); 128 Exporter::export_ok_tags('rl_state'); 129 130 bootstrap Term::ReadLine::Gnu $VERSION; # DynaLoader 131} 132require Term::ReadLine::Gnu::XS; 133 134# Global Variables 135 136our($readline_version); 137 138# Each variable in the GNU Readline Library is tied to an entry of 139# this hash (%Attribs). By accessing the hash entry, you can read 140# and/or write the variable in the GNU Readline Library. See the 141# package definition of Term::ReadLine::Gnu::Var and following code 142# for further details. 143 144# Normal (non-tied) entries 145our %Attribs = ( 146 MinLength => 1, 147 do_expand => 0, 148 completion_word => [], 149 term_set => ['', '', '', ''], 150 ); 151our %Features = ( 152 appname => 1, minline => 1, autohistory => 1, 153 getHistory => 1, setHistory => 1, addHistory => 1, 154 readHistory => 1, writeHistory => 1, 155 preput => 1, attribs => 1, newTTY => 1, 156 tkRunning => Term::ReadLine::Stub->Features->{'tkRunning'}, 157 ornaments => Term::ReadLine::Stub->Features->{'ornaments'}, 158 stiflehistory => 1, 159 ); 160 161# 162# GNU Readline/History Library constant definition 163# These are included in @EXPORT_OK. 164 165# I can define these variables in XS code to use the value defined in 166# readline.h, etc. But it needs some calling convention change and 167# will cause compatiblity problem. I hope the definition of these 168# constant value will not be changed. 169 170# for non-printing characters in prompt string 171sub RL_PROMPT_START_IGNORE { "\001"; } 172sub RL_PROMPT_END_IGNORE { "\002"; } 173 174# for rl_filename_quoting_function 175sub NO_MATCH { 0; } 176sub SINGLE_MATCH { 1; } 177sub MULT_MATCH { 2; } 178 179# for rl_generic_bind, rl_function_of_keyseq 180sub ISFUNC { 0; } 181sub ISKMAP { 1; } 182sub ISMACR { 2; } 183 184# for rl_add_undo 185sub UNDO_DELETE { 0; } 186sub UNDO_INSERT { 1; } 187sub UNDO_BEGIN { 2; } 188sub UNDO_END { 3; } 189 190# for rl_readline_state which was implemented since 4.2 191sub RL_STATE_NONE { 0x00000; } # no state; before first call 192sub RL_STATE_INITIALIZING { 0x00001; } # initializing 193sub RL_STATE_INITIALIZED { 0x00002; } # initialization done 194sub RL_STATE_TERMPREPPED { 0x00004; } # terminal is prepped 195sub RL_STATE_READCMD { 0x00008; } # reading a command key 196sub RL_STATE_METANEXT { 0x00010; } # reading input after ESC 197sub RL_STATE_DISPATCHING { 0x00020; } # dispatching to a command 198sub RL_STATE_MOREINPUT { 0x00040; } # reading more input in a command function 199sub RL_STATE_ISEARCH { 0x00080; } # doing incremental search 200sub RL_STATE_NSEARCH { 0x00100; } # doing non-inc search 201sub RL_STATE_SEARCH { 0x00200; } # doing a history search 202sub RL_STATE_NUMERICARG { 0x00400; } # reading numeric argument 203sub RL_STATE_MACROINPUT { 0x00800; } # getting input from a macro 204sub RL_STATE_MACRODEF { 0x01000; } # defining keyboard macro 205sub RL_STATE_OVERWRITE { 0x02000; } # overwrite mode 206sub RL_STATE_COMPLETING { 0x04000; } # doing completion 207sub RL_STATE_SIGHANDLER { 0x08000; } # in readline sighandler 208sub RL_STATE_UNDOING { 0x10000; } # doing an undo 209sub RL_STATE_INPUTPENDING { 0x02_0000; } # rl_execute_next called 210sub RL_STATE_TTYCSAVED { 0x04_0000; } # tty special chars saved [5.0] 211sub RL_STATE_CALLBACK { 0x08_0000; } # using the callback interface [5.1] 212sub RL_STATE_VIMOTION { 0x10_0000; } # reading vi motion arg [5.1] 213sub RL_STATE_MULTIKEY { 0x20_0000; } # reading multiple-key command [5.1] 214sub RL_STATE_VICMDONCE { 0x40_0000; } # entered vi command mode at least once [5.1] 215sub RL_STATE_CHARSEARCH { 0x80_0000; } # vi mode char search [7.0] 216sub RL_STATE_REDISPLAYING { # updating terminal display [6.1] 217 $readline_version < 0x0700 ? 0x80_0000 : 0x100_0000; 218} 219sub RL_STATE_DONE { # done; accepted line 220 $readline_version < 0x0501 ? 0x8_0000 : 221 ($readline_version < 0x0601 ? 0x80_0000 : 222 ($readline_version < 0x0700 ? 0x100_0000 : 0x200_0000)); 223} 224 225# 226# Methods Definition 227# 228 229=over 4 230 231=item C<ReadLine> 232 233returns the actual package that executes the commands. If 234this package is being used, C<Term::ReadLine::Gnu> is returned. 235 236=cut 237 238sub ReadLine { 'Term::ReadLine::Gnu'; } 239 240=item C<new(NAME,[IN,OUT])> 241 242returns the handle for subsequent calls to following functions. 243Argument is the name of the application. Optionally can be followed 244by two arguments for C<IN> and C<OUT> file handles. These arguments 245should be globs. 246 247=cut 248 249# The origin of this function is Term::ReadLine::Perl.pm by Ilya Zakharevich. 250sub new { 251 my $this = shift; # Package 252 my $class = ref($this) || $this; 253 254 # Debian Bug Report #204362 255 croak "Wrong number of arguments" unless @_ == 1 or @_ == 3; 256 my $name = shift; 257 258 my $self = \%Attribs; 259 bless $self, $class; 260 261 # set rl_readline_name before .inputrc is read in rl_initialize() 262 $Attribs{readline_name} = $name; 263 264 # some version of Perl cause segmentation fault, if XS module 265 # calls setenv() before the 1st assignment to $ENV{}. 266 $ENV{_TRL_DUMMY} = ''; 267 268 # UTF-8 condition conpatible with Term:ReadLine 269 $Attribs{utf8_mode} ||= ${^UNICODE} & 1 || defined ${^ENCODING}; 270 #printf "\${^UNICODE}: 0x%X, ", ${^UNICODE}; 271 #print "\${^ENCODING}: ", defined ${^ENCODING} ? 'defined' : 'undef', "\n"; 272 273 # set tty before calling rl_initialize() not to output some 274 # charactores to STDIO. 275 # https://rt.cpan.org/Ticket/Display.html?id=96569 276 if (!@_) { 277 my ($in, $out) = $self->findConsole(); 278 open(my $IN,"<$in") || croak "Cannot open $in for read"; 279 open(my $OUT,">$out") || croak "Cannot open $out for write"; 280 if ($Attribs{utf8_mode}) { 281 binmode $IN, ':encoding(UTF-8)'; # not necessary 282 binmode $OUT, ':encoding(UTF-8)'; 283 } 284 $self->newTTY($IN, $OUT); 285 } else { 286 # enable UTF-8 mode if input stream has the utf8 layer. 287 my @layers = PerlIO::get_layers($_[0]); 288 $Attribs{utf8_mode} ||= ($layers[$#layers] eq 'utf8'); 289 290 $self->newTTY(@_); 291 } 292 293 # initialize the GNU Readline Library and termcap library 294 # This calls tgetent(). 295 $self->initialize(); 296 297 # enable ornaments to be compatible with perl5.004_05(?) 298 # This calls tgetstr(). 299 $self->ornaments(1) unless ($ENV{PERL_RL} and $ENV{PERL_RL} =~ /\bo\w*=0/); 300 301 # keep rl_readline_version value for efficiency 302 $readline_version = $Attribs{readline_version}; 303 304 # bind operate-and-get-next to \C-o by default for the compatibility 305 # with bash and Term::ReadLine::Perl 306 # GNU Readline 8.1 and later support operate-and-get-next natively. 307 Term::ReadLine::Gnu::XS::rl_add_defun('operate-and-get-next', 308 \&Term::ReadLine::Gnu::XS::operate_and_get_next, ord "\co") 309 if ($readline_version < 0x801); 310 311 $self; 312} 313 314sub DESTROY {} 315 316=item C<readline(PROMPT[,PREPUT])> 317 318gets an input line, with actual C<GNU Readline> support. Trailing 319newline is removed. Returns C<undef> on C<EOF>. C<PREPUT> is an 320optional argument meaning the initial value of input. 321 322The optional argument C<PREPUT> is granted only if the value C<preput> 323is in C<Features>. 324 325C<PROMPT> may include some escape sequences. Use 326C<RL_PROMPT_START_IGNORE> to begin a sequence of non-printing 327characters, and C<RL_PROMPT_END_IGNORE> to end the sequence. 328 329=cut 330 331# to peacify -w 332$Term::ReadLine::registered = $Term::ReadLine::registered; 333 334sub readline { # should be ReadLine 335 my $self = shift; 336 my ($prompt, $preput) = @_; 337 338 # A contributed fix for Perl debugger 339 # make sure the outstream fd inside the readline library is 340 # in sync (see http://bugs.debian.org/236018) 341 # This is not a real fix but left for system where this fix works. 342 # Here is the real fix for perl5db.pl. 343 # https://rt.perl.org/Public/Bug/Display.html?id=121456 344 $Attribs{outstream} = $Attribs{outstream}; 345 346 # ornament support (now prompt only) 347 $prompt = ${$Attribs{term_set}}[0] . $prompt . ${$Attribs{term_set}}[1]; 348 349 # `completion_function' support for compatibility with 350 # Term:ReadLine::Perl. Prefer $completion_entry_function, since a 351 # program which uses $completion_entry_function should know 352 # Term::ReadLine::Gnu and have better completion function using 353 # the variable. 354 $Attribs{completion_entry_function} = $Attribs{_trp_completion_function} 355 if (!defined $Attribs{completion_entry_function} 356 && defined $Attribs{completion_function}); 357 358 # TkRunning support 359 if (not $Term::ReadLine::registered and $Term::ReadLine::toloop 360 and defined &Tk::DoOneEvent) { 361 $self->register_Tk; 362 $Attribs{getc_function} = $Attribs{Tk_getc}; 363 } 364 365 # call readline() 366 my $line; 367 if (defined $preput) { 368 my $saved_startup_hook = $Attribs{startup_hook}; 369 $Attribs{startup_hook} = sub { 370 $self->rl_insert_text($preput); 371 &$saved_startup_hook 372 if defined $saved_startup_hook; 373 }; 374 $line = $self->rl_readline($prompt); 375 $Attribs{startup_hook} = $saved_startup_hook; 376 } else { 377 $line = $self->rl_readline($prompt); 378 } 379 return undef unless defined $line; 380 381 # history expansion 382 if ($Attribs{do_expand}) { 383 my $result; 384 ($result, $line) = $self->history_expand($line); 385 my $outstream = $Attribs{outstream}; 386 print $outstream "$line\n" if ($result); 387 388 # return without adding line into history 389 if ($result < 0 || $result == 2) { 390 return ''; # don't return `undef' which means EOF. 391 } 392 } 393 394 # add to history buffer 395 $self->add_history($line) 396 if (defined $self->{MinLength} && $self->{MinLength} > 0 397 && length($line) >= $self->{MinLength}); 398 399 return $line; 400} 401 402=item C<AddHistory(LINE1, LINE2, ...)> 403 404adds the lines to the history of input, from where it can be used if 405the actual C<readline> is present. 406 407=cut 408 409#use vars '*addhistory'; 410*addhistory = \&AddHistory; # for backward compatibility 411 412sub AddHistory { 413 my $self = shift; 414 foreach (@_) { 415 $self->add_history($_); 416 } 417} 418 419=item C<IN>, C<OUT> 420 421return the file handles for input and output or C<undef> if 422C<readline> input and output cannot be used for Perl. 423 424=cut 425 426sub IN { $Attribs{instream}; } 427sub OUT { $Attribs{outstream}; } 428 429=item C<MinLine([MAX])> 430 431If argument C<MAX> is specified, it is an advice on minimal size of 432line to be included into history. C<undef> means do not include 433anything into history. Returns the old value. 434 435=cut 436 437sub MinLine { 438 my $self = shift; 439 my $old_minlength = $self->{MinLength}; 440 $self->{MinLength} = shift; 441 $old_minlength; 442} 443 444=item C<findConsole> 445 446returns an array with two strings that give most appropriate names for 447files for input and output using conventions C<"E<lt>$in">, C<"E<gt>$out">. 448 449=cut 450 451# findConsole is defined in ReadLine.pm. 452 453=item C<Attribs> 454 455returns a reference to a hash which describes internal configuration 456(variables) of the package. Names of keys in this hash conform to 457standard conventions with the leading C<rl_> stripped. 458 459See section L</"C<Term::ReadLine::Gnu> Variables"> for supported variables. 460 461=cut 462 463sub Attribs { \%Attribs; } 464 465=item C<Features> 466 467Returns a reference to a hash with keys being features present in 468current implementation. Several optional features are used in the 469minimal interface: C<appname> should be present if the first argument 470to C<new> is recognized, and C<minline> should be present if 471C<MinLine> method is not dummy. C<autohistory> should be present if 472lines are put into history automatically (maybe subject to 473C<MinLine>), and C<addHistory> if C<AddHistory> method is not dummy. 474C<preput> means the second argument to C<readline> method is processed. 475C<getHistory> and C<setHistory> denote that the corresponding methods are 476present. C<tkRunning> denotes that a Tk application may run while ReadLine 477is getting input. 478 479=cut 480 481sub Features { \%Features; } 482 483=item C<tkRunning> 484 485makes Tk event loop run when waiting for user input (i.e., during 486C<readline> method). 487 488=cut 489 490# tkRunning is defined in ReadLine.pm. 491 492=item C<event_loop> 493 494See the description of C<event_loop> on 495L<Term::ReadLine|http://search.cpan.org/dist/Term-ReadLine/>. 496 497=item C<ornaments> 498 499makes the command line stand out by using termcap data. The argument 500to C<ornaments> should be 0, 1, or a string of a form 501C<"aa,bb,cc,dd">. Four components of this string should be names of 502I<terminal capacities>, first two will be issued to make the prompt 503standout, last two to make the input line standout. 504 505=cut 506 507sub ornaments { 508 my $self = shift; 509 return Term::ReadLine::Gnu::XS::ornaments(@_); 510} 511 512=item C<newTTY> 513 514takes two arguments which are input filehandle and output filehandle. 515Switches to use these filehandles. 516 517=cut 518 519# used by a program (ex. perldb5.pl) who changes input/output stream. 520sub newTTY { 521 my ($self, $in, $out) = @_; 522 523 # borrowed from Term/ReadLine.pm 524 my $sel = select($out); 525 $| = 1; # for DB::OUT 526 select($sel); 527 528 $Attribs{instream} = $in; 529 $Attribs{outstream} = $out; 530} 531 532=item C<enableUTF8> 533 534Enables UTF-8 support. 535 536If STDIN is in UTF-8 by the C<-C> command-line switch or 537C<PERL_UNICODE> environment variable, or C<IN> file handle has C<utf8> 538IO layer, then UTF-8 support is also enabled. In other cases you need 539this C<enableUTF8> method. 540 541This is an original method of C<Term::ReadLine:Gnu>. 542 543=cut 544 545sub enableUTF8 { 546 my $self = shift; 547 $Attribs{utf8_mode} = 1; 548 binmode $self->IN, ':encoding(UTF-8)'; # not necessary 549 binmode $self->OUT, ':encoding(UTF-8)'; 550} 551 552=back 553 554=cut 555 556# documented later 557sub CallbackHandlerInstall { 558 my $self = shift; 559 my ($prompt, $lhandler) = @_; 560 561 $Attribs{_callback_handler} = $lhandler; 562 563 # ornament support (now prompt only) 564 $prompt = ${$Attribs{term_set}}[0] . $prompt . ${$Attribs{term_set}}[1]; 565 566 $Attribs{completion_entry_function} = $Attribs{_trp_completion_function} 567 if (!defined $Attribs{completion_entry_function} 568 && defined $Attribs{completion_function}); 569 570 $self->rl_callback_handler_install($prompt, 571 \&Term::ReadLine::Gnu::XS::_ch_wrapper); 572} 573 574 575# 576# Additional Supported Methods 577# 578 579# Documentation is after '__END__' for efficiency. 580 581# for backward compatibility 582#use vars qw(*AddDefun *BindKey *UnbindKey *ParseAndBind *StifleHistory); 583*AddDefun = \&add_defun; 584*BindKey = \&bind_key; 585*UnbindKey = \&unbind_key; 586*ParseAndBind = \&parse_and_bind; 587*StifleHistory = \&stifle_history; 588 589sub SetHistory { 590 my $self = shift; 591 $self->clear_history(); 592 $self->AddHistory(@_); 593} 594 595sub GetHistory { 596 my $self = shift; 597 $self->history_list(); 598} 599 600sub ReadHistory { 601 my $self = shift; 602 ! $self->read_history_range(@_); 603} 604 605sub WriteHistory { 606 my $self = shift; 607 ! $self->write_history(@_); 608} 609 610# 611# Access Routines for GNU Readline/History Library Variables 612# 613package Term::ReadLine::Gnu::Var; 614use Carp; 615use strict; 616use warnings; 617our %_rl_vars; 618 619%_rl_vars 620 = ( 621 rl_line_buffer => ['S', 0], 622 rl_prompt => ['S', 1], 623 rl_library_version => ['S', 2], 624 rl_terminal_name => ['S', 3], 625 rl_readline_name => ['S', 4], 626 rl_basic_word_break_characters => ['S', 5], 627 rl_basic_quote_characters => ['S', 6], 628 rl_completer_word_break_characters => ['S', 7], 629 rl_completer_quote_characters => ['S', 8], 630 rl_filename_quote_characters => ['S', 9], 631 rl_special_prefixes => ['S', 10], 632 history_no_expand_chars => ['S', 11], 633 history_search_delimiter_chars => ['S', 12], 634 rl_executing_macro => ['S', 13], # GRL 4.2 635 history_word_delimiters => ['S', 14], # GRL 4.2 636 rl_display_prompt => ['S', 15], # GRL 6.0 637 rl_executing_keyseq => ['S', 16], # GRL 6.3 638 639 rl_point => ['I', 0], 640 rl_end => ['I', 1], 641 rl_mark => ['I', 2], 642 rl_done => ['I', 3], 643 rl_pending_input => ['I', 4], 644 rl_completion_query_items => ['I', 5], 645 rl_completion_append_character => ['C', 6], 646 rl_ignore_completion_duplicates => ['I', 7], 647 rl_filename_completion_desired => ['I', 8], 648 rl_filename_quoting_desired => ['I', 9], 649 rl_inhibit_completion => ['I', 10], 650 history_base => ['I', 11], 651 history_length => ['I', 12], 652 history_max_entries => ['I', 13], 653 max_input_history => ['I', 13], # before GRL 4.2 654 history_write_timestamps => ['I', 14], # GRL 5.0 655 history_expansion_char => ['C', 15], 656 history_subst_char => ['C', 16], 657 history_comment_char => ['C', 17], 658 history_quotes_inhibit_expansion => ['I', 18], 659 rl_erase_empty_line => ['I', 19], # GRL 4.0 660 rl_catch_signals => ['I', 20], # GRL 4.0 661 rl_catch_sigwinch => ['I', 21], # GRL 4.0 662 rl_already_prompted => ['I', 22], # GRL 4.1 663 rl_num_chars_to_read => ['I', 23], # GRL 4.1 664 rl_dispatching => ['I', 24], # GRL 4.2 665 rl_gnu_readline_p => ['I', 25], # GRL 4.1 666 rl_readline_state => ['I', 26], # GRL 4.2 667 rl_explicit_arg => ['I', 27], # GRL 4.2 668 rl_numeric_arg => ['I', 28], # GRL 4.2 669 rl_editing_mode => ['I', 29], # GRL 4.2 670 rl_attempted_completion_over => ['I', 30], # GRL 4.2 671 rl_completion_type => ['I', 31], # GRL 4.2 672 rl_readline_version => ['I', 32], # GRL 4.2a 673 rl_completion_suppress_append => ['I', 33], # GRL 4.3 674 rl_completion_quote_character => ['C', 34], # GRL 5.0 675 rl_completion_suppress_quote => ['I', 35], # GRL 5.0 676 rl_completion_found_quote => ['I', 36], # GRL 5.0 677 rl_completion_mark_symlink_dirs => ['I', 37], # GRL 4.3 678 rl_prefer_env_winsize => ['I', 38], # GRL 5.1 679 rl_sort_completion_matches => ['I', 39], # GRL 6.0 680 rl_completion_invoking_key => ['C', 40], # GRL 6.0 681 rl_executing_key => ['I', 41], # GRL 6.3 682 rl_key_sequence_length => ['I', 42], # GRL 6.3 683 rl_change_environment => ['I', 43], # GRL 6.3 684 rl_persistent_signal_handlers => ['I', 44], # GRL 7.0 685 history_quoting_state => ['I', 45], # GRL 8.0 686 utf8_mode => ['I', 46], # internal 687 688 rl_startup_hook => ['F', 0], 689 rl_event_hook => ['F', 1], 690 rl_getc_function => ['F', 2], 691 rl_redisplay_function => ['F', 3], 692 rl_completion_entry_function => ['F', 4], 693 rl_attempted_completion_function => ['F', 5], 694 rl_filename_quoting_function => ['F', 6], 695 rl_filename_dequoting_function => ['F', 7], 696 rl_char_is_quoted_p => ['F', 8], 697 rl_ignore_some_completions_function => ['F', 9], 698 rl_directory_completion_hook => ['F', 10], 699 history_inhibit_expansion_function => ['F', 11], 700 rl_pre_input_hook => ['F', 12], # GRL 4.0 701 rl_completion_display_matches_hook => ['F', 13], # GRL 4.0 702 rl_completion_word_break_hook => ['F', 14], # GRL 5.0 703 rl_prep_term_function => ['F', 15], # GRL 4.2 704 rl_deprep_term_function => ['F', 16], # GRL 4.2 705 rl_directory_rewrite_hook => ['F', 17], # GRL 4.2 706 rl_filename_rewrite_hook => ['F', 18], # GRL 6.1 707 rl_signal_event_hook => ['F', 19], # GRL 6.3 708 rl_input_available_hook => ['F', 20], # GRL 6.3 709 rl_filename_stat_hook => ['F', 21], # GRL 6.3 710 711 rl_instream => ['IO', 0], 712 rl_outstream => ['IO', 1], 713 714 rl_executing_keymap => ['K', 0], 715 rl_binding_keymap => ['K', 1], 716 717 rl_last_func => ['LF', 0], 718 ); 719 720my @stream; 721 722sub TIESCALAR { 723 my $class = shift; 724 my $name = shift; 725 return bless \$name, $class; 726} 727 728sub FETCH { 729 my $self = shift; 730 confess "wrong type" unless ref $self; 731 732 my $name = $$self; 733 if (! defined $_rl_vars{$name}) { 734 confess "Term::ReadLine::Gnu::Var::FETCH: Unknown variable name `$name'\n"; 735 return undef ; 736 } 737 738 my ($type, $id) = @{$_rl_vars{$name}}; 739 if ($type eq 'S') { 740 return _rl_fetch_str($id); 741 } elsif ($type eq 'I') { 742 return _rl_fetch_int($id); 743 } elsif ($type eq 'C') { 744 return chr(_rl_fetch_int($id)); 745 } elsif ($type eq 'F') { 746 return _rl_fetch_function($id); 747 } elsif ($type eq 'IO') { 748 # STORE was called in new() before coming here 749 return $stream[$id]; 750 } elsif ($type eq 'K') { 751 return _rl_fetch_keymap($id); 752 } elsif ($type eq 'LF') { 753 return _rl_fetch_last_func(); 754 } else { 755 carp "Term::ReadLine::Gnu::Var::FETCH: Illegal type `$type'\n"; 756 return undef; 757 } 758} 759 760sub STORE { 761 my $self = shift; 762 confess "wrong type" unless ref $self; 763 764 my $name = $$self; 765 if (! defined $_rl_vars{$name}) { 766 confess "Term::ReadLine::Gnu::Var::STORE: Unknown variable name `$name'\n"; 767 return undef ; 768 } 769 770 my $value = shift; 771 my ($type, $id) = @{$_rl_vars{$name}}; 772 if ($type eq 'S') { 773 if ($name eq 'rl_line_buffer') { 774 return _rl_store_rl_line_buffer($value); 775 } else { 776 return _rl_store_str($value, $id); 777 } 778 } elsif ($type eq 'I') { 779 return _rl_store_int($value, $id); 780 } elsif ($type eq 'C') { 781 return chr(_rl_store_int(ord($value), $id)); 782 } elsif ($type eq 'F') { 783 return _rl_store_function($value, $id); 784 } elsif ($type eq 'IO') { 785 _rl_store_iostream($value, $id); 786 # _rl_store_iostream() calls PerlIO_findFILE(). It pushes the 787 # 'stdio' layer on perl 5.10 and later. We must pop the stdio 788 # layer. 789 # https://rt.cpan.org/Ticket/Display.html?id=59832 790 # But we must pop the 'stdio' layer only when utf8 layer is 791 # included for remote debugging. 792 # https://rt.cpan.org/Ticket/Display.html?id=110121 793 if ($] >= 5.010) { 794 my @layers = PerlIO::get_layers($value); 795 if ((grep /^utf8$/, @layers) > 0 && $layers[$#layers] eq 'stdio') { 796 binmode($value, ":pop"); 797 } 798 } 799 return $stream[$id] = $value; 800 } elsif ($type eq 'K' || $type eq 'LF') { 801 carp "Term::ReadLine::Gnu::Var::STORE: read only variable `$name'\n"; 802 return undef; 803 } else { 804 carp "Term::ReadLine::Gnu::Var::STORE: Illegal type `$type'\n"; 805 return undef; 806 } 807} 808 809package Term::ReadLine::Gnu; 810use Carp; 811use strict; 812use warnings; 813 814# 815# set value of %Attribs 816# 817 818# Tie all Readline/History variables 819foreach (keys %Term::ReadLine::Gnu::Var::_rl_vars) { 820 my $name; 821 ($name = $_) =~ s/^rl_//; # strip leading `rl_' 822 tie $Attribs{$name}, 'Term::ReadLine::Gnu::Var', $_; 823} 824 825# add reference to some functions 826{ 827 my ($name, $fname); 828 no strict 'refs'; # allow symbolic reference 829 map { 830 ($name = $_) =~ s/^rl_//; # strip leading `rl_' 831 $fname = 'Term::ReadLine::Gnu::XS::' . $_; 832 $Attribs{$name} = \&$fname; # symbolic reference 833 } qw(rl_getc 834 rl_redisplay 835 rl_callback_read_char 836 rl_display_match_list 837 rl_filename_completion_function 838 rl_username_completion_function 839 list_completion_function 840 _trp_completion_function); 841 # auto-splited subroutines cannot be processed in the map loop above 842 use strict 'refs'; 843 $Attribs{shadow_redisplay} = \&Term::ReadLine::Gnu::XS::shadow_redisplay; 844 $Attribs{Tk_getc} = \&Term::ReadLine::Gnu::XS::Tk_getc; 845 $Attribs{list_completion_function} = \&Term::ReadLine::Gnu::XS::list_completion_function; 846} 847 848package Term::ReadLine::Gnu::AU; 849use Carp; 850no strict qw(refs vars); 851use warnings; 852 853sub AUTOLOAD { 854 { $AUTOLOAD =~ s/.*:://; } # preserve match data 855 my $name; 856 if (exists $Term::ReadLine::Gnu::XS::{"rl_$AUTOLOAD"}) { 857 $name = "Term::ReadLine::Gnu::XS::rl_$AUTOLOAD"; 858 } elsif (exists $Term::ReadLine::Gnu::XS::{"$AUTOLOAD"}) { 859 $name = "Term::ReadLine::Gnu::XS::$AUTOLOAD"; 860 } else { 861 croak "Cannot do `$AUTOLOAD' in Term::ReadLine::Gnu"; 862 } 863 no warnings 'redefine'; # Why is this line necessary ??? 864 *$AUTOLOAD = sub { shift; &$name(@_); }; 865 goto &$AUTOLOAD; 866} 8671; 868__END__ 869 870 871=head2 C<Term::ReadLine::Gnu> Functions 872 873All these GNU Readline/History Library functions supported are callable via 874method interface and have names which conform to standard conventions 875with the leading C<rl_> stripped. For example C<rl_foo()> 876function is called as C<$term-E<gt>foo()>. 877 878The titles of the following sections are same as the titles of the 879corresponding sections in the "Programming with GNU Readline" section 880in the L<GNU Readline Library 881Manual|https://tiswww.cwru.edu/php/chet/readline/readline.html>. 882Refer them for further details. 883 884Although it is preferred to use method interface, most methods have 885lower level functions in 886C<Term::ReadLine::Gnu::XS> package. To use them a full qualified name 887is required. 888 889=head3 Basic Behavior 890 891The function C<readline()> prints a prompt and then reads and returns 892a single line of text from the user. 893 894 $_ = $term->readline('Enter a line: '); 895 896You can change key-bindings using C<bind_key(KEY, FUNCTION [,MAP])> 897function. The first argument, C<KEY>, is the character that you want 898bind. The second argument, C<FUNCTION>, is the function to call when 899C<KEY> is pressed. The C<FUNCTION> can be a reference to a Perl 900function (see L</"Custom Functions">) or a "named function" named by 901C<add_defun()> function or commands described in the "Bindable 902Readline Commands" section in the L<GNU Readline Library 903Manual|https://tiswww.cwru.edu/php/chet/readline/readline.html>. 904 905 $term->bind_key(ord "\ci, 'tab-insert'); 906 907The above example binds Control-I to the 'tab-insert' command. 908 909=head3 Custom Functions 910 911You can write new functions using Perl. The calling sequence for a 912command foo looks like 913 914 sub foo ($count, $key) { ... } 915 916where C<$count> is the numeric argument (or 1 if defaulted) and 917C<$key> is the key that invoked this function. 918 919Here is an example; 920 921 sub reverse_line { # reverse a whole line 922 my($count, $key) = @_; # ignored in this sample function 923 924 $t->modifying(0, $a->{end}); # save undo information 925 $a->{line_buffer} = reverse $a->{line_buffer}; 926 } 927 928See the "Writing a New Function" section in the L<GNU Readline Library 929Manual|https://tiswww.cwru.edu/php/chet/readline/readline.html> for 930further details. 931 932=head3 Readline Convenience Functions 933 934=head4 Naming a Function 935 936=over 4 937 938=item C<add_defun(NAME, FUNCTION [,KEY=-1])> 939 940Add name to a Perl function C<FUNCTION>. If optional argument C<KEY> 941is specified, bind it to the C<FUNCTION>. Returns reference to 942C<FunctionPtr>. 943 944 Example: 945 # name `reverse-line' to a function reverse_line(), 946 # and bind it to "\C-t" 947 $term->add_defun('reverse-line', \&reverse_line, ord "\ct"); 948 949=back 950 951=head4 Selecting a Keymap 952 953=over 4 954 955=item C<make_bare_keymap> 956 957 Keymap rl_make_bare_keymap() 958 959=item C<copy_keymap(MAP)> 960 961 Keymap rl_copy_keymap(Keymap|str map) 962 963=item C<make_keymap> 964 965 Keymap rl_make_keymap() 966 967=item C<discard_keymap(MAP)> 968 969 Keymap rl_discard_keymap(Keymap|str map) 970 971=item C<free_keymap(MAP)> 972 973 void rl_free_keymap(Keymap|str map) 974 975=item C<empty_keymap(MAP)> 976 977 int rl_empty_keymap(Keymap|str map) # GRL 8.0 978 979=item C<get_keymap> 980 981 Keymap rl_get_keymap() 982 983=item C<set_keymap(MAP)> 984 985 Keymap rl_set_keymap(Keymap|str map) 986 987=item C<get_keymap_by_name(NAME)> 988 989 Keymap rl_get_keymap_by_name(str name) 990 991=item C<get_keymap_name(MAP)> 992 993 str rl_get_keymap_name(Keymap map) 994 995=item C<set_keymap_name(NAME, MAP)> 996 997 int rl_set_keymap_name(str name, Keymap|str map) # GRL 8.0 998 999=back 1000 1001=head4 Binding Keys 1002 1003=over 4 1004 1005=item C<bind_key(KEY, FUNCTION [,MAP])> 1006 1007 int rl_bind_key(int key, FunctionPtr|str function, 1008 Keymap|str map = rl_get_keymap()) 1009 1010Bind C<KEY> to the C<FUNCTION>. C<FUNCTION> is the name added by the 1011C<add_defun> method. If optional argument C<MAP> is specified, binds 1012in C<MAP>. Returns non-zero in case of error. 1013 1014=item C<bind_key_if_unbound(KEY, FUNCTION [,MAP])> 1015 1016 int rl_bind_key_if_unbound(int key, FunctionPtr|str function, 1017 Keymap|str map = rl_get_keymap()) # GRL 5.0 1018 1019=item C<unbind_key(KEY [,MAP])> 1020 1021 int rl_unbind_key(int key, Keymap|str map = rl_get_keymap()) 1022 1023Bind C<KEY> to the null function. Returns non-zero in case of error. 1024 1025=item C<unbind_function(FUNCTION [,MAP])> 1026 1027 int rl_unbind_function(FunctionPtr|str function, 1028 Keymap|str map = rl_get_keymap()) 1029 1030=item C<unbind_command(COMMAND [,MAP])> 1031 1032 int rl_unbind_command(str command, 1033 Keymap|str map = rl_get_keymap()) 1034 1035=item C<bind_keyseq(KEYSEQ, FUNCTION [,MAP])> 1036 1037 int rl_bind_keyseq(str keyseq, FunctionPtr|str function, 1038 Keymap|str map = rl_get_keymap()) # GRL 5.0 1039 1040=item C<set_key(KEYSEQ, FUNCTION [,MAP])> 1041 1042 int rl_set_key(str keyseq, FunctionPtr|str function, 1043 Keymap|str map = rl_get_keymap()) # GRL 4.2 1044 1045=item C<bind_keyseq_if_unbound(KEYSEQ, FUNCTION [,MAP])> 1046 1047 int rl_bind_keyseq_if_unbound(str keyseq, FunctionPtr|str function, 1048 Keymap|str map = rl_get_keymap()) # GRL 5.0 1049 1050=item C<generic_bind(TYPE, KEYSEQ, DATA, [,MAP])> 1051 1052 int rl_generic_bind(int type, str keyseq, 1053 FunctionPtr|Keymap|str data, 1054 Keymap|str map = rl_get_keymap()) 1055 1056=item C<parse_and_bind(LINE)> 1057 1058 void rl_parse_and_bind(str line) 1059 1060Parse C<LINE> as if it had been read from the F<~/.inputrc> file and 1061perform any key bindings and variable assignments found. For further 1062detail see L<GNU Readline Library 1063Manual|https://tiswww.cwru.edu/php/chet/readline/readline.html>. 1064 1065=item C<read_init_file([FILENAME])> 1066 1067 int rl_read_init_file(str filename = '~/.inputrc') 1068 1069=back 1070 1071=head4 Associating Function Names and Bindings 1072 1073=over 4 1074 1075=item C<named_function(NAME)> 1076 1077 FunctionPtr rl_named_function(str name) 1078 1079=item C<get_function_name(FUNCTION)> 1080 1081 str rl_get_function_name(FunctionPtr function) # TRG original 1082 1083=item C<function_of_keyseq(KEYSEQ [,MAP])> 1084 1085 (FunctionPtr|Keymap|str data, int type) 1086 rl_function_of_keyseq(str keyseq, 1087 Keymap|str map = rl_get_keymap()) 1088 1089=item C<invoking_keyseqs(FUNCTION [,MAP])> 1090 1091 (@str) rl_invoking_keyseqs(FunctionPtr|str function, 1092 Keymap|str map = rl_get_keymap()) 1093 1094=item C<function_dumper([READABLE])> 1095 1096 void rl_function_dumper(int readable = 0) 1097 1098=item C<list_funmap_names> 1099 1100 void rl_list_funmap_names() 1101 1102=item C<funmap_names> 1103 1104 (@str) rl_funmap_names() 1105 1106=item C<add_funmap_entry(NAME, FUNCTION)> 1107 1108 int rl_add_funmap_entry(char *name, FunctionPtr|str function) 1109 1110=back 1111 1112=head4 Allowing Undoing 1113 1114=over 4 1115 1116=item C<begin_undo_group> 1117 1118 int rl_begin_undo_group() 1119 1120=item C<end_undo_group> 1121 1122 int rl_end_undo_group() 1123 1124=item C<add_undo(WHAT, START, END, TEXT)> 1125 1126 int rl_add_undo(int what, int start, int end, str text) 1127 1128=item C<free_undo_list> 1129 1130 void rl_free_undo_list() 1131 1132=item C<do_undo> 1133 1134 int rl_do_undo() 1135 1136=item C<modifying([START [,END]])> 1137 1138 int rl_modifying(int start = 0, int end = rl_end) 1139 1140=back 1141 1142=head4 Redisplay 1143 1144=over 4 1145 1146=item C<redisplay> 1147 1148 void rl_redisplay() 1149 1150=item C<forced_update_display> 1151 1152 int rl_forced_update_display() 1153 1154=item C<on_new_line> 1155 1156 int rl_on_new_line() 1157 1158=item C<on_new_line_with_prompt> 1159 1160 int rl_on_new_line_with_prompt() # GRL 4.1 1161 1162=item C<clear_visible_line()> 1163 1164 int rl_clear_visible_line() # GRL 7.0 1165 1166=item C<reset_line_state> 1167 1168 int rl_reset_line_state() 1169 1170=item C<crlf> 1171 1172 int rl_crlf() 1173 1174=item C<show_char(C)> 1175 1176 int rl_show_char(int c) 1177 1178=item C<message(FMT[, ...])> 1179 1180 int rl_message(str fmt, ...) 1181 1182=item C<clear_message> 1183 1184 int rl_clear_message() 1185 1186=item C<save_prompt> 1187 1188 void rl_save_prompt() 1189 1190=item C<restore_prompt> 1191 1192 void rl_restore_prompt() 1193 1194=item C<expand_prompt(PROMPT)> 1195 1196 int rl_expand_prompt(str prompt) 1197 1198=item C<set_prompt(PROMPT)> 1199 1200 int rl_set_prompt(const str prompt) # GRL 4.2 1201 1202=back 1203 1204=head4 Modifying Text 1205 1206=over 4 1207 1208=item C<insert_text(TEXT)> 1209 1210 int rl_insert_text(str text) 1211 1212=item C<delete_text([START [,END]])> 1213 1214 int rl_delete_text(int start = 0, int end = rl_end) 1215 1216=item C<copy_text([START [,END]])> 1217 1218 str rl_copy_text(int start = 0, int end = rl_end) 1219 1220=item C<kill_text([START [,END]])> 1221 1222 int rl_kill_text(int start = 0, int end = rl_end) 1223 1224=item C<push_macro_input(MACRO)> 1225 1226 int rl_push_macro_input(str macro) 1227 1228=back 1229 1230=head4 Character Input 1231 1232=over 4 1233 1234=item C<read_key> 1235 1236 int rl_read_key() 1237 1238=item C<getc(STREAM)> 1239 1240 int rl_getc(FILE *STREAM) 1241 1242=item C<stuff_char(C)> 1243 1244 int rl_stuff_char(int c) 1245 1246=item C<execute_next(C)> 1247 1248 int rl_execute_next(int c) 1249 1250=item C<clear_pending_input()> 1251 1252 int rl_clear_pending_input() # GRL 4.2 1253 1254=item C<set_keyboard_input_timeout(uSEC)> 1255 1256 int rl_set_keyboard_input_timeout(int usec) # GRL 4.2 1257 1258=back 1259 1260=head4 Terminal Management 1261 1262=over 4 1263 1264=item C<prep_terminal(META_FLAG)> 1265 1266 void rl_prep_terminal(int META_FLAG) 1267 1268=item C<deprep_terminal()> 1269 1270 void rl_deprep_terminal() 1271 1272=item C<tty_set_default_bindings([MAP])> 1273 1274 void rl_tty_set_default_bindings([Keymap|str map = rl_get_keymap()]) # GRL 4.0 1275 1276=item C<tty_unset_default_bindings([MAP])> 1277 1278 void rl_tty_unset_default_bindings([Keymap|str map = rl_get_keymap()]) # GRL 5.0 1279 1280=item C<tty_set_echoing(VALUE)> 1281 1282 int rl_tty_set_echoing(int value) # GRL 7.0 1283 1284=item C<reset_terminal([TERMINAL_NAME])> 1285 1286 int rl_reset_terminal(str terminal_name = getenv($TERM)) 1287 1288=back 1289 1290=head4 Utility Functions 1291 1292=over 4 1293 1294=item C<save_state(READLINE_STATE)> 1295 1296 READLINE_STATE rl_save_state() # GRL 6.0 1297 1298=item C<restore_state(READLINE_STATE)> 1299 1300 int rl_restore_state(READLINE_STATE) # GRL 6.0 1301 1302=item C<free(MEM)> 1303 1304 Not implemented since not required for Perl. 1305 int rl_free(void *mem) # GRL 6.0 1306 1307=item C<replace_line(TEXT [,CLEAR_UNDO])> 1308 1309 int rl_replace_line(str text, int clear_undo = 0) # GRL 4.3 1310 1311=item C<extend_line_buffer(LEN)> 1312 1313 Not implemented since not required for Perl. 1314 int rl_extend_line_buffer(int len) 1315 1316=item C<initialize> 1317 1318 int rl_initialize() 1319 1320=item C<ding> 1321 1322 int rl_ding() 1323 1324=item C<alphabetic(C)> 1325 1326 int rl_alphabetic(int C) # GRL 4.2 1327 1328=item C<display_match_list(MATCHES [,LEN [,MAX]])> 1329 1330 void rl_display_match_list(\@matches, len = $#maches, max) # GRL 4.0 1331 1332Since the first element of an array C<@matches> as treated as a possible 1333completion, it is not displayed. See the descriptions of 1334C<completion_matches()>. 1335When C<MAX> is omitted, the max length of an item in C<@matches> is used. 1336 1337=back 1338 1339=head4 Miscellaneous Functions 1340 1341=over 4 1342 1343=item C<macro_bind(KEYSEQ, MACRO [,MAP])> 1344 1345 int rl_macro_bind(const str keyseq, const str macro, Keymap map) 1346 1347=item C<macro_dumper(READABLE)> 1348 1349 int rl_macro_dumper(int readline) 1350 1351=item C<variable_bind(VARIABLE, VALUE)> 1352 1353 int rl_variable_bind(const str variable, const str value) 1354 1355=item C<variable_value(VARIABLE)> 1356 1357 str rl_variable_value(const str variable) # GRL 5.1 1358 1359=item C<variable_dumper(READABLE)> 1360 1361 int rl_variable_dumper(int readline) 1362 1363=item C<set_paren_blink_timeout(uSEC)> 1364 1365 int rl_set_paren_blink_timeout(usec) # GRL 4.2 1366 1367=item C<get_termcap(cap)> 1368 1369 str rl_get_termcap(cap) 1370 1371=item C<clear_history> 1372 1373 void rl_clear_history() # GRL 6.3 1374 1375=item C<activate_mark> 1376 1377 void rl_activate_mark() # GRL 8.1 1378 1379=item C<deactivate_mark> 1380 1381 void rl_deactivate_mark() # GRL 8.1 1382 1383=item C<keep_mark_active> 1384 1385 void rl_keep_mark_active() # GRL 8.1 1386 1387=item C<mark_active_p> 1388 1389 int rl_mark_active_p() # GRL 8.1 1390 1391=back 1392 1393=head4 Alternate Interface 1394 1395=over 4 1396 1397=item C<callback_handler_install(PROMPT, LHANDLER)> 1398 1399 void rl_callback_handler_install(str prompt, pfunc lhandler) 1400 1401=item C<callback_read_char> 1402 1403 void rl_callback_read_char() 1404 1405=item C<callback_sigcleanup> # GRL 7.0 1406 1407 void rl_callback_sigcleanup() 1408 1409=item C<callback_handler_remove> 1410 1411 void rl_callback_handler_remove() 1412 1413=back 1414 1415=head3 Readline Signal Handling 1416 1417=over 4 1418 1419=item C<pending_signal()> 1420 1421 int rl_pending_signal() # GRL 7.0 1422 1423=item C<cleanup_after_signal> 1424 1425 void rl_cleanup_after_signal() # GRL 4.0 1426 1427=item C<free_line_state> 1428 1429 void rl_free_line_state() # GRL 4.0 1430 1431=item C<reset_after_signal> 1432 1433 void rl_reset_after_signal() # GRL 4.0 1434 1435=item C<check_signals> 1436 1437 void rl_check_signals() # GRL 8.0 1438 1439=item C<echo_signal_char> 1440 1441 void rl_echo_signal_char(int sig) # GRL 6.0 1442 1443=item C<resize_terminal> 1444 1445 void rl_resize_terminal() # GRL 4.0 1446 1447=item C<set_screen_size(ROWS, COLS)> 1448 1449 void rl_set_screen_size(int ROWS, int COLS) # GRL 4.2 1450 1451=item C<get_screen_size()> 1452 1453 (int rows, int cols) rl_get_screen_size() # GRL 4.2 1454 1455=item C<reset_screen_size()> 1456 1457 void rl_reset_screen_size() # GRL 5.1 1458 1459=item C<set_signals> 1460 1461 int rl_set_signals() # GRL 4.0 1462 1463=item C<clear_signals> 1464 1465 int rl_clear_signals() # GRL 4.0 1466 1467=back 1468 1469=head3 Completion Functions 1470 1471=over 4 1472 1473=item C<complete_internal([WHAT_TO_DO])> 1474 1475 int rl_complete_internal(int what_to_do = TAB) 1476 1477=item C<completion_mode(FUNCTION)> 1478 1479 int rl_completion_mode(FunctionPtr|str function) # GRL 4.3 1480 1481=item C<completion_matches(TEXT [,FUNC])> 1482 1483 (@str) rl_completion_matches(str text, 1484 pfunc func = filename_completion_function) 1485 1486=item C<filename_completion_function(TEXT, STATE)> 1487 1488 str rl_filename_completion_function(str text, int state) 1489 1490=item C<username_completion_function(TEXT, STATE)> 1491 1492 str rl_username_completion_function(str text, int state) 1493 1494=item C<list_completion_function(TEXT, STATE)> 1495 1496 str list_completion_function(str text, int state) # TRG original 1497 1498=back 1499 1500=head3 History Functions 1501 1502=head4 Initializing History and State Management 1503 1504=over 4 1505 1506=item C<using_history> 1507 1508 void using_history() 1509 1510=item C<history_get_history_state> 1511 1512 HISTORY_STATE history_get_hitory_state() # GRL 6.3 1513 1514=item C<history_set_history_state> 1515 1516 void history_set_hitory_state(HISTORY_STATE) # GRL 6.3 1517 1518=back 1519 1520=head4 History List Management 1521 1522=over 4 1523 1524=item C<add_history(STRING)> 1525 1526 void add_history(str string) 1527 1528=item C<add_history_time(STRING)> 1529 1530 void add_history_time(str string) # GRL 5.0 1531 1532=item C<remove_history(WHICH)> 1533 1534 str remove_history(int which) 1535 1536=item C<free_history(HISTENT)> 1537 1538 Not implemented since Term::ReadLine::Gnu does not support the 1539 member 'data' of HIST_ENTRY structure. remove_history() frees 1540 the memory. 1541 histdata_t free_history_entry(HIST_ENTRY *histent) # GRL 5.0 1542 1543=item C<replace_history_entry(WHICH, STRING)> 1544 1545 str replace_history_entry(int which, str string) 1546 1547=item C<clear_history> 1548 1549 void clear_history() 1550 1551=item C<StifleHistory(MAX)> 1552 1553 int stifle_history(int max|undef) 1554 1555stifles the history list, remembering only the last C<MAX> entries. 1556If C<MAX> is undef, remembers all entries. This is a replacement 1557of C<unstifle_history()>. 1558 1559=item C<unstifle_history> 1560 1561 int unstifle_history() 1562 1563This is equivalent with C<stifle_history(undef)>. 1564 1565=item C<history_is_stifled> 1566 1567 int history_is_stifled() 1568 1569=item C<SetHistory(LINE1 [, LINE2, ...])> 1570 1571sets the history of input, from where it can be used if the actual 1572C<readline> is present. 1573 1574=back 1575 1576=head4 Information About the History List 1577 1578=over 4 1579 1580=item C<history_list> 1581 1582 Not implemented since not required for Perl. 1583 HIST_ENTRY **history_list() 1584 1585=item C<where_history> 1586 1587 int where_history() 1588 1589=item C<current_history> 1590 1591 str current_history() 1592 1593=item C<history_get(OFFSET)> 1594 1595 str history_get(offset) 1596 1597=item C<history_get_time(OFFSET)> 1598 1599 time_t history_get_time(offset) # GRL 5.0 1600 1601=item C<history_total_bytes> 1602 1603 int history_total_bytes() 1604 1605=item C<GetHistory> 1606 1607returns the history of input as a list, if actual C<readline> is present. 1608 1609=back 1610 1611=head4 Moving Around the History List 1612 1613=over 4 1614 1615=item C<history_set_pos(POS)> 1616 1617 int history_set_pos(int pos) 1618 1619=item C<previous_history> 1620 1621 str previous_history() 1622 1623=item C<next_history> 1624 1625 str next_history() 1626 1627=back 1628 1629=head4 Searching the History List 1630 1631=over 4 1632 1633=item C<history_search(STRING [,DIRECTION])> 1634 1635 int history_search(str string, int direction = -1) 1636 1637=item C<history_search_prefix(STRING [,DIRECTION])> 1638 1639 int history_search_prefix(str string, int direction = -1) 1640 1641=item C<history_search_pos(STRING [,DIRECTION [,POS]])> 1642 1643 int history_search_pos(str string, 1644 int direction = -1, 1645 int pos = where_history()) 1646 1647=back 1648 1649=head4 Managing the History File 1650 1651=over 4 1652 1653=item C<ReadHistory([FILENAME [,FROM [,TO]]])> 1654 1655 int read_history(str filename = '~/.history', 1656 int from = 0, int to = -1) 1657 1658 int read_history_range(str filename = '~/.history', 1659 int from = 0, int to = -1) 1660 1661adds the contents of C<FILENAME> to the history list, a line at a 1662time. If C<FILENAME> is false, then read from F<~/.history>. Start 1663reading at line C<FROM> and end at C<TO>. If C<FROM> is omitted or 1664zero, start at the beginning. If C<TO> is omitted or less than 1665C<FROM>, then read until the end of the file. Returns true if 1666successful, or false if not. C<read_history()> is an alias of 1667C<read_history_range()>. 1668 1669=item C<WriteHistory([FILENAME])> 1670 1671 int write_history(str filename = '~/.history') 1672 1673writes the current history to C<FILENAME>, overwriting C<FILENAME> if 1674necessary. If C<FILENAME> is false, then write the history list to 1675F<~/.history>. Returns true if successful, or false if not. 1676 1677 1678=item C<append_history(NELEMENTS [,FILENAME])> 1679 1680 int append_history(int nelements, str filename = '~/.history') 1681 1682=item C<history_truncate_file([FILENAME [,NLINES]])> 1683 1684 int history_truncate_file(str filename = '~/.history', 1685 int nlines = 0) 1686 1687=back 1688 1689=head4 History Expansion 1690 1691=over 4 1692 1693=item C<history_expand(STRING)> 1694 1695 (int result, str expansion) history_expand(str string) 1696 1697Note that this function returns C<expansion> in the scalar context. 1698 1699=item C<get_history_event(STRING, CINDEX [,QCHAR])> 1700 1701 (str text, int cindex) = get_history_event(str string, 1702 int cindex, 1703 char qchar = '\0') 1704 1705=item C<history_tokenize(STRING)> 1706 1707 (@str) history_tokenize(str string) 1708 1709=item C<history_arg_extract(STRING, [FIRST [,LAST]])> 1710 1711 str history_arg_extract(str string, int first = 0, int last = '$') 1712 1713=back 1714 1715=head2 C<Term::ReadLine::Gnu> Variables 1716 1717Following GNU Readline/History Library variables can be accessed by a 1718Perl program. See L<GNU Readline Library 1719Manual|https://tiswww.cwru.edu/php/chet/readline/readline.html> and 1720L<GNU History Library 1721Manual|https://tiswww.cwru.edu/php/chet/readline/history.html> for 1722details of each variable. You can access them by using C<Attribs> 1723methods. Names of keys in this hash conform to standard conventions 1724with the leading C<rl_> stripped. 1725 1726Examples: 1727 1728 $attribs = $term->Attribs; 1729 $v = $attribs->{library_version}; # rl_library_version 1730 $v = $attribs->{history_base}; # history_base 1731 1732=head3 Readline Variables 1733 1734 str rl_line_buffer 1735 int rl_point 1736 int rl_end 1737 int rl_mark 1738 int rl_done 1739 int rl_num_chars_to_read (GRL 4.1) 1740 int rl_pending_input 1741 int rl_dispatching 1742 int rl_erase_empty_line (GRL 4.0) 1743 str rl_prompt (read only) 1744 str rl_display_prompt 1745 int rl_already_prompted (GRL 4.1) 1746 str rl_library_version (read only) 1747 int rl_readline_version (read only) 1748 int rl_gnu_readline_p (GRL 4.1, read only) 1749 str rl_terminal_name 1750 str rl_readline_name 1751 filehandle rl_instream 1752 filehandle rl_outstream 1753 int rl_prefer_env_winsize (GRL 5.1) 1754 pfunc rl_last_func (GRL 4.2, read only) 1755 pfunc rl_startup_hook 1756 pfunc rl_pre_input_hook (GRL 4.0) 1757 pfunc rl_event_hook 1758 pfunc rl_getc_function 1759 pfunc rl_signal_event_hook (GRL 6.3) 1760 pfunc rl_input_available_hook (GRL 6.3) 1761 pfunc rl_redisplay_function 1762 pfunc rl_prep_term_function (GRL 2.1) 1763 pfunc rl_deprep_term_function (GRL 2.1) 1764 Keymap rl_executing_keymap (read only) 1765 Keymap rl_binding_keymap (read only) 1766 str rl_executing_macro (GRL 4.2, read only) 1767 int rl_executing_key (GRL 6.3, read only) 1768 str rl_executing_keyseq (GRL 6.3, read only) 1769 int rl_key_sequence_length (read only) 1770 int rl_readline_state (GRL 4.2) 1771 int rl_explicit_arg (read only) 1772 int rl_numeric_arg (read only) 1773 int rl_editing_mode (read only) 1774 1775=head3 Signal Handling Variables 1776 1777 int rl_catch_signals (GRL 4.0) 1778 int rl_catch_sigwinch (GRL 4.0) 1779 int rl_persistent_signal_handlers (GRL 7.0) 1780 int rl_change_environment (GRL 6.3) 1781 1782=head3 Completion Variables 1783 1784 pfunc rl_completion_entry_function 1785 pfunc rl_attempted_completion_function 1786 pfunc rl_filename_quoting_function 1787 pfunc rl_filename_dequoting_function 1788 pfunc rl_char_is_quoted_p 1789 pfunc rl_ignore_some_completions_function 1790 pfunc rl_directory_completion_hook 1791 pfunc rl_directory_rewrite_hook (GRL 4.2) 1792 pfunc rl_filename_stat_hook (GRL 6.3) 1793 pfunc rl_filename_rewrite_hook (GRL 6.1) 1794 pfunc rl_completion_display_matches_hook (GRL 4.0) 1795 str rl_basic_word_break_characters 1796 str rl_basic_quote_characters 1797 str rl_completer_word_break_characters 1798 pfunc rl_completion_word_break_hook (GRL 5.0) 1799 str rl_completer_quote_characters 1800 str rl_filename_quote_characters 1801 str rl_special_prefixes 1802 int rl_completion_query_items 1803 int rl_completion_append_character 1804 int rl_completion_suppress_append (GRL 4.3) 1805 int rl_completion_quote_character (GRL 5.0, read only) 1806 int rl_completion_suppress_quote (GRL 5.0) 1807 int rl_completion_found_quote (GRL 5.0, read only) 1808 int rl_completion_mark_symlink_dirs (GRL 4.3) 1809 int rl_ignore_completion_duplicates 1810 int rl_filename_completion_desired 1811 int rl_filename_quoting_desired 1812 int rl_attempted_completion_over 1813 int rl_sort_completion_matches (GRL 6.0) 1814 int rl_completion_type (read only) 1815 int rl_completion_invoking_key (GRL 6.0, read only) 1816 int rl_inhibit_completion 1817 1818=head3 History Variables 1819 1820 int history_base 1821 int history_length 1822 int history_max_entries (called `max_input_history', read only) 1823 int history_write_timestamps (GRL 5.0) 1824 char history_expansion_char 1825 char history_subst_char 1826 char history_comment_char 1827 str history_word_delimiters (GRL 4.2) 1828 str history_search_delimiter_chars 1829 str history_no_expand_chars 1830 int history_quotes_inhibit_expansion 1831 int history_quoting_state 1832 pfunc history_inhibit_expansion_function 1833 1834=head3 Function References 1835 1836 rl_getc 1837 rl_redisplay 1838 rl_callback_read_char 1839 rl_display_match_list 1840 rl_filename_completion_function 1841 rl_username_completion_function 1842 list_completion_function 1843 shadow_redisplay 1844 Tk_getc 1845 1846=head2 Custom Completion 1847 1848In this section variables and functions for custom completion are 1849described along with examples. 1850 1851Most of descriptions in this section came from L<GNU Readline 1852Library 1853Manual|https://tiswww.cwru.edu/php/chet/readline/readline.html>. 1854 1855=over 4 1856 1857=item C<completion_entry_function> 1858 1859This variable holds reference refers to a generator function for 1860C<completion_matches()>. 1861 1862A generator function is called repeatedly from 1863C<completion_matches()>, returning a string each time. The arguments 1864to the generator function are C<TEXT> and C<STATE>. C<TEXT> is the 1865partial word to be completed. C<STATE> is zero the first time the 1866function is called, allowing the generator to perform any necessary 1867initialization, and a positive non-zero integer for each subsequent 1868call. When the generator function returns C<undef> this signals 1869C<completion_matches()> that there are no more possibilities left. 1870 1871If this variable set to undef, built-in C<filename_completion_function> is 1872used. 1873 1874A sample generator function, C<list_completion_function>, is defined 1875in Gnu.pm. You can use it as follows; 1876 1877 use Term::ReadLine; 1878 ... 1879 my $term = new Term::ReadLine 'sample'; 1880 my $attribs = $term->Attribs; 1881 ... 1882 $attribs->{completion_entry_function} = 1883 $attribs->{list_completion_function}; 1884 ... 1885 $attribs->{completion_word} = 1886 [qw(reference to a list of words which you want to use for completion)]; 1887 $term->readline("custom completion>"); 1888 1889See also C<completion_matches>. 1890 1891=item C<attempted_completion_function> 1892 1893A reference to an alternative function to create matches. 1894 1895The function is called with C<TEXT>, C<LINE_BUFFER>, C<START>, and 1896C<END>. C<LINE_BUFFER> is a current input buffer string. C<START> 1897and C<END> are indices in C<LINE_BUFFER> saying what the boundaries of 1898C<TEXT> are. 1899 1900If this function exists and returns null list or C<undef>, or if this 1901variable is set to C<undef>, then an internal function 1902C<rl_complete()> will call the value of 1903C<completion_entry_function> to generate matches, otherwise the 1904array of strings returned will be used. 1905 1906The default value of this variable is C<undef>. You can use it as follows; 1907 1908 use Term::ReadLine; 1909 ... 1910 my $term = new Term::ReadLine 'sample'; 1911 my $attribs = $term->Attribs; 1912 ... 1913 sub sample_completion { 1914 my ($text, $line, $start, $end) = @_; 1915 # If first word then username completion, else filename completion 1916 if (substr($line, 0, $start) =~ /^\s*$/) { 1917 return $term->completion_matches($text, 1918 $attribs->{'username_completion_function'}); 1919 } else { 1920 return (); 1921 } 1922 } 1923 ... 1924 $attribs->{attempted_completion_function} = \&sample_completion; 1925 1926=item C<completion_matches(TEXT, ENTRY_FUNC)> 1927 1928Returns an array of strings which is a list of completions for 1929C<TEXT>. If there are no completions, returns C<undef>. The first 1930entry in the returned array is the substitution for C<TEXT>. The 1931remaining entries are the possible completions. 1932 1933C<ENTRY_FUNC> is a generator function which has two arguments, and 1934returns a string. The first argument is C<TEXT>. The second is a 1935state argument; it is zero on the first call, and non-zero on 1936subsequent calls. C<ENTRY_FUNC> returns C<undef> to the caller when 1937there are no more matches. 1938 1939If the value of C<ENTRY_FUNC> is undef, built-in 1940C<filename_completion_function> is used. 1941 1942C<completion_matches> is a Perl wrapper function of an internal 1943function C<completion_matches()>. See also 1944C<completion_entry_function>. 1945 1946=item C<completion_function> 1947 1948A variable whose content is a reference to a function which returns a 1949list of candidates to complete. 1950 1951This variable is compatible with L<Term::ReadLine::Perl|http://search.cpan.org/dist/Term-ReadLine-Perl/> and very easy 1952to use. 1953 1954 use Term::ReadLine; 1955 ... 1956 my $term = new Term::ReadLine 'sample'; 1957 my $attribs = $term->Attribs; 1958 ... 1959 $attribs->{completion_function} = sub { 1960 my ($text, $line, $start) = @_; 1961 return qw(a list of candidates to complete); 1962 }; 1963 1964=item C<list_completion_function(TEXT, STATE)> 1965 1966A sample generator function defined by C<Term::ReadLine::Gnu>. 1967Example code at C<completion_entry_function> shows how to use this 1968function. 1969 1970=back 1971 1972=head2 C<Term::ReadLine::Gnu> Specific Features 1973 1974=head3 C<Term::ReadLine::Gnu> Specific Functions 1975 1976=over 4 1977 1978=item C<CallbackHandlerInstall(PROMPT, LHANDLER)> 1979 1980This method provides the function C<rl_callback_handler_install()> 1981with the following additional feature compatible with C<readline> 1982method; ornament feature, L<Term::ReadLine::Perl|http://search.cpan.org/dist/Term-ReadLine-Perl/> compatible 1983completion function, history expansion, and addition to history 1984buffer. 1985 1986=item C<call_function(FUNCTION, [COUNT [,KEY]])> 1987 1988 int rl_call_function(FunctionPtr|str function, count = 1, key = -1) 1989 1990=item C<get_all_function_names> 1991 1992Returns a list of all function names. 1993 1994=item C<shadow_redisplay> 1995 1996A redisplay function for password input. You can use it as follows; 1997 1998 $attribs->{redisplay_function} = $attribs->{shadow_redisplay}; 1999 $line = $term->readline("password> "); 2000 2001=item C<filename_list> 2002 2003Returns candidates of filenames to complete. This function can be used 2004with C<completion_function> and is implemented for the compatibility 2005with L<Term::ReadLine::Perl|http://search.cpan.org/dist/Term-ReadLine-Perl/>. 2006 2007=item C<list_completion_function> 2008 2009See the description of section L<"Custom Completion"|"Custom Completion">. 2010 2011=back 2012 2013=head3 C<Term::ReadLine::Gnu> Specific Variables 2014 2015=over 4 2016 2017=item C<do_expand> 2018 2019When true, the history expansion is enabled. By default false. 2020 2021=item C<completion_function> 2022 2023See the description of section L<"Custom Completion"|"Custom Completion">. 2024 2025=item C<completion_word> 2026 2027A reference to a list of candidates to complete for 2028C<list_completion_function>. 2029 2030=back 2031 2032=head3 C<Term::ReadLine::Gnu> Specific Commands 2033 2034=over 4 2035 2036=item C<history-expand-line> 2037 2038The equivalent of the Bash C<history-expand-line> editing command. 2039 2040=item C<operate-and-get-next> 2041 2042The equivalent of the Korn shell C<operate-and-get-next-history-line> 2043editing command and the Bash C<operate-and-get-next>. 2044 2045This command is bound to C<\C-o> by default for the compatibility with 2046the Bash and L<Term::ReadLine::Perl|http://search.cpan.org/dist/Term-ReadLine-Perl/>. 2047 2048=item C<display-readline-version> 2049 2050Shows the version of C<Term::ReadLine::Gnu> and the one of the GNU 2051Readline Library. 2052 2053=item C<change-ornaments> 2054 2055Change ornaments interactively. 2056 2057=back 2058 2059=head1 FILES 2060 2061=over 4 2062 2063=item F<~/.inputrc> 2064 2065Readline init file. Using this file it is possible that you would 2066like to use a different set of key bindings. When a program which 2067uses the GNU Readline library starts up, the init file is read, and 2068the key bindings are set. 2069 2070The conditional init constructs is supported. The program name which is 2071specified by the first argument of C<new> method is used as the 2072application construct. 2073 2074For example, when your program calls C<new> method as follows; 2075 2076 ... 2077 $term = new Term::ReadLine 'PerlSh'; 2078 ... 2079 2080your F<~/.inputrc> can define key bindings only for the program as 2081follows; 2082 2083 ... 2084 $if PerlSh 2085 Meta-Rubout: backward-kill-word 2086 "\C-x\C-r": re-read-init-file 2087 "\e[11~": "Function Key 1" 2088 $endif 2089 ... 2090 2091For further details, see the section "Readline Init File" in the L<GNU 2092Readline Library 2093Manual|https://tiswww.cwru.edu/php/chet/readline/readline.html> 2094 2095=back 2096 2097=head1 EXPORTS 2098 2099No symbols are exported by default. 2100The following tags are defined and their symbols can be exported. 2101 2102=over 4 2103 2104=item prompt 2105 2106RL_PROMPT_START_IGNORE RL_PROMPT_END_IGNORE 2107 2108=item match_type 2109 2110NO_MATCH SINGLE_MATCH MULT_MATCH 2111 2112=item keymap_type 2113 2114ISFUNC ISKMAP ISMACR 2115 2116=item undo_code 2117 2118UNDO_DELETE UNDO_INSERT UNDO_BEGIN UNDO_END 2119 2120=item rl_state 2121 2122RL_STATE_NONE RL_STATE_INITIALIZING 2123RL_STATE_INITIALIZED RL_STATE_TERMPREPPED 2124RL_STATE_READCMD RL_STATE_METANEXT 2125RL_STATE_DISPATCHING RL_STATE_MOREINPUT 2126RL_STATE_ISEARCH RL_STATE_NSEARCH 2127RL_STATE_SEARCH RL_STATE_NUMERICARG 2128RL_STATE_MACROINPUT RL_STATE_MACRODEF 2129RL_STATE_OVERWRITE RL_STATE_COMPLETING 2130RL_STATE_SIGHANDLER RL_STATE_UNDOING 2131RL_STATE_INPUTPENDING RL_STATE_TTYCSAVED 2132RL_STATE_CALLBACK RL_STATE_VIMOTION 2133RL_STATE_MULTIKEY RL_STATE_VICMDONCE 2134RL_STATE_CHARSEARCH RL_STATE_REDISPLAYING 2135RL_STATE_DONE 2136 2137=back 2138 2139They can be exported as follows; 2140 2141 use Term::ReadLine; 2142 BEGIN { 2143 import Term::ReadLine::Gnu qw(:keymap_type RL_STATE_INITIALIZED); 2144 } 2145 2146=head1 ENVIRONMENT 2147 2148The environment variable C<PERL_RL> governs which ReadLine clone is 2149loaded. See the ENVIRONMENT section on 2150L<Term::ReadLine|http://search.cpan.org/dist/Term-ReadLine/> for 2151further details. 2152 2153=head1 SEE ALSO 2154 2155=over 4 2156 2157=item L<Term::ReadLine::Gnu Project Home Page|https://github.com/hirooih/perl-trg> 2158 2159=item L<GNU Readline Library Manual|https://tiswww.cwru.edu/php/chet/readline/readline.html> 2160 2161=item L<GNU History Library Manual|https://tiswww.cwru.edu/php/chet/readline/history.html> 2162 2163=item Sample and test programs (F<eg/*> and F<t/*>) in L<the C<Term::ReadLine::Gnu> distribution|http://search.cpan.org/dist/Term-ReadLine-Gnu/> 2164 2165=item L<Term::ReadLine|http://search.cpan.org/dist/Term-ReadLine/> 2166 2167=item Works which use Term::ReadLine::Gnu 2168 2169=over 4 2170 2171=item Distributions which depend on Term::ReadLine::Gnu on L<CPAN|http://www.cpan.org/> 2172 2173L<https://metacpan.org/requires/distribution/Term-ReadLine-Gnu> 2174 2175=item L<Perl Debugger|http://perldoc.perl.org/perldebug.html> 2176 2177 perl -d 2178 2179=item L<Perl Shell (psh)|http://gnp.github.io/psh/> 2180 2181The Perl Shell is a shell that combines the interactive nature of a 2182Unix shell with the power of Perl. 2183 2184A programmable completion feature compatible with bash is implemented. 2185 2186=item L<SPP (Synopsys Plus Perl)|http://vlsiweb.stanford.edu/~jsolomon/SPP/> 2187 2188SPP (Synopsys Plus Perl) is a Perl module that wraps around Synopsys' 2189shell programs. SPP is inspired by the original dc_perl written by 2190Steve Golson, but it's an entirely new implementation. Why is it 2191called SPP and not dc_perl? Well, SPP was written to wrap around any 2192of Synopsys' shells. 2193 2194=item L<PFM (Personal File Manager for UnixE<sol>Linux)|http://p-f-m.sourceforge.net/> 2195 2196Pfm is a terminal-based file manager written in Perl, based on PFM.COM 2197for MS-DOS (originally by Paul Culley and Henk de Heer). 2198 2199=item L<The soundgrab|https://sourceforge.net/projects/soundgrab/> 2200 2201soundgrab is designed to help you slice up a big long raw audio file 2202(by default 44.1 kHz 2 channel signed sixteen bit little endian) and 2203save your favorite sections to other files. It does this by providing 2204you with a cassette player like command line interface. 2205 2206=item L<PDL (The Perl Data Language)|http://pdl.perl.org/> 2207 2208PDL (``Perl Data Language'') gives standard Perl the ability to 2209compactly store and speedily manipulate the large N-dimensional data 2210arrays which are the bread and butter of scientific computing. 2211 2212=item L<PIQT (Perl Interactive DBI Query Tool)|http://piqt.sourceforge.net/> 2213 2214PIQT is an interactive query tool using the Perl DBI database 2215interface. It supports ReadLine, provides a built in scripting language 2216with a Lisp like syntax, an online help system, and uses wrappers to 2217interface to the DBD modules. 2218 2219=item L<vshnu (the New Visual Shell)|http://www.cs.indiana.edu/~kinzler/vshnu/> 2220 2221A visual shell and CLI shell supplement. 2222 2223=back 2224 2225If you know any other works you recommend, please let me know. 2226 2227=back 2228 2229=head1 AUTHOR 2230 2231Hiroo Hayashi C<E<lt>hiroo.hayashi@computer.orgE<gt>> 2232 2233L<http://search.cpan.org/~hayashi/> 2234 2235=head1 TODO 2236 2237GTK+ support in addition to Tk. 2238 2239=head1 BUGS 2240 2241=over 4 2242 2243=item Submit a bug report to 2244L<the bug tracker on GitHub|https://github.com/hirooih/perl-trg/issues>. 2245 2246=item C<add_defun()> can define up to 16 functions. 2247 2248=item Some functions and variables do not have test code yet. Your 2249contribution is welcome. See F<t/readline.t> for details. 2250 2251=item If the pager command (| or ||) in Perl debugger causes segmentation 2252fault, you need to fix F<perl5db.pl>. See 2253L<https://rt.perl.org/Public/Bug/Display.html?id=121456> for details. 2254 2255=back 2256 2257=head1 LICENSE 2258 2259Copyright (c) 1996-2020 Hiroo Hayashi. All rights reserved. 2260 2261This program is free software; you can redistribute it and/or modify 2262it under the same terms as Perl itself. 2263 2264=cut 2265