Fix errors in documentation for filtering
[spider.git] / gtkconsole / gtkconsole
index e67ff0c9b6a3568b6ee036701426f645fd53e29c..e545824407873ad2515aead2654d7412697d894d 100755 (executable)
@@ -14,20 +14,24 @@ BEGIN {
        $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
        
        unshift @INC, "$root/perl";     # this IS the right way round!
+       unshift @INC, "$root/gtkconsole";
        unshift @INC, "$root/local";
 }
 
 use strict;
 
-use vars qw(@modules);                    
+use Gtk qw(-init);
+
+use vars qw(@modules $font);                    
 
 @modules = ();                                 # is the list of modules that need init calling
                                                                # on them. It is set up by each  'use'ed module
                                                                # that has Gtk stuff in it
+$font = Gtk::Gdk::Font->load("-misc-fixed-medium-r-normal-*-*-130-*-*-c-*-koi8-r");
 
 use DXVars;
+use DXUtil;
 use IO::Socket::INET;
-use Gtk qw(-init);
 use Text;
 use DebugHandler;
 
@@ -49,6 +53,9 @@ die "You cannot connect as your cluster callsign ($main::mycall)\n" if $call eq
 my $sock = IO::Socket::INET->new(PeerAddr=>$main::clusteraddr, PeerPort=>$main::clusterport);
 die "Cannot connect to $main::clusteraddr/$main::clusterport ($!)\n" unless $sock;
 sendmsg('A', 'local');
+sendmsg('G', '2');
+sendmsg('I', 'set/page 500');
+sendmsg('I', 'set/nobeep');
 
 #
 # start of GTK stuff
@@ -67,7 +74,6 @@ $main->set_title("gtkconsole - The DXSpider Console - $call");
 my $vbox = new Gtk::VBox(0, 1);
 $vbox->border_width(1);
 $main->add($vbox);
-$vbox->show;
 
 # the menu bar
 my @menu = ( 
@@ -84,31 +90,55 @@ my $menu = $itemf->get_widget('<main>');
 $vbox->pack_start($menu, 0, 1, 0);
 $menu->show;
 
-# create a vertically paned window and stick it in the bottom of the screen
-my $paned = new Gtk::VPaned;
-$vbox->pack_end($paned, 1, 1, 0);
 
 my $top = new Text(1);
 my $toplist = $top->text;
 $toplist->set_editable(0);
-$paned->pack1($top, 1, 1);
+$toplist->sensitive(0);
 
 # add the handler for incoming messages from the node
 my $tophandler = Gtk::Gdk->input_add($sock->fileno, ['read'], \&tophandler, $sock);
 my $rbuf = "";                                         # used in handler
 
+#$toplist->{signalid} = $toplist->signal_connect(insert_text => \&doinsert, $toplist); 
+#$bot->{signalid} = $bot->signal_connect(insert_text => \&botinsert, $bot); 
+$vbox->pack_start($top, 1, 1, 0);
+$vbox->show;
+
 # the bottom handler
-my $bot = new Text(1);
-my $botlist = $bot->text;
-$botlist->set_editable(1);
-$botlist->signal_connect('activate', \&bothandler);
-$botlist->can_focus(1);
-$botlist->can_default(1);
-$botlist->grab_focus;
-$botlist->grab_default;
-$toplist->{signalid} = $toplist->signal_connect(insert_text => \&doinsert); 
-$paned->pack2($bot, 0, 1);
-$paned->show;
+my $bot = new Gtk::Entry;
+my $style = $toplist->style;
+$style->font($main::font);
+$bot->set_style($style);
+$bot->set_editable(1);
+$bot->signal_connect('activate', \&bothandler);
+$bot->can_default(1);
+$bot->grab_default;
+$bot->grab_focus;
+$bot->show;
+
+# a horizontal box
+my $hbox = new Gtk::HBox;
+$hbox->show;
+
+# callsign and current date and time
+my $calllabel = new Gtk::Label($call);
+my $date = new Gtk::Label(cldatetime(time));
+Gtk->timeout_add(1000, \&updatetime);
+$calllabel->show;
+$date->show;
+$hbox->pack_start( $calllabel, 0, 1, 0 );
+$hbox->pack_end($date, 0, 1, 0);
+
+
+$vbox->pack_start($hbox, 0, 1, 0); 
+
+# nice little separator
+my $separator = new Gtk::HSeparator();
+$vbox->pack_start( $separator, 0, 1, 0 );
+$separator->show();
+$vbox->pack_start($bot, 0, 1, 0);
 
 # the main loop
 $main->show_all;
@@ -118,26 +148,32 @@ Gtk->main;
 # handlers
 #
 
+sub updatetime
+{
+       $date->set_text(cldatetime(time));
+       1;
+}
+
 sub doinsert {
        my ($self, $text) = @_;
 
        # we temporarily block this handler to avoid recursion
        $self->signal_handler_block($self->{signalid});
-       my $pos = $self->insert($self->{font}, undef, undef, $text);
+       my $pos = $self->insert($self->{font}, $toplist->style->black, $toplist->style->white, $text);
        $self->signal_handler_unblock($self->{signalid});
 
        # we already inserted the text if it was valid: no need
        # for the self to process this signal emission
        $self->signal_emit_stop_by_name('insert-text');
-       $self->signal_emit('activate') if $text eq "\n";
        1;
 }
 
 sub bothandler
 {
        my ($self, $data) = @_;
-       my ($msg) = $self->get_chars =~ /([^\n]*)\r?\n$/;
-       $msg ||= '';
+       my $msg = $self->get_text;
+       $msg =~ s/\r?\n$//;
+       $self->set_text('');
        senddata($msg);
 }
 
@@ -177,6 +213,16 @@ sub handlemsg
        my ($sort, $call, $line) = $msg =~ /^(\w)([^\|]+)\|(.*)$/;
        if ($sort eq 'D') {
                $toplist->insert($toplist->{font}, undef, undef, "$line\n");
+       } elsif ($sort eq 'X') {
+               $toplist->insert($toplist->{font}, undef, undef, "$line\n");
+       } elsif ($sort eq 'Y') {
+               $toplist->insert($toplist->{font}, undef, undef, "$line\n");
+       } elsif ($sort eq 'V') {
+               $toplist->insert($toplist->{font}, undef, undef, "$line\n");
+       } elsif ($sort eq 'N') {
+               $toplist->insert($toplist->{font}, undef, undef, "$line\n");
+       } elsif ($sort eq 'W') {
+               $toplist->insert($toplist->{font}, undef, undef, "$line\n");
        } elsif ($sort eq 'Z') {
                Gtk->exit(0);
        }