X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Fconsole.pl;h=fad52b963e3b94121a3c677489c0d7b25e63698d;hb=4dfc1f60733b682dc1ac9724fd75395d1c41c62d;hp=2a88f5b5db7aff99cd7dc3bf8d2ba86f6b3f5ef4;hpb=9e6322c41076ff462cb37416e28c3742567dc62a;p=spider.git diff --git a/perl/console.pl b/perl/console.pl index 2a88f5b5..fad52b96 100755 --- a/perl/console.pl +++ b/perl/console.pl @@ -13,7 +13,7 @@ # # -require 5.004; +require 5.16.1; use warnings; # search local then perl directories @@ -132,8 +132,26 @@ sub doresize do_initscr(); $inscroll = 0; + dbg("resize: l=$lines c=$cols"); + dbg("resize: sh=". scalar @sh ); +# my @tsh; +# my $t; +# while (defined ($t = shift @sh)) { +# dbg("t: $t(" , length $t . ')'); +# if ($t =~ /^\t/) { +# $t =~ s/^\t/ /; +# push(@tsh, pop(@tsh) . $t) +# } else { +# push(@tsh, $t); +# } +# dbg("tsh: " . scalar @tsh); +# } +# dbg("resize: tsh=". scalar @tsh ); +# $spos = @tsh < $pagel ? 0 : @tsh - $pagel; + # addtotop(@tsh); $spos = @sh < $pagel ? 0 : @sh - $pagel; show_screen(); + $conn->send_later("C$call|$cols") if $conn; } # cease communications @@ -454,10 +472,15 @@ sub addtotop while (@_) { my $inbuf = shift; my $l = length $inbuf; + dbg("addtotop: $l $inbuf"); if ($l > $cols) { -# $Text::Wrap::Columns = $cols; -# push @sh, wrap('',"\t", $inbuf); - push @sh, $inbuf; + $inbuf =~ s/\s+/ /g; + if (length $inbuf > $cols) { + $Text::Wrap::columns = $cols; + push @sh, split /\n/, wrap('',' ' x 19, $inbuf); + } else { + push @sh, $inbuf; + } } else { push @sh, $inbuf; } @@ -518,10 +541,10 @@ sub idle_loop } my $ch = $bot->getch(); # this is here just to catch RESIZE events if (defined $ch) { - if ($ch == KEY_RESIZE) { + if ($ch eq KEY_RESIZE) { doresize(); } else { - rec_stdin($ch) unless $ch == '-1'; + rec_stdin($ch) unless $ch eq '-1'; } } $top->refresh() if $top->is_wintouched; @@ -550,7 +573,11 @@ sub on_disconnect while (@ARGV && $ARGV[0] =~ /^-/) { my $arg = shift; - dbgadd('console'), $maxshist = 200 if $arg eq '-x'; + if ($arg eq '-x') { + dbginit('console'); + dbgadd('console'); + $maxshist = 200; + } } $call = uc shift @ARGV if @ARGV; @@ -569,8 +596,6 @@ if ($call eq $mycall) { exit(0); } -dbginit(); - unless ($DB::VERSION) { $SIG{'INT'} = \&sig_term; $SIG{'TERM'} = \&sig_term; @@ -578,12 +603,14 @@ unless ($DB::VERSION) { $SIG{'HUP'} = \&sig_term; -# start up + +# start upb +$Text::Wrap::Columns = $cols; doresize(); $SIG{__DIE__} = \&sig_term; -#$Text::Wrap::Columns = $cols; +$Text::Wrap::columns = $cols; my $lastmin = 0; @@ -592,7 +619,7 @@ $conn = IntMsg->connect($clusteraddr, $clusterport, rproc => \&rec_socket); $conn->{on_connect} = \&on_connect; $conn->{on_disconnect} = \&on_disconnect; -my $timer = Mojo::IOLoop->recurring(1, sub {DXLog::flushall()}); +my $timer = Mojo::IOLoop->recurring(1, sub {DXLog::flushall()}) if $DXDebug::fp; $idle = Mojo::IOLoop->recurring(0.100 => \&idle_loop); Mojo::IOLoop->singleton->reactor->io(\*STDIN => sub {