1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
Author: Stephen Zander <gibreel@debian.org>
Description: make ListBox.pm keep the bottom element of a list in view when
paging down & the top element of a list in view when paging up,
Bug: #171719
--- a/Widgets/ListBox.pm
+++ b/Widgets/ListBox.pm
@@ -314,6 +314,8 @@ sub input_key {
my $sel = $$conf{VALUE};
my @items = @{$$conf{LISTITEMS}};
my $pos = $$conf{CURSORPOS};
+ my $top = $$conf{TOPELEMENT};
+ my $lines = $$conf{LINES};
my $re = $$conf{TOGGLE};
my $np;
@@ -337,17 +339,23 @@ sub input_key {
if ($in eq KEY_HOME) {
beep if $pos == 0;
$pos = 0;
+ $top = 0;
} elsif ($in eq KEY_END) {
beep if $pos == $#items;
$pos = $#items;
+ $top = $#items - $lines + 1;
} elsif ($in eq KEY_PPAGE) {
beep if $pos == 0;
- $pos -= $$conf{LINES};
+ $pos -= ($lines - 1);
+ $top -= ($lines - 1);
$pos = 0 if $pos < 0;
+ $top = 0 if $top < 0;
} elsif ($in eq KEY_NPAGE) {
beep if $pos == $#items;
- $pos += $$conf{LINES};
+ $pos += ($lines - 1);
+ $top += ($lines - 1);
$pos = $#items if $pos > $#items;
+ $top = ($#items - $lines + 1) if $pos > ($#items - $lines + 1);
}
} else {
beep;
@@ -377,7 +385,7 @@ sub input_key {
}
# Save the changes
- @$conf{qw(VALUE CURSORPOS)} = ($sel, $pos);
+ @$conf{qw(VALUE CURSORPOS TOPELEMENT)} = ($sel, $pos, $top);
}
sub match_key {
|