summaryrefslogtreecommitdiff
path: root/lib/Term
diff options
context:
space:
mode:
authorPerl 5 Porters <perl5-porters@africa.nicoh.com>1997-04-09 00:00:00 +0000
committerChip Salzenberg <chip@atlantic.net>1997-04-09 00:00:00 +0000
commit7a2e2cd6e4407ff4fe23355f0373307425305867 (patch)
treeb8bac221ca9fae30bb25f4d8ac3ae8f8d5a1b483 /lib/Term
parentfa85963645b525b23ccb5a91ab9199c740773c41 (diff)
downloadperl-7a2e2cd6e4407ff4fe23355f0373307425305867.tar.gz
[inseparable changes from match from perl-5.003_97c to perl-5.003_97d]perl-5.003_97d
DOCUMENTATION Subject: more (err, less) doubled words Date: Fri, 11 Apr 1997 22:31:25 +0300 (EET DST) From: Jarkko Hietaniemi <Jarkko.Hietaniemi@cc.hut.fi> Files: ext/DB_File/DB_File.pm ext/DynaLoader/DynaLoader.pm ext/IO/lib/IO/Pipe.pm lib/CGI.pm lib/Exporter.pm lib/ExtUtils/MakeMaker.pm lib/IPC/Open2.pm lib/IPC/Open3.pm lib/vars.pm pod/perlcall.pod pod/perldiag.pod pod/perlfaq1.pod pod/perlfaq3.pod pod/perlfaq5.pod pod/perlfaq7.pod pod/perlfaq8.pod pod/perlipc.pod private-msgid: 199704111931.WAA24460@alpha.hut.fi LIBRARY AND EXTENSIONS Subject: win32: perl5db patch Date: Thu, 10 Apr 1997 17:42:13 -0400 From: Gurusamy Sarathy <gsar@engin.umich.edu> Files: lib/perl5db.pl Msg-ID: 199704102142.RAA27396@aatma.engin.umich.edu (applied based on p5p patch as commit 56cbacacb6c634a626b06407cbd555bc1519a2d5) Subject: Enhancements to debugger, Term::ReadLine, Term::Cap Date: Thu, 10 Apr 1997 15:48:07 -0400 (EDT) From: Ilya Zakharevich <ilya@math.ohio-state.edu> Files: lib/Term/Cap.pm lib/Term/ReadLine.pm lib/perl5db.pl Msg-ID: 199704101948.PAA01841@monk.mps.ohio-state.edu (applied based on p5p patch as commit 6fb2d361298c4eb5d42f1f63b0f74a60d407e546) OTHER CORE CHANGES Subject: New error msg for low-key failure of C<require> From: Chip Salzenberg <chip@perl.com> Files: pod/perldiag.pod pp_ctl.c t/pragma/strict-subs t/pragma/strict-vars
Diffstat (limited to 'lib/Term')
-rw-r--r--lib/Term/Cap.pm7
-rw-r--r--lib/Term/ReadLine.pm46
2 files changed, 48 insertions, 5 deletions
diff --git a/lib/Term/Cap.pm b/lib/Term/Cap.pm
index 0b3b4aa4ad..5703405c9d 100644
--- a/lib/Term/Cap.pm
+++ b/lib/Term/Cap.pm
@@ -104,8 +104,11 @@ as C<$self-E<gt>{TERMCAP}>.
sub termcap_path { ## private
my @termcap_path;
# $TERMCAP, if it's a filespec
- push(@termcap_path, $ENV{TERMCAP}) if ((exists $ENV{TERMCAP}) &&
- ($ENV{TERMCAP} =~ /^\//));
+ push(@termcap_path, $ENV{TERMCAP})
+ if ((exists $ENV{TERMCAP}) &&
+ (($^O eq 'os2' || $^O eq 'MSWin32')
+ ? $ENV{TERMCAP} =~ /^[a-z]:[\\\/]/i
+ : $ENV{TERMCAP} =~ /^\//));
if ((exists $ENV{TERMPATH}) && ($ENV{TERMPATH})) {
# Add the users $TERMPATH
push(@termcap_path, split(/(:|\s+)/, $ENV{TERMPATH}))
diff --git a/lib/Term/ReadLine.pm b/lib/Term/ReadLine.pm
index 7b735eb424..a52b558b22 100644
--- a/lib/Term/ReadLine.pm
+++ b/lib/Term/ReadLine.pm
@@ -105,6 +105,15 @@ support reacher set of commands.
All these commands are callable via method interface and have names
which conform to standard conventions with the leading C<rl_> stripped.
+The stub package included with the perl distribution allows two
+additional methods: C<tkRunning> and C<ornaments>. The first one
+makes Tk event loop run when waiting for user input (i.e., during
+C<readline> method), the second one makes the command line stand out
+by using termcap data. The argument to C<ornaments> should be 0, 1,
+or a string of a form "aa,bb,cc,dd". Four components of this string
+should be names of I<terminal capacities>, first two will be issued to
+make the prompt standout, last two to make the input line standout.
+
=head1 EXPORTS
None
@@ -121,20 +130,22 @@ If the variable is not set, the best available package is loaded.
=cut
package Term::ReadLine::Stub;
-@ISA = 'Term::ReadLine::Tk';
+@ISA = qw'Term::ReadLine::Tk Term::ReadLine::TermCap';
$DB::emacs = $DB::emacs; # To peacify -w
+*rl_term_set = \@Term::ReadLine::TermCap::rl_term_set;
sub ReadLine {'Term::ReadLine::Stub'}
sub readline {
my $self = shift;
my ($in,$out,$str) = @$self;
- print $out shift;
+ print $out $rl_term_set[0], shift, $rl_term_set[1], $rl_term_set[2];
$self->register_Tk
if not $Term::ReadLine::registered and $Term::ReadLine::toloop
and defined &Tk::DoOneEvent;
#$str = scalar <$in>;
$str = $self->get_line;
+ print $out $rl_term_set[3];
# bug in 5.000: chomping empty string creats length -1:
chomp $str if defined $str;
$str;
@@ -200,7 +211,7 @@ sub OUT { shift->[1] }
sub MinLine { undef }
sub Attribs { {} }
-my %features = (tkRunning => 1);
+my %features = (tkRunning => 1, ornaments => 1);
sub Features { \%features }
package Term::ReadLine; # So late to allow the above code be defined?
@@ -233,6 +244,35 @@ if (defined &Term::ReadLine::Gnu::readline) {
@ISA = qw(Term::ReadLine::Stub);
}
+package Term::ReadLine::TermCap;
+
+# Prompt-start, prompt-end, command-line-start, command-line-end
+# -- zero-width beautifies to emit around prompt and the command line.
+@rl_term_set = ("","","","");
+# string encoded:
+$rl_term_set = ',,,';
+
+sub LoadTermCap {
+ return if defined $terminal;
+
+ require Term::Cap;
+ $terminal = Tgetent Term::Cap ({OSPEED => 9600}); # Avoid warning.
+}
+
+sub ornaments {
+ shift;
+ return $rl_term_set unless @_;
+ $rl_term_set = shift;
+ $rl_term_set ||= ',,,';
+ $rl_term_set = 'us,ue,md,me' if $rl_term_set == 1;
+ my @ts = split /,/, $rl_term_set, 4;
+ eval { LoadTermCap };
+ warn("Cannot find termcap: $@\n"), return unless defined $terminal;
+ @rl_term_set = map {$_ ? $terminal->Tputs($_,1) || '' : ''} @ts;
+ return $rl_term_set;
+}
+
+
package Term::ReadLine::Tk;
$count_handle = $count_DoOne = $count_loop = 0;