+
+# add a line to the end of the top screen
+sub addtotop
+{
+ while (@_) {
+ my $inbuf = shift;
+ my $l = length $inbuf;
+ if ($l > $cols) {
+# $Text::Wrap::Columns = $cols;
+# push @sh, wrap('',"\t", $inbuf);
+ push @sh, $inbuf;
+ } else {
+ push @sh, $inbuf;
+ }
+ }
+ show_screen() unless $inscroll;
+}
+
+# handle incoming messages
+sub rec_socket
+{
+ my ($con, $msg, $err) = @_;
+ if (defined $err && $err) {
+ cease(1);
+ }
+ if (defined $msg) {
+ dbg("msg: " . length($msg) . " '$msg'") if isdbg('console');
+ my ($sort, $incall, $line) = $msg =~ /^(\w)([^\|]+)\|(.*)$/;
+ if ($line =~ s/\x07+$//) {
+ beep();
+ }
+ $line =~ s/[\r\n]+//s;
+
+ # change my call if my node says "tonight Michael you are Jane" or something like that...
+ $call = $incall if $call ne $incall;
+
+ $line =~ s/[\x00-\x06\x08\x0a-\x19\x1b-\x1f\x80-\x9f]/./g; # immutable CSI sequence + control characters
+ if ($sort && $sort eq 'D') {
+ $line = " " unless length($line);
+ addtotop($line);
+ } elsif ($sort && $sort eq 'Z') { # end, disconnect, go, away .....
+ cease(0);
+ }
+ # ******************************************************
+ # ******************************************************
+ # any other sorts that might happen are silently ignored.
+ # ******************************************************
+ # ******************************************************
+ } else {
+ cease(0);
+ }
+ $top->refresh();
+ $lasttime = time;
+}
+
+