[libterm-clui-perl] 01/04: Imported Upstream version 1.68

Axel Beckert abe at deuxchevaux.org
Sat Sep 28 02:14:50 UTC 2013


This is an automated email from the git hooks/post-receive script.

abe pushed a commit to branch master
in repository libterm-clui-perl.

commit f66003f4a0a862ec3104a0b50ef6281b4fbcf145
Author: Axel Beckert <abe at deuxchevaux.org>
Date:   Sat Sep 28 03:53:18 2013 +0200

    Imported Upstream version 1.68
---
 Changes              |    2 ++
 Clui.pm              |   46 +++++++++++++++++++-----------
 Clui/FileSelect.pm   |    2 +-
 META.yml             |    2 +-
 examples/audio_stuff |    9 +++++-
 py/TermClui.py       |   76 +++++++++++++++++++++++++++-----------------------
 6 files changed, 83 insertions(+), 54 deletions(-)

diff --git a/Changes b/Changes
index 6c8cd05..2026260 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,5 @@
+20130999 1.68 handle Haiku's \eO[ABCD] arrow-keys
+20130323 1.67 Home and End work in sub ask; bug fixes in sub ask_password
 20120905 1.66 ask_filename strips trailing space after filename-completion
 20120327 1.65 also ask_filename introduced
 20120310 view uses antiword, wv or catdoc on .doc files
diff --git a/Clui.pm b/Clui.pm
index 2876f5b..ec0650f 100644
--- a/Clui.pm
+++ b/Clui.pm
@@ -8,7 +8,7 @@
 #########################################################################
 
 package Term::Clui;
-$VERSION = '1.66';   # 
+$VERSION = '1.68';   # handle Haiku's \eO[ABCD] arrow-keys
 my $stupid_bloody_warning = $VERSION;  # circumvent -w warning
 require Exporter;
 @ISA = qw(Exporter);
@@ -42,7 +42,7 @@ if ($ENV{'CLUI_SPEAK'}) {  # 1.62 emacspeak not very relevant as a criterion
 	}
 	$Eflite = &which('eflite');
 	$Espeak = &which('espeak');
-	if ($Eflite) {
+	if ($Eflite && !$Espeak) {   # 1.68 Espeak should be the default
 		if (open($Eflite_FH,'|-',$Eflite)) {
 			select((select($Eflite_FH), $| = 1)[$[]); print $Eflite_FH q{};
 		} else {
@@ -74,13 +74,15 @@ $KEY_DOWN  = 0402;
 $KEY_ENTER = "\r";
 $KEY_INSERT = 0525;
 $KEY_DELETE = 0524;
-$KEY_PPAGE = 0523;
-$KEY_NPAGE = 0522;
-$KEY_BTAB  = 0541;
+$KEY_HOME   = 0523;
+$KEY_END    = 0522;
+$KEY_PPAGE  = 0521;
+$KEY_NPAGE  = 0520;
+$KEY_BTAB   = 0541;
 my $AbsCursX = 0; my $AbsCursY = 0; my $TopRow = 0; my $CursorRow;
 my $LastEventWasPress = 0;  # in order to ignore left-over button-ups
 my %SpecialKey = map { $_, 1 } (   # 1.51, used by ask to ignore these
-	$KEY_UP, $KEY_LEFT, $KEY_RIGHT, $KEY_DOWN,
+	$KEY_UP, $KEY_LEFT, $KEY_RIGHT, $KEY_DOWN, $KEY_HOME, $KEY_END,
 	$KEY_PPAGE, $KEY_NPAGE, $KEY_BTAB, $KEY_INSERT, $KEY_DELETE
 );
 
@@ -140,12 +142,24 @@ sub getch {
 		if ($c eq '5') { getc_wrapper(0); return($KEY_PPAGE); }
 		if ($c eq '6') { getc_wrapper(0); return($KEY_NPAGE); }
 		if ($c eq 'Z') { return($KEY_BTAB); }
+		if ($c eq 'O') {   # 1.68 Haiku wierdness, inherited from an old Suse
+			$c = getc_wrapper(0);
+			if ($c eq 'A') { return($KEY_UP); }    # 1.68
+			if ($c eq 'B') { return($KEY_DOWN); }  # 1.68
+			if ($c eq 'C') { return($KEY_RIGHT); } # 1.68
+			if ($c eq 'D') { return($KEY_LEFT); }  # 1.68
+			if ($c eq 'F') { return($KEY_END); }   # 1.68
+			if ($c eq 'H') { return($KEY_HOME); }  # 1.68
+			return($c);
+		}
 		if ($c eq '[') {
 			$c = getc_wrapper(0);
 			if ($c eq 'A') { return($KEY_UP); }
 			if ($c eq 'B') { return($KEY_DOWN); }
 			if ($c eq 'C') { return($KEY_RIGHT); }
 			if ($c eq 'D') { return($KEY_LEFT); }
+			if ($c eq 'F') { return($KEY_END); }   # 1.67
+			if ($c eq 'H') { return($KEY_HOME); }  # 1.67
             if ($c eq 'M') {   # mouse report - we must be in BYTES !
 				# http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
 				my $event_type = ord(getc_wrapper(0))-32;
@@ -434,7 +448,7 @@ sub ask { my ($question, $default) = @_;
 		&speak("$question, default is $default");
 		$default =~ s/\t/	/g;
 		@s = split(q{}, $default); $n = scalar @s; $i = $[;
-		foreach $j ($[ .. $n) { &puts($s[$j]); }
+		foreach $j ($[ .. $#s) { &puts($s[$j]); }
 		&left($n);
 	} else {
 		&speak($question);
@@ -453,7 +467,7 @@ sub ask { my ($question, $default) = @_;
 		} elsif ($c == $KEY_DELETE) {  # 1.54
 			if ($i < $n) {
 			 	$n--; splice(@s, $i, 1);
-			  	foreach $j ($i .. $n) { &puts($s[$j]); }
+			  	foreach $j ($i..$#s) { &puts($silent ? "x" : $s[$j]); } # 1.67
 			  	&clrtoeol(); &left($n-$i);
 			}
 		} elsif (($c eq "\cH") || ($c eq "\c?")) {
@@ -461,7 +475,7 @@ sub ask { my ($question, $default) = @_;
 			 	$n--; $i--;
 				if (! $silent) { &speak($s[$i]); }   # 1.63
 				splice(@s, $i, 1); &left(1);
-			  	foreach $j ($i .. $n) { &puts($s[$j]); }
+			  	foreach $j ($i..$#s) { &puts($silent ? "x" : $s[$j]); } # 1.67
 			  	&clrtoeol(); &left($n-$i);
 			}
 		} elsif ($c eq "\cC") {  # 1.56
@@ -469,8 +483,8 @@ sub ask { my ($question, $default) = @_;
 			warn "^C\n"; kill('INT', $$); return undef;
 		} elsif ($c eq "\cX" || $c eq "\cD") {  # clear ...
 			&left($i); $i = 0; $n = 0; &clrtoeol(); @s = ();
-		} elsif ($c eq "\cA") { &left($i); $i = 0;
-		} elsif ($c eq "\cE") { &right($n-$i); $i = $n;
+		} elsif ($c eq "\cA" || $c == $KEY_HOME) { &left($i); $i = 0;
+		} elsif ($c eq "\cE" || $c == $KEY_END)  { &right($n-$i); $i = $n;
 		} elsif ($c eq "\cL") { &speak(join("", @s));  # redraw ...
 		} elsif ($SpecialKey{$c}) { &beep();
 		} elsif (ord($c) >= 32) {  # 1.51
@@ -478,7 +492,7 @@ sub ask { my ($question, $default) = @_;
 			&puts($silent ? "x" : $c);
 			if (! $silent) {  &speak($c); }
 			$n++; $i++;
-			foreach $j ($i .. $n) { &puts($s[$j]); }
+			foreach $j ($i..$#s) { &puts($silent ? "x" : $s[$j]); }  # 1.67
 			&clrtoeol();  &left($n-$i);
 		} else { &beep();
 		}
@@ -1177,7 +1191,7 @@ sub speak {  my ($text, $wait) = @_;
 			# useless emacspeak op: tts_sy nc_state all 0 0  1 225\nq {[:np  ]}
 			if ($wait) { select(undef,undef,undef,0.3+0.07*length($text)); }
 		}
-	} elsif ($Espeak) {
+	} elsif ($Espeak) {  # 1.68 should be using Speech::eSpeak !
 		if ($Espeak_PID) { kill SIGHUP, $Espeak_PID; wait; $Espeak_PID = 0; }
 		$Espeak_PID = fork();
 		if ($Espeak_PID) {
@@ -1356,9 +1370,9 @@ The application needs no modification.
 
 There is an equivalent Python3 module,
 with (as far as possible) the same calling interface, at
-http://cpansearch.perl.org/src/PJB/Term-Clui-1.62/py/TermClui.py
+http://cpansearch.perl.org/src/PJB/Term-Clui-1.68/py/TermClui.py
 
-This is Term::Clui.pm version 1.66
+This is Term::Clui.pm version 1.68
 
 =head1 WINDOW-SIZE
 
@@ -1658,6 +1672,6 @@ which were in turn based on some even older curses-based programs in I<C>.
 
 There is an equivalent Python3 module,
 with (as far as possible) the same calling interface, at
-http://cpansearch.perl.org/src/PJB/Term-Clui-1.66/py/TermClui.py
+http://cpansearch.perl.org/src/PJB/Term-Clui-1.68/py/TermClui.py
 
 =cut
diff --git a/Clui/FileSelect.pm b/Clui/FileSelect.pm
index d89dd49..ca2ded7 100644
--- a/Clui/FileSelect.pm
+++ b/Clui/FileSelect.pm
@@ -8,7 +8,7 @@
 #########################################################################
 
 package Term::Clui::FileSelect;
-$VERSION = '1.66';
+$VERSION = '1.68';
 import Term::Clui(':DEFAULT','back_up');
 require Exporter;
 @ISA = qw(Exporter);
diff --git a/META.yml b/META.yml
index 04162df..04d6cce 100644
--- a/META.yml
+++ b/META.yml
@@ -1,7 +1,7 @@
 # http://module-build.sourceforge.net/META-spec-current.html
 #XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
 name:         Term-Clui
-version:      1.66
+version:      1.68
 version_from: Clui.pm
 installdirs:  site
 requires:
diff --git a/examples/audio_stuff b/examples/audio_stuff
index c7905a4..ac39926 100755
--- a/examples/audio_stuff
+++ b/examples/audio_stuff
@@ -159,7 +159,7 @@ sub burn_files {
 	if (! mkdir $tmp_dir) { sorry("can't mkdir $tmp_dir: $!"); $ok=0; }
 	return unless $ok;
 	# must choose_files repeatedly to within size limit
-	my $max_mb = 670;
+	my $max_mb = 800;
 	while (1) {
 		my $mb_so_far = `du -ms $tmp_dir`; $mb_so_far =~ s/\s.*$//;
 		my $remaining = $max_mb - $mb_so_far;
@@ -213,6 +213,9 @@ sub copy_cd {
 	if ($eject) { system $eject; }
 	while (1) {
 		ask("insert blank CD into drive and press Return...");
+		if (($> == 0) and (! -e '/dev/cdrom')) {  # CURSE icedax!
+			symlink '/dev/sr0', '/dev/cdrom';
+		}
 		system "$cdrecord dev=/dev/cdrom -v -dao -useinfo -text  *.wav";
 		if ($eject) { system $eject; }
 		last unless confirm "do you want to write that to another CD ?";
@@ -278,6 +281,7 @@ sub copy_dvd {
 	use File::Path; File::Path::remove_tree("$tmp_mnt");
 	system "ls -l $tmpfile";
 	# to be fussy, could  mount -o loop $tmpfile  and check it's OK ...
+	if (! -s $tmpfile) { warn " the iso fs was empty :-(\n"; return; }
 	while (1) {
 		ask("insert blank DVD into drive, wait for light to go out, then press Return...");
 		# suppress line-feeds in the progress-bar (on stderr) ...
@@ -783,6 +787,7 @@ sub timiditycfg {
 	}
 	close P; return '';
 }
+
 sub set_cdda_device {
 	if ($ENV{CDDA_DEVICE}) { return 1; }
 	inform(" you should set the CDDA_DEVICE environment variable!");
@@ -790,6 +795,8 @@ sub set_cdda_device {
 		$ENV{CDDA_DEVICE} = '/dev/cdrom:@';
 		inform("using $ENV{CDDA_DEVICE} ...");
 		return 1;
+	} elsif (-e '/dev/sr0' and ! $>) {
+		symlink '/dev/sr0', '/dev/cdrom';
 	}
 	system "eject"; system "eject -t"; sleep 3;
 	if ($>) {
diff --git a/py/TermClui.py b/py/TermClui.py
index ee13e05..2072c9a 100644
--- a/py/TermClui.py
+++ b/py/TermClui.py
@@ -57,16 +57,16 @@ the computer is a human-like conversation-partner, this works very
 naturally.  The application needs no modification.
 
 Download TermClui.py from  www.pjb.com.au/midi/free/TermClui.py  or
-from http://cpansearch.perl.org/src/PJB/Term-Clui-1.62/py/TermClui.py
+from http://cpansearch.perl.org/src/PJB/Term-Clui-1.67/py/TermClui.py
 and put it in your PYTHONPATH.  TermClui.py depends on Python3.
 
 TermClui.py is a translation into Python3 of the Perl CPAN Modules
-Term::Clui and Term::Clui::FileSelect.  This is version 1.65
+Term::Clui and Term::Clui::FileSelect.  This is version 1.67
 '''
 import re, sys, select, signal, subprocess, os, random
 import termios, fcntl, struct, stat, time, dbm
 
-VERSION = '1.65'
+VERSION = '1.67'
 
 def _which(s):
     for d in os.getenv('PATH').split(':'):
@@ -137,15 +137,17 @@ _KEY_DOWN  = 0o402
 _KEY_ENTER = "\r"
 _KEY_INSERT = 0o525
 _KEY_DELETE = 0o524
-_KEY_PPAGE = 0o523
-_KEY_NPAGE = 0o522
-_KEY_BTAB  = 0o541
+_KEY_HOME   = 0o523
+_KEY_END    = 0o522
+_KEY_PPAGE  = 0o521
+_KEY_NPAGE  = 0o520
+_KEY_BTAB   = 0o541
 _getchar = lambda: sys.stdin.read(1)
-_ttyin   = 0
-_ttyout  = 0
+_ttyin    = 0
+_ttyout   = 0
 _AbsCursX = 0
 _AbsCursY = 0
-_TopRow = 0
+_TopRow   = 0
 _CursorRow = 0
 _LastEventWasPress = False
 # _SpecialKey unneeded - we test for class int
@@ -235,7 +237,7 @@ def _dbc(c):
 
 def _getch():
     global _KEY_UP, _KEY_DOWN, _KEY_RIGHT, _KEY_LEFT
-    global _KEY_PPAGE, _KEY_NPAGE, _KEY_BTAB
+    global _KEY_PPAGE, _KEY_NPAGE, _KEY_BTAB, _KEY_HOME, _KEY_END
     global _AbsCursX, _AbsCursY
     c = _getc_wrapper(0)
     if c == "\033":
@@ -274,6 +276,10 @@ def _getch():
                 return _KEY_RIGHT 
             if (c == 'D'):
                 return _KEY_LEFT 
+            if (c == 'F'):
+                return _KEY_END  # 1.67
+            if (c == 'H'):
+                return _KEY_HOME  # 1.67
             if (c == 'M'):   # mouse report
                 # http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
                 event_type = ord(_getc_wrapper(0))-32;
@@ -593,7 +599,7 @@ def ask_password(question):
     r'''Like ask, but with no echo. Use it for passwords.'''
     global _silent
     _silent = True
-    ask(question)
+    return ask(question)
 
 def ask_filename(question):
     r'''Uses the readline module to provide filename-completion with the Tab
@@ -609,7 +615,7 @@ and choose() do.  This function was introduced in version 1.65.'''
     #my $filename = $term->readline('');
     #print STDERR "\e[J";
     #return $filename;
-    ask(question)
+    return ask(question)
 
 def ask(question, default=''):
   try:
@@ -654,41 +660,41 @@ ask() returns the string when the user presses Enter.
                 i-=1
                 _left(1)
         elif c == _KEY_RIGHT and i < n:
-            _puts('x') if _silent else _puts(s_a[i])
+            _puts('x') if _silent else _puts(s_a[j])
             i+=1
         elif c == _KEY_DELETE and i < n:
-             n -= 1
-             s_a.pop(i)   # splice(@s, $i, 1)
-             j = i
-             while j < n:
-                 _puts(s_a[j])
-                 j += 1
-             _clrtoeol()
-             _left(n-i)
+            n -= 1
+            s_a.pop(i)   # splice(@s, $i, 1)
+            j = i
+            while j < n:
+                _puts('x') if _silent else _puts(s_a[j])
+                j += 1
+            _clrtoeol()
+            _left(n-i)
         elif (c == "\b") or (c == "\177"):
             if i > 0:
-                 n -= 1
-                 i -= 1
-                 if not _silent:   # 1.63
-                     _speak(s_a[i])
-                 s_a.pop(i)   # splice(@s, $i, 1)
-                 _left(1)
-                 j = i
-                 while j < n:
-                     _puts(s_a[j])
-                     j += 1
-                 _clrtoeol()
-                 _left(n-i)
+                n -= 1
+                i -= 1
+                if not _silent:   # 1.63
+                    _speak(s_a[i])
+                s_a.pop(i)   # splice(@s, $i, 1)
+                _left(1)
+                j = i
+                while j < n:
+                    _puts('x') if _silent else _puts(s_a[j])
+                    j += 1
+                _clrtoeol()
+                _left(n-i)
         elif c == "\030" or c == "\004":  # clear ...
             _left(i)
             i = 0
             n = 0
             _clrtoeol()
             s_a = []
-        elif c == "\001":
+        elif c == "\001" or c == _KEY_HOME:  # 1.67
             _left(i)
             i = 0
-        elif c == "\005":
+        elif c == "\005" or c == _KEY_END:  # 1.67
             _right(n-i)
             i = n
         elif c == "\014":

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libterm-clui-perl.git



More information about the Pkg-perl-cvs-commits mailing list