factor out modules; modal -> dialog

This commit is contained in:
🪞👃🪞 2025-04-06 16:05:48 +03:00
parent c075871e50
commit b157a87647
7 changed files with 163 additions and 158 deletions

View file

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