backport mojo console.pl width/scolling changes
[spider.git] / perl / DXCommandmode.pm
index 35c92341d17cbc896a0a64d6941e9a3d156dea77..c8decb72e1b3b5c39e34e2fd3f283d0f23741b54 100644 (file)
@@ -960,29 +960,40 @@ sub format_dx_spot
 
        my $t = ztime($_[2]);
        my $loc = '';
-       my $clth = $self->{consort} eq 'local' ? 29 : 30;
+
+       my $clth = 30 + $self->{width} - 80;    # allow comment to grow according the screen width 
+       #       --$clth if $self->{consort} eq 'local';
+       
        my $comment = substr (($_[3] || ''), 0, $clth);
-       $comment .= ' ' x ($clth - length($comment));
-       if ($self->{user}->wantgrid) {
-               my $ref = DXUser::get_current($_[4]);
-               if ($ref) {
-                       $loc = $ref->qra || '';
-                       $loc = ' ' . substr($loc, 0, 4) if $loc;
+       $comment =~ s/\t/ /g;
+       
+       $comment .= ' ' x ($clth - (length($comment)));
+       
+    if ($self->{user}->wantgrid) {
+               my $ref = DXUser::get_current($_[1]);
+               if ($ref && $ref->qra) {
+                       my $cloc = ' ' . substr($ref->qra, 0, 4);
+                       $comment = substr $comment, 0,  ($clth - (length($comment)+length($cloc)));
+                       $comment .= $cloc;
                }
-       }
-
-       if ($self->{user}->wantdxitu) {
+               my $origin = $_[4];
+               $origin =~ s/-#$//;                     # sigh......
+               $ref = DXUser::get_current($origin);
+               if ($ref && $ref->qra) {
+                       $loc = ' ' . substr($ref->qra, 0, 4);
+               }
+       } elsif ($self->{user}->wantdxitu) {
                $loc = ' ' . sprintf("%2d", $_[10]) if defined $_[10];
-               $comment = substr($comment, 0,  $self->{consort} eq 'local' ? 26 : 27) . ' ' . sprintf("%2d", $_[8]) if defined $_[8]; 
+               $comment = substr($comment, 0,  $clth-3) . ' ' . sprintf("%2d", $_[8]) if defined $_[8]; 
        } elsif ($self->{user}->wantdxcq) {
                $loc = ' ' . sprintf("%2d", $_[11]) if defined $_[11];
-               $comment = substr($comment, 0,  $self->{consort} eq 'local' ? 26 : 27) . ' ' . sprintf("%2d", $_[9]) if defined $_[9]; 
+               $comment = substr($comment, 0, $clth-3) . ' ' . sprintf("%2d", $_[9]) if defined $_[9]; 
        } elsif ($self->{user}->wantusstate) {
                $loc = ' ' . $_[13] if $_[13];
-               $comment = substr($comment, 0,  $self->{consort} eq 'local' ? 26 : 27) . ' ' . $_[12] if $_[12]; 
+               $comment = substr($comment, 0,  $clth-3) . ' ' . $_[12] if $_[12]; 
        }
 
-       return sprintf "DX de %-7.7s%11.1f  %-12.12s %-s $t$loc", "$_[4]:", $_[0], $_[1], $comment;
+       return sprintf "DX de %-8.8s%10.1f  %-12.12s %-s $t$loc", "$_[4]:", $_[0], $_[1], $comment;
 }
 
 # send a dx spot