Browse Source

ui: fix pageup/dn behaviour

tags/pre-alpha-0.2.0
Manos Pitsidianakis 1 year ago
parent
commit
714f8255fc
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS. GPG Key ID: 73627C2F690DF710
3 changed files with 41 additions and 2 deletions
  1. +7
    -1
      ui/src/components/mail/listing/compact.rs
  2. +7
    -1
      ui/src/components/mail/listing/plain.rs
  3. +27
    -0
      ui/src/components/mail/listing/thread.rs

+ 7
- 1
ui/src/components/mail/listing/compact.rs View File

@ -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;
}
}
}
}

+ 7
- 1
ui/src/components/mail/listing/plain.rs View File

@ -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;
}
}
}
}

+ 27
- 0
ui/src/components/mail/listing/thread.rs View File

@ -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…
Cancel
Save