From: Dirk Koopman Date: Fri, 19 Nov 2021 19:23:11 +0000 (+0000) Subject: fix comment width issues for tabs X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=commitdiff_plain;h=942a06f9a573659489eb4a9185b73c4296cd31fd;p=spider.git fix comment width issues for tabs --- 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/columns.pl deleted file mode 100644 index 5575fe3b..00000000 --- a/cmd/set/columns.pl +++ /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 index 00000000..5575fe3b --- /dev/null +++ b/cmd/set/width.pl @@ -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)); 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