add page up

pull/6/head
dvkt 5 years ago
parent 8549abcccc
commit 4e19ba009f

@ -194,13 +194,10 @@ impl MenuView {
match dir {
LinkDir::Above => {
let scroll = self.scroll;
if let Some(&pos) = self
.links()
.iter()
.skip(self.link)
.find(|&&i| i >= scroll - 1)
if let Some(&pos) =
self.links().iter().skip(self.link).find(|&&i| i >= scroll)
{
self.link = self.lines().get(pos).unwrap().link;
self.link = self.lines().get(pos).unwrap().link - 1;
}
}
LinkDir::Below => {}
@ -220,6 +217,27 @@ impl MenuView {
} else {
self.scroll = 0;
}
if self.link == 0 {
return Action::Redraw;
}
if let Some(dir) = self.link_visibility(self.link) {
match dir {
LinkDir::Below => {
let scroll = self.scroll;
if let Some(&pos) = self
.links()
.iter()
.take(self.link)
.rev()
.find(|&&i| i < (self.size.1 + scroll - 2))
{
self.link = self.lines().get(pos).unwrap().link;
}
}
LinkDir::Above => {}
LinkDir::Visible => {}
}
}
Action::Redraw
} else {
Action::None

Loading…
Cancel
Save