Codebase list libterm-readline-gnu-perl / edbeb66
Imported Upstream version 1.28 gregor herrmann 8 years ago
26 changed file(s) with 595 addition(s) and 356 deletion(s). Raw diff Collapse all Expand all
00 -*- Indented-text -*-
1 $Id: Changes 468 2014-03-23 11:56:58Z hayashi $
1 $Id: Changes 498 2015-09-21 13:10:38Z hayashi $
2
3 1.28 2015-09-21
4 - Makefile.PL: revert a change on 1.27 which causes fail on
5 the rlmalloc test. [rt.cpan.org #107201]
6 - t/readline.t, t/history.t: use LC_ALL instead of LANG.
7
8 1.27 2015-09-06
9 - readline-7.0 support
10 new function
11 rl_callback_sigcleanup
12 - improve POD documents
13 - Gnu.xs: not to use obsoleted typedefs which were obsoleted
14 by ReadLine 6.3
15 - fix a wrong fix on 1.21 to let completion_function do case
16 insensitive match. [rt.cpan.org #72378]
17 - fix rl_display_match_list to show the first entry of the
18 array. The bug caused segmentation fault with readline-7.0.
19 - some improvement of Makefile.PL:
20 - add support homebrew on Mac OS X. [rt.cpan.org #104389]
21 - print an error string when system() fails.
22 - specify 'int' on 'main()'.
23 - use -O when -D_FORTIFY_SOURCE is defined.
24
25 1.26 2015-01-31
26 - call ornaments() after rl_initialize() to set tty before
27 calling rl_initialize() not to output some charactores to
28 STDIO. [rt.cpan.org #96569, #101196]
29 - make handling of iostreams simple (make _rl_store_iostream()
30 return void and remove _rl_fetch_iostream()) [rt.cpan.org #101078]
31 - fix the Prerequisites section to require Perl 5.8 (it was
32 required since TRG 1.23.).
33 - t/callback.t: add some new Tk-tests from CPAN Testers' site.
34
35 1.25 2014-12-13
36 - fix to call rl_initialize() after I/O stream
37 setting. [rt.cpan.org #96569]
38 - t/readline.t: comment-out stty-command calls.
39 - t/history.t, t/readline.t: print out the corresponding
40 section names in the manuals of the libraries.
41 - eg/perlsh: use 'IO' instead of 'FILEHANDLE' which Perl 5.20
42 warns. [rt.cpan.org #100883]
43 - fix copyright notices to use the year of first publication.
244
345 1.24 2014-03-23
446 - fix not to make the PerlIO layer empty for Perl 5.8.9 or
547 before. [rt.cpan.org #59832]
648 - update Pod document assuming the use of Pod::Simple::HTMLBatch.
7 - t/00checkver.t: not to use 'display-readline-version') and "use
49 - t/00checkver.t: not to use 'display-readline-version' and "use
850 Test;"
951 - INSTALL: add "(Install) Using Package" section.
1052
423465 the callback functions
424466
425467 0.08 Sun Apr 13 23:24:52 1997
426
427468 - bug fix: AddHistory() accepts list again.
428469 - move perlsh into eg/.
429470 - add eg/ptksh+ which demonstrates the callback functions.
433474 - internal functions, fetch_var() and store_var(), are removed.
434475
435476 0.07 Wed Mar 19 02:26:06 1997
436
437477 - interface to internal function and variables are changed.
438478 New interface is compatible with new Term::ReadLine.pm which
439479 is distributed with Perl 5.003_92 and later. But it is not
11 #
22 # XS.pm : perl function definition for Term::ReadLine::Gnu
33 #
4 # $Id: XS.pm 468 2014-03-23 11:56:58Z hayashi $
5 #
6 # Copyright (c) 2014 Hiroo Hayashi. All rights reserved.
4 # $Id: XS.pm 498 2015-09-21 13:10:38Z hayashi $
5 #
6 # Copyright (c) 1999 Hiroo Hayashi. All rights reserved.
77 #
88 # This program is free software; you can redistribute it and/or
99 # modify it under the same terms as Perl itself.
1616 use AutoLoader 'AUTOLOAD';
1717
1818 use vars qw($VERSION);
19 $VERSION='1.24'; # added for CPAN
19 $VERSION='1.28'; # added for CPAN
2020
2121 # make aliases
2222 use vars qw(%Attribs);
564564 my($text, $state) = @_;
565565
566566 my $cf;
567 return undef unless defined ($cf = $Attribs{completion_function});
567 if (not defined ($cf = $Attribs{completion_function})) {
568 carp "_trp_comletion_fuction: internal error\n";
569 return undef;
570 }
568571
569572 if ($state) {
570573 $_i++;
579582 return undef unless defined $_matches[0];
580583 }
581584
582 return $_matches[$_i];
585 for (; $_i <= $#_matches; $_i++) {
586 # case insensitive match to be compatible with
587 # Term::ReadLine::Perl.
588 # https://rt.cpan.org/Ticket/Display.html?id=72378
589 return $_matches[$_i] if ($_matches[$_i] =~ /^\Q$text/i);
590 }
591 return undef;
583592 }
584593
585594 1;
+214
-141
Gnu.pm less more
00 #
11 # Gnu.pm --- The GNU Readline/History Library wrapper module
22 #
3 # $Id: Gnu.pm 468 2014-03-23 11:56:58Z hayashi $
3 # $Id: Gnu.pm 498 2015-09-21 13:10:38Z hayashi $
44 #
5 # Copyright (c) 2014 Hiroo Hayashi. All rights reserved.
5 # Copyright (c) 1996 Hiroo Hayashi. All rights reserved.
66 #
77 # This program is free software; you can redistribute it and/or
88 # modify it under the same terms as Perl itself.
3434 Library|http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html>.
3535
3636 For basic functions object oriented interface is provided. These are
37 described in the section L<"Standard Methods"|"Standard Methods"> and
38 L<"C<Term::ReadLine::Gnu> Functions"|"C<Term::ReadLine::Gnu> Functions">.
37 described in the section L</"Standard Methods"> and
38 L</"C<Term::ReadLine::Gnu> Functions">.
3939
4040 This package also has the interface with the almost all functions and
4141 variables which are documented in the GNU Readline/History Library
4242 Manual. They are documented in the section
43 L<"C<Term::ReadLine::Gnu> Functions"|"C<Term::ReadLine::Gnu> Functions">
43 L</"C<Term::ReadLine::Gnu> Functions">
4444 and
45 L<"C<Term::ReadLine::Gnu> Variables"|"C<Term::ReadLine::Gnu>
46 Variables"> briefly. For more detail of the GNU Readline/History
45 L</"C<Term::ReadLine::Gnu>
46 Variables"> briefly. For further details of the GNU Readline/History
4747 Library, see L<GNU Readline Library
4848 Manual|http://cnswww.cns.cwru.edu/php/chet/readline/readline.html> and
4949 L<GNU History Library
5050 Manual|http://cnswww.cns.cwru.edu/php/chet/readline/history.html>.
5151
52 There are some C<Term::ReadLine::Gnu> original features. They are
53 described in the section L</"C<Term::ReadLine::Gnu> Specific
54 Features">
55
5256 The sample programs under F<eg/> directory and test programs under
5357 F<t/> directory in L<the C<Term::ReadLine::Gnu> distribution|http://search.cpan.org/dist/Term-ReadLine-Gnu/> include
54 many example of this module.
58 many examples of this module.
5559
5660 =head2 Standard Methods
5761
58 These methods are standard methods defined by
62 These are standard methods defined by
5963 L<Term::ReadLine|http://search.cpan.org/dist/Term-ReadLine/>.
6064
6165 =cut
8185 use DynaLoader;
8286 use vars qw($VERSION @ISA @EXPORT_OK);
8387
84 $VERSION = '1.24'; # update Gnu::XS::VERSION also.
88 $VERSION = '1.28'; # update Gnu::XS::VERSION also.
8589
8690 # Term::ReadLine::Gnu::AU makes a function in
8791 # `Term::ReadLine::Gnu::XS' as a method.
120124 # this hash (%Attribs). By accessing the hash entry, you can read
121125 # and/or write the variable in the GNU Readline Library. See the
122126 # package definition of Term::ReadLine::Gnu::Var and following code
123 # for more details.
127 # for further details.
124128
125129 # Normal (non-tied) entries
126130 %Attribs = (
212216
213217 =item C<ReadLine>
214218
215 returns the actual package that executes the commands. If you have
216 installed this package, possible value is C<Term::ReadLine::Gnu>.
219 returns the actual package that executes the commands. If
220 this package is being used, C<Term::ReadLine::Gnu> is returned.
217221
218222 =cut
219223
245249 # calls setenv() before the 1st assignment to $ENV{}.
246250 $ENV{_TRL_DUMMY} = '';
247251
248 # initialize the GNU Readline Library and termcap library
249 $self->initialize();
250
251 # enable ornaments to be compatible with perl5.004_05(?)
252 $self->ornaments(1) unless ($ENV{PERL_RL} and $ENV{PERL_RL} =~ /\bo\w*=0/);
253
252 # set tty before calling rl_initialize() not to output some
253 # charactores to STDIO.
254 # https://rt.cpan.org/Ticket/Display.html?id=96569
254255 if (!@_) {
255256 my ($IN,$OUT) = $self->findConsole();
256257 open(IN,"<$IN") || croak "Cannot open $IN for read";
265266 $Attribs{instream} = shift;
266267 $Attribs{outstream} = shift;
267268 }
269
270 # initialize the GNU Readline Library and termcap library
271 # This calls tgetent().
272 $self->initialize();
273
274 # enable ornaments to be compatible with perl5.004_05(?)
275 # This calls tgetstr().
276 $self->ornaments(1) unless ($ENV{PERL_RL} and $ENV{PERL_RL} =~ /\bo\w*=0/);
277
268278 $readline_version = $Attribs{readline_version};
269279
270280 $self;
283293
284294 C<PROMPT> may include some escape sequences. Use
285295 C<RL_PROMPT_START_IGNORE> to begin a sequence of non-printing
286 characters, and C<RL_PROMPT_END_IGNORE> to end of such a sequence.
296 characters, and C<RL_PROMPT_END_IGNORE> to end the sequence.
287297
288298 =cut
289299
423433 (variables) of the package. Names of keys in this hash conform to
424434 standard conventions with the leading C<rl_> stripped.
425435
426 See section "Variables" for supported variables.
436 See section L</"C<Term::ReadLine::Gnu> Variables"> for supported variables.
427437
428438 =cut
429439
455465 =cut
456466
457467 # tkRunning is defined in ReadLine.pm.
468
469 =item C<event_loop>
470
471 See the description of C<event_loop> on
472 L<Term::ReadLine|http://search.cpan.org/dist/Term-ReadLine/>.
458473
459474 =item C<ornaments>
460475
653668 rl_last_func => ['LF', 0],
654669 );
655670
671 my @stream;
672
656673 sub TIESCALAR {
657674 my $class = shift;
658675 my $name = shift;
679696 } elsif ($type eq 'F') {
680697 return _rl_fetch_function($id);
681698 } elsif ($type eq 'IO') {
682 return _rl_fetch_iostream($id);
699 # STORE was called in new() before coming here
700 return $stream[$id];
683701 } elsif ($type eq 'K') {
684702 return _rl_fetch_keymap($id);
685703 } elsif ($type eq 'LF') {
715733 } elsif ($type eq 'F') {
716734 return _rl_store_function($value, $id);
717735 } elsif ($type eq 'IO') {
736 my $FH = $value;
737 # Pass filehandles to the GNU Readline Library
738 _rl_store_iostream($value, $id);
718739 # pop stdio layer pushed by PerlIO_findFILE().
719740 # https://rt.cpan.org/Ticket/Display.html?id=59832
720 my $FH = _rl_store_iostream($value, $id);
721741 my @layers = PerlIO::get_layers($FH);
722742 #warn "$id<", join(':', @layers), "\n";
723743 binmode($FH, ":pop") if @layers > 1;
724744 #@layers = PerlIO::get_layers($FH); warn "$id>", join(':', @layers), "\n";
725 return $FH;
745 return $stream[$id] = $FH;
726746 } elsif ($type eq 'K' || $type eq 'LF') {
727747 carp "Term::ReadLine::Gnu::Var::STORE: read only variable `$name'\n";
728748 return undef;
794814
795815 =head2 C<Term::ReadLine::Gnu> Functions
796816
797 All these GNU Readline/History Library functions are callable via
817 All these GNU Readline/History Library functions supported are callable via
798818 method interface and have names which conform to standard conventions
799 with the leading C<rl_> stripped.
800
801 Almost methods have lower level functions in
802 C<Term::ReadLine::Gnu::XS> package. To use them full qualified name
803 is required. Using method interface is preferred.
804
805 =over 4
806
807 =item Readline Convenience Functions
808
809 =over 4
810
811 =item Naming Function
812
813 =over 4
814
815 =item C<add_defun(NAME, FUNC [,KEY=-1])>
816
817 Add name to the Perl function C<FUNC>. If optional argument C<KEY> is
818 specified, bind it to the C<FUNC>. Returns reference to
819 with the leading C<rl_> stripped. For example C<rl_foo()>
820 function is called as C<$term-E<gt>foo()>.
821
822 The titles of the following sections are same as the titles of the
823 corresponding sections in the "Programming with GNU Readline" section
824 in the L<GNU Readline Library
825 Manual|http://cnswww.cns.cwru.edu/php/chet/readline/readline.html>.
826 Refer them for further details.
827
828 Although it is preferred to use method interface, most methods have
829 lower level functions in
830 C<Term::ReadLine::Gnu::XS> package. To use them a full qualified name
831 is required.
832
833 =head3 Basic Behavior
834
835 The function C<readline()> prints a prompt and then reads and returns
836 a single line of text from the user.
837
838 $_ = $term->readline('Enter a line: ');
839
840 You can change key-bindings using C<bind_key(KEY, FUNCTION [,MAP])>
841 function. The first argument, C<KEY>, is the character that you want
842 bind. The second argument, C<FUNCTION>, is the function to call when
843 C<KEY> is pressed. The C<FUNCTION> can be a reference to a Perl
844 function (see L</"Custom Functions">) or a "named function" named by
845 C<add_defun()> function or commands described in the "Bindable
846 Readline Commands" section in the L<GNU Readline Library
847 Manual|http://cnswww.cns.cwru.edu/php/chet/readline/readline.html>.
848
849 $term->bind_key(ord "\ci, 'tab-insert');
850
851 The above example binds Control-I to the 'tab-insert' command.
852
853 =head3 Custom Functions
854
855 You can write new functions using Perl. The calling sequence for a
856 command foo looks like
857
858 sub foo ($count, $key) { ... }
859
860 where C<$count> is the numeric argument (or 1 if defaulted) and
861 C<$key> is the key that invoked this function.
862
863 Here is an example;
864
865 sub reverse_line { # reverse a whole line
866 my($count, $key) = @_; # ignored in this sample function
867
868 $t->modifying(0, $a->{end}); # save undo information
869 $a->{line_buffer} = reverse $a->{line_buffer};
870 }
871
872 See the "Writing a New Function" section in the L<GNU Readline Library
873 Manual|http://cnswww.cns.cwru.edu/php/chet/readline/readline.html> for
874 further details.
875
876 =head3 Readline Convenience Functions
877
878 =head4 Naming a Function
879
880 =over 4
881
882 =item C<add_defun(NAME, FUNCTION [,KEY=-1])>
883
884 Add name to a Perl function C<FUNCTION>. If optional argument C<KEY>
885 is specified, bind it to the C<FUNCTION>. Returns reference to
819886 C<FunctionPtr>.
820887
821888 Example:
822 # name name `reverse-line' to a function reverse_line(),
889 # name `reverse-line' to a function reverse_line(),
823890 # and bind it to "\C-t"
824891 $term->add_defun('reverse-line', \&reverse_line, ord "\ct");
825892
826893 =back
827894
828 =item Selecting a Keymap
895 =head4 Selecting a Keymap
829896
830897 =over 4
831898
867934
868935 =back
869936
870 =item Binding Keys
937 =head4 Binding Keys
871938
872939 =over 4
873940
927994 void rl_parse_and_bind(str line)
928995
929996 Parse C<LINE> as if it had been read from the F<~/.inputrc> file and
930 perform any key bindings and variable assignments found. For more
997 perform any key bindings and variable assignments found. For further
931998 detail see L<GNU Readline Library
932999 Manual|http://cnswww.cns.cwru.edu/php/chet/readline/readline.html>.
9331000
9371004
9381005 =back
9391006
940 =item Associating Function Names and Bindings
1007 =head4 Associating Function Names and Bindings
9411008
9421009 =over 4
9431010
9781045
9791046 =back
9801047
981 =item Allowing Undoing
1048 =head4 Allowing Undoing
9821049
9831050 =over 4
9841051
10081075
10091076 =back
10101077
1011 =item Redisplay
1078 =head4 Redisplay
10121079
10131080 =over 4
10141081
10361103
10371104 int rl_crlf()
10381105
1039 =item C<rl_show_char(C)>
1106 =item C<show_char(C)>
10401107
10411108 int rl_show_char(int c)
10421109
10661133
10671134 =back
10681135
1069 =item Modifying Text
1136 =head4 Modifying Text
10701137
10711138 =over 4
10721139
10921159
10931160 =back
10941161
1095 =item Character Input
1162 =head4 Character Input
10961163
10971164 =over 4
10981165
11221189
11231190 =back
11241191
1125 =item Terminal Management
1192 =head4 Terminal Management
11261193
11271194 =over 4
11281195
11481215
11491216 =back
11501217
1151 =item Utility Functions
1218 =head4 Utility Functions
11521219
11531220 =over 4
11541221
11921259
11931260 void rl_display_match_list(\@matches, len = $#maches, max) # GRL 4.0
11941261
1195 Since the first element of an array @matches as treated as a possible
1262 Since the first element of an array C<@matches> as treated as a possible
11961263 completion, it is not displayed. See the descriptions of
11971264 C<completion_matches()>.
1198 When C<MAX> is ommited, the max length of an item in @matches is used.
1199
1200 =back
1201
1202 =item Miscellaneous Functions
1265 When C<MAX> is omitted, the max length of an item in C<@matches> is used.
1266
1267 =back
1268
1269 =head4 Miscellaneous Functions
12031270
12041271 =over 4
12051272
12371304
12381305 =back
12391306
1240 =item Alternate Interface
1307 =head4 Alternate Interface
12411308
12421309 =over 4
12431310
12491316
12501317 void rl_callback_read_char()
12511318
1319 =item C<callback_sigcleanup> # GRL 7.0
1320
1321 void rl_callback_sigcleanup()
1322
12521323 =item C<callback_handler_remove>
12531324
12541325 void rl_callback_handler_remove()
12551326
12561327 =back
12571328
1258 =back
1259
1260 =item Readline Signal Handling
1329 =head3 Readline Signal Handling
12611330
12621331 =over 4
12631332
13031372
13041373 =back
13051374
1306 =item Completion Functions
1375 =head3 Completion Functions
13071376
13081377 =over 4
13091378
13341403
13351404 =back
13361405
1337 =item History Functions
1338
1339 =over 4
1340
1341 =item Initializing History and State Management
1406 =head3 History Functions
1407
1408 =head4 Initializing History and State Management
13421409
13431410 =over 4
13441411
13581425
13591426 =back
13601427
1361 =item History List Management
1428 =head4 History List Management
13621429
13631430 =over 4
13641431
13941461
13951462 stifles the history list, remembering only the last C<MAX> entries.
13961463 If C<MAX> is undef, remembers all entries. This is a replacement
1397 of unstifle_history().
1464 of C<unstifle_history()>.
13981465
13991466 =item C<unstifle_history>
14001467
14011468 int unstifle_history()
14021469
1403 This is equivalent with 'stifle_history(undef)'.
1470 This is equivalent with C<stifle_history(undef)>.
14041471
14051472 =item C<SetHistory(LINE1 [, LINE2, ...])>
14061473
14131480
14141481 =back
14151482
1416 =item Information About the History List
1483 =head4 Information About the History List
14171484
14181485 =over 4
14191486
14481515
14491516 =back
14501517
1451 =item Moving Around the History List
1518 =head4 Moving Around the History List
14521519
14531520 =over 4
14541521
14661533
14671534 =back
14681535
1469 =item Searching the History List
1536 =head4 Searching the History List
14701537
14711538 =over 4
14721539
14861553
14871554 =back
14881555
1489 =item Managing the History File
1556 =head4 Managing the History File
14901557
14911558 =over 4
14921559
15031570 reading at line C<FROM> and end at C<TO>. If C<FROM> is omitted or
15041571 zero, start at the beginning. If C<TO> is omitted or less than
15051572 C<FROM>, then read until the end of the file. Returns true if
1506 successful, or false if not. C<read_history()> is an aliase of
1573 successful, or false if not. C<read_history()> is an alias of
15071574 C<read_history_range()>.
15081575
15091576 =item C<WriteHistory([FILENAME])>
15261593
15271594 =back
15281595
1529 =item History Expansion
1596 =head4 History Expansion
15301597
15311598 =over 4
15321599
15341601
15351602 (int result, str expansion) history_expand(str line)
15361603
1537 Note that this function returns C<expansion> in scalar context.
1604 Note that this function returns C<expansion> in the scalar context.
15381605
15391606 =item C<get_history_event(STRING, CINDEX [,QCHAR])>
15401607
15491616 =item C<history_arg_extract(LINE, [FIRST [,LAST]])>
15501617
15511618 str history_arg_extract(str line, int first = 0, int last = '$')
1552
1553 =back
1554
1555 =back
15561619
15571620 =back
15581621
15631626 Manual|http://cnswww.cns.cwru.edu/php/chet/readline/readline.html> and
15641627 L<GNU History Library
15651628 Manual|http://cnswww.cns.cwru.edu/php/chet/readline/history.html> for
1566 details of each variable. You can access them with C<Attribs>
1629 details of each variable. You can access them by using C<Attribs>
15671630 methods. Names of keys in this hash conform to standard conventions
15681631 with the leading C<rl_> stripped.
15691632
15731636 $v = $attribs->{library_version}; # rl_library_version
15741637 $v = $attribs->{history_base}; # history_base
15751638
1576 =over 4
1577
1578 =item Readline Variables
1639 =head3 Readline Variables
15791640
15801641 str rl_line_buffer
15811642 int rl_point
16181679 int rl_numeric_arg (read only)
16191680 int rl_editing_mode (read only)
16201681
1621 =item Signal Handling Variables
1682 =head3 Signal Handling Variables
16221683
16231684 int rl_catch_signals (GRL 4.0)
16241685 int rl_catch_sigwinch (GRL 4.0)
16251686 int rl_change_environment (GRL 6.3)
16261687
1627 =item Completion Variables
1688 =head3 Completion Variables
16281689
16291690 pfunc rl_completion_entry_function
16301691 pfunc rl_attempted_completion_function
16601721 int rl_completion_invoking_key (GRL 6.0, read only)
16611722 int rl_inhibit_completion
16621723
1663 =item History Variables
1724 =head3 History Variables
16641725
16651726 int history_base (read only)
16661727 int history_length (read only)
16751736 int history_quotes_inhibit_expansion
16761737 pfunc history_inhibit_expansion_function
16771738
1678 =item Function References
1739 =head3 Function References
16791740
16801741 rl_getc
16811742 rl_redisplay
16871748 shadow_redisplay
16881749 Tk_getc
16891750
1690 =back
1691
16921751 =head2 Custom Completion
16931752
16941753 In this section variables and functions for custom completion are
1695 described with examples.
1696
1697 Most of descriptions in this section are cited from L<GNU Readline
1754 described along with examples.
1755
1756 Most of descriptions in this section came from L<GNU Readline
16981757 Library
16991758 Manual|http://cnswww.cns.cwru.edu/php/chet/readline/readline.html>.
17001759
17011760 =over 4
17021761
1703 =item C<rl_completion_entry_function>
1762 =item C<completion_entry_function>
17041763
17051764 This variable holds reference refers to a generator function for
17061765 C<completion_matches()>.
17141773 call. When the generator function returns C<undef> this signals
17151774 C<completion_matches()> that there are no more possibilities left.
17161775
1717 If the value is undef, built-in C<filename_completion_function> is
1776 If this variable set to undef, built-in C<filename_completion_function> is
17181777 used.
17191778
17201779 A sample generator function, C<list_completion_function>, is defined
17341793
17351794 See also C<completion_matches>.
17361795
1737 =item C<rl_attempted_completion_function>
1796 =item C<attempted_completion_function>
17381797
17391798 A reference to an alternative function to create matches.
17401799
17461805 If this function exists and returns null list or C<undef>, or if this
17471806 variable is set to C<undef>, then an internal function
17481807 C<rl_complete()> will call the value of
1749 C<$rl_completion_entry_function> to generate matches, otherwise the
1808 C<completion_entry_function> to generate matches, otherwise the
17501809 array of strings returned will be used.
17511810
17521811 The default value of this variable is C<undef>. You can use it as follows;
17791838 C<ENTRY_FUNC> is a generator function which has two arguments, and
17801839 returns a string. The first argument is C<TEXT>. The second is a
17811840 state argument; it is zero on the first call, and non-zero on
1782 subsequent calls. C<ENTRY_FUNC> returns a C<undef> to the caller when
1841 subsequent calls. C<ENTRY_FUNC> returns C<undef> to the caller when
17831842 there are no more matches.
17841843
17851844 If the value of C<ENTRY_FUNC> is undef, built-in
17871846
17881847 C<completion_matches> is a Perl wrapper function of an internal
17891848 function C<completion_matches()>. See also
1790 C<$rl_completion_entry_function>.
1849 C<completion_entry_function>.
17911850
17921851 =item C<completion_function>
17931852
17941853 A variable whose content is a reference to a function which returns a
17951854 list of candidates to complete.
17961855
1797 This variable is compatible with C<Term::ReadLine::Perl> and very easy
1856 This variable is compatible with L<Term::ReadLine::Perl|http://search.cpan.org/dist/Term-ReadLine-Perl/> and very easy
17981857 to use.
17991858
18001859 use Term::ReadLine;
18051864 $attribs->{completion_function} = sub {
18061865 my ($text, $line, $start) = @_;
18071866 return qw(a list of candidates to complete);
1808 }
1867 };
18091868
18101869 =item C<list_completion_function(TEXT, STATE)>
18111870
18121871 A sample generator function defined by C<Term::ReadLine::Gnu>.
1813 Example code at C<rl_completion_entry_function> shows how to use this
1872 Example code at C<completion_entry_function> shows how to use this
18141873 function.
18151874
18161875 =back
18171876
18181877 =head2 C<Term::ReadLine::Gnu> Specific Features
18191878
1820 =over 4
1821
1822 =item C<Term::ReadLine::Gnu> Specific Functions
1879 =head3 C<Term::ReadLine::Gnu> Specific Functions
18231880
18241881 =over 4
18251882
18261883 =item C<CallbackHandlerInstall(PROMPT, LHANDLER)>
18271884
18281885 This method provides the function C<rl_callback_handler_install()>
1829 with the following addtional feature compatible with C<readline>
1830 method; ornament feature, C<Term::ReadLine::Perl> compatible
1831 completion function, histroy expansion, and addition to history
1886 with the following additional feature compatible with C<readline>
1887 method; ornament feature, L<Term::ReadLine::Perl|http://search.cpan.org/dist/Term-ReadLine-Perl/> compatible
1888 completion function, history expansion, and addition to history
18321889 buffer.
18331890
18341891 =item C<call_function(FUNCTION, [COUNT [,KEY]])>
18351892
18361893 int rl_call_function(FunctionPtr|str function, count = 1, key = -1)
18371894
1838 =item C<rl_get_all_function_names>
1895 =item C<get_all_function_names>
18391896
18401897 Returns a list of all function names.
18411898
18461903 $attribs->{redisplay_function} = $attribs->{shadow_redisplay};
18471904 $line = $term->readline("password> ");
18481905
1849 =item C<rl_filename_list>
1850
1851 Returns candidates of filename to complete. This function can be used
1906 =item C<filename_list>
1907
1908 Returns candidates of filenames to complete. This function can be used
18521909 with C<completion_function> and is implemented for the compatibility
1853 with C<Term::ReadLine::Perl>.
1910 with L<Term::ReadLine::Perl|http://search.cpan.org/dist/Term-ReadLine-Perl/>.
18541911
18551912 =item C<list_completion_function>
18561913
18581915
18591916 =back
18601917
1861 =item C<Term::ReadLine::Gnu> Specific Variables
1918 =head3 C<Term::ReadLine::Gnu> Specific Variables
18621919
18631920 =over 4
18641921
18771934
18781935 =back
18791936
1880 =item C<Term::ReadLine::Gnu> Specific Commands
1937 =head3 C<Term::ReadLine::Gnu> Specific Commands
18811938
18821939 =over 4
18831940
18911948 editing command and the Bash C<operate-and-get-next>.
18921949
18931950 This command is bound to C<\C-o> by default for the compatibility with
1894 the Bash and C<Term::ReadLine::Perl>.
1951 the Bash and L<Term::ReadLine::Perl|http://search.cpan.org/dist/Term-ReadLine-Perl/>.
18951952
18961953 =item C<display-readline-version>
18971954
19011958 =item C<change-ornaments>
19021959
19031960 Change ornaments interactively.
1904
1905 =back
19061961
19071962 =back
19081963
19171972 uses the GNU Readline library starts up, the init file is read, and
19181973 the key bindings are set.
19191974
1920 Conditional key binding is also available. The program name which is
1975 The conditional init constructs is supported. The program name which is
19211976 specified by the first argument of C<new> method is used as the
19221977 application construct.
19231978
1924 For example, when your program call C<new> method like this;
1979 For example, when your program calls C<new> method as follows;
19251980
19261981 ...
19271982 $term = new Term::ReadLine 'PerlSh';
19281983 ...
19291984
1930 your F<~/.inputrc> can define key bindings only for it as follows;
1985 your F<~/.inputrc> can define key bindings only for the program as
1986 follows;
19311987
19321988 ...
19331989 $if PerlSh
19371993 $endif
19381994 ...
19391995
1996 For further details, see the section "Readline Init File" in the L<GNU
1997 Readline Library
1998 Manual|http://cnswww.cns.cwru.edu/php/chet/readline/readline.html>
1999
19402000 =back
19412001
19422002 =head1 EXPORTS
19432003
19442004 None.
19452005
2006 =head1 ENVIRONMENT
2007
2008 The environment variable C<PERL_RL> governs which ReadLine clone is
2009 loaded. See the ENVIRONMENT section on
2010 L<Term::ReadLine|http://search.cpan.org/dist/Term-ReadLine/> for
2011 further details.
2012
19462013 =head1 SEE ALSO
19472014
19482015 =over 4
19602027 =item Works which use Term::ReadLine::Gnu
19612028
19622029 =over 4
2030
2031 =item Distributions which depend on Term::ReadLine::Gnu on L<CPAN|http://www.cpan.org/>
2032
2033 L<https://metacpan.org/requires/distribution/Term-ReadLine-Gnu>
19632034
19642035 =item L<Perl Debugger|http://perldoc.perl.org/perldebug.html>
19652036
20092080
20102081 A visual shell and CLI shell supplement.
20112082
2012 =item Distributions which depend on Term::ReadLine::Gnu on L<CPAN|http://www.cpan.org/>
2013
2014 L<https://metacpan.org/requires/distribution/Term-ReadLine-Gnu>
2015
2016 =back
2017
2018 If you know any other works which can be listed here, please let me
2019 know.
2083 =back
2084
2085 If you know any other works you recommend, please let me know.
20202086
20212087 =back
20222088
20322098
20332099 =head1 BUGS
20342100
2035 C<rl_add_defun()> can define up to 16 functions.
2036
2037 Some functions and variables do not have test code yet. Your
2101 =over 4
2102
2103 =item Submit a bug report to
2104 L<rt.cpan.org|https://rt.cpan.org/Dist/Display.html?Name=Term-ReadLine-Gnu>.
2105
2106 =item C<add_defun()> can define up to 16 functions.
2107
2108 =item Some functions and variables do not have test code yet. Your
20382109 contribution is welcome. See F<t/readline.t> for details.
20392110
2040 If the pager command (| or ||) in Perl debugger causes segmentation
2111 =item If the pager command (| or ||) in Perl debugger causes segmentation
20412112 fault, you need to fix F<perl5db.pl>. See
20422113 L<https://rt.perl.org/Public/Bug/Display.html?id=121456> for details.
20432114
2115 =back
2116
20442117 =head1 LICENSE
20452118
2046 Copyright (c) 2014 Hiroo Hayashi. All rights reserved.
2119 Copyright (c) 1996 Hiroo Hayashi. All rights reserved.
20472120
20482121 This program is free software; you can redistribute it and/or modify
20492122 it under the same terms as Perl itself.
00 /*
11 * Gnu.xs --- GNU Readline wrapper module
22 *
3 * $Id: Gnu.xs 446 2014-03-01 16:17:57Z hayashi $
3 * $Id: Gnu.xs 493 2015-09-06 05:03:42Z hayashi $
44 *
5 * Copyright (c) 2014 Hiroo Hayashi. All rights reserved.
5 * Copyright (c) 1996 Hiroo Hayashi. All rights reserved.
66 *
77 * This program is free software; you can redistribute it and/or
88 * modify it under the same terms as Perl itself.
8181 typedef void rl_vcppfunc_t PARAMS((char **));
8282
8383 /* rl_last_func() is defined in rlprivate.h */
84 extern Function *rl_last_func;
84 extern rl_command_func_t *rl_last_func;
8585 #endif /* (RL_READLINE_VERSION < 0x0402) */
8686
87 #if (RL_READLINE_VERSION >= 0x0603)
88 /* obsoleted by Readline 6.3 */
89 typedef int Function ();
90 typedef void VFunction ();
91 typedef char *CPFunction ();
92 typedef char **CPPFunction ();
93 #endif /* (RL_READLINE_VERSION >= 0x0603) */
87 #if (RL_READLINE_VERSION < 0x0500)
88 typedef char *rl_cpvfunc_t PARAMS((void));
89 #endif /* (RL_READLINE_VERSION < 0x0500) */
90
9491
9592 #if (RL_READLINE_VERSION < 0x0201)
9693 /* features introduced by GNU Readline 2.1 */
97 static VFunction *rl_prep_term_function;
98 static VFunction *rl_deprep_term_function;
94 static rl_vintfunc_t *rl_prep_term_function;
95 static rl_voidfunc_t *rl_deprep_term_function;
9996 #endif /* (RL_READLINE_VERSION < 0x0201) */
10097
10198 #if (RL_READLINE_VERSION < 0x0202)
136133 /* documented by Readline 4.0 but already implemented since 2.0 or 2.1. */
137134 extern void rl_extend_line_buffer PARAMS((int));
138135 extern char **rl_funmap_names PARAMS((void));
139 extern int rl_add_funmap_entry PARAMS((CONST char *, Function *));
136 extern int rl_add_funmap_entry PARAMS((CONST char *, rl_command_func_t *));
140137 extern void rl_prep_terminal PARAMS((int));
141138 extern void rl_deprep_terminal PARAMS((void));
142139 extern int rl_execute_next PARAMS((int));
144141 /* features introduced by GNU Readline 4.0 */
145142 /* dummy variable/function definition */
146143 static int rl_erase_empty_line = 0;
147 static Function *rl_pre_input_hook;
144 static rl_hook_func_t *rl_pre_input_hook;
148145 static int rl_catch_signals = 1;
149146 static int rl_catch_sigwinch = 1;
150 static VFunction *rl_completion_display_matches_hook;
147 static rl_compdisp_func_t *rl_completion_display_matches_hook;
151148
152149 static void rl_display_match_list(){}
153150 static void rl_cleanup_after_signal(){}
186183 static int rl_alphabetic(){ return 0; }
187184 static int rl_set_paren_blink_timeout(){ return 0; }
188185 static void rl_set_screen_size(int row, int col){}
189 static void rl_get_screen_size(int *row, int *col){}
186 static void rl_get_screen_size(int *row, int *col){
187 *row = *col = 0;
188 }
190189
191190 static char *rl_executing_macro = NULL; /* was _rl_executing_macro */
192191 static int rl_readline_state = 2; /* RL_STATE_INITIALIZED */
193 static Function *rl_directory_rewrite_hook = NULL;
192 static rl_icppfunc_t *rl_directory_rewrite_hook = NULL;
194193 static char *history_word_delimiters = " \t\n;&()|<>";
195194
196195 /* documented by 4.2a but implemented since 2.1 */
233232 char *s;
234233 rl_compentry_func_t *f;
235234 {
236 return completion_matches (s, (CPFunction *)f);
235 return completion_matches (s, f);
237236 }
238237
239238 static char *
263262
264263 #if (RL_VERSION_MAJOR < 5)
265264 /* features introduced by GNU Readline 5.0 */
266 static Function *rl_completion_word_break_hook = NULL;
265 static rl_cpvfunc_t *rl_completion_word_break_hook = NULL;
267266 static int rl_completion_quote_character = 0;
268267 static int rl_completion_suppress_quote = 0;
269268 static int rl_completion_found_quote = 0;
338337 static void *history_set_hitory_state(HISTORY_STATE *state)
339338 */
340339 #endif /* (RL_READLINE_VERSION < 0x0603) */
340
341 #if (RL_READLINE_VERSION < 0x0700)
342 /* features introduced by GNU Readline 7.0 */
343 static void rl_callback_sigcleanup (void) {}
344 #endif /* (RL_READLINE_VERSION < 0x0700) */
341345
342346 /*
343347 * utility/dummy functions
534538 };
535539
536540 /*
537 * PerlIO variables for _rl_store_iostream(), _rl_fetch_iostream()
538 */
539 static PerlIO *instreamPIO = NULL;
540 static PerlIO *outstreamPIO = NULL;
541
542 /*
543541 * function pointer variable table for _rl_store_function(),
544542 * _rl_fetch_funtion()
545543 */
577575 SIG_EVT, INP_AVL, FN_STAT
578576 };
579577
578 typedef int XFunction ();
580579 static struct fn_vars {
581 Function **rlfuncp; /* GNU Readline Library variable */
582 Function *defaultfn; /* default function */
583 Function *wrapper; /* wrapper function */
580 XFunction **rlfuncp; /* GNU Readline Library variable */
581 XFunction *defaultfn; /* default function */
582 XFunction *wrapper; /* wrapper function */
584583 SV *callback; /* Perl function */
585584 } fn_tbl[] = {
586585 { &rl_startup_hook, NULL, startup_hook_wrapper, NULL }, /* 0 */
587586 { &rl_event_hook, NULL, event_hook_wrapper, NULL }, /* 1 */
588587 { &rl_getc_function, rl_getc, getc_function_wrapper, NULL }, /* 2 */
589588 {
590 (Function **)&rl_redisplay_function, /* 3 */
591 (Function *)rl_redisplay,
592 (Function *)redisplay_function_wrapper,
589 (XFunction **)&rl_redisplay_function, /* 3 */
590 (XFunction *)rl_redisplay,
591 (XFunction *)redisplay_function_wrapper,
593592 NULL
594593 },
595594 {
596 (Function **)&rl_completion_entry_function, /* 4 */
595 (XFunction **)&rl_completion_entry_function, /* 4 */
597596 NULL,
598 (Function *)completion_entry_function_wrapper,
597 (XFunction *)completion_entry_function_wrapper,
599598 NULL
600599 },
601600 {
602 (Function **)&rl_attempted_completion_function, /* 5 */
601 (XFunction **)&rl_attempted_completion_function, /* 5 */
603602 NULL,
604 (Function *)attempted_completion_function_wrapper,
603 (XFunction *)attempted_completion_function_wrapper,
605604 NULL
606605 },
607606 {
608 (Function **)&rl_filename_quoting_function, /* 6 */
609 (Function *)rl_quote_filename,
610 (Function *)filename_quoting_function_wrapper,
607 (XFunction **)&rl_filename_quoting_function, /* 6 */
608 (XFunction *)rl_quote_filename,
609 (XFunction *)filename_quoting_function_wrapper,
611610 NULL
612611 },
613612 {
614 (Function **)&rl_filename_dequoting_function, /* 7 */
613 (XFunction **)&rl_filename_dequoting_function, /* 7 */
615614 NULL,
616 (Function *)filename_dequoting_function_wrapper,
615 (XFunction *)filename_dequoting_function_wrapper,
617616 NULL
618617 },
619618 {
620 (Function **)&rl_char_is_quoted_p, /* 8 */
619 (XFunction **)&rl_char_is_quoted_p, /* 8 */
621620 NULL,
622 (Function *)char_is_quoted_p_wrapper,
621 (XFunction *)char_is_quoted_p_wrapper,
623622 NULL
624623 },
625624 {
626 (Function **)&rl_ignore_some_completions_function, /* 9 */
625 (XFunction **)&rl_ignore_some_completions_function, /* 9 */
627626 NULL,
628 (Function *)ignore_some_completions_function_wrapper,
627 (XFunction *)ignore_some_completions_function_wrapper,
629628 NULL
630629 },
631630 {
632 (Function **)&rl_directory_completion_hook, /* 10 */
631 (XFunction **)&rl_directory_completion_hook, /* 10 */
633632 NULL,
634 (Function *)directory_completion_hook_wrapper,
633 (XFunction *)directory_completion_hook_wrapper,
635634 NULL
636635 },
637636 {
638 (Function **)&history_inhibit_expansion_function, /* 11 */
637 (XFunction **)&history_inhibit_expansion_function, /* 11 */
639638 NULL,
640 (Function *)history_inhibit_expansion_function_wrapper,
639 (XFunction *)history_inhibit_expansion_function_wrapper,
641640 NULL
642641 },
643642 { &rl_pre_input_hook, NULL, pre_input_hook_wrapper, NULL }, /* 12 */
644643 {
645 (Function **)&rl_completion_display_matches_hook, /* 13 */
644 (XFunction **)&rl_completion_display_matches_hook, /* 13 */
646645 NULL,
647 (Function *)completion_display_matches_hook_wrapper,
646 (XFunction *)completion_display_matches_hook_wrapper,
648647 NULL
649648 },
650649 {
651 (Function **)&rl_completion_word_break_hook, /* 14 */
650 (XFunction **)&rl_completion_word_break_hook, /* 14 */
652651 NULL,
653 (Function *)completion_word_break_hook_wrapper,
652 (XFunction *)completion_word_break_hook_wrapper,
654653 NULL
655654 },
656655 {
657 (Function **)&rl_prep_term_function, /* 15 */
658 (Function *)rl_prep_terminal,
659 (Function *)prep_term_function_wrapper,
656 (XFunction **)&rl_prep_term_function, /* 15 */
657 (XFunction *)rl_prep_terminal,
658 (XFunction *)prep_term_function_wrapper,
660659 NULL
661660 },
662661 {
663 (Function **)&rl_deprep_term_function, /* 16 */
664 (Function *)rl_deprep_terminal,
665 (Function *)deprep_term_function_wrapper,
662 (XFunction **)&rl_deprep_term_function, /* 16 */
663 (XFunction *)rl_deprep_terminal,
664 (XFunction *)deprep_term_function_wrapper,
666665 NULL
667666 },
668667 {
669 (Function **)&rl_directory_rewrite_hook, /* 17 */
668 (XFunction **)&rl_directory_rewrite_hook, /* 17 */
670669 NULL,
671 (Function *)directory_rewrite_hook_wrapper,
670 (XFunction *)directory_rewrite_hook_wrapper,
672671 NULL
673672 },
674673 {
675 (Function **)&rl_filename_rewrite_hook, /* 18 */
674 (XFunction **)&rl_filename_rewrite_hook, /* 18 */
676675 NULL,
677 (Function *)filename_rewrite_hook_wrapper,
676 (XFunction *)filename_rewrite_hook_wrapper,
678677 NULL
679678 },
680679 {
681 (Function **)&rl_signal_event_hook, /* 19 */
680 (XFunction **)&rl_signal_event_hook, /* 19 */
682681 NULL,
683 (Function *)signal_event_hook_wrapper,
682 (XFunction *)signal_event_hook_wrapper,
684683 NULL
685684 },
686685 {
687 (Function **)&rl_input_available_hook, /* 20 */
686 (XFunction **)&rl_input_available_hook, /* 20 */
688687 NULL,
689 (Function *)input_available_hook_wrapper,
688 (XFunction *)input_available_hook_wrapper,
690689 NULL
691690 },
692691 {
693 (Function **)&rl_filename_stat_hook, /* 21 */
692 (XFunction **)&rl_filename_stat_hook, /* 21 */
694693 NULL,
695 (Function *)filename_stat_hook_wrapper,
694 (XFunction *)filename_stat_hook_wrapper,
696695 NULL
697696 }
698697 };
16641663 static int fw_15(c, k) int c; int k; { return function_wrapper(c, k, 15); }
16651664
16661665 static struct fnnode {
1667 Function *wrapper; /* C wrapper function */
1666 rl_command_func_t *wrapper; /* C wrapper function */
16681667 SV *pfn; /* Perl function */
16691668 } fntbl[] = {
16701669 { fw_00, NULL },
24342433 SV **pvp;
24352434
24362435 if (SvTYPE(SvRV(pmatches)) != SVt_PVAV) {
2437 warn("Gnu.xs:_rl_display_match_list: the 1st arguments must be a reference of an array\n");
2436 warn("Gnu.xs:_rl_display_match_list: the 1st arguments must be a reference to an array\n");
24382437 return;
24392438 }
24402439 av_matches = (AV *)SvRV(ST(0));
2441 /* index zero contains possible match and is ignored */
2440 /* index zero contains a possible match and is not counted */
24422441 if ((len = av_len(av_matches) + 1 - 1) == 0)
24432442 return;
24442443 matches = (char **)xmalloc (sizeof(char *) * (len + 2));
24452444 max = 0;
2446 for (i = 1; i <= len; i++) {
2445 for (i = 0; i <= len; i++) {
24472446 pvp = av_fetch(av_matches, i, 0);
24482447 if (SvPOKp(*pvp)) {
24492448 matches[i] = dupstr(SvPV(*pvp, l));
25652564 PROTOTYPE:
25662565
25672566 void
2567 rl_callback_sigcleanup()
2568 PROTOTYPE:
2569
2570 void
25682571 rl_callback_handler_remove()
25692572 PROTOTYPE:
25702573
26522655
26532656 if (SvTRUE(fn)) {
26542657 /* use completion_entry_function temporarily */
2655 Function *rlfunc_save = *(fn_tbl[CMP_ENT].rlfuncp);
2658 XFunction *rlfunc_save = *(fn_tbl[CMP_ENT].rlfuncp); /* ??? */
26562659 SV *callback_save = fn_tbl[CMP_ENT].callback;
26572660 fn_tbl[CMP_ENT].callback = newSVsv(fn);
26582661
26612664
26622665 SvREFCNT_dec(fn_tbl[CMP_ENT].callback);
26632666 fn_tbl[CMP_ENT].callback = callback_save;
2664 *(fn_tbl[CMP_ENT].rlfuncp) = rlfunc_save;
2667 *(fn_tbl[CMP_ENT].rlfuncp) = rlfunc_save; /* ??? */
26652668 } else
26662669 matches = rl_completion_matches(text, NULL);
26672670
31433146 }
31443147 }
31453148
3146 PerlIO *
3149 void
31473150 _rl_store_iostream(stream, id)
31483151 PerlIO *stream
31493152 int id
31523155 {
31533156 switch (id) {
31543157 case 0:
3155 #if 0 /* PerlIO_releaseFILE must be called only before closing FILE *. */
3156 if (instreamPIO != NULL)
3157 PerlIO_releaseFILE(instreamPIO, rl_instream);
3158 #endif
31593158 rl_instream = PerlIO_findFILE(stream);
3160 RETVAL = instreamPIO = stream;
31613159 break;
31623160 case 1:
3163 #if 0 /* PerlIO_releaseFILE must be called only before closing FILE *. */
3164 if (outstreamPIO != NULL)
3165 PerlIO_releaseFILE(outstreamPIO, rl_outstream);
3166 #endif
31673161 rl_outstream = PerlIO_findFILE(stream);
3168 RETVAL = outstreamPIO = stream;
31693162 #ifdef __CYGWIN__
31703163 {
31713164 /* Cygwin b20.1 library converts NL to CR-NL
31823175 break;
31833176 default:
31843177 warn("Gnu.xs:_rl_store_iostream: Illegal `id' value: `%d'", id);
3185 XSRETURN_UNDEF;
31863178 break;
31873179 }
31883180 PerlIO_debug("TRG:store_iostream id %d fd %d\n",
3189 id, PerlIO_fileno(RETVAL));
3181 id, PerlIO_fileno(stream));
31903182 }
3191 OUTPUT:
3192 RETVAL
3183
3184 #if 0 /* not used since 1.26 */
31933185
31943186 PerlIO *
31953187 _rl_fetch_iostream(id)
32203212 }
32213213 OUTPUT:
32223214 RETVAL
3215
3216 #endif
32233217
32243218 Keymap
32253219 _rl_fetch_keymap(id)
32973291 }
32983292 }
32993293
3300 Function *
3294 rl_command_func_t *
33013295 _rl_fetch_last_func()
33023296 PROTOTYPE:
33033297 CODE:
00 -*- Indented-text -*-
1 # $Id: INSTALL 467 2014-03-23 08:08:33Z hayashi $
1 # $Id: INSTALL 487 2015-05-23 08:00:11Z hayashi $
22
33 1. How to Install Term::ReadLine::Gnu
44
123123
124124 2.2. Using Package
125125
126 2.2.1. RPM on Linux
127
126128 On Linux you need to install 'ncurses-devel' package in
127129 addition to 'readline-devel' package. On distributions using
128130 RPM do follows;
130132 % sudo yum install ncurses-devel
131133 % sudo yum install readline-devel
132134
135 2.2.2. homebrew on Mac OS X
136
137 1. Install homebrew
138 See http://brew.sh/.
139
140 2. Use homebrew to install the GNU Readline Library:
141 % brew install readline
142
143 Because the GNU Readline library conflicts with the the
144 similarly-named-but-different library installed in the base
145 OS, homebrew does not link readline into /usr/local (it is
146 "keg-only").
147
148 Makefile.PL uses `brew prefix readline' to find and use the
149 "keg" directory so things work seamlessly.
150
151 3. Build Term::ReadLine::Gnu as described above:
152 % perl Makefile.PL
153 % make
154 % make test
155 % make install
156
157 `brew cleanup' will not remove keg-only formula, to avoid
158 breaking things that have been linked against it. However, if
159 you force it, `brew cleanup --force', then it will remove the
160 keg-only formula and Term::ReadLine::Gnu will cease to work.
161 You'll need to rebuild Term::ReadLine::GNU so that it links
162 against whichever newer version you have installed.
163
133164 EOF
2121 t/inputrc A file for t/readline.t
2222 t/readline.t A test script for the GNU Readline Library function
2323 typemap The GNU Readline extension interface types
24 META.yml Module meta-data (added by MakeMaker)
24 META.yml Module YAML meta-data (added by MakeMaker)
25 META.json Module JSON meta-data (added by MakeMaker)
0 {
1 "abstract" : "Perl extension for the GNU Readline/History Library",
2 "author" : [
3 "Hiroo HAYASHI <hiroo.hayashi@computer.org>"
4 ],
5 "dynamic_config" : 1,
6 "generated_by" : "ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150001",
7 "license" : [
8 "perl_5"
9 ],
10 "meta-spec" : {
11 "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
12 "version" : "2"
13 },
14 "name" : "Term-ReadLine-Gnu",
15 "no_index" : {
16 "directory" : [
17 "t",
18 "inc"
19 ]
20 },
21 "prereqs" : {
22 "build" : {
23 "requires" : {
24 "ExtUtils::MakeMaker" : "0"
25 }
26 },
27 "configure" : {
28 "requires" : {
29 "ExtUtils::MakeMaker" : "0"
30 }
31 },
32 "runtime" : {
33 "requires" : {
34 "perl" : "5.008000"
35 }
36 }
37 },
38 "release_status" : "stable",
39 "resources" : {
40 "bugtracker" : {
41 "web" : "http://rt.cpan.org/Public/Dist/Display.html?Name=Term-ReadLine-Gnu"
42 },
43 "homepage" : "http://sourceforge.net/projects/perl-trg/",
44 "license" : [
45 "http://dev.perl.org/licenses/"
46 ],
47 "repository" : {
48 "url" : "https://sourceforge.net/p/perl-trg/code/HEAD/tree/"
49 }
50 },
51 "version" : "1.28"
52 }
0 --- #YAML:1.0
1 name: Term-ReadLine-Gnu
2 version: 1.24
3 abstract: Perl extension for the GNU Readline/History Library
0 ---
1 abstract: 'Perl extension for the GNU Readline/History Library'
42 author:
5 - Hiroo HAYASHI <hiroo.hayashi@computer.org>
6 license: perl
7 distribution_type: module
3 - 'Hiroo HAYASHI <hiroo.hayashi@computer.org>'
4 build_requires:
5 ExtUtils::MakeMaker: '0'
86 configure_requires:
9 ExtUtils::MakeMaker: 0
10 build_requires:
11 ExtUtils::MakeMaker: 0
7 ExtUtils::MakeMaker: '0'
8 dynamic_config: 1
9 generated_by: 'ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150001'
10 license: perl
11 meta-spec:
12 url: http://module-build.sourceforge.net/META-spec-v1.4.html
13 version: '1.4'
14 name: Term-ReadLine-Gnu
15 no_index:
16 directory:
17 - t
18 - inc
1219 requires:
13 perl: 5.008000
20 perl: '5.008000'
1421 resources:
15 bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=Term-ReadLine-Gnu
16 homepage: http://sourceforge.net/projects/perl-trg/
17 license: http://dev.perl.org/licenses/
18 repository: https://sourceforge.net/p/perl-trg/code/HEAD/tree/
19 no_index:
20 directory:
21 - t
22 - inc
23 generated_by: ExtUtils::MakeMaker version 6.57_05
24 meta-spec:
25 url: http://module-build.sourceforge.net/META-spec-v1.4.html
26 version: 1.4
22 bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=Term-ReadLine-Gnu
23 homepage: http://sourceforge.net/projects/perl-trg/
24 license: http://dev.perl.org/licenses/
25 repository: https://sourceforge.net/p/perl-trg/code/HEAD/tree/
26 version: '1.28'
00 #
11 # Makefile.PL for Term::ReadLine::Gnu
22 #
3 # $Id: Makefile.PL 462 2014-03-19 15:25:54Z hayashi $
4 #
5 # Copyright (c) 2014 Hiroo Hayashi. All rights reserved.
3 # $Id: Makefile.PL 498 2015-09-21 13:10:38Z hayashi $
4 #
5 # Copyright (c) 1996 Hiroo Hayashi. All rights reserved.
66 # <hiroo.hayashi@computer.org>
77 #
88 # This program is free software; you can redistribute it and/or
3737 }
3838
3939 $defs = ($Config{strings} =~ m|/string.h$|) ? '-DHAVE_STRING_H' : '';
40
41 # pacify warnings for -D_FORTIFY_SOURCE which perl 5.20.0 started using
42 if ($Config{ccflags} =~ /-D_FORTIFY_SOURCE=/) {
43 $defs .= ' -O';
44 }
4045
4146 # Parse command line to specify paths for the GNU Readline Library
4247 {
5661 $defs .= ' -DOS2_USEDLL';
5762 $lddflags = '';
5863 } else {
64 # if user hasn't provided RLLIB or RLINC....
65 # OS X uses libedit, but they've named it libreadline...
66 # see if user has installed gnu readline via homebrew
67 if ($Config{osname} eq 'darwin' && !($RLLIB || $RLINC)) {
68 my $homebrew_prefix = `brew --prefix readline`;
69 if ($homebrew_prefix) {
70 chomp $homebrew_prefix;
71 $RLLIB = "-L$homebrew_prefix/lib";
72 $RLINC = "-I$homebrew_prefix/include";
73 }
74 }
75
5976 # Search libtermcap, libncurses, or libcurses in this order.
6077 # I emulate the behavior of the configure script for bash, and don't
6178 # know why AIX prefers curses.
191208 /* used by Makefile.pl to check the version of the GNU Readline Library */
192209 #include <stdio.h>
193210 #include <readline/readline.h>
194 main() { puts(rl_library_version); }
211 int main() { puts(rl_library_version); return 0; }
195212 EOF
196213 close(F);
197214
204221 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
205222 Could not compile $frlver.
206223
224 system(): $!
225
207226 If you have installed the GNU Readline Library (libreadline.{a,so} and
208227 readline/readline.h, etc.) on directories for which your perl is not
209228 configured to search (refer the value of `ccflags' and `libpath' in
234253 EOM
235254 exit $err;
236255 }
237 print "It seems that you have the GNU Readline Library version $rlver.\n";
238 # $rlver may be '8.21-beta3' or '4.2a'
256 print "<<<It seems that you have the GNU Readline Library version $rlver.>>>\n";
257 # $rlver may be '8.21-beta3', '4.2a', or etc.
239258 return $rlver =~ /(\d+)\.(\d+)/;
240259 }
241260
243262 # Check whether the xmalloc exported by readline is indeed called
244263 # 'xmalloc' or whether it has been renamed to '_rl_malloc'.
245264 # Contributed by KENTNL at cpan.org
265
266 # Gentoo Linux requires this hack, because it renames xmalloc,
267 # xrealloc, and xfree. It is not a good idea. Yes, I agree with Chet.
246268 # https://rt.cpan.org/Ticket/Display.html?id=65973
269
247270 sub guess_malloc_names {
248271 my ($RLINC, $RLLIB, $defs, $lddflags, $libs) = @_;
249272 my $frlmalloc = 'rlmalloc.c';
294317 # compile it
295318 my $comp_cmd = "$Config{cc} $RLINC $Config{ccflags} $defs $xdef $frlmalloc -o rlmalloc $RLLIB $lddflags $Config{ldflags} $libs";
296319 print $comp_cmd, "\n";
297 system($comp_cmd);
298320 unless (system($comp_cmd) || `./rlmalloc` !~ /^ok$/ || $?) {
299321 $extra_defs = $xdef;
300322 last;
00 -*- Indented-text -*-
1 $Id: README 457 2014-03-09 14:44:24Z hayashi $
1 $Id: README 477 2014-12-14 05:35:36Z hayashi $
22
33 Term::ReadLine::Gnu --- GNU Readline Library Wrapper Module
44
5 Copyright (c) 2014 Hiroo Hayashi. All rights reserved.
5 Copyright (c) 1996 Hiroo Hayashi. All rights reserved.
66
77 This program is free software; you can redistribute it and/or
88 modify it under the same terms as Perl itself.
4141 of fixing his module.
4242
4343 Prerequisites:
44 You must have Perl 5.7 or later. If you have to use old Perl
44 You must have Perl 5.8 or later. If you have to use old Perl
4545 for some reason, use Term::ReadLine::Gnu 1.09. (I recommend
4646 you to use newer Perl.)
4747
(No changes)
00 #! /usr/local/bin/perl
11 #
2 # $Id: perlsh 465 2014-03-23 08:04:11Z hayashi $
3 #
4 # Copyright (c) 2014 Hiroo Hayashi. All Rights Reserved.
2 # $Id: perlsh 475 2014-12-13 03:20:00Z hayashi $
3 #
4 # Copyright (c) 1996 Hiroo Hayashi. All Rights Reserved.
55 #
66 # This program is free software; you can redistribute it and/or
77 # modify it under the same terms as Perl itself.
287287 !$prefix && @keyword,
288288 grep (/^\w+$/
289289 && ($sym = $pkg . $_,
290 defined *$sym{CODE}
291 || defined *$sym{FILEHANDLE}
290 defined *$sym{CODE} || defined *$sym{IO}
292291 ),
293292 keys %$pkg));
294293 }
00 #! /usr/local/bin/perl
11 #
2 # $Id: pftp 454 2014-03-02 14:28:30Z hayashi $
3 #
4 # Copyright (c) 2014 Hiroo Hayashi. All Rights Reserved.
2 # $Id: pftp 475 2014-12-13 03:20:00Z hayashi $
3 #
4 # Copyright (c) 1997 Hiroo Hayashi. All Rights Reserved.
55 #
66 # This program is free software; you can redistribute it and/or
77 # modify it under the same terms as Perl itself.
00 #!/usr/local/bin/perl -w
11 #
2 # $Id: ptksh+ 438 2014-02-03 14:40:47Z hayashi $
2 # $Id: ptksh+ 475 2014-12-13 03:20:00Z hayashi $
33 #
44 # POD documentation after __END__
55
66 # This program is contributed by Achim Bohnet. It demonstrates how to
77 # use the callback functions in the GNU Readline Library. This script
8 # is essetially equivalent with executing the following lines in
8 # is essentially equivalent with executing the following lines in
99 # `eg/perlsh';
1010 # $PerlSh::term->tkRunning(1);
1111 # use Tk;
(No changes)
00 # -*- perl -*-
11 # 00check.t - check versions
22 #
3 # $Id: 00checkver.t 466 2014-03-23 08:05:23Z hayashi $
3 # $Id: 00checkver.t 475 2014-12-13 03:20:00Z hayashi $
44 #
5 # Copyright (c) 2014 Hiroo Hayashi. All rights reserved.
5 # Copyright (c) 2008 Hiroo Hayashi. All rights reserved.
66 #
77 # This program is free software; you can redistribute it and/or
88 # modify it under the same terms as Perl itself.
00 # -*- perl -*-
11 # callback.t - Test script for Term::ReadLine:GNU callback function
22 #
3 # $Id: callback.t 454 2014-03-02 14:28:30Z hayashi $
3 # $Id: callback.t 478 2014-12-27 15:18:37Z hayashi $
44 #
5 # Copyright (c) 2014 Hiroo Hayashi. All rights reserved.
5 # Copyright (c) 1999 Hiroo Hayashi. All rights reserved.
66 #
77 # This program is free software; you can redistribute it and/or
88 # modify it under the same terms as Perl itself.
3737 my ($version) = $attribs->{library_version} =~ /(\d+\.\d+)/;
3838
3939 ########################################################################
40 # check Tk is installed and X Window is available
41 #disable the warning, "Too late to run INIT block at..."
42
43 {
44 no warnings 'uninitialized';
45 if (eval "use Tk; 1" && $ENV{DISPLAY} ne '') {
46 print "ok $n\tuse Tk\n"; $n++;
47 } else {
48 print "ok $n\t# skipped since Tk is not available.\n"; $n++;
49 print "ok $n\t# skipped since Tk is not available.\n"; $n++;
50 print "ok $n\t# skipped since Tk is not available.\n"; $n++;
51 print "ok $n\t# skipped since Tk is not available.\n"; $n++;
52 exit 0;
53 }
54 }
55
56 ########################################################################
5740 my ($IN, $OUT);
5841 if ($verbose) {
5942 # wait for Perl Tk script from tty
7356 }
7457
7558 ########################################################################
59 # check Tk is installed and X Window is available
60 #disable the warning, "Too late to run INIT block at..."
61
62 {
63 no warnings 'uninitialized';
64 if (eval "use Tk; 1" && $ENV{DISPLAY} ne '') {
65 print "ok $n\tuse Tk\n"; $n++;
66 } else {
67 print "ok $n\t# skipped since Tk is not available.\n"; $n++;
68 print "ok $n\t# skipped since Tk is not available.\n"; $n++;
69 print "ok $n\t# skipped since Tk is not available.\n"; $n++;
70 print "ok $n\t# skipped since Tk is not available.\n"; $n++;
71 exit 0;
72 }
73 }
74
75 ########################################################################
7676 my $mw;
77 $mw = MainWindow->new();
77 $mw = eval { MainWindow->new(); };
78 if (!$mw) {
79 print "ok $n\t# skipped since Tk is not available.\n"; $n++;
80 print "ok $n\t# skipped since Tk is not available.\n"; $n++;
81 print "ok $n\t# skipped since Tk is not available.\n"; $n++;
82 exit 0;
83 }
7884 $mw->protocol('WM_DELETE_WINDOW' => \&quit);
7985
8086 $attribs->{instream} = $IN;
(No changes)
(No changes)
(No changes)
(No changes)
(No changes)
00 # -*- perl -*-
11 # history.t --- Term::ReadLine:GNU History Library Test Script
22 #
3 # $Id: history.t 454 2014-03-02 14:28:30Z hayashi $
3 # $Id: history.t 497 2015-09-21 12:46:09Z hayashi $
44 #
5 # Copyright (c) 2014 Hiroo Hayashi. All rights reserved.
5 # Copyright (c) 1998 Hiroo Hayashi. All rights reserved.
66 #
77 # This program is free software; you can redistribute it and/or
88 # modify it under the same terms as Perl itself.
1313 BEGIN {
1414 print "1..84\n"; $n = 1;
1515 $ENV{PERL_RL} = 'Gnu'; # force to use Term::ReadLine::Gnu
16 $ENV{LANG} = 'C';
16 $ENV{LC_ALL} = 'C';
1717 }
1818 END {print "not ok $n\n" unless $loaded;}
1919
7474 my ($version) = $attribs->{library_version} =~ /(\d+\.\d+)/;
7575
7676 ########################################################################
77 # 2.3.1 Initializing History and State Management
77 print "# 2.3.1 Initializing History and State Management\n";
7878
7979 # test using_history
8080 # This is verbose since 'new' has already initialized the GNU history library.
111111 ? "ok $n\n" : "not ok $n\n"; $n++;
112112
113113 ########################################################################
114 # 2.3.2 History List Management
114 print "# 2.3.2 History List Management\n";
115115
116116 my @list_set;
117117 # default value of `history_base' is 1
177177 show_indices;
178178
179179 ########################################################################
180 # 2.3.3 Information About the History List
180 print "# 2.3.3 Information About the History List\n";
181181
182182 $attribs->{history_base} = 0;
183183 show_indices;
208208 print $t->history_total_bytes == 15 ? "ok $n\n" : "not ok $n\n"; $n++;
209209
210210 ########################################################################
211 # 2.3.4 Moving Around the History List
211 print "# 2.3.4 Moving Around the History List\n";
212212
213213 # history_set_pos()
214214 $t->history_set_pos(2);
242242
243243
244244 ########################################################################
245 # 2.3.5 Searching the History List
245 print "# 2.3.5 Searching the History List\n";
246246
247247 @list_set = ('red yellow', 'green red', 'yellow blue', 'green blue');
248248 $t->SetHistory(@list_set);
298298 ? "ok $n\n" : "not ok $n\n"); $n++;
299299
300300 ########################################################################
301 # 2.3.6 Managing the History File
301 print "# 2.3.6 Managing the History File\n";
302302
303303 $t->stifle_history(undef);
304304 my $hfile = '.history_test';
349349 #print "@{[$t->GetHistory]}\n";
350350
351351 ########################################################################
352 # 2.3.7 History Expansion
352 print "# 2.3.7 History Expansion\n";
353353
354354 my ($string, $ret, @ret, $exp, @exp);
355355
420420 print $ret eq $exp ? "ok $n\n" : "not ok $n\n"; $n++;
421421
422422 ########################################################################
423 # 2.4 History Variables
423 print "# 2.4 History Variables\n";
424424
425425 # history_base, history_length, max_input_history are tested above
426426
(No changes)
00 # -*- perl -*-
11 # readline.t - Test script for Term::ReadLine:GNU
22 #
3 # $Id: readline.t 454 2014-03-02 14:28:30Z hayashi $
3 # $Id: readline.t 497 2015-09-21 12:46:09Z hayashi $
44 #
5 # Copyright (c) 2014 Hiroo Hayashi. All rights reserved.
5 # Copyright (c) 1996 Hiroo Hayashi. All rights reserved.
66 #
77 # This program is free software; you can redistribute it and/or
88 # modify it under the same terms as Perl itself.
1313 BEGIN {
1414 print "1..140\n"; $n = 1;
1515 $ENV{PERL_RL} = 'Gnu'; # force to use Term::ReadLine::Gnu
16 $ENV{LANG} = 'C';
16 $ENV{LC_ALL} = 'C'; # LC_ALL is stronger than LANG
1717 }
1818 END {print "not ok 1\tfail to loading\n" unless $loaded;}
1919
2626 eval "use ExtUtils::testlib;" or eval "use lib './blib';";
2727 use Term::ReadLine;
2828 use Term::ReadLine::Gnu qw(ISKMAP ISMACR ISFUNC RL_STATE_INITIALIZED);
29
30 print "# Testing Term::ReadLine::Gnu version $Term::ReadLine::Gnu::VERSION\n";
2931
3032 $loaded = 1;
3133 print "ok 1\tloading\n"; $n++;
4446 print "ok $n\t$what\n";
4547 } else {
4648 print "not ok $n\t$what";
47 print @_ ? "\t@_\n" : "\n";
49 print @_ ? "\t[@_]\n" : "\n";
4850 $ok = 0;
4951 }
5052 $n++;
5759 $ENV{'INPUTRC'} = '/dev/null';
5860 # These tty setting affects GNU Readline key-bindings.
5961 # Set the standard bindings before rl_initialize() being called.
60 system('stty erase ^h') == 0 or warn "stty erase failed: $?";
61 system('stty kill ^u') == 0 or warn "stty kill failed: $?";
62 system('stty lnext ^v') == 0 or warn "stty lnext failed: $?";
63 system('stty werase ^w') == 0 or warn "stty werase failed: $?";
62 # comment out since check_default_keybind_and_fix() takes care.
63 # system('stty erase ^?') == 0 or warn "stty erase failed: $?";
64 # system('stty kill ^u') == 0 or warn "stty kill failed: $?";
65 # system('stty lnext ^v') == 0 or warn "stty lnext failed: $?";
66 # system('stty werase ^w') == 0 or warn "stty werase failed: $?";
6467
6568 my $t = new Term::ReadLine 'ReadLineTest';
6669 $res = defined $t; ok('new');
9699 $res = defined $a; ok('Attrib method');
97100
98101 ########################################################################
99 # 2.3 Readline Variables
102 print "# 2.3 Readline Variables\n";
100103
101104 my ($maj, $min) = $a->{library_version} =~ /(\d+)\.(\d+)/;
102105 my $version = $a->{readline_version};
174177
175178
176179 ########################################################################
177 # 2.4 Readline Convenience Functions
180 print "# 2.4 Readline Convenience Functions\n";
178181
179182 ########################################################################
180183 # define some custom functions
225228 }
226229
227230 ########################################################################
228 # 2.4.1 Naming a Function
231 print "# 2.4.1 Naming a Function\n";
229232
230233 my ($func, $type);
231234
256259 ok;
257260
258261 ########################################################################
259 # 2.4.2 Selecting a Keymap
262 print "# 2.4.2 Selecting a Keymap\n";
260263
261264 # test rl_make_bare_keymap, rl_copy_keymap, rl_make_keymap, rl_discard_keymap
262265 my $baremap = $t->make_bare_keymap;
294297 ok;
295298
296299 ########################################################################
297 # 2.4.3 Binding Keys
300 print "# 2.4.3 Binding Keys\n";
298301
299302 #print $t->get_keymap_name($a->{executing_keymap}), "\n";
300303 #print $t->get_keymap_name($a->{binding_keymap}), "\n";
406409 $n++;
407410 }
408411 ########################################################################
409 # 2.4.4 Associating Function Names and Bindings
412 print "# 2.4.4 Associating Function Names and Bindings\n";
410413
411414 bind_my_function; # do bind
412415
420423 ok('invoking_keyseqs');
421424
422425 ########################################################################
423 # 2.4.5 Allowing Undoing
426 print "# 2.4.5 Allowing Undoing\n";
424427 # rl_begin_undo_group!!!, rl_end_undo_group!!!, rl_add_undo!!!,
425428 # rl_free_undo_list!!!, rl_do_undo!!!, rl_modifying
426429
427430 ########################################################################
428 # 2.4.6 Redisplay
431 print "# 2.4.6 Redisplay\n";
429432 # rl_redisplay!!!, rl_forced_update_display, rl_on_new_line!!!,
430433 # rl_on_new_line_with_prompt!!!, rl_reset_line_state!!!, rl_crlf!!!,
431434 # rl_show_char!!!,
434437 # rl_expand_prompt!!!, rl_set_prompt!!!
435438
436439 ########################################################################
437 # 2.4.7 Modifying Text
440 print "# 2.4.7 Modifying Text\n";
438441 # rl_insert_text!!!, rl_delete_text!!!, rl_copy_text!!!, rl_kill_text!!!,
439442 # rl_push_macro_input!!!
440443
441444 ########################################################################
442 # 2.4.8 Character Input
445 print "# 2.4.8 Character Input\n";
443446 # rl_read_key!!!, rl_getc, rl_stuff_char!!!, rl_execute_next!!!,
444447 # rl_clear_pending_input!!!, rl_set_keyboard_input_timeout!!!
445448
446449 ########################################################################
447 # 2.4.9 Terminal Management
450 print "# 2.4.9 Terminal Management\n";
448451 # rl_prep_terminal!!!, rl_deprep_terminal!!!,
449452 # rl_tty_set_default_bindings!!!, rl_tty_unset_default_bindings!!!,
450453 # rl_reset_terminal!!!
451454
452455 ########################################################################
453 # 2.4.10 Utility Functions
456 print "# 2.4.10 Utility Functions\n";
454457 # rl_save_state!!!, rl_restore_state!!!, rl_replace_line!!!,
455458 # rl_initialize, rl_ding!!!, rl_alphabetic!!!,
456459 # rl_display_match_list
457460
458461 ########################################################################
459 # 2.4.11 Miscellaneous Functions
462 print "# 2.4.11 Miscellaneous Functions\n";
460463 # rl_macro_bind!!!, rl_macro_dumpter!!!,
461464 # rl_variable_bind!!!, rl_variable_value!!!, rl_variable_dumper!!!
462465 # rl_set_paren_blink_timeout!!!, rl_get_termcap!!!, rl_clear_history!!!
463466
464467 ########################################################################
465 # 2.4.12 Alternate Interface
468 print "# 2.4.12 Alternate Interface\n";
466469 # tested in callback.t
467470 # rl_callback_handler_install, rl_callback_read_char,
468471 # rl_callback_handler_remove,
469472
470473 ########################################################################
471 # 2.5 Readline Signal Handling
474 print "# 2.5 Readline Signal Handling\n";
472475 $res = $a->{catch_signals} == 1; ok('catch_signals');
473476 $res = $a->{catch_sigwinch} == 1; ok('catch_sigwinch');
474477 $res = $a->{change_environment} == 1; ok('change_environment');
493496 # rl_reset_screen_size!!!, rl_set_signals!!!, rl_clear_signals!!!
494497
495498 ########################################################################
496 # 2.6 Custom Completers
497 # 2.6.1 How Completing Works
498 # 2.6.2 Completion Functions
499 print "# 2.6 Custom Completers\n";
500 print "# 2.6.1 How Completing Works\n";
501 print "# 2.6.2 Completion Functions\n";
499502 # rl_complete_internal!!!, rl_completion_mode!!!, rl_completion_matches,
500503 # rl_filename_completion_function, rl_username_completion_function,
501504 # list_completion_function
502505
503 # 2.6.3 Completion Variables
506 print "# 2.6.3 Completion Variables\n";
504507 $res = ! defined $a->{completion_entry_function}; ok;
505508 $res = ! defined $a->{attempted_completion_function}; ok;
506509 $res = ! defined $a->{filename_quoting_function}; ok;
546549 ########################################################################
547550
548551 $t->parse_and_bind('set bell-style none'); # make readline quiet
552 #$t->parse_and_bind('set enable-bracketed-paste on');
553 #$t->parse_and_bind('set blink-matching-paren on');
554 #$t->parse_and_bind('set colored-completion-prefix off');
549555
550556 my ($INSTR, $line);
551557 # simulate key input by using a variable 'rl_getc_function'
648654 $res = $line eq 'one'; ok('operate_and_get_next 4', $line);
649655
650656 ########################################################################
651 # test history expansion
657 print "# test history expansion\n";
652658
653659 $t->ornaments(0); # ornaments off
654660
679685 $res = $line eq '1234'; ok('history 3', $line);
680686
681687 ########################################################################
682 # test custom completion function
688 print "# test custom completion function\n";
683689
684690 $t->parse_and_bind('set bell-style none'); # make readline quiet
685691
845851 $t->parse_and_bind('set bell-style audible'); # resume to default style
846852
847853 ########################################################################
848 # test rl_startup_hook, rl_pre_input_hook
854 print "# test rl_startup_hook, rl_pre_input_hook\n";
849855
850856 $a->{startup_hook} = sub { $a->{point} = 10; };
851857 $INSTR = "insert\cM";
865871 $a->{pre_input_hook} = undef;
866872
867873 #########################################################################
868 # test redisplay_function
874 print "# test redisplay_function\n";
869875 $a->{redisplay_function} = $a->{shadow_redisplay};
870876 $INSTR = "\cX\cVThis is a password.\cM";
871877 $line = $t->readline("password> ");
875881 print "ok $n\n"; $n++;
876882
877883 #########################################################################
878 # test rl_display_match_list
884 print "# test rl_display_match_list\n";
879885
880886 if ($version >= 0x0400) {
881 my @match_list = @{$a->{completion_word}};
887 # my @match_list = @{$a->{completion_word}};
888 my @match_list = qw(possible_completion one two three four five six);
882889 $t->display_match_list(\@match_list);
883890 $t->parse_and_bind('set print-completions-horizontally on');
884891 $t->display_match_list(\@match_list);
885892 $t->parse_and_bind('set print-completions-horizontally off');
893 @match_list = qw(foo/ foo/bar1 foo/bar2 foo/bar3);
894 $t->display_match_list(\@match_list);
895 @match_list = qw(foo/bar foo/bar1 foo/bar2 foo/bar3);
896 $t->display_match_list(\@match_list);
886897 print "ok $n\n"; $n++;
887898 } else {
888899 print "ok $n # skipped because GNU Readline Library is older than 4.0.\n";
890901 }
891902
892903 #########################################################################
893 # test rl_completion_display_matches_hook
904 print "# test rl_completion_display_matches_hook\n";
894905
895906 if ($version >= 0x0400) {
896907 # See 'eg/perlsh' for better example
912923 }
913924
914925 ########################################################################
915 # test ornaments
926 print "# test ornaments\n";
916927
917928 $INSTR = "\cM\cM\cM\cM\cM\cM\cM";
918929 print $OUT "# ornaments test\n";
941952 print "ok $n\n"; $n++;
942953
943954 ########################################################################
944 # end of non-interactive test
955 print "# end of non-interactive test\n";
945956 unless ($verbose) {
946957 # Be quiet during CPAN Testers testing.
947958 print STDERR "ok\tTry \`$^X -Mblib t/readline.t verbose\', if you will.\n"
952963 undef $a->{input_available_hook};
953964
954965 ########################################################################
955 # interactive test
966 print "# interactive test\n";
956967
957968 ########################################################################
958969 # test redisplay_function
(No changes)