+use vars qw($maxkhist $maxshist $foreground $background $mycallcolor @colors );
+
+#
+# initialisation
+#
+
+my $call = ""; # the callsign being used
+my $conn = 0; # the connection object for the cluster
+my $lasttime = time; # lasttime something happened on the interface
+
+my $connsort = "local";
+my @khistory = ();
+my @shistory = ();
+my $khistpos = 0;
+my $pos;
+my $lth;
+my $bot;
+my $top;
+my $pagel = 25;
+my $cols = 80;
+my $lines = 25;
+my $scr;
+my $spos = $pos = $lth = 0;
+my $inbuf = "";
+my @time = ();
+
+my $lastmin = 0;
+my $sigint;
+my $sigterm;
+my $decease;
+
+#$SIG{WINCH} = sub {@time = gettimeofday};
+
+sub mydbg
+{
+ local *STDOUT = undef;
+ dbg(@_);
+}
+
+# do the screen initialisation
+sub do_initscr
+{
+ $scr = new Curses;
+ if ($main::has_colors) {
+ start_color();
+ init_pair("0", $main::foreground, $main::background);
+# init_pair(0, $main::background, $main::foreground);
+ init_pair(1, COLOR_RED, $main::background);
+ init_pair(2, COLOR_YELLOW, $main::background);
+ init_pair(3, COLOR_GREEN, $main::background);
+ init_pair(4, COLOR_CYAN, $main::background);
+ init_pair(5, COLOR_BLUE, $main::background);
+ init_pair(6, COLOR_MAGENTA, $main::background);
+ init_pair(7, COLOR_RED, COLOR_BLUE);
+ init_pair(8, COLOR_YELLOW, COLOR_BLUE);
+ init_pair(9, COLOR_GREEN, COLOR_BLUE);
+ init_pair(10, COLOR_CYAN, COLOR_BLUE);
+ init_pair(11, COLOR_BLUE, COLOR_RED);
+ init_pair(12, COLOR_MAGENTA, COLOR_BLUE);
+ init_pair(13, COLOR_YELLOW, COLOR_GREEN);
+ init_pair(14, COLOR_RED, COLOR_GREEN);
+ eval { assume_default_colors($main::foreground, $main::background) } unless $main::is_win;
+ }
+
+ $top = $scr->subwin($lines-4, $cols, 0, 0);
+ $top->intrflush(0);
+ $top->scrollok(1);
+ $top->idlok(1);
+ $top->meta(1);
+# $scr->addstr($lines-4, 0, '-' x $cols);
+ $bot = $scr->subwin(3, $cols, $lines-3, 0);
+ $bot->intrflush(0);
+ $bot->scrollok(1);
+ $top->idlok(1);
+ $bot->keypad(1);
+ $bot->move(1,0);
+ $bot->meta(1);
+ $bot->nodelay(1);
+ $scr->refresh();
+
+ $pagel = $lines-4;
+ $mycallcolor = COLOR_PAIR(1) unless $mycallcolor;
+}
+
+sub do_resize
+{
+ endwin() if $scr;
+ initscr();
+ raw();
+ noecho();
+ nonl();
+ $lines = LINES;
+ $cols = COLS;
+ $main::has_colors = has_colors();
+ do_initscr();
+
+ show_screen();
+}
+
+my $ceasing = 0;