r22610 - in /branches/upstream/libterm-visual-perl/current: MANIFEST META.yml Visual.pm examples/no_status_title.pl examples/simple_test.pl visual.pm.diff

dmn at users.alioth.debian.org dmn at users.alioth.debian.org
Tue Jul 1 09:57:14 UTC 2008


Author: dmn
Date: Tue Jul  1 09:57:14 2008
New Revision: 22610

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=22610
Log:
[svn-upgrade] Integrating new upstream version, libterm-visual-perl (0.08)

Added:
    branches/upstream/libterm-visual-perl/current/META.yml
Removed:
    branches/upstream/libterm-visual-perl/current/visual.pm.diff
Modified:
    branches/upstream/libterm-visual-perl/current/MANIFEST
    branches/upstream/libterm-visual-perl/current/Visual.pm
    branches/upstream/libterm-visual-perl/current/examples/no_status_title.pl
    branches/upstream/libterm-visual-perl/current/examples/simple_test.pl

Modified: branches/upstream/libterm-visual-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libterm-visual-perl/current/MANIFEST?rev=22610&op=diff
==============================================================================
--- branches/upstream/libterm-visual-perl/current/MANIFEST (original)
+++ branches/upstream/libterm-visual-perl/current/MANIFEST Tue Jul  1 09:57:14 2008
@@ -3,7 +3,6 @@
 Makefile.PL
 README
 Visual.pm
-visual.pm.diff
 Visual/StatusBar.pm
 examples/logmon.pl
 examples/no_status_title.pl
@@ -12,3 +11,4 @@
 examples/test_scrollback.pl
 examples/tailall.pl
 t/use.t
+META.yml                                 Module meta-data (added by MakeMaker)

Added: branches/upstream/libterm-visual-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libterm-visual-perl/current/META.yml?rev=22610&op=file
==============================================================================
--- branches/upstream/libterm-visual-perl/current/META.yml (added)
+++ branches/upstream/libterm-visual-perl/current/META.yml Tue Jul  1 09:57:14 2008
@@ -1,0 +1,15 @@
+--- #YAML:1.0
+name:                Term-Visual
+version:             0.08
+abstract:            Curses split-terminal interface for applications.
+license:             ~
+generated_by:        ExtUtils::MakeMaker version 6.36
+distribution_type:   module
+requires:     
+    Curses:                        
+    POE:                           0.19
+meta-spec:
+    url:     http://module-build.sourceforge.net/META-spec-v1.2.html
+    version: 1.2
+author:
+    - Charles Ayres <lunartear at cpan.org>

Modified: branches/upstream/libterm-visual-perl/current/Visual.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libterm-visual-perl/current/Visual.pm?rev=22610&op=diff
==============================================================================
--- branches/upstream/libterm-visual-perl/current/Visual.pm (original)
+++ branches/upstream/libterm-visual-perl/current/Visual.pm Tue Jul  1 09:57:14 2008
@@ -4,9 +4,9 @@
 use strict;
 use warnings;
 use vars qw($VERSION $REVISION $console);
-$VERSION = '0.06';
-$REVISION = do {my at r=(q$Revision: 0.06 $=~/\d+/g);sprintf"%d."."%02d"x$#r, at r};
-
+$VERSION = '0.08';
+$REVISION = do {my at r=(q$Revision: 0.08 $=~/\d+/g);sprintf"%d."."%02d"x$#r, at r};
+#use Visual::StatusBar;
 use Term::Visual::StatusBar;
 use POE qw(Wheel::Curses Wheel::ReadWrite ); 
 use Curses;
@@ -148,6 +148,7 @@
   
   $kernel->alias_set( $alias );
   $console = POE::Wheel::Curses->new( InputEvent => 'private_input');
+   use_default_colors();
   my $old_mouse_events = 0;
   mousemask(0, $old_mouse_events);
 
@@ -194,7 +195,11 @@
   my $use_status = 1 unless defined $params{Use_Status};
   my $new_window_id = CREATE_WINDOW_ID($self);
   my $window_name = $params{Window_Name} || $new_window_id;
-
+  my $input_prompt = $params{Input_Prompt} || ""; 
+  my $prompt_size = 0;
+  if (length $input_prompt) {
+       $prompt_size = length( $input_prompt ) ;
+  }
   my $input;
   if ($self->[COMMON_INPUT]) {
     $input = $self->[COMMON_INPUT];
@@ -206,11 +211,13 @@
        Command_History  => [ ],
        Data             => "",
        Data_Save        => "",
-       Cursor           => 0,
+       Cursor           => $prompt_size || 0,
        Cursor_Save      => 0,
        Tab_Complete     => undef,
        Insert           => 1,
        Edit_Position    => 0,
+       Prompt           => $input_prompt,
+       Prompt_Size      => $prompt_size,
     };
   }
   # Allow override of possible global options
@@ -654,6 +661,13 @@
 
   $heap->{input_session} = $sender->ID();
   $heap->{input_event}   = $event;
+ 
+   # Increase the sender's reference count so the session stays alive
+   # while the terminal is active.  We'll decrease the reference count
+   # in _stop so it can go away when the terminal does.
+ 
+   $kernel->refcount_increment( $sender->ID(), "terminal link" );
+
 }
 
 ### Get input from the Curses thing.
