fix comment width issues for tabs
authorDirk Koopman <djk@tobit.co.uk>
Fri, 19 Nov 2021 19:23:11 +0000 (19:23 +0000)
committerDirk Koopman <djk@tobit.co.uk>
Fri, 19 Nov 2021 19:23:11 +0000 (19:23 +0000)
Changes
cmd/set/columns.pl [deleted file]
cmd/set/width.pl [new file with mode: 0644]
perl/DXCommandmode.pm
perl/Spot.pm

diff --git a/Changes b/Changes
index 38ea489651b43ed28ae8f623f64ea7d2300a96bb..9d9bed6e53e82f6c27f3cad3a19abbb5c9e02d97 100644 (file)
--- a/Changes
+++ b/Changes
@@ -4,7 +4,7 @@
    also work similarly. If you make the console width smaller or wider then 
    spots already on the screen will not resize. 
 2. For client programs that parse the output (why? use set/ve7cc to get more
-   easily machine parsed output), a new command "set/columns <width>" is 
+   easily machine parsed output), a new command "set/width <width>" is 
    available. 
 18Nov21=======================================================================
 1. Add a dx spot cache which will store 2 days worth (configurable) of spots.
diff --git a/cmd/set/columns.pl b/cmd/set/columns.pl
deleted file mode 100644 (file)
index 5575fe3..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#
-# set the page width for this invocation of the client
-#
-# Copyright (c) 2021 - Dirk Koopman G1TLH
-#
-#
-#
-my $self = shift;
-my $l = shift;
-$l = 80 if $l < 80;
-$self->width($l);
-return (1, $self->msg('pagewidth', $l));
diff --git a/cmd/set/width.pl b/cmd/set/width.pl
new file mode 100644 (file)
index 0000000..5575fe3
--- /dev/null
@@ -0,0 +1,12 @@
+#
+# set the page width for this invocation of the client
+#
+# Copyright (c) 2021 - Dirk Koopman G1TLH
+#
+#
+#
+my $self = shift;
+my $l = shift;
+$l = 80 if $l < 80;
+$self->width($l);
+return (1, $self->msg('pagewidth', $l));
index cd37c5e93c5833638491871427f7f92bba832941..051332b03b75c8f85ff9e32d75dbe23755a25f0d 100644 (file)
@@ -996,10 +996,11 @@ sub format_dx_spot
 
        my $t = ztime($_[2]);
        my $loc = '';
-       my $clth = 30 + $self->{width} - 80;    # allow comment to grow according the screen width 
+       my $clth = 31 + $self->{width} - 80;    # allow comment to grow according the screen width 
        #       --$clth if $self->{consort} eq 'local';
        
        my $comment = substr (($_[3] || ''), 0, $clth);
+       $comment =~ s/\t/ /g;
        $comment .= ' ' x ($clth - (length($comment)));
        
     if ($self->{user}->wantgrid) {
index df2a9730db869361a3a355a2d9475fab26c46cd0..cbe37cc66960e2decda72de2d553f544ac9a1912 100644 (file)
@@ -460,13 +460,18 @@ sub formatl
 {
        my $t = ztime($_[3]);
        my $d = cldate($_[3]);
-       my $width = ($_[0] ? $_[0] : 80) - 80 + 28;
+       my $spotter = "<$_[5]>";
        my $comment = $_[4] || '';
-       $comment = substr $comment, 0, $width if length($comment) > $width;
-       $comment .= ' ' x ($width - length($comment)) if length($comment) < $width;
+       $comment =~ s/\t+/ /g;
+       my $cl = length $comment;
+       my $s = sprintf "%8.1f  %-11s %s %s", $_[1], $_[2], $d, $t;
+       my $width = ($_[0] ? $_[0] : 80) - length($spotter) - length($s) - 2;
+       
+       $comment = substr $comment, 0, $width if $cl > $width;
+       $comment .= ' ' x ($width-$cl) if $cl < $width;
 
 #      return sprintf "%8.1f  %-11s %s %s  %-28.28s%7s>", $_[0], $_[1], $d, $t, ($_[3]||''), "<$_[4]" ;
-       return sprintf "%8.1f  %-11s %s %s  ${comment}%7s>", $_[1], $_[2], $d, $t, "<$_[5]" ;
+       return "$s $comment$spotter";
 }
 
 # enter the spot for dup checking and return true if it is already a dup