+sub idle_loop
+{
+ my $t;
+
+ $t = time;
+ if ($t > $lasttime) {
+ my ($min)= (gmtime($t))[1];
+ if ($min != $lastmin) {
+ show_screen();
+ $lastmin = $min;
+ }
+ $lasttime = $t;
+ }
+ my $ch = $bot->getch();
+ if (@time && tv_interval(\@time, [gettimeofday]) >= 1) {
+ next;
+ }
+ if (defined $ch) {
+ if ($ch ne '-1') {
+ rec_stdin($ch);
+ }
+ }
+ $top->refresh() if $top->is_wintouched;
+ $bot->refresh();
+}
+
+sub on_connect
+{
+ my $conn = shift;
+ $conn->send_later("A$call|$connsort width=$cols");
+ $conn->send_later("I$call|set/page $maxshist");
+ #$conn->send_later("I$call|set/nobeep");
+}
+
+sub on_disconnect
+{
+ $conn = shift;
+ Mojo::IOLoop->remove($idle);
+ Mojo::IOLoop->stop;
+}