3 # This library is no longer being maintained, and is included for backward
4 # compatibility with Perl 4 programs which may require it.
5 # This legacy library is deprecated and will be removed in a future
8 # In particular, this should not be used as an example of modern Perl
9 # programming techniques.
11 # Suggested alternative: Term::Complete
13 ;# @(#)complete.pl,v1.1 (me@anywhere.EBay.Sun.COM) 09/23/91
15 ;# Author: Wayne Thompson
18 ;# This routine provides word completion.
19 ;# (TAB) attempts word completion.
20 ;# (^D) prints completion list.
21 ;# (These may be changed by setting $Complete'complete, etc.)
24 ;# Bell when word completion fails.
27 ;# The tty driver is put into raw mode.
32 ;# $input = &Complete('prompt_string', *completion_list);
34 ;# $input = &Complete('prompt_string', @completion_list);
49 local($prompt, @cmp_list, $return, @match, $l, $test, $cmp, $r);
50 if ($_[1] =~ /^StB\0/) {
58 system('stty raw -echo');
60 print($prompt, $return);
61 while (($_ = getc(STDIN)) ne "\r") {
63 # (TAB) attempt completion
65 @match = grep(/^$return/, @cmp_lst);
66 $l = length($test = shift(@match));
67 unless ($#match < 0) {
68 foreach $cmp (@match) {
69 until (substr($cmp, 0, $l) eq substr($test, 0, $l)) {
75 print($test = substr($test, $r, $l - $r));
76 $r = length($return .= $test);
80 # (^D) completion list
81 $_ eq $complete && do {
82 print(join("\r\n", '', grep(/^$return/, @cmp_lst)), "\r\n");
98 ($_ eq $erase1 || $_ eq $erase2) && do {
117 system('stty -raw echo');