ui: fix pageup/dn behaviour
parent
678921d2b7
commit
714f8255fc
|
@ -220,6 +220,8 @@ impl ListingTrait for CompactListing {
|
|||
PageMovement::PageDown => {
|
||||
if self.new_cursor_pos.2 + rows + 1 < self.length {
|
||||
self.new_cursor_pos.2 += rows;
|
||||
} else if self.new_cursor_pos.2 + rows > self.length {
|
||||
self.new_cursor_pos.2 = self.length - 1;
|
||||
} else {
|
||||
self.new_cursor_pos.2 = (self.length / rows) * rows;
|
||||
}
|
||||
|
@ -228,7 +230,11 @@ impl ListingTrait for CompactListing {
|
|||
self.new_cursor_pos.2 = 0;
|
||||
}
|
||||
PageMovement::End => {
|
||||
self.new_cursor_pos.2 = (self.length / rows) * rows;
|
||||
if self.new_cursor_pos.2 + rows > self.length {
|
||||
self.new_cursor_pos.2 = self.length - 1;
|
||||
} else {
|
||||
self.new_cursor_pos.2 = (self.length / rows) * rows;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,6 +137,8 @@ impl ListingTrait for PlainListing {
|
|||
PageMovement::PageDown => {
|
||||
if self.new_cursor_pos.2 + rows + 1 < self.length {
|
||||
self.new_cursor_pos.2 += rows;
|
||||
} else if self.new_cursor_pos.2 + rows > self.length {
|
||||
self.new_cursor_pos.2 = self.length - 1;
|
||||
} else {
|
||||
self.new_cursor_pos.2 = (self.length / rows) * rows;
|
||||
}
|
||||
|
@ -145,7 +147,11 @@ impl ListingTrait for PlainListing {
|
|||
self.new_cursor_pos.2 = 0;
|
||||
}
|
||||
PageMovement::End => {
|
||||
self.new_cursor_pos.2 = (self.length / rows) * rows;
|
||||
if self.new_cursor_pos.2 + rows > self.length {
|
||||
self.new_cursor_pos.2 = self.length - 1;
|
||||
} else {
|
||||
self.new_cursor_pos.2 = (self.length / rows) * rows;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,33 @@ impl ListingTrait for ThreadListing {
|
|||
return;
|
||||
}
|
||||
let rows = get_y(bottom_right) - get_y(upper_left) + 1;
|
||||
if let Some(mvm) = self.movement.take() {
|
||||
match mvm {
|
||||
PageMovement::PageUp => {
|
||||
self.new_cursor_pos.2 = self.new_cursor_pos.2.saturating_sub(rows);
|
||||
}
|
||||
PageMovement::PageDown => {
|
||||
if self.new_cursor_pos.2 + rows + 1 < self.length {
|
||||
self.new_cursor_pos.2 += rows;
|
||||
} else if self.new_cursor_pos.2 + rows > self.length {
|
||||
self.new_cursor_pos.2 = self.length - 1;
|
||||
} else {
|
||||
self.new_cursor_pos.2 = (self.length / rows) * rows;
|
||||
}
|
||||
}
|
||||
PageMovement::Home => {
|
||||
self.new_cursor_pos.2 = 0;
|
||||
}
|
||||
PageMovement::End => {
|
||||
if self.new_cursor_pos.2 + rows > self.length {
|
||||
self.new_cursor_pos.2 = self.length - 1;
|
||||
} else {
|
||||
self.new_cursor_pos.2 = (self.length / rows) * rows;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let prev_page_no = (self.cursor_pos.2).wrapping_div(rows);
|
||||
let page_no = (self.new_cursor_pos.2).wrapping_div(rows);
|
||||
|
||||
|
|
Loading…
Reference in New Issue