Imported Upstream version 1.28
gregor herrmann
8 years ago
0 | 0 | -*- 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. | |
2 | 44 | |
3 | 45 | 1.24 2014-03-23 |
4 | 46 | - fix not to make the PerlIO layer empty for Perl 5.8.9 or |
5 | 47 | before. [rt.cpan.org #59832] |
6 | 48 | - 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 | |
8 | 50 | Test;" |
9 | 51 | - INSTALL: add "(Install) Using Package" section. |
10 | 52 | |
423 | 465 | the callback functions |
424 | 466 | |
425 | 467 | 0.08 Sun Apr 13 23:24:52 1997 |
426 | ||
427 | 468 | - bug fix: AddHistory() accepts list again. |
428 | 469 | - move perlsh into eg/. |
429 | 470 | - add eg/ptksh+ which demonstrates the callback functions. |
433 | 474 | - internal functions, fetch_var() and store_var(), are removed. |
434 | 475 | |
435 | 476 | 0.07 Wed Mar 19 02:26:06 1997 |
436 | ||
437 | 477 | - interface to internal function and variables are changed. |
438 | 478 | New interface is compatible with new Term::ReadLine.pm which |
439 | 479 | is distributed with Perl 5.003_92 and later. But it is not |
1 | 1 | # |
2 | 2 | # XS.pm : perl function definition for Term::ReadLine::Gnu |
3 | 3 | # |
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. | |
7 | 7 | # |
8 | 8 | # This program is free software; you can redistribute it and/or |
9 | 9 | # modify it under the same terms as Perl itself. |
16 | 16 | use AutoLoader 'AUTOLOAD'; |
17 | 17 | |
18 | 18 | use vars qw($VERSION); |
19 | $VERSION='1.24'; # added for CPAN | |
19 | $VERSION='1.28'; # added for CPAN | |
20 | 20 | |
21 | 21 | # make aliases |
22 | 22 | use vars qw(%Attribs); |
564 | 564 | my($text, $state) = @_; |
565 | 565 | |
566 | 566 | 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 | } | |
568 | 571 | |
569 | 572 | if ($state) { |
570 | 573 | $_i++; |
579 | 582 | return undef unless defined $_matches[0]; |
580 | 583 | } |
581 | 584 | |
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; | |
583 | 592 | } |
584 | 593 | |
585 | 594 | 1; |
0 | 0 | # |
1 | 1 | # Gnu.pm --- The GNU Readline/History Library wrapper module |
2 | 2 | # |
3 | # $Id: Gnu.pm 468 2014-03-23 11:56:58Z hayashi $ | |
3 | # $Id: Gnu.pm 498 2015-09-21 13:10:38Z hayashi $ | |
4 | 4 | # |
5 | # Copyright (c) 2014 Hiroo Hayashi. All rights reserved. | |
5 | # Copyright (c) 1996 Hiroo Hayashi. All rights reserved. | |
6 | 6 | # |
7 | 7 | # This program is free software; you can redistribute it and/or |
8 | 8 | # modify it under the same terms as Perl itself. |
34 | 34 | Library|http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html>. |
35 | 35 | |
36 | 36 | 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">. | |
39 | 39 | |
40 | 40 | This package also has the interface with the almost all functions and |
41 | 41 | variables which are documented in the GNU Readline/History Library |
42 | 42 | 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"> | |
44 | 44 | 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 | |
47 | 47 | Library, see L<GNU Readline Library |
48 | 48 | Manual|http://cnswww.cns.cwru.edu/php/chet/readline/readline.html> and |
49 | 49 | L<GNU History Library |
50 | 50 | Manual|http://cnswww.cns.cwru.edu/php/chet/readline/history.html>. |
51 | 51 | |
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 | ||
52 | 56 | The sample programs under F<eg/> directory and test programs under |
53 | 57 | 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. | |
55 | 59 | |
56 | 60 | =head2 Standard Methods |
57 | 61 | |
58 | These methods are standard methods defined by | |
62 | These are standard methods defined by | |
59 | 63 | L<Term::ReadLine|http://search.cpan.org/dist/Term-ReadLine/>. |
60 | 64 | |
61 | 65 | =cut |
81 | 85 | use DynaLoader; |
82 | 86 | use vars qw($VERSION @ISA @EXPORT_OK); |
83 | 87 | |
84 | $VERSION = '1.24'; # update Gnu::XS::VERSION also. | |
88 | $VERSION = '1.28'; # update Gnu::XS::VERSION also. | |
85 | 89 | |
86 | 90 | # Term::ReadLine::Gnu::AU makes a function in |
87 | 91 | # `Term::ReadLine::Gnu::XS' as a method. |
120 | 124 | # this hash (%Attribs). By accessing the hash entry, you can read |
121 | 125 | # and/or write the variable in the GNU Readline Library. See the |
122 | 126 | # package definition of Term::ReadLine::Gnu::Var and following code |
123 | # for more details. | |
127 | # for further details. | |
124 | 128 | |
125 | 129 | # Normal (non-tied) entries |
126 | 130 | %Attribs = ( |
212 | 216 | |
213 | 217 | =item C<ReadLine> |
214 | 218 | |
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. | |
217 | 221 | |
218 | 222 | =cut |
219 | 223 | |
245 | 249 | # calls setenv() before the 1st assignment to $ENV{}. |
246 | 250 | $ENV{_TRL_DUMMY} = ''; |
247 | 251 | |
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 | |
254 | 255 | if (!@_) { |
255 | 256 | my ($IN,$OUT) = $self->findConsole(); |
256 | 257 | open(IN,"<$IN") || croak "Cannot open $IN for read"; |
265 | 266 | $Attribs{instream} = shift; |
266 | 267 | $Attribs{outstream} = shift; |
267 | 268 | } |
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 | ||
268 | 278 | $readline_version = $Attribs{readline_version}; |
269 | 279 | |
270 | 280 | $self; |
283 | 293 | |
284 | 294 | C<PROMPT> may include some escape sequences. Use |
285 | 295 | 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. | |
287 | 297 | |
288 | 298 | =cut |
289 | 299 | |
423 | 433 | (variables) of the package. Names of keys in this hash conform to |
424 | 434 | standard conventions with the leading C<rl_> stripped. |
425 | 435 | |
426 | See section "Variables" for supported variables. | |
436 | See section L</"C<Term::ReadLine::Gnu> Variables"> for supported variables. | |
427 | 437 | |
428 | 438 | =cut |
429 | 439 | |
455 | 465 | =cut |
456 | 466 | |
457 | 467 | # 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/>. | |
458 | 473 | |
459 | 474 | =item C<ornaments> |
460 | 475 | |
653 | 668 | rl_last_func => ['LF', 0], |
654 | 669 | ); |
655 | 670 | |
671 | my @stream; | |
672 | ||
656 | 673 | sub TIESCALAR { |
657 | 674 | my $class = shift; |
658 | 675 | my $name = shift; |
679 | 696 | } elsif ($type eq 'F') { |
680 | 697 | return _rl_fetch_function($id); |
681 | 698 | } elsif ($type eq 'IO') { |
682 | return _rl_fetch_iostream($id); | |
699 | # STORE was called in new() before coming here | |
700 | return $stream[$id]; | |
683 | 701 | } elsif ($type eq 'K') { |
684 | 702 | return _rl_fetch_keymap($id); |
685 | 703 | } elsif ($type eq 'LF') { |
715 | 733 | } elsif ($type eq 'F') { |
716 | 734 | return _rl_store_function($value, $id); |
717 | 735 | } elsif ($type eq 'IO') { |
736 | my $FH = $value; | |
737 | # Pass filehandles to the GNU Readline Library | |
738 | _rl_store_iostream($value, $id); | |
718 | 739 | # pop stdio layer pushed by PerlIO_findFILE(). |
719 | 740 | # https://rt.cpan.org/Ticket/Display.html?id=59832 |
720 | my $FH = _rl_store_iostream($value, $id); | |
721 | 741 | my @layers = PerlIO::get_layers($FH); |
722 | 742 | #warn "$id<", join(':', @layers), "\n"; |
723 | 743 | binmode($FH, ":pop") if @layers > 1; |
724 | 744 | #@layers = PerlIO::get_layers($FH); warn "$id>", join(':', @layers), "\n"; |
725 | return $FH; | |
745 | return $stream[$id] = $FH; | |
726 | 746 | } elsif ($type eq 'K' || $type eq 'LF') { |
727 | 747 | carp "Term::ReadLine::Gnu::Var::STORE: read only variable `$name'\n"; |
728 | 748 | return undef; |
794 | 814 | |
795 | 815 | =head2 C<Term::ReadLine::Gnu> Functions |
796 | 816 | |
797 | All these GNU Readline/History Library functions are callable via | |
817 | All these GNU Readline/History Library functions supported are callable via | |
798 | 818 | 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 | |
819 | 886 | C<FunctionPtr>. |
820 | 887 | |
821 | 888 | Example: |
822 | # name name `reverse-line' to a function reverse_line(), | |
889 | # name `reverse-line' to a function reverse_line(), | |
823 | 890 | # and bind it to "\C-t" |
824 | 891 | $term->add_defun('reverse-line', \&reverse_line, ord "\ct"); |
825 | 892 | |
826 | 893 | =back |
827 | 894 | |
828 | =item Selecting a Keymap | |
895 | =head4 Selecting a Keymap | |
829 | 896 | |
830 | 897 | =over 4 |
831 | 898 | |
867 | 934 | |
868 | 935 | =back |
869 | 936 | |
870 | =item Binding Keys | |
937 | =head4 Binding Keys | |
871 | 938 | |
872 | 939 | =over 4 |
873 | 940 | |
927 | 994 | void rl_parse_and_bind(str line) |
928 | 995 | |
929 | 996 | 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 | |
931 | 998 | detail see L<GNU Readline Library |
932 | 999 | Manual|http://cnswww.cns.cwru.edu/php/chet/readline/readline.html>. |
933 | 1000 | |
937 | 1004 | |
938 | 1005 | =back |
939 | 1006 | |
940 | =item Associating Function Names and Bindings | |
1007 | =head4 Associating Function Names and Bindings | |
941 | 1008 | |
942 | 1009 | =over 4 |
943 | 1010 | |
978 | 1045 | |
979 | 1046 | =back |
980 | 1047 | |
981 | =item Allowing Undoing | |
1048 | =head4 Allowing Undoing | |
982 | 1049 | |
983 | 1050 | =over 4 |
984 | 1051 | |
1008 | 1075 | |
1009 | 1076 | =back |
1010 | 1077 | |
1011 | =item Redisplay | |
1078 | =head4 Redisplay | |
1012 | 1079 | |
1013 | 1080 | =over 4 |
1014 | 1081 | |
1036 | 1103 | |
1037 | 1104 | int rl_crlf() |
1038 | 1105 | |
1039 | =item C<rl_show_char(C)> | |
1106 | =item C<show_char(C)> | |
1040 | 1107 | |
1041 | 1108 | int rl_show_char(int c) |
1042 | 1109 | |
1066 | 1133 | |
1067 | 1134 | =back |
1068 | 1135 | |
1069 | =item Modifying Text | |
1136 | =head4 Modifying Text | |
1070 | 1137 | |
1071 | 1138 | =over 4 |
1072 | 1139 | |
1092 | 1159 | |
1093 | 1160 | =back |
1094 | 1161 | |
1095 | =item Character Input | |
1162 | =head4 Character Input | |
1096 | 1163 | |
1097 | 1164 | =over 4 |
1098 | 1165 | |
1122 | 1189 | |
1123 | 1190 | =back |
1124 | 1191 | |
1125 | =item Terminal Management | |
1192 | =head4 Terminal Management | |
1126 | 1193 | |
1127 | 1194 | =over 4 |
1128 | 1195 | |
1148 | 1215 | |
1149 | 1216 | =back |
1150 | 1217 | |
1151 | =item Utility Functions | |
1218 | =head4 Utility Functions | |
1152 | 1219 | |
1153 | 1220 | =over 4 |
1154 | 1221 | |
1192 | 1259 | |
1193 | 1260 | void rl_display_match_list(\@matches, len = $#maches, max) # GRL 4.0 |
1194 | 1261 | |
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 | |
1196 | 1263 | completion, it is not displayed. See the descriptions of |
1197 | 1264 | 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 | |
1203 | 1270 | |
1204 | 1271 | =over 4 |
1205 | 1272 | |
1237 | 1304 | |
1238 | 1305 | =back |
1239 | 1306 | |
1240 | =item Alternate Interface | |
1307 | =head4 Alternate Interface | |
1241 | 1308 | |
1242 | 1309 | =over 4 |
1243 | 1310 | |
1249 | 1316 | |
1250 | 1317 | void rl_callback_read_char() |
1251 | 1318 | |
1319 | =item C<callback_sigcleanup> # GRL 7.0 | |
1320 | ||
1321 | void rl_callback_sigcleanup() | |
1322 | ||
1252 | 1323 | =item C<callback_handler_remove> |
1253 | 1324 | |
1254 | 1325 | void rl_callback_handler_remove() |
1255 | 1326 | |
1256 | 1327 | =back |
1257 | 1328 | |
1258 | =back | |
1259 | ||
1260 | =item Readline Signal Handling | |
1329 | =head3 Readline Signal Handling | |
1261 | 1330 | |
1262 | 1331 | =over 4 |
1263 | 1332 | |
1303 | 1372 | |
1304 | 1373 | =back |
1305 | 1374 | |
1306 | =item Completion Functions | |
1375 | =head3 Completion Functions | |
1307 | 1376 | |
1308 | 1377 | =over 4 |
1309 | 1378 | |
1334 | 1403 | |
1335 | 1404 | =back |
1336 | 1405 | |
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 | |
1342 | 1409 | |
1343 | 1410 | =over 4 |
1344 | 1411 | |
1358 | 1425 | |
1359 | 1426 | =back |
1360 | 1427 | |
1361 | =item History List Management | |
1428 | =head4 History List Management | |
1362 | 1429 | |
1363 | 1430 | =over 4 |
1364 | 1431 | |
1394 | 1461 | |
1395 | 1462 | stifles the history list, remembering only the last C<MAX> entries. |
1396 | 1463 | If C<MAX> is undef, remembers all entries. This is a replacement |
1397 | of unstifle_history(). | |
1464 | of C<unstifle_history()>. | |
1398 | 1465 | |
1399 | 1466 | =item C<unstifle_history> |
1400 | 1467 | |
1401 | 1468 | int unstifle_history() |
1402 | 1469 | |
1403 | This is equivalent with 'stifle_history(undef)'. | |
1470 | This is equivalent with C<stifle_history(undef)>. | |
1404 | 1471 | |
1405 | 1472 | =item C<SetHistory(LINE1 [, LINE2, ...])> |
1406 | 1473 | |
1413 | 1480 | |
1414 | 1481 | =back |
1415 | 1482 | |
1416 | =item Information About the History List | |
1483 | =head4 Information About the History List | |
1417 | 1484 | |
1418 | 1485 | =over 4 |
1419 | 1486 | |
1448 | 1515 | |
1449 | 1516 | =back |
1450 | 1517 | |
1451 | =item Moving Around the History List | |
1518 | =head4 Moving Around the History List | |
1452 | 1519 | |
1453 | 1520 | =over 4 |
1454 | 1521 | |
1466 | 1533 | |
1467 | 1534 | =back |
1468 | 1535 | |
1469 | =item Searching the History List | |
1536 | =head4 Searching the History List | |
1470 | 1537 | |
1471 | 1538 | =over 4 |
1472 | 1539 | |
1486 | 1553 | |
1487 | 1554 | =back |
1488 | 1555 | |
1489 | =item Managing the History File | |
1556 | =head4 Managing the History File | |
1490 | 1557 | |
1491 | 1558 | =over 4 |
1492 | 1559 | |
1503 | 1570 | reading at line C<FROM> and end at C<TO>. If C<FROM> is omitted or |
1504 | 1571 | zero, start at the beginning. If C<TO> is omitted or less than |
1505 | 1572 | 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 | |
1507 | 1574 | C<read_history_range()>. |
1508 | 1575 | |
1509 | 1576 | =item C<WriteHistory([FILENAME])> |
1526 | 1593 | |
1527 | 1594 | =back |
1528 | 1595 | |
1529 | =item History Expansion | |
1596 | =head4 History Expansion | |
1530 | 1597 | |
1531 | 1598 | =over 4 |
1532 | 1599 | |
1534 | 1601 | |
1535 | 1602 | (int result, str expansion) history_expand(str line) |
1536 | 1603 | |
1537 | Note that this function returns C<expansion> in scalar context. | |
1604 | Note that this function returns C<expansion> in the scalar context. | |
1538 | 1605 | |
1539 | 1606 | =item C<get_history_event(STRING, CINDEX [,QCHAR])> |
1540 | 1607 | |
1549 | 1616 | =item C<history_arg_extract(LINE, [FIRST [,LAST]])> |
1550 | 1617 | |
1551 | 1618 | str history_arg_extract(str line, int first = 0, int last = '$') |
1552 | ||
1553 | =back | |
1554 | ||
1555 | =back | |
1556 | 1619 | |
1557 | 1620 | =back |
1558 | 1621 | |
1563 | 1626 | Manual|http://cnswww.cns.cwru.edu/php/chet/readline/readline.html> and |
1564 | 1627 | L<GNU History Library |
1565 | 1628 | 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> | |
1567 | 1630 | methods. Names of keys in this hash conform to standard conventions |
1568 | 1631 | with the leading C<rl_> stripped. |
1569 | 1632 | |
1573 | 1636 | $v = $attribs->{library_version}; # rl_library_version |
1574 | 1637 | $v = $attribs->{history_base}; # history_base |
1575 | 1638 | |
1576 | =over 4 | |
1577 | ||
1578 | =item Readline Variables | |
1639 | =head3 Readline Variables | |
1579 | 1640 | |
1580 | 1641 | str rl_line_buffer |
1581 | 1642 | int rl_point |
1618 | 1679 | int rl_numeric_arg (read only) |
1619 | 1680 | int rl_editing_mode (read only) |
1620 | 1681 | |
1621 | =item Signal Handling Variables | |
1682 | =head3 Signal Handling Variables | |
1622 | 1683 | |
1623 | 1684 | int rl_catch_signals (GRL 4.0) |
1624 | 1685 | int rl_catch_sigwinch (GRL 4.0) |
1625 | 1686 | int rl_change_environment (GRL 6.3) |
1626 | 1687 | |
1627 | =item Completion Variables | |
1688 | =head3 Completion Variables | |
1628 | 1689 | |
1629 | 1690 | pfunc rl_completion_entry_function |
1630 | 1691 | pfunc rl_attempted_completion_function |
1660 | 1721 | int rl_completion_invoking_key (GRL 6.0, read only) |
1661 | 1722 | int rl_inhibit_completion |
1662 | 1723 | |
1663 | =item History Variables | |
1724 | =head3 History Variables | |
1664 | 1725 | |
1665 | 1726 | int history_base (read only) |
1666 | 1727 | int history_length (read only) |
1675 | 1736 | int history_quotes_inhibit_expansion |
1676 | 1737 | pfunc history_inhibit_expansion_function |
1677 | 1738 | |
1678 | =item Function References | |
1739 | =head3 Function References | |
1679 | 1740 | |
1680 | 1741 | rl_getc |
1681 | 1742 | rl_redisplay |
1687 | 1748 | shadow_redisplay |
1688 | 1749 | Tk_getc |
1689 | 1750 | |
1690 | =back | |
1691 | ||
1692 | 1751 | =head2 Custom Completion |
1693 | 1752 | |
1694 | 1753 | 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 | |
1698 | 1757 | Library |
1699 | 1758 | Manual|http://cnswww.cns.cwru.edu/php/chet/readline/readline.html>. |
1700 | 1759 | |
1701 | 1760 | =over 4 |
1702 | 1761 | |
1703 | =item C<rl_completion_entry_function> | |
1762 | =item C<completion_entry_function> | |
1704 | 1763 | |
1705 | 1764 | This variable holds reference refers to a generator function for |
1706 | 1765 | C<completion_matches()>. |
1714 | 1773 | call. When the generator function returns C<undef> this signals |
1715 | 1774 | C<completion_matches()> that there are no more possibilities left. |
1716 | 1775 | |
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 | |
1718 | 1777 | used. |
1719 | 1778 | |
1720 | 1779 | A sample generator function, C<list_completion_function>, is defined |
1734 | 1793 | |
1735 | 1794 | See also C<completion_matches>. |
1736 | 1795 | |
1737 | =item C<rl_attempted_completion_function> | |
1796 | =item C<attempted_completion_function> | |
1738 | 1797 | |
1739 | 1798 | A reference to an alternative function to create matches. |
1740 | 1799 | |
1746 | 1805 | If this function exists and returns null list or C<undef>, or if this |
1747 | 1806 | variable is set to C<undef>, then an internal function |
1748 | 1807 | 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 | |
1750 | 1809 | array of strings returned will be used. |
1751 | 1810 | |
1752 | 1811 | The default value of this variable is C<undef>. You can use it as follows; |
1779 | 1838 | C<ENTRY_FUNC> is a generator function which has two arguments, and |
1780 | 1839 | returns a string. The first argument is C<TEXT>. The second is a |
1781 | 1840 | 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 | |
1783 | 1842 | there are no more matches. |
1784 | 1843 | |
1785 | 1844 | If the value of C<ENTRY_FUNC> is undef, built-in |
1787 | 1846 | |
1788 | 1847 | C<completion_matches> is a Perl wrapper function of an internal |
1789 | 1848 | function C<completion_matches()>. See also |
1790 | C<$rl_completion_entry_function>. | |
1849 | C<completion_entry_function>. | |
1791 | 1850 | |
1792 | 1851 | =item C<completion_function> |
1793 | 1852 | |
1794 | 1853 | A variable whose content is a reference to a function which returns a |
1795 | 1854 | list of candidates to complete. |
1796 | 1855 | |
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 | |
1798 | 1857 | to use. |
1799 | 1858 | |
1800 | 1859 | use Term::ReadLine; |
1805 | 1864 | $attribs->{completion_function} = sub { |
1806 | 1865 | my ($text, $line, $start) = @_; |
1807 | 1866 | return qw(a list of candidates to complete); |
1808 | } | |
1867 | }; | |
1809 | 1868 | |
1810 | 1869 | =item C<list_completion_function(TEXT, STATE)> |
1811 | 1870 | |
1812 | 1871 | 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 | |
1814 | 1873 | function. |
1815 | 1874 | |
1816 | 1875 | =back |
1817 | 1876 | |
1818 | 1877 | =head2 C<Term::ReadLine::Gnu> Specific Features |
1819 | 1878 | |
1820 | =over 4 | |
1821 | ||
1822 | =item C<Term::ReadLine::Gnu> Specific Functions | |
1879 | =head3 C<Term::ReadLine::Gnu> Specific Functions | |
1823 | 1880 | |
1824 | 1881 | =over 4 |
1825 | 1882 | |
1826 | 1883 | =item C<CallbackHandlerInstall(PROMPT, LHANDLER)> |
1827 | 1884 | |
1828 | 1885 | 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 | |
1832 | 1889 | buffer. |
1833 | 1890 | |
1834 | 1891 | =item C<call_function(FUNCTION, [COUNT [,KEY]])> |
1835 | 1892 | |
1836 | 1893 | int rl_call_function(FunctionPtr|str function, count = 1, key = -1) |
1837 | 1894 | |
1838 | =item C<rl_get_all_function_names> | |
1895 | =item C<get_all_function_names> | |
1839 | 1896 | |
1840 | 1897 | Returns a list of all function names. |
1841 | 1898 | |
1846 | 1903 | $attribs->{redisplay_function} = $attribs->{shadow_redisplay}; |
1847 | 1904 | $line = $term->readline("password> "); |
1848 | 1905 | |
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 | |
1852 | 1909 | 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/>. | |
1854 | 1911 | |
1855 | 1912 | =item C<list_completion_function> |
1856 | 1913 | |
1858 | 1915 | |
1859 | 1916 | =back |
1860 | 1917 | |
1861 | =item C<Term::ReadLine::Gnu> Specific Variables | |
1918 | =head3 C<Term::ReadLine::Gnu> Specific Variables | |
1862 | 1919 | |
1863 | 1920 | =over 4 |
1864 | 1921 | |
1877 | 1934 | |
1878 | 1935 | =back |
1879 | 1936 | |
1880 | =item C<Term::ReadLine::Gnu> Specific Commands | |
1937 | =head3 C<Term::ReadLine::Gnu> Specific Commands | |
1881 | 1938 | |
1882 | 1939 | =over 4 |
1883 | 1940 | |
1891 | 1948 | editing command and the Bash C<operate-and-get-next>. |
1892 | 1949 | |
1893 | 1950 | 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/>. | |
1895 | 1952 | |
1896 | 1953 | =item C<display-readline-version> |
1897 | 1954 | |
1901 | 1958 | =item C<change-ornaments> |
1902 | 1959 | |
1903 | 1960 | Change ornaments interactively. |
1904 | ||
1905 | =back | |
1906 | 1961 | |
1907 | 1962 | =back |
1908 | 1963 | |
1917 | 1972 | uses the GNU Readline library starts up, the init file is read, and |
1918 | 1973 | the key bindings are set. |
1919 | 1974 | |
1920 | Conditional key binding is also available. The program name which is | |
1975 | The conditional init constructs is supported. The program name which is | |
1921 | 1976 | specified by the first argument of C<new> method is used as the |
1922 | 1977 | application construct. |
1923 | 1978 | |
1924 | For example, when your program call C<new> method like this; | |
1979 | For example, when your program calls C<new> method as follows; | |
1925 | 1980 | |
1926 | 1981 | ... |
1927 | 1982 | $term = new Term::ReadLine 'PerlSh'; |
1928 | 1983 | ... |
1929 | 1984 | |
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; | |
1931 | 1987 | |
1932 | 1988 | ... |
1933 | 1989 | $if PerlSh |
1937 | 1993 | $endif |
1938 | 1994 | ... |
1939 | 1995 | |
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 | ||
1940 | 2000 | =back |
1941 | 2001 | |
1942 | 2002 | =head1 EXPORTS |
1943 | 2003 | |
1944 | 2004 | None. |
1945 | 2005 | |
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 | ||
1946 | 2013 | =head1 SEE ALSO |
1947 | 2014 | |
1948 | 2015 | =over 4 |
1960 | 2027 | =item Works which use Term::ReadLine::Gnu |
1961 | 2028 | |
1962 | 2029 | =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> | |
1963 | 2034 | |
1964 | 2035 | =item L<Perl Debugger|http://perldoc.perl.org/perldebug.html> |
1965 | 2036 | |
2009 | 2080 | |
2010 | 2081 | A visual shell and CLI shell supplement. |
2011 | 2082 | |
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. | |
2020 | 2086 | |
2021 | 2087 | =back |
2022 | 2088 | |
2032 | 2098 | |
2033 | 2099 | =head1 BUGS |
2034 | 2100 | |
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 | |
2038 | 2109 | contribution is welcome. See F<t/readline.t> for details. |
2039 | 2110 | |
2040 | If the pager command (| or ||) in Perl debugger causes segmentation | |
2111 | =item If the pager command (| or ||) in Perl debugger causes segmentation | |
2041 | 2112 | fault, you need to fix F<perl5db.pl>. See |
2042 | 2113 | L<https://rt.perl.org/Public/Bug/Display.html?id=121456> for details. |
2043 | 2114 | |
2115 | =back | |
2116 | ||
2044 | 2117 | =head1 LICENSE |
2045 | 2118 | |
2046 | Copyright (c) 2014 Hiroo Hayashi. All rights reserved. | |
2119 | Copyright (c) 1996 Hiroo Hayashi. All rights reserved. | |
2047 | 2120 | |
2048 | 2121 | This program is free software; you can redistribute it and/or modify |
2049 | 2122 | it under the same terms as Perl itself. |
0 | 0 | /* |
1 | 1 | * Gnu.xs --- GNU Readline wrapper module |
2 | 2 | * |
3 | * $Id: Gnu.xs 446 2014-03-01 16:17:57Z hayashi $ | |
3 | * $Id: Gnu.xs 493 2015-09-06 05:03:42Z hayashi $ | |
4 | 4 | * |
5 | * Copyright (c) 2014 Hiroo Hayashi. All rights reserved. | |
5 | * Copyright (c) 1996 Hiroo Hayashi. All rights reserved. | |
6 | 6 | * |
7 | 7 | * This program is free software; you can redistribute it and/or |
8 | 8 | * modify it under the same terms as Perl itself. |
81 | 81 | typedef void rl_vcppfunc_t PARAMS((char **)); |
82 | 82 | |
83 | 83 | /* rl_last_func() is defined in rlprivate.h */ |
84 | extern Function *rl_last_func; | |
84 | extern rl_command_func_t *rl_last_func; | |
85 | 85 | #endif /* (RL_READLINE_VERSION < 0x0402) */ |
86 | 86 | |
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 | ||
94 | 91 | |
95 | 92 | #if (RL_READLINE_VERSION < 0x0201) |
96 | 93 | /* 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; | |
99 | 96 | #endif /* (RL_READLINE_VERSION < 0x0201) */ |
100 | 97 | |
101 | 98 | #if (RL_READLINE_VERSION < 0x0202) |
136 | 133 | /* documented by Readline 4.0 but already implemented since 2.0 or 2.1. */ |
137 | 134 | extern void rl_extend_line_buffer PARAMS((int)); |
138 | 135 | 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 *)); | |
140 | 137 | extern void rl_prep_terminal PARAMS((int)); |
141 | 138 | extern void rl_deprep_terminal PARAMS((void)); |
142 | 139 | extern int rl_execute_next PARAMS((int)); |
144 | 141 | /* features introduced by GNU Readline 4.0 */ |
145 | 142 | /* dummy variable/function definition */ |
146 | 143 | static int rl_erase_empty_line = 0; |
147 | static Function *rl_pre_input_hook; | |
144 | static rl_hook_func_t *rl_pre_input_hook; | |
148 | 145 | static int rl_catch_signals = 1; |
149 | 146 | 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; | |
151 | 148 | |
152 | 149 | static void rl_display_match_list(){} |
153 | 150 | static void rl_cleanup_after_signal(){} |
186 | 183 | static int rl_alphabetic(){ return 0; } |
187 | 184 | static int rl_set_paren_blink_timeout(){ return 0; } |
188 | 185 | 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 | } | |
190 | 189 | |
191 | 190 | static char *rl_executing_macro = NULL; /* was _rl_executing_macro */ |
192 | 191 | 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; | |
194 | 193 | static char *history_word_delimiters = " \t\n;&()|<>"; |
195 | 194 | |
196 | 195 | /* documented by 4.2a but implemented since 2.1 */ |
233 | 232 | char *s; |
234 | 233 | rl_compentry_func_t *f; |
235 | 234 | { |
236 | return completion_matches (s, (CPFunction *)f); | |
235 | return completion_matches (s, f); | |
237 | 236 | } |
238 | 237 | |
239 | 238 | static char * |
263 | 262 | |
264 | 263 | #if (RL_VERSION_MAJOR < 5) |
265 | 264 | /* 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; | |
267 | 266 | static int rl_completion_quote_character = 0; |
268 | 267 | static int rl_completion_suppress_quote = 0; |
269 | 268 | static int rl_completion_found_quote = 0; |
338 | 337 | static void *history_set_hitory_state(HISTORY_STATE *state) |
339 | 338 | */ |
340 | 339 | #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) */ | |
341 | 345 | |
342 | 346 | /* |
343 | 347 | * utility/dummy functions |
534 | 538 | }; |
535 | 539 | |
536 | 540 | /* |
537 | * PerlIO variables for _rl_store_iostream(), _rl_fetch_iostream() | |
538 | */ | |
539 | static PerlIO *instreamPIO = NULL; | |
540 | static PerlIO *outstreamPIO = NULL; | |
541 | ||
542 | /* | |
543 | 541 | * function pointer variable table for _rl_store_function(), |
544 | 542 | * _rl_fetch_funtion() |
545 | 543 | */ |
577 | 575 | SIG_EVT, INP_AVL, FN_STAT |
578 | 576 | }; |
579 | 577 | |
578 | typedef int XFunction (); | |
580 | 579 | 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 */ | |
584 | 583 | SV *callback; /* Perl function */ |
585 | 584 | } fn_tbl[] = { |
586 | 585 | { &rl_startup_hook, NULL, startup_hook_wrapper, NULL }, /* 0 */ |
587 | 586 | { &rl_event_hook, NULL, event_hook_wrapper, NULL }, /* 1 */ |
588 | 587 | { &rl_getc_function, rl_getc, getc_function_wrapper, NULL }, /* 2 */ |
589 | 588 | { |
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, | |
593 | 592 | NULL |
594 | 593 | }, |
595 | 594 | { |
596 | (Function **)&rl_completion_entry_function, /* 4 */ | |
595 | (XFunction **)&rl_completion_entry_function, /* 4 */ | |
597 | 596 | NULL, |
598 | (Function *)completion_entry_function_wrapper, | |
597 | (XFunction *)completion_entry_function_wrapper, | |
599 | 598 | NULL |
600 | 599 | }, |
601 | 600 | { |
602 | (Function **)&rl_attempted_completion_function, /* 5 */ | |
601 | (XFunction **)&rl_attempted_completion_function, /* 5 */ | |
603 | 602 | NULL, |
604 | (Function *)attempted_completion_function_wrapper, | |
603 | (XFunction *)attempted_completion_function_wrapper, | |
605 | 604 | NULL |
606 | 605 | }, |
607 | 606 | { |
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, | |
611 | 610 | NULL |
612 | 611 | }, |
613 | 612 | { |
614 | (Function **)&rl_filename_dequoting_function, /* 7 */ | |
613 | (XFunction **)&rl_filename_dequoting_function, /* 7 */ | |
615 | 614 | NULL, |
616 | (Function *)filename_dequoting_function_wrapper, | |
615 | (XFunction *)filename_dequoting_function_wrapper, | |
617 | 616 | NULL |
618 | 617 | }, |
619 | 618 | { |
620 | (Function **)&rl_char_is_quoted_p, /* 8 */ | |
619 | (XFunction **)&rl_char_is_quoted_p, /* 8 */ | |
621 | 620 | NULL, |
622 | (Function *)char_is_quoted_p_wrapper, | |
621 | (XFunction *)char_is_quoted_p_wrapper, | |
623 | 622 | NULL |
624 | 623 | }, |
625 | 624 | { |
626 | (Function **)&rl_ignore_some_completions_function, /* 9 */ | |
625 | (XFunction **)&rl_ignore_some_completions_function, /* 9 */ | |
627 | 626 | NULL, |
628 | (Function *)ignore_some_completions_function_wrapper, | |
627 | (XFunction *)ignore_some_completions_function_wrapper, | |
629 | 628 | NULL |
630 | 629 | }, |
631 | 630 | { |
632 | (Function **)&rl_directory_completion_hook, /* 10 */ | |
631 | (XFunction **)&rl_directory_completion_hook, /* 10 */ | |
633 | 632 | NULL, |
634 | (Function *)directory_completion_hook_wrapper, | |
633 | (XFunction *)directory_completion_hook_wrapper, | |
635 | 634 | NULL |
636 | 635 | }, |
637 | 636 | { |
638 | (Function **)&history_inhibit_expansion_function, /* 11 */ | |
637 | (XFunction **)&history_inhibit_expansion_function, /* 11 */ | |
639 | 638 | NULL, |
640 | (Function *)history_inhibit_expansion_function_wrapper, | |
639 | (XFunction *)history_inhibit_expansion_function_wrapper, | |
641 | 640 | NULL |
642 | 641 | }, |
643 | 642 | { &rl_pre_input_hook, NULL, pre_input_hook_wrapper, NULL }, /* 12 */ |
644 | 643 | { |
645 | (Function **)&rl_completion_display_matches_hook, /* 13 */ | |
644 | (XFunction **)&rl_completion_display_matches_hook, /* 13 */ | |
646 | 645 | NULL, |
647 | (Function *)completion_display_matches_hook_wrapper, | |
646 | (XFunction *)completion_display_matches_hook_wrapper, | |
648 | 647 | NULL |
649 | 648 | }, |
650 | 649 | { |
651 | (Function **)&rl_completion_word_break_hook, /* 14 */ | |
650 | (XFunction **)&rl_completion_word_break_hook, /* 14 */ | |
652 | 651 | NULL, |
653 | (Function *)completion_word_break_hook_wrapper, | |
652 | (XFunction *)completion_word_break_hook_wrapper, | |
654 | 653 | NULL |
655 | 654 | }, |
656 | 655 | { |
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, | |
660 | 659 | NULL |
661 | 660 | }, |
662 | 661 | { |
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, | |
666 | 665 | NULL |
667 | 666 | }, |
668 | 667 | { |
669 | (Function **)&rl_directory_rewrite_hook, /* 17 */ | |
668 | (XFunction **)&rl_directory_rewrite_hook, /* 17 */ | |
670 | 669 | NULL, |
671 | (Function *)directory_rewrite_hook_wrapper, | |
670 | (XFunction *)directory_rewrite_hook_wrapper, | |
672 | 671 | NULL |
673 | 672 | }, |
674 | 673 | { |
675 | (Function **)&rl_filename_rewrite_hook, /* 18 */ | |
674 | (XFunction **)&rl_filename_rewrite_hook, /* 18 */ | |
676 | 675 | NULL, |
677 | (Function *)filename_rewrite_hook_wrapper, | |
676 | (XFunction *)filename_rewrite_hook_wrapper, | |
678 | 677 | NULL |
679 | 678 | }, |
680 | 679 | { |
681 | (Function **)&rl_signal_event_hook, /* 19 */ | |
680 | (XFunction **)&rl_signal_event_hook, /* 19 */ | |
682 | 681 | NULL, |
683 | (Function *)signal_event_hook_wrapper, | |
682 | (XFunction *)signal_event_hook_wrapper, | |
684 | 683 | NULL |
685 | 684 | }, |
686 | 685 | { |
687 | (Function **)&rl_input_available_hook, /* 20 */ | |
686 | (XFunction **)&rl_input_available_hook, /* 20 */ | |
688 | 687 | NULL, |
689 | (Function *)input_available_hook_wrapper, | |
688 | (XFunction *)input_available_hook_wrapper, | |
690 | 689 | NULL |
691 | 690 | }, |
692 | 691 | { |
693 | (Function **)&rl_filename_stat_hook, /* 21 */ | |
692 | (XFunction **)&rl_filename_stat_hook, /* 21 */ | |
694 | 693 | NULL, |
695 | (Function *)filename_stat_hook_wrapper, | |
694 | (XFunction *)filename_stat_hook_wrapper, | |
696 | 695 | NULL |
697 | 696 | } |
698 | 697 | }; |
1664 | 1663 | static int fw_15(c, k) int c; int k; { return function_wrapper(c, k, 15); } |
1665 | 1664 | |
1666 | 1665 | static struct fnnode { |
1667 | Function *wrapper; /* C wrapper function */ | |
1666 | rl_command_func_t *wrapper; /* C wrapper function */ | |
1668 | 1667 | SV *pfn; /* Perl function */ |
1669 | 1668 | } fntbl[] = { |
1670 | 1669 | { fw_00, NULL }, |
2434 | 2433 | SV **pvp; |
2435 | 2434 | |
2436 | 2435 | 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"); | |
2438 | 2437 | return; |
2439 | 2438 | } |
2440 | 2439 | 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 */ | |
2442 | 2441 | if ((len = av_len(av_matches) + 1 - 1) == 0) |
2443 | 2442 | return; |
2444 | 2443 | matches = (char **)xmalloc (sizeof(char *) * (len + 2)); |
2445 | 2444 | max = 0; |
2446 | for (i = 1; i <= len; i++) { | |
2445 | for (i = 0; i <= len; i++) { | |
2447 | 2446 | pvp = av_fetch(av_matches, i, 0); |
2448 | 2447 | if (SvPOKp(*pvp)) { |
2449 | 2448 | matches[i] = dupstr(SvPV(*pvp, l)); |
2565 | 2564 | PROTOTYPE: |
2566 | 2565 | |
2567 | 2566 | void |
2567 | rl_callback_sigcleanup() | |
2568 | PROTOTYPE: | |
2569 | ||
2570 | void | |
2568 | 2571 | rl_callback_handler_remove() |
2569 | 2572 | PROTOTYPE: |
2570 | 2573 | |
2652 | 2655 | |
2653 | 2656 | if (SvTRUE(fn)) { |
2654 | 2657 | /* use completion_entry_function temporarily */ |
2655 | Function *rlfunc_save = *(fn_tbl[CMP_ENT].rlfuncp); | |
2658 | XFunction *rlfunc_save = *(fn_tbl[CMP_ENT].rlfuncp); /* ??? */ | |
2656 | 2659 | SV *callback_save = fn_tbl[CMP_ENT].callback; |
2657 | 2660 | fn_tbl[CMP_ENT].callback = newSVsv(fn); |
2658 | 2661 | |
2661 | 2664 | |
2662 | 2665 | SvREFCNT_dec(fn_tbl[CMP_ENT].callback); |
2663 | 2666 | fn_tbl[CMP_ENT].callback = callback_save; |
2664 | *(fn_tbl[CMP_ENT].rlfuncp) = rlfunc_save; | |
2667 | *(fn_tbl[CMP_ENT].rlfuncp) = rlfunc_save; /* ??? */ | |
2665 | 2668 | } else |
2666 | 2669 | matches = rl_completion_matches(text, NULL); |
2667 | 2670 | |
3143 | 3146 | } |
3144 | 3147 | } |
3145 | 3148 | |
3146 | PerlIO * | |
3149 | void | |
3147 | 3150 | _rl_store_iostream(stream, id) |
3148 | 3151 | PerlIO *stream |
3149 | 3152 | int id |
3152 | 3155 | { |
3153 | 3156 | switch (id) { |
3154 | 3157 | 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 | |
3159 | 3158 | rl_instream = PerlIO_findFILE(stream); |
3160 | RETVAL = instreamPIO = stream; | |
3161 | 3159 | break; |
3162 | 3160 | 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 | |
3167 | 3161 | rl_outstream = PerlIO_findFILE(stream); |
3168 | RETVAL = outstreamPIO = stream; | |
3169 | 3162 | #ifdef __CYGWIN__ |
3170 | 3163 | { |
3171 | 3164 | /* Cygwin b20.1 library converts NL to CR-NL |
3182 | 3175 | break; |
3183 | 3176 | default: |
3184 | 3177 | warn("Gnu.xs:_rl_store_iostream: Illegal `id' value: `%d'", id); |
3185 | XSRETURN_UNDEF; | |
3186 | 3178 | break; |
3187 | 3179 | } |
3188 | 3180 | PerlIO_debug("TRG:store_iostream id %d fd %d\n", |
3189 | id, PerlIO_fileno(RETVAL)); | |
3181 | id, PerlIO_fileno(stream)); | |
3190 | 3182 | } |
3191 | OUTPUT: | |
3192 | RETVAL | |
3183 | ||
3184 | #if 0 /* not used since 1.26 */ | |
3193 | 3185 | |
3194 | 3186 | PerlIO * |
3195 | 3187 | _rl_fetch_iostream(id) |
3220 | 3212 | } |
3221 | 3213 | OUTPUT: |
3222 | 3214 | RETVAL |
3215 | ||
3216 | #endif | |
3223 | 3217 | |
3224 | 3218 | Keymap |
3225 | 3219 | _rl_fetch_keymap(id) |
3297 | 3291 | } |
3298 | 3292 | } |
3299 | 3293 | |
3300 | Function * | |
3294 | rl_command_func_t * | |
3301 | 3295 | _rl_fetch_last_func() |
3302 | 3296 | PROTOTYPE: |
3303 | 3297 | CODE: |
0 | 0 | -*- Indented-text -*- |
1 | # $Id: INSTALL 467 2014-03-23 08:08:33Z hayashi $ | |
1 | # $Id: INSTALL 487 2015-05-23 08:00:11Z hayashi $ | |
2 | 2 | |
3 | 3 | 1. How to Install Term::ReadLine::Gnu |
4 | 4 | |
123 | 123 | |
124 | 124 | 2.2. Using Package |
125 | 125 | |
126 | 2.2.1. RPM on Linux | |
127 | ||
126 | 128 | On Linux you need to install 'ncurses-devel' package in |
127 | 129 | addition to 'readline-devel' package. On distributions using |
128 | 130 | RPM do follows; |
130 | 132 | % sudo yum install ncurses-devel |
131 | 133 | % sudo yum install readline-devel |
132 | 134 | |
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 | ||
133 | 164 | EOF |
21 | 21 | t/inputrc A file for t/readline.t |
22 | 22 | t/readline.t A test script for the GNU Readline Library function |
23 | 23 | 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' | |
4 | 2 | 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' | |
8 | 6 | 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 | |
12 | 19 | requires: |
13 | perl: 5.008000 | |
20 | perl: '5.008000' | |
14 | 21 | 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' |
0 | 0 | # |
1 | 1 | # Makefile.PL for Term::ReadLine::Gnu |
2 | 2 | # |
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. | |
6 | 6 | # <hiroo.hayashi@computer.org> |
7 | 7 | # |
8 | 8 | # This program is free software; you can redistribute it and/or |
37 | 37 | } |
38 | 38 | |
39 | 39 | $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 | } | |
40 | 45 | |
41 | 46 | # Parse command line to specify paths for the GNU Readline Library |
42 | 47 | { |
56 | 61 | $defs .= ' -DOS2_USEDLL'; |
57 | 62 | $lddflags = ''; |
58 | 63 | } 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 | ||
59 | 76 | # Search libtermcap, libncurses, or libcurses in this order. |
60 | 77 | # I emulate the behavior of the configure script for bash, and don't |
61 | 78 | # know why AIX prefers curses. |
191 | 208 | /* used by Makefile.pl to check the version of the GNU Readline Library */ |
192 | 209 | #include <stdio.h> |
193 | 210 | #include <readline/readline.h> |
194 | main() { puts(rl_library_version); } | |
211 | int main() { puts(rl_library_version); return 0; } | |
195 | 212 | EOF |
196 | 213 | close(F); |
197 | 214 | |
204 | 221 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
205 | 222 | Could not compile $frlver. |
206 | 223 | |
224 | system(): $! | |
225 | ||
207 | 226 | If you have installed the GNU Readline Library (libreadline.{a,so} and |
208 | 227 | readline/readline.h, etc.) on directories for which your perl is not |
209 | 228 | configured to search (refer the value of `ccflags' and `libpath' in |
234 | 253 | EOM |
235 | 254 | exit $err; |
236 | 255 | } |
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. | |
239 | 258 | return $rlver =~ /(\d+)\.(\d+)/; |
240 | 259 | } |
241 | 260 | |
243 | 262 | # Check whether the xmalloc exported by readline is indeed called |
244 | 263 | # 'xmalloc' or whether it has been renamed to '_rl_malloc'. |
245 | 264 | # 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. | |
246 | 268 | # https://rt.cpan.org/Ticket/Display.html?id=65973 |
269 | ||
247 | 270 | sub guess_malloc_names { |
248 | 271 | my ($RLINC, $RLLIB, $defs, $lddflags, $libs) = @_; |
249 | 272 | my $frlmalloc = 'rlmalloc.c'; |
294 | 317 | # compile it |
295 | 318 | my $comp_cmd = "$Config{cc} $RLINC $Config{ccflags} $defs $xdef $frlmalloc -o rlmalloc $RLLIB $lddflags $Config{ldflags} $libs"; |
296 | 319 | print $comp_cmd, "\n"; |
297 | system($comp_cmd); | |
298 | 320 | unless (system($comp_cmd) || `./rlmalloc` !~ /^ok$/ || $?) { |
299 | 321 | $extra_defs = $xdef; |
300 | 322 | last; |
0 | 0 | -*- Indented-text -*- |
1 | $Id: README 457 2014-03-09 14:44:24Z hayashi $ | |
1 | $Id: README 477 2014-12-14 05:35:36Z hayashi $ | |
2 | 2 | |
3 | 3 | Term::ReadLine::Gnu --- GNU Readline Library Wrapper Module |
4 | 4 | |
5 | Copyright (c) 2014 Hiroo Hayashi. All rights reserved. | |
5 | Copyright (c) 1996 Hiroo Hayashi. All rights reserved. | |
6 | 6 | |
7 | 7 | This program is free software; you can redistribute it and/or |
8 | 8 | modify it under the same terms as Perl itself. |
41 | 41 | of fixing his module. |
42 | 42 | |
43 | 43 | 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 | |
45 | 45 | for some reason, use Term::ReadLine::Gnu 1.09. (I recommend |
46 | 46 | you to use newer Perl.) |
47 | 47 |
0 | 0 | #! /usr/local/bin/perl |
1 | 1 | # |
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. | |
5 | 5 | # |
6 | 6 | # This program is free software; you can redistribute it and/or |
7 | 7 | # modify it under the same terms as Perl itself. |
287 | 287 | !$prefix && @keyword, |
288 | 288 | grep (/^\w+$/ |
289 | 289 | && ($sym = $pkg . $_, |
290 | defined *$sym{CODE} | |
291 | || defined *$sym{FILEHANDLE} | |
290 | defined *$sym{CODE} || defined *$sym{IO} | |
292 | 291 | ), |
293 | 292 | keys %$pkg)); |
294 | 293 | } |
0 | 0 | #! /usr/local/bin/perl |
1 | 1 | # |
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. | |
5 | 5 | # |
6 | 6 | # This program is free software; you can redistribute it and/or |
7 | 7 | # modify it under the same terms as Perl itself. |
0 | 0 | #!/usr/local/bin/perl -w |
1 | 1 | # |
2 | # $Id: ptksh+ 438 2014-02-03 14:40:47Z hayashi $ | |
2 | # $Id: ptksh+ 475 2014-12-13 03:20:00Z hayashi $ | |
3 | 3 | # |
4 | 4 | # POD documentation after __END__ |
5 | 5 | |
6 | 6 | # This program is contributed by Achim Bohnet. It demonstrates how to |
7 | 7 | # 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 | |
9 | 9 | # `eg/perlsh'; |
10 | 10 | # $PerlSh::term->tkRunning(1); |
11 | 11 | # use Tk; |
0 | 0 | # -*- perl -*- |
1 | 1 | # 00check.t - check versions |
2 | 2 | # |
3 | # $Id: 00checkver.t 466 2014-03-23 08:05:23Z hayashi $ | |
3 | # $Id: 00checkver.t 475 2014-12-13 03:20:00Z hayashi $ | |
4 | 4 | # |
5 | # Copyright (c) 2014 Hiroo Hayashi. All rights reserved. | |
5 | # Copyright (c) 2008 Hiroo Hayashi. All rights reserved. | |
6 | 6 | # |
7 | 7 | # This program is free software; you can redistribute it and/or |
8 | 8 | # modify it under the same terms as Perl itself. |
0 | 0 | # -*- perl -*- |
1 | 1 | # callback.t - Test script for Term::ReadLine:GNU callback function |
2 | 2 | # |
3 | # $Id: callback.t 454 2014-03-02 14:28:30Z hayashi $ | |
3 | # $Id: callback.t 478 2014-12-27 15:18:37Z hayashi $ | |
4 | 4 | # |
5 | # Copyright (c) 2014 Hiroo Hayashi. All rights reserved. | |
5 | # Copyright (c) 1999 Hiroo Hayashi. All rights reserved. | |
6 | 6 | # |
7 | 7 | # This program is free software; you can redistribute it and/or |
8 | 8 | # modify it under the same terms as Perl itself. |
37 | 37 | my ($version) = $attribs->{library_version} =~ /(\d+\.\d+)/; |
38 | 38 | |
39 | 39 | ######################################################################## |
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 | ######################################################################## | |
57 | 40 | my ($IN, $OUT); |
58 | 41 | if ($verbose) { |
59 | 42 | # wait for Perl Tk script from tty |
73 | 56 | } |
74 | 57 | |
75 | 58 | ######################################################################## |
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 | ######################################################################## | |
76 | 76 | 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 | } | |
78 | 84 | $mw->protocol('WM_DELETE_WINDOW' => \&quit); |
79 | 85 | |
80 | 86 | $attribs->{instream} = $IN; |
0 | 0 | # -*- perl -*- |
1 | 1 | # history.t --- Term::ReadLine:GNU History Library Test Script |
2 | 2 | # |
3 | # $Id: history.t 454 2014-03-02 14:28:30Z hayashi $ | |
3 | # $Id: history.t 497 2015-09-21 12:46:09Z hayashi $ | |
4 | 4 | # |
5 | # Copyright (c) 2014 Hiroo Hayashi. All rights reserved. | |
5 | # Copyright (c) 1998 Hiroo Hayashi. All rights reserved. | |
6 | 6 | # |
7 | 7 | # This program is free software; you can redistribute it and/or |
8 | 8 | # modify it under the same terms as Perl itself. |
13 | 13 | BEGIN { |
14 | 14 | print "1..84\n"; $n = 1; |
15 | 15 | $ENV{PERL_RL} = 'Gnu'; # force to use Term::ReadLine::Gnu |
16 | $ENV{LANG} = 'C'; | |
16 | $ENV{LC_ALL} = 'C'; | |
17 | 17 | } |
18 | 18 | END {print "not ok $n\n" unless $loaded;} |
19 | 19 | |
74 | 74 | my ($version) = $attribs->{library_version} =~ /(\d+\.\d+)/; |
75 | 75 | |
76 | 76 | ######################################################################## |
77 | # 2.3.1 Initializing History and State Management | |
77 | print "# 2.3.1 Initializing History and State Management\n"; | |
78 | 78 | |
79 | 79 | # test using_history |
80 | 80 | # This is verbose since 'new' has already initialized the GNU history library. |
111 | 111 | ? "ok $n\n" : "not ok $n\n"; $n++; |
112 | 112 | |
113 | 113 | ######################################################################## |
114 | # 2.3.2 History List Management | |
114 | print "# 2.3.2 History List Management\n"; | |
115 | 115 | |
116 | 116 | my @list_set; |
117 | 117 | # default value of `history_base' is 1 |
177 | 177 | show_indices; |
178 | 178 | |
179 | 179 | ######################################################################## |
180 | # 2.3.3 Information About the History List | |
180 | print "# 2.3.3 Information About the History List\n"; | |
181 | 181 | |
182 | 182 | $attribs->{history_base} = 0; |
183 | 183 | show_indices; |
208 | 208 | print $t->history_total_bytes == 15 ? "ok $n\n" : "not ok $n\n"; $n++; |
209 | 209 | |
210 | 210 | ######################################################################## |
211 | # 2.3.4 Moving Around the History List | |
211 | print "# 2.3.4 Moving Around the History List\n"; | |
212 | 212 | |
213 | 213 | # history_set_pos() |
214 | 214 | $t->history_set_pos(2); |
242 | 242 | |
243 | 243 | |
244 | 244 | ######################################################################## |
245 | # 2.3.5 Searching the History List | |
245 | print "# 2.3.5 Searching the History List\n"; | |
246 | 246 | |
247 | 247 | @list_set = ('red yellow', 'green red', 'yellow blue', 'green blue'); |
248 | 248 | $t->SetHistory(@list_set); |
298 | 298 | ? "ok $n\n" : "not ok $n\n"); $n++; |
299 | 299 | |
300 | 300 | ######################################################################## |
301 | # 2.3.6 Managing the History File | |
301 | print "# 2.3.6 Managing the History File\n"; | |
302 | 302 | |
303 | 303 | $t->stifle_history(undef); |
304 | 304 | my $hfile = '.history_test'; |
349 | 349 | #print "@{[$t->GetHistory]}\n"; |
350 | 350 | |
351 | 351 | ######################################################################## |
352 | # 2.3.7 History Expansion | |
352 | print "# 2.3.7 History Expansion\n"; | |
353 | 353 | |
354 | 354 | my ($string, $ret, @ret, $exp, @exp); |
355 | 355 | |
420 | 420 | print $ret eq $exp ? "ok $n\n" : "not ok $n\n"; $n++; |
421 | 421 | |
422 | 422 | ######################################################################## |
423 | # 2.4 History Variables | |
423 | print "# 2.4 History Variables\n"; | |
424 | 424 | |
425 | 425 | # history_base, history_length, max_input_history are tested above |
426 | 426 |
0 | 0 | # -*- perl -*- |
1 | 1 | # readline.t - Test script for Term::ReadLine:GNU |
2 | 2 | # |
3 | # $Id: readline.t 454 2014-03-02 14:28:30Z hayashi $ | |
3 | # $Id: readline.t 497 2015-09-21 12:46:09Z hayashi $ | |
4 | 4 | # |
5 | # Copyright (c) 2014 Hiroo Hayashi. All rights reserved. | |
5 | # Copyright (c) 1996 Hiroo Hayashi. All rights reserved. | |
6 | 6 | # |
7 | 7 | # This program is free software; you can redistribute it and/or |
8 | 8 | # modify it under the same terms as Perl itself. |
13 | 13 | BEGIN { |
14 | 14 | print "1..140\n"; $n = 1; |
15 | 15 | $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 | |
17 | 17 | } |
18 | 18 | END {print "not ok 1\tfail to loading\n" unless $loaded;} |
19 | 19 | |
26 | 26 | eval "use ExtUtils::testlib;" or eval "use lib './blib';"; |
27 | 27 | use Term::ReadLine; |
28 | 28 | use Term::ReadLine::Gnu qw(ISKMAP ISMACR ISFUNC RL_STATE_INITIALIZED); |
29 | ||
30 | print "# Testing Term::ReadLine::Gnu version $Term::ReadLine::Gnu::VERSION\n"; | |
29 | 31 | |
30 | 32 | $loaded = 1; |
31 | 33 | print "ok 1\tloading\n"; $n++; |
44 | 46 | print "ok $n\t$what\n"; |
45 | 47 | } else { |
46 | 48 | print "not ok $n\t$what"; |
47 | print @_ ? "\t@_\n" : "\n"; | |
49 | print @_ ? "\t[@_]\n" : "\n"; | |
48 | 50 | $ok = 0; |
49 | 51 | } |
50 | 52 | $n++; |
57 | 59 | $ENV{'INPUTRC'} = '/dev/null'; |
58 | 60 | # These tty setting affects GNU Readline key-bindings. |
59 | 61 | # 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: $?"; | |
64 | 67 | |
65 | 68 | my $t = new Term::ReadLine 'ReadLineTest'; |
66 | 69 | $res = defined $t; ok('new'); |
96 | 99 | $res = defined $a; ok('Attrib method'); |
97 | 100 | |
98 | 101 | ######################################################################## |
99 | # 2.3 Readline Variables | |
102 | print "# 2.3 Readline Variables\n"; | |
100 | 103 | |
101 | 104 | my ($maj, $min) = $a->{library_version} =~ /(\d+)\.(\d+)/; |
102 | 105 | my $version = $a->{readline_version}; |
174 | 177 | |
175 | 178 | |
176 | 179 | ######################################################################## |
177 | # 2.4 Readline Convenience Functions | |
180 | print "# 2.4 Readline Convenience Functions\n"; | |
178 | 181 | |
179 | 182 | ######################################################################## |
180 | 183 | # define some custom functions |
225 | 228 | } |
226 | 229 | |
227 | 230 | ######################################################################## |
228 | # 2.4.1 Naming a Function | |
231 | print "# 2.4.1 Naming a Function\n"; | |
229 | 232 | |
230 | 233 | my ($func, $type); |
231 | 234 | |
256 | 259 | ok; |
257 | 260 | |
258 | 261 | ######################################################################## |
259 | # 2.4.2 Selecting a Keymap | |
262 | print "# 2.4.2 Selecting a Keymap\n"; | |
260 | 263 | |
261 | 264 | # test rl_make_bare_keymap, rl_copy_keymap, rl_make_keymap, rl_discard_keymap |
262 | 265 | my $baremap = $t->make_bare_keymap; |
294 | 297 | ok; |
295 | 298 | |
296 | 299 | ######################################################################## |
297 | # 2.4.3 Binding Keys | |
300 | print "# 2.4.3 Binding Keys\n"; | |
298 | 301 | |
299 | 302 | #print $t->get_keymap_name($a->{executing_keymap}), "\n"; |
300 | 303 | #print $t->get_keymap_name($a->{binding_keymap}), "\n"; |
406 | 409 | $n++; |
407 | 410 | } |
408 | 411 | ######################################################################## |
409 | # 2.4.4 Associating Function Names and Bindings | |
412 | print "# 2.4.4 Associating Function Names and Bindings\n"; | |
410 | 413 | |
411 | 414 | bind_my_function; # do bind |
412 | 415 | |
420 | 423 | ok('invoking_keyseqs'); |
421 | 424 | |
422 | 425 | ######################################################################## |
423 | # 2.4.5 Allowing Undoing | |
426 | print "# 2.4.5 Allowing Undoing\n"; | |
424 | 427 | # rl_begin_undo_group!!!, rl_end_undo_group!!!, rl_add_undo!!!, |
425 | 428 | # rl_free_undo_list!!!, rl_do_undo!!!, rl_modifying |
426 | 429 | |
427 | 430 | ######################################################################## |
428 | # 2.4.6 Redisplay | |
431 | print "# 2.4.6 Redisplay\n"; | |
429 | 432 | # rl_redisplay!!!, rl_forced_update_display, rl_on_new_line!!!, |
430 | 433 | # rl_on_new_line_with_prompt!!!, rl_reset_line_state!!!, rl_crlf!!!, |
431 | 434 | # rl_show_char!!!, |
434 | 437 | # rl_expand_prompt!!!, rl_set_prompt!!! |
435 | 438 | |
436 | 439 | ######################################################################## |
437 | # 2.4.7 Modifying Text | |
440 | print "# 2.4.7 Modifying Text\n"; | |
438 | 441 | # rl_insert_text!!!, rl_delete_text!!!, rl_copy_text!!!, rl_kill_text!!!, |
439 | 442 | # rl_push_macro_input!!! |
440 | 443 | |
441 | 444 | ######################################################################## |
442 | # 2.4.8 Character Input | |
445 | print "# 2.4.8 Character Input\n"; | |
443 | 446 | # rl_read_key!!!, rl_getc, rl_stuff_char!!!, rl_execute_next!!!, |
444 | 447 | # rl_clear_pending_input!!!, rl_set_keyboard_input_timeout!!! |
445 | 448 | |
446 | 449 | ######################################################################## |
447 | # 2.4.9 Terminal Management | |
450 | print "# 2.4.9 Terminal Management\n"; | |
448 | 451 | # rl_prep_terminal!!!, rl_deprep_terminal!!!, |
449 | 452 | # rl_tty_set_default_bindings!!!, rl_tty_unset_default_bindings!!!, |
450 | 453 | # rl_reset_terminal!!! |
451 | 454 | |
452 | 455 | ######################################################################## |
453 | # 2.4.10 Utility Functions | |
456 | print "# 2.4.10 Utility Functions\n"; | |
454 | 457 | # rl_save_state!!!, rl_restore_state!!!, rl_replace_line!!!, |
455 | 458 | # rl_initialize, rl_ding!!!, rl_alphabetic!!!, |
456 | 459 | # rl_display_match_list |
457 | 460 | |
458 | 461 | ######################################################################## |
459 | # 2.4.11 Miscellaneous Functions | |
462 | print "# 2.4.11 Miscellaneous Functions\n"; | |
460 | 463 | # rl_macro_bind!!!, rl_macro_dumpter!!!, |
461 | 464 | # rl_variable_bind!!!, rl_variable_value!!!, rl_variable_dumper!!! |
462 | 465 | # rl_set_paren_blink_timeout!!!, rl_get_termcap!!!, rl_clear_history!!! |
463 | 466 | |
464 | 467 | ######################################################################## |
465 | # 2.4.12 Alternate Interface | |
468 | print "# 2.4.12 Alternate Interface\n"; | |
466 | 469 | # tested in callback.t |
467 | 470 | # rl_callback_handler_install, rl_callback_read_char, |
468 | 471 | # rl_callback_handler_remove, |
469 | 472 | |
470 | 473 | ######################################################################## |
471 | # 2.5 Readline Signal Handling | |
474 | print "# 2.5 Readline Signal Handling\n"; | |
472 | 475 | $res = $a->{catch_signals} == 1; ok('catch_signals'); |
473 | 476 | $res = $a->{catch_sigwinch} == 1; ok('catch_sigwinch'); |
474 | 477 | $res = $a->{change_environment} == 1; ok('change_environment'); |
493 | 496 | # rl_reset_screen_size!!!, rl_set_signals!!!, rl_clear_signals!!! |
494 | 497 | |
495 | 498 | ######################################################################## |
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"; | |
499 | 502 | # rl_complete_internal!!!, rl_completion_mode!!!, rl_completion_matches, |
500 | 503 | # rl_filename_completion_function, rl_username_completion_function, |
501 | 504 | # list_completion_function |
502 | 505 | |
503 | # 2.6.3 Completion Variables | |
506 | print "# 2.6.3 Completion Variables\n"; | |
504 | 507 | $res = ! defined $a->{completion_entry_function}; ok; |
505 | 508 | $res = ! defined $a->{attempted_completion_function}; ok; |
506 | 509 | $res = ! defined $a->{filename_quoting_function}; ok; |
546 | 549 | ######################################################################## |
547 | 550 | |
548 | 551 | $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'); | |
549 | 555 | |
550 | 556 | my ($INSTR, $line); |
551 | 557 | # simulate key input by using a variable 'rl_getc_function' |
648 | 654 | $res = $line eq 'one'; ok('operate_and_get_next 4', $line); |
649 | 655 | |
650 | 656 | ######################################################################## |
651 | # test history expansion | |
657 | print "# test history expansion\n"; | |
652 | 658 | |
653 | 659 | $t->ornaments(0); # ornaments off |
654 | 660 | |
679 | 685 | $res = $line eq '1234'; ok('history 3', $line); |
680 | 686 | |
681 | 687 | ######################################################################## |
682 | # test custom completion function | |
688 | print "# test custom completion function\n"; | |
683 | 689 | |
684 | 690 | $t->parse_and_bind('set bell-style none'); # make readline quiet |
685 | 691 | |
845 | 851 | $t->parse_and_bind('set bell-style audible'); # resume to default style |
846 | 852 | |
847 | 853 | ######################################################################## |
848 | # test rl_startup_hook, rl_pre_input_hook | |
854 | print "# test rl_startup_hook, rl_pre_input_hook\n"; | |
849 | 855 | |
850 | 856 | $a->{startup_hook} = sub { $a->{point} = 10; }; |
851 | 857 | $INSTR = "insert\cM"; |
865 | 871 | $a->{pre_input_hook} = undef; |
866 | 872 | |
867 | 873 | ######################################################################### |
868 | # test redisplay_function | |
874 | print "# test redisplay_function\n"; | |
869 | 875 | $a->{redisplay_function} = $a->{shadow_redisplay}; |
870 | 876 | $INSTR = "\cX\cVThis is a password.\cM"; |
871 | 877 | $line = $t->readline("password> "); |
875 | 881 | print "ok $n\n"; $n++; |
876 | 882 | |
877 | 883 | ######################################################################### |
878 | # test rl_display_match_list | |
884 | print "# test rl_display_match_list\n"; | |
879 | 885 | |
880 | 886 | 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); | |
882 | 889 | $t->display_match_list(\@match_list); |
883 | 890 | $t->parse_and_bind('set print-completions-horizontally on'); |
884 | 891 | $t->display_match_list(\@match_list); |
885 | 892 | $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); | |
886 | 897 | print "ok $n\n"; $n++; |
887 | 898 | } else { |
888 | 899 | print "ok $n # skipped because GNU Readline Library is older than 4.0.\n"; |
890 | 901 | } |
891 | 902 | |
892 | 903 | ######################################################################### |
893 | # test rl_completion_display_matches_hook | |
904 | print "# test rl_completion_display_matches_hook\n"; | |
894 | 905 | |
895 | 906 | if ($version >= 0x0400) { |
896 | 907 | # See 'eg/perlsh' for better example |
912 | 923 | } |
913 | 924 | |
914 | 925 | ######################################################################## |
915 | # test ornaments | |
926 | print "# test ornaments\n"; | |
916 | 927 | |
917 | 928 | $INSTR = "\cM\cM\cM\cM\cM\cM\cM"; |
918 | 929 | print $OUT "# ornaments test\n"; |
941 | 952 | print "ok $n\n"; $n++; |
942 | 953 | |
943 | 954 | ######################################################################## |
944 | # end of non-interactive test | |
955 | print "# end of non-interactive test\n"; | |
945 | 956 | unless ($verbose) { |
946 | 957 | # Be quiet during CPAN Testers testing. |
947 | 958 | print STDERR "ok\tTry \`$^X -Mblib t/readline.t verbose\', if you will.\n" |
952 | 963 | undef $a->{input_available_hook}; |
953 | 964 | |
954 | 965 | ######################################################################## |
955 | # interactive test | |
966 | print "# interactive test\n"; | |
956 | 967 | |
957 | 968 | ######################################################################## |
958 | 969 | # test redisplay_function |