/[iselect]/bin/iselect.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /bin/iselect.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 8 by dpavlin, Thu Oct 25 14:52:56 2007 UTC revision 11 by dpavlin, Thu Oct 25 15:19:51 2007 UTC
# Line 23  my $data = <<'EOF'; Line 23  my $data = <<'EOF';
23    
24  EOF  EOF
25    
26  open(my $ps, "ps ax |") || die "can't do ps ax: $!";  $data .= ( rand(10) < 5 ? '{s}' : '' ) . "foobar $_\n" foreach ( 1 .. 300 );
 while(<$ps>) {  
         $data .= '{s}'.$_;  
         $data .= $_;  
 }  
 close($ps);  
27    
28  $data .= "\n--EOF--";  $data .= "\n--EOF--";
29    
# Line 56  my $status_lines = 3; Line 51  my $status_lines = 3;
51  my $selectable_line;  my $selectable_line;
52    
53  for my $l (0 .. $#lines) {  for my $l (0 .. $#lines) {
54          if ($lines[$l] !~ s/^{s}//) {          if ($lines[$l] =~ s/^{s}//) {
55                  $selectable_line->{$l}++;                  $selectable_line->{$l}++;
56          }          }
57  }  }
# Line 83  sub chunk { Line 78  sub chunk {
78  sub redraw_line {  sub redraw_line {
79          my ($l,$line) = @_;          my ($l,$line) = @_;
80    
81          if ( defined $selectable_line->{ $l } ) {          if ( defined $selectable_line->{ $l + $top_screen_line } ) {
82                  $scr->at($l,0)->bold()->puts( full_line( chunk($line) ) )->normal();                  $scr->at($l,0)->bold()->puts( full_line( chunk($line) ) )->normal();
83          } else {          } else {
84                  $scr->at($l,0)->puts( full_line( chunk($line) ) );                  $scr->at($l,0)->puts( full_line( chunk($line) ) );
# Line 191  while(my $key = $scr->getch()) { Line 186  while(my $key = $scr->getch()) {
186                  $status_text .= sprintf("key: %s [%03d][%02x]", $key =~ m/\w/ ? $key : '?' , ord($key), ord($key) );                  $status_text .= sprintf("key: %s [%03d][%02x]", $key =~ m/\w/ ? $key : '?' , ord($key), ord($key) );
187          }          }
188    
         status;  
   
189          # CTRL+L          # CTRL+L
190          redraw if ord($key) eq 0x0c;          redraw if ord($key) eq 0x0c;
191    
192            # Enter
193            if ( ord($key) eq 0x0d && $sel_pos > 0 ) {
194                    $error_text = "execute: " . $lines[ $sel_pos ];
195            }
196    
197          exit if (lc($key) eq 'q');          exit if (lc($key) eq 'q');
198    
199            status;
200    
201  }  }
202    
203  $scr->clrscr();  $scr->clrscr();

Legend:
Removed from v.8  
changed lines
  Added in v.11

  ViewVC Help
Powered by ViewVC 1.1.26