From: Dirk Koopman Date: Sat, 4 Jul 2020 01:03:29 +0000 (+0100) Subject: fix longstanding issues with console EOL handling X-Git-Url: http://dxcluster.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=2747e0fe4269e9a7e095c333598191eb9dca63fc;p=spider.git fix longstanding issues with console EOL handling Historically there has been an issue with line endings in console.pl which meant that the spot line (for instance) had to be 1 character less than the window width (e.g. 79 chars in an 80 char window). This has now FINALLY been fixed. In the process I have fixed the issues of extra things like cq/itu/us state/dxgrid strings overwriting or coming out in a stupid priority. So the priority is now from nearest/smallest area -> largest wiz: QRA, US State, ITU or CQ zone. So you can have them all on, but ITU zone will always trump CQ zone. --- diff --git a/perl/DXCommandmode.pm b/perl/DXCommandmode.pm index 729675be..e6b612fa 100644 --- a/perl/DXCommandmode.pm +++ b/perl/DXCommandmode.pm @@ -996,18 +996,11 @@ sub format_dx_spot my $t = ztime($_[2]); my $loc = ''; - my $clth = $self->{consort} eq 'local' ? 29 : 30; + my $clth = 30; + --$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($_[1]); - if ($ref && $ref->qra) { - $loc = ' ' . substr($ref->qra, 0, 4); - $comment = substr $comment, 0, ($clth - (length($comment)+length($loc))); - $comment .= $loc; - $loc = ''; - } - } if ($self->{user}->wantgrid) { my $ref = DXUser::get_current($_[4]); @@ -1016,15 +1009,23 @@ sub format_dx_spot } } - if ($self->{user}->wantdxitu) { + if ($self->{user}->wantgrid) { + my $ref = DXUser::get_current($_[1]); + if ($ref && $ref->qra) { + $loc = ' ' . substr($ref->qra, 0, 4); + $comment = substr $comment, 0, ($clth - (length($comment)+length($loc))); + $comment .= $loc; + $loc = ''; + } + } 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; diff --git a/perl/console.pl b/perl/console.pl index cd4a4492..97b6220d 100755 --- a/perl/console.pl +++ b/perl/console.pl @@ -180,13 +180,18 @@ sub measure sub show_screen { if ($spos == @shistory - 1) { - # if we really are scrolling thru at the end of the history my $line = $shistory[$spos]; - $top->addstr("\n") if $spos > 0; + my $y = $spos; + if ($spos >= $pagel) { + $top->scrl(1); + $y = $pagel-1; +# $top->addstr("\r"); + } + $top->move($y, 0); + $top->refresh; setattr($line); $top->addstr($line); -# $top->addstr("\n"); $top->attrset(COLOR_PAIR(0)) if $has_colors; $spos = @shistory; @@ -208,8 +213,7 @@ sub show_screen for ($i = 0; $i < $pagel && $p < @shistory; $p++) { my $line = $shistory[$p]; my $lines = measure($line); - last if $i + $lines > $pagel; - $top->addstr("\n") if $i; + $top->move($i, 0); setattr($line); $top->addstr($line); $top->attrset(COLOR_PAIR(0)) if $has_colors; @@ -242,7 +246,8 @@ sub addtotop if ($inbuf =~ s/\x07+$//) { beep(); } - if (length $inbuf >= $cols) { + $inbuf =~ s/\s+$//s; + if (length $inbuf > $cols) { $Text::Wrap::Columns = $cols; push @shistory, wrap('',"\t", $inbuf); } else {