mirror of
https://codeberg.org/unspeaker/perch.git
synced 2025-12-06 17:46:42 +01:00
factor out modules; modal -> dialog
This commit is contained in:
parent
c075871e50
commit
b157a87647
7 changed files with 163 additions and 158 deletions
18
src/model.rs
18
src/model.rs
|
|
@ -47,4 +47,22 @@ impl Taggart {
|
|||
entries,
|
||||
})
|
||||
}
|
||||
/// Make sure cursor is always in view
|
||||
pub(crate) fn clamp (&mut self, min: usize, max: usize) {
|
||||
if self.cursor < min {
|
||||
self.offset = self.cursor;
|
||||
}
|
||||
if self.cursor > max {
|
||||
self.offset += self.cursor - max;
|
||||
}
|
||||
if self.offset > self.entries.len().saturating_sub(self.display.h()) {
|
||||
self.offset = self.entries.len().saturating_sub(self.display.h())
|
||||
}
|
||||
if self.cursor >= self.entries.len() {
|
||||
self.cursor = self.entries.len().saturating_sub(1)
|
||||
}
|
||||
if self.column + 1 > self.columns.0.len() {
|
||||
self.column = self.columns.0.len().saturating_sub(1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue