From 86c334abf506fc0bd01133c06aa1d81b1ae9d522 Mon Sep 17 00:00:00 2001 From: DF6FR Date: Fri, 18 Sep 2009 13:41:05 +0000 Subject: [PATCH] Taught Search&Edit to remember cursor position and to use home/end keys. --- yfk | 7 ++++--- yfksubs.pl | 22 ++++++++++++++++++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/yfk b/yfk index 0176b8e..0098f5b 100755 --- a/yfk +++ b/yfk @@ -1274,7 +1274,6 @@ if ($aw eq 'm') { # back to menu last; # break out from while (1) loop } elsif ($aw == 0) { # back to QSO list - $editnr = 0; $aw = 2; } @@ -1293,8 +1292,9 @@ while ($aw == 2) { # We have selected search criteria in the QSO-array. Now display a # scrollable list with only the matching QSOs. The user selects one QSO, # the number of the QSO (as in the NR field in the database) is returned. + # To remember the position of the last qso edited, we tell the editnr. - $editnr = &choseeditqso(\$weditlog, \@sqso); + $editnr = &choseeditqso(\$weditlog, \@sqso, $editnr); if ($editnr eq 'm') { # back to MAIN MENU $status = 2; @@ -1306,7 +1306,8 @@ while ($aw == 2) { for (0 .. 25) { # clear the QSO and if no results also $qso[$_] = ''; # sqso } - @sqso = (); + @sqso = (); + $editnr = 0; # forget last edited qso $aw = 1; # back to list } else { diff --git a/yfksubs.pl b/yfksubs.pl index 72d0154..fe4f5ca 100644 --- a/yfksubs.pl +++ b/yfksubs.pl @@ -3796,8 +3796,8 @@ sub choseeditqso { my $ret; # return number my $goon=1; # becomes 0 when we are done my $count; # number of entries/QSOs matching - my $pos=1; # position in the QSOs from 1 .. $count - + my $pos=$_[2]; # position in the QSOs from 1 .. $count + if ($pos == 0) {$pos = 1;} # last edited qso if not equal 0 my $win = ${$_[0]}; # Window where output goes. height = 17 my $sql; # SQL string with search criteria my $sql2=' AND 1 '; @@ -3840,6 +3840,13 @@ sub choseeditqso { $count = $eq->fetchrow_array(); if ($count == 0) { return 0 }; # no QSO to edit-> $editnr = 0. + + # calculate offset and aline for possible last edited qso + if ($pos > 17) { + $offset = int(($pos-1) / 17) * 17; + $aline = $pos-1 - $offset; + } + else {$aline = $pos-1;} do { my $eq = $dbh->prepare($sql.$sql2." ORDER BY `DATE`, `T_ON` LIMIT $offset, 17;"); @@ -3920,6 +3927,17 @@ do { } } + elsif ($ch eq KEY_HOME) { # go to first qso + $pos = 1; + $aline = 0; + $offset = 0; + } + + elsif ($ch eq KEY_END) { # go to last qso + $pos = $count; + $offset = int(($count-1) / 17) * 17; + $aline = $count-1 - $offset; + } elsif ($ch eq KEY_F(1)) { # F1 -> Back to main menu return 'm'; }