From 942a06f9a573659489eb4a9185b73c4296cd31fd Mon Sep 17 00:00:00 2001 From: Dirk Koopman Date: Fri, 19 Nov 2021 19:23:11 +0000 Subject: [PATCH] fix comment width issues for tabs --- Changes | 2 +- cmd/set/{columns.pl => width.pl} | 0 perl/DXCommandmode.pm | 3 ++- perl/Spot.pm | 13 +++++++++---- 4 files changed, 12 insertions(+), 6 deletions(-) rename cmd/set/{columns.pl => width.pl} (100%) diff --git a/Changes b/Changes index 38ea4896..9d9bed6e 100644 --- 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 " is + easily machine parsed output), a new command "set/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/width.pl similarity index 100% rename from cmd/set/columns.pl rename to cmd/set/width.pl diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index cd37c5e9..051332b0 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -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) { diff --git a/perl/Spot.pm b/perl/Spot.pm index df2a9730..cbe37cc6 100644 --- a/perl/Spot.pm +++ b/perl/Spot.pm @@ -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 -- 2.43.0