X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Fconsole.pl;h=594bc67eea73c0c8762b1c6598a455616b50ba52;hb=bca5cd40374f12da5e0d46980e54bffc61fdc9c9;hp=75632aa8d35726fbf44094b3f526733926ae98fb;hpb=c961a6af6d9aec8eba4d58803f890fc514a109cc;p=spider.git diff --git a/perl/console.pl b/perl/console.pl index 75632aa8..594bc67e 100755 --- a/perl/console.pl +++ b/perl/console.pl @@ -28,6 +28,7 @@ BEGIN { use Msg; use DXVars; use DXDebug; +use DXUtil; use IO::File; use Curses; @@ -81,6 +82,7 @@ sub do_initscr $scr->refresh(); $pagel = LINES()-4; + $mycallcolor = COLOR_PAIR(1) unless $mycallcolor; } sub do_resize @@ -139,7 +141,7 @@ sub show_screen if ($spos == @shistory - 1) { # if we really are scrolling thru at the end of the history - my $line = $shistory[-1]; + my $line = $shistory[$spos]; $top->addstr("\n") if $spos > 0; setattr($line); $top->addstr($line); @@ -151,7 +153,7 @@ sub show_screen # anywhere else my ($i, $l); my $p = $spos-1; - for ($i = 0; $i <= $pagel && $p >= 0; ) { + for ($i = 0; $i < $pagel && $p >= 0; ) { $l = measure($shistory[$p]); $i += $l; $p-- if $i < $pagel; @@ -161,27 +163,40 @@ sub show_screen $top->move(0, 0); $top->attrset(COLOR_PAIR(0)) if $has_colors; $top->clrtobot(); - for ($i = 0; $i <= $pagel && $p < @shistory; $p++) { + for ($i = 0; $i < $pagel && $p < @shistory; $p++) { my $line = $shistory[$p]; my $lines = measure($line); last if $i + $lines > $pagel; - $top->move($i, 0); setattr($line); - $top->addstr($line); + $top->addstr($i, 0, $line); $top->attrset(COLOR_PAIR(0)) if $has_colors; $i += $lines; } $spos = $p; + $spos = @shistory if $spos > @shistory; } - $top->refresh(); + my $shl = @shistory; + my $add = "-$spos-$shl"; + my $time = ztime(time); + my $str = "-" . $time . '-' x (COLS() - (length($call) + length($add) + length($time) + 1)); + $scr->addstr(LINES()-4, 0, $str); + + $scr->attrset($mycallcolor) if $has_colors; + $scr->addstr("$call"); + $scr->attrset(COLOR_PAIR(0)) if $has_colors; + $scr->addstr($add); + $scr->refresh(); +# $top->refresh(); } # add a line to the end of the top screen sub addtotop { - my $inbuf = shift; - push @shistory, $inbuf; - shift @shistory if @shistory > $maxshist; + while (@_) { + my $inbuf = shift; + push @shistory, $inbuf; + shift @shistory if @shistory > $maxshist; + } show_screen(); } @@ -246,6 +261,10 @@ sub rec_stdin } # add it to the monitor window + unless ($spos == @shistory) { + $spos = @shistory; + show_screen(); + }; addtotop($inbuf) if $inbuf; # send it to the cluster @@ -290,7 +309,7 @@ sub rec_stdin $i += $l; $spos++ if $i <= $pagel; } - $spos = @shistory if $spos > @shistory; + $spos = @shistory if $spos >= @shistory - 1; show_screen(); } else { beep(); @@ -336,7 +355,7 @@ sub rec_stdin } } elsif ($r ge ' ' && $r le '~') { # move the top screen back to the bottom if you type something - if ($spos < @shistory - 1) { + if ($spos < @shistory) { $spos = @shistory; show_screen(); } @@ -413,13 +432,14 @@ Msg->set_event_handler(\*STDIN, "read" => \&rec_stdin); for (;;) { my $t; - Msg->event_loop(1, 0.010); - $top->refresh() if $top->is_wintouched; - $bot->refresh(); + Msg->event_loop(1, 1); $t = time; if ($t > $lasttime) { + show_screen(); $lasttime = $t; } + $top->refresh() if $top->is_wintouched; + $bot->refresh(); } exit(0);