@@ -692,7 +706,11 @@
   # Beginning of line.
   if ($key eq '^A' or $key eq 'KEY_HOME') {
     if ($winref->{Input}{Cursor}) {
-      $winref->{Input}{Cursor} = 0;
+      if ($winref->{Input}{Prompt_Size}) {
+        $winref->{Input}{Cursor} = $winref->{Input}{Prompt_Size};
+      } else {
+         $winref->{Input}{Cursor} = 0;
+      }
       _refresh_edit($self, $window_id); 
       doupdate();        
     }
@@ -702,9 +720,15 @@
   # Back one character.
   if ($key eq 'KEY_LEFT') {
     if ($winref->{Input}{Cursor}) {
-      $winref->{Input}{Cursor}--;
-      _refresh_edit($self, $window_id);
-      doupdate();
+      if($winref->{Input}{Prompt}) {
+        if($winref->{Input}{Cursor} > $winref->{Input}{Prompt_Size}) {
+            $winref->{Input}{Cursor}--;
+        }
+      } else {
+            $winref->{Input}{Cursor}--;
+        }
+            _refresh_edit($self, $window_id);
+            doupdate();
     }
     return;
   }
@@ -727,14 +751,22 @@
 
   # Interrupt.
   if ($key eq '^\\') {
-    &shutdown;
+
+    $kernel->alias_remove($self->[ALIAS]);
+    delete $heap->{stderr_reader};
+    undef $console;
+    if (defined $heap->{input_session}) {
+        delete $heap->{input_session};          
+    }
+    $kernel->signal($kernel, "UIDESTROY");
     return;
   }
 
   # Delete a character.
   if ($key eq '^D' or $key eq 'KEY_DC') {
-    if ($winref->{Input}{Cursor} < length($winref->{Input}{Data})) {
-      substr($winref->{Input}{Data}, $winref->{Input}{Cursor}, 1) = '';
+       my $csize = $winref->{Input}{Cursor} - $winref->{Input}{Prompt_Size};
+    if ($csize < length($winref->{Input}{Data})) {
+      substr($winref->{Input}{Data}, $winref->{Input}{Cursor} - $winref->{Input}{Prompt_Size}, 1) = '';
       _refresh_edit($self, $window_id);
       doupdate();
     }
@@ -753,7 +785,7 @@
 
   # Forward character.
   if ($key eq '^F' or $key eq 'KEY_RIGHT') {
-    if ($winref->{Input}{Cursor} < length($winref->{Input}{Data})) {
+    if (($winref->{Input}{Cursor} - $winref->{Input}{Prompt_Size}) < length($winref->{Input}{Data})) {
       $winref->{Input}{Cursor}++;
       _refresh_edit($self, $window_id);
       doupdate();
@@ -764,10 +796,12 @@
   # Backward delete character.
   if ($key eq '^H' or $key eq "^?" or $key eq 'KEY_BACKSPACE') {
     if ($winref->{Input}{Cursor}) {
+     if ($winref->{Input}{Cursor} > ($winref->{Input}{Prompt_Size} )) {
       $winref->{Input}{Cursor}--;
-      substr($winref->{Input}{Data}, $winref->{Input}{Cursor}, 1) = '';
+      substr($winref->{Input}{Data}, $winref->{Input}{Cursor} - $winref->{Input}{Prompt_Size}, 1) = '';
       _refresh_edit($self, $window_id);
       doupdate();
+     }
     }
     return;
   }
@@ -1282,28 +1316,29 @@
     my $line = $winref->{Buffer}->[$buffer_y]; # does this work?
     my $column = 1;
     while (length $line) {
-      if ($line =~ s/^\0\(blink_(on|off)\)//) {
-         if ($1 eq 'on') { $screen->attron(A_BLINK); }
-         if ($1 eq 'off') { $screen->attroff(A_BLINK); }
-         $screen->noutrefresh();
-      }
-
-      if ($line =~ s/^\0\(bold_(on|off)\)//) {
-         if ($1 eq 'on') { $screen->attron(A_BOLD); }
-         if ($1 eq 'off') { $screen->attroff(A_BOLD); }
-         $screen->noutrefresh();
-      }
-
-      if ($line =~ s/^\0\(underline_(on|off)\)//) {
-         if ($1 eq 'on') { $screen->attron(A_UNDERLINE); }
-         if ($1 eq 'off') { $screen->attroff(A_UNDERLINE); }
-         $screen->noutrefresh();
-      }
-
-      if ($line =~ s/^ \0 \( ([^\)]+) \) //x) {
-        $screen->attrset($self->[PALETTE]->{$1}->[PAL_PAIR]); 
-        $screen->noutrefresh();
-      }
+      while ($line =~ s/^\0\(([^)]+)\)//) {
+        my $cmd = $1;
+        if ($cmd =~ /blink_(on|off)/) {
+          if ($1 eq 'on') { $screen->attron(A_BLINK); }
+          if ($1 eq 'off') { $screen->attroff(A_BLINK); }
+          $screen->noutrefresh();
+        }
+        elsif ($cmd =~ /bold_(on|off)/) {
+          if ($1 eq 'on') { $screen->attron(A_BOLD); }
+          if ($1 eq 'off') { $screen->attroff(A_BOLD); }
+          $screen->noutrefresh();
+        }
+        elsif ($cmd =~ /underline_(on|off)/) {
+          if ($1 eq 'on') { $screen->attron(A_UNDERLINE); }
+          if ($1 eq 'off') { $screen->attroff(A_UNDERLINE); }
+          $screen->noutrefresh();
+        }
+        else {
+          $screen->attrset($self->[PALETTE]->{$cmd}->[PAL_PAIR]); 
+          $screen->noutrefresh();
+        }
+      }
+
       if ($line =~ s/^([^\0]+)//x) {
 
         # TODO: This needs to be revised so it cuts off the last word,
@@ -1354,6 +1389,7 @@
      re      => COLOR_RED,      red     => COLOR_RED,
      wh      => COLOR_WHITE,    white   => COLOR_WHITE,
      ye      => COLOR_YELLOW,   yellow  => COLOR_YELLOW,
+     de      => -1,             default => -1,
    );
 
   my %attribute_table =
@@ -1464,8 +1500,12 @@
 sub terminal_stopped {
   if (DEBUG) { print ERRS "Enter terminal_stopped\n"; }
   my ($kernel, $heap) = @_[KERNEL, HEAP];
+    $kernel->alias_remove($_[OBJECT][ALIAS]);
+    delete $heap->{stderr_reader};
+    undef $console;
 
   if (defined $heap->{input_session}) {
+     $kernel->refcount_decrement( $heap->{input_session}, "terminal link" );
     delete $heap->{input_session};
   }
 }
@@ -1557,7 +1597,9 @@
   $edit->attron(A_NORMAL);
   $edit->erase();
   $edit->noutrefresh();
-
+  if ($winref->{Input}{Prompt}) {
+    $visible_input = $winref->{Input}{Prompt} . $visible_input;
+  }
   while (length($visible_input)) {
     if ($visible_input =~ /^[\x00-\x1f]/) {
       $edit->attron(A_UNDERLINE);
@@ -1597,7 +1639,7 @@
     # edit box.
 
     $winref->{Input}{Data_Save} = $winref->{Input}{Data} = "";
-    $winref->{Input}{Cursor_Save} = $winref->{Input}{Cursor} = 0;
+    $winref->{Input}{Cursor_Save} = $winref->{Input}{Cursor} = $winref->{Input}{Prompt_Size} || 0;
     $winref->{Input}{History_Position} = -1;
 
     _refresh_edit($self, $window_id);
@@ -1619,7 +1661,9 @@
         $winref->{Input}{Data} = 
           $winref->{Input}{Command_History}->[++$winref->{Input}{History_Position}];
         $winref->{Input}{Cursor} = length($winref->{Input}{Data});
-
+        if ($winref->{Input}{Prompt_Size}) {
+          $winref->{Input}{Cursor} += $winref->{Input}{Prompt_Size};
+        }
         _refresh_edit($self, $window_id);
         doupdate();
       }
@@ -1631,7 +1675,9 @@
     elsif ($winref->{Input}{History_Position} < @{$winref->{Input}{Command_History}} - 1) {
       $winref->{Input}{Data} = $winref->{Input}{Command_History}->[++$winref->{Input}{History_Position}];
       $winref->{Input}{Cursor} = length($winref->{Input}{Data});
-
+        if ($winref->{Input}{Prompt_Size}) {
+          $winref->{Input}{Cursor} += $winref->{Input}{Prompt_Size};
+        }
       _refresh_edit($self, $window_id);
       doupdate();
     }
@@ -1654,6 +1700,9 @@
     elsif ($winref->{Input}{History_Position} > 0) {
       $winref->{Input}{Data} = $winref->{Input}{Command_History}->[--$winref->{Input}{History_Position}];
       $winref->{Input}{Cursor} = length($winref->{Input}{Data});
+        if ($winref->{Input}{Prompt_Size}) {
+          $winref->{Input}{Cursor} += $winref->{Input}{Prompt_Size};
+        }
       _refresh_edit($self, $window_id);
       doupdate();
     }
@@ -1746,7 +1795,21 @@
 
 }
 
-
+sub set_input_prompt {
+  if (DEBUG) { print ERRS "Enter set_input_prompt\n"; }
+  my $self = shift;
+  my $window_id = shift;
+  my $prompt = shift;
+  my $validity = validate_window($self, $window_id);
+  if ($validity) {
+    my $winref = $self->[WINDOW]->{$window_id};
+    $winref->{Input}{Cursor} -= $winref->{Input}{Prompt_Size};
+    $winref->{Input}{Prompt} = $prompt;
+    $winref->{Input}{Cursor} = $winref->{Input}{Prompt_Size} = length $prompt;
+      _refresh_edit($self, $window_id);
+      doupdate();
+ }
+}
 
 sub set_errlevel {}
 sub get_errlevel {}
@@ -1759,13 +1822,20 @@
 }
 
 sub shutdown {
-    $_[KERNEL]->alias_remove($_[OBJECT][ALIAS]);
-    delete $_[HEAP]->{stderr_reader};
-    undef $console;
-    if (defined $_[HEAP]->{input_session}) {
-      $_[KERNEL]->post( $_[HEAP]->{input_session}, $_[HEAP]->{input_event},
-                        undef, 'interrupt' );
-    }
+my $self = shift;
+
+$poe_kernel->post($self->[ALIAS], "_stop");
+
+#    $_[KERNEL]->alias_remove($_[OBJECT][ALIAS]);
+#    delete $_[HEAP]->{stderr_reader};
+#    undef $console;
+#    if (defined $_[HEAP]->{input_session}) {
+#      $_[KERNEL]->post( $_[HEAP]->{input_session}, $_[HEAP]->{input_event},
+#                        undef, 'interrupt' );
+
+#clean up, and close Term::Visual's session so that the only thing that is left is client side, and when ^\ is punched in, clean up things that would leak otherwise, and interrupt?
+
+#    }
 }
 
 1;
@@ -1802,6 +1872,8 @@
 
         Buffer_Size  => 1000,
         History_Size => 50,
+
+        Input_Prompt => "[foo] ", # Set the input prompt for the input line.
  
         Use_Title    => 0, # Don't use a titlebar 
         Use_Status   => 0, # Don't use a statusbar
@@ -1815,13 +1887,15 @@
      }
     );
 
-  sub _start_handler {
+  sub start_handler {
     my $kernel = $_[KERNEL];
 
     # Tell the terminal to send me input as "got_term_input".
     $kernel->post( interface => send_me_input => "got_term_input" );
                     
     $vt->set_status_field( $window_id, bar => $value );
+
+    $vt->set_input_prompt($window_id, "\$");
 
     $vt->print( $window_id, "my Window ID is $window_id" );
   }
@@ -1936,6 +2010,10 @@
 
   History_Size => 50
 
+Set the input prompt of the window
+
+  Input_Prompt => "foo"
+
 Set the title of the window
 
   Title => "This is the Titlebar"
@@ -2055,6 +2133,16 @@
          are set and used by Term::Visual internally.
          It is safe to redifine there values.
 
+=item color codes
+
+Once your color definitions are set in the palette you must insert
+color codes to your output.
+These are formatted as follows: "\0(ncolor)"
+
+So if you wanted to print something with a color you could simply use:
+
+  $vt->print( $window_id, "\0(color_name)My this is a wonderful color." );
+
 =item set_title
 
   $vt->set_title( $window_id, "This is the new Title" );
@@ -2088,6 +2176,12 @@
   $vt->set_status_field( $window_id, field => "value" );
 
   $vt->set_status_field( $window_id, foo => "bar", biz => "baz" );
+
+=item set_input_prompt
+
+  $vt->set_input_prompt($window_id, "\$");
+
+  $vt->set_input_prompt($window_id, "[foo]");
 
 =item columnize
   columnize takes a list of text and formats it into
@@ -2307,11 +2401,11 @@
 
 
 Except where otherwise noted, 
-Term::Visual is Copyright 2002, 2003, 2004 Charles Ayres. All rights reserved.
+Term::Visual is Copyright 2002-2007 Charles Ayres. All rights reserved.
 Term::Visual is free software; you may redistribute it and/or modify
 it under the same terms as Perl itself.
 
-Questions and Comments can be sent to lunartear+visterm at ambientheory.com
+Questions and Comments can be sent to lunartear at cpan.org
 
 Please send bug reports and wishlist items to:
  http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Term-Visual

Modified: branches/upstream/libterm-visual-perl/current/examples/no_status_title.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libterm-visual-perl/current/examples/no_status_title.pl?rev=22610&op=diff
==============================================================================
--- branches/upstream/libterm-visual-perl/current/examples/no_status_title.pl (original)
+++ branches/upstream/libterm-visual-perl/current/examples/no_status_title.pl Tue Jul  1 09:57:14 2008
@@ -41,7 +41,7 @@
 
   # Tell the terminal to send me input as "got_term_input".
   $kernel->post( interface => send_me_input => "got_term_input" );
-
+#  $vt->print($window_id, $vt->[0]{$window_id}->{Screen_Height});
 }
 
 ### The main input handler for this program.  This would be supplied

Modified: branches/upstream/libterm-visual-perl/current/examples/simple_test.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libterm-visual-perl/current/examples/simple_test.pl?rev=22610&op=diff
==============================================================================
--- branches/upstream/libterm-visual-perl/current/examples/simple_test.pl (original)
+++ branches/upstream/libterm-visual-perl/current/examples/simple_test.pl Tue Jul  1 09:57:14 2008
@@ -2,7 +2,7 @@
 use strict;
 sub Term::Visual::DEBUG () { 1 }
 sub Term::Visual::DEBUG_FILE () { 'test.log' }
-use lib '../.';
+#use lib '../.';
 use Carp;
 use POE;
 use Term::Visual;
@@ -40,7 +40,7 @@
 
        Buffer_Size => 1000,
        History_Size => 50,
-
+       Input_Prompt => "[foo] ",
        Title => "Title of window_one"  );
 
 POE::Session->create
@@ -50,6 +50,7 @@
       update_time    => \&update_time,
       update_name    => \&update_name,
       test_buffer    => \&test_buffer,
+      _stop          => \&stop_guts,
     }
   );
 
@@ -70,7 +71,9 @@
   # Start updating the time.
   $kernel->yield( "update_time" );
   $kernel->yield( "update_name" );
+  $vt->set_input_prompt($window_id, "\$");
 #  $kernel->yield( "test_buffer" );
+#  $vt->shutdown;
 }
 
 ### The main input handler for this program.  This would be supplied
@@ -81,11 +84,16 @@
   my ($kernel, $heap, $input, $exception) = @_[KERNEL, HEAP, ARG0, ARG1];
 
   # Got an exception.  These are interrupt (^C) or quit (^\).
-  if (defined $exception) {
-    warn "got exception: $exception";
-    exit;
+#  if (defined $exception) {
+#    warn "got exception: $exception";
+#    exit;
+#  }
+  if ($input eq 'quit') {
+   $kernel->yield('_stop'); 
   }
-  $vt->print($window_id, $input);
+  else {
+    $vt->print($window_id, $input);
+  }
 }
 
 ### Update the time on the status bar.
@@ -117,6 +125,17 @@
   $kernel->alarm( test_buffer => int(time() / 60) * 60 + 20 ); 
 }
 
+sub stop_guts {
+  my ($kernel, $heap) = @_[KERNEL, HEAP];
+  $vt->shutdown;
+  $kernel->alarm_remove_all();
+  if (defined $heap->{input_session}) {
+    delete $heap->{input_session};
+  }
+
+}
+
+
 $poe_kernel->run();
-$vt->shutdown;
+#$vt->shutdown;
 exit 0;




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