fix scrolling

This commit is contained in:
2025-11-11 14:30:30 -07:00
parent 4288f60441
commit 0fd9f1522e
2 changed files with 82 additions and 13 deletions

View File

@@ -63,7 +63,7 @@ impl Widget for &App {
x_idx = x as usize - 1 + self.screen.scroll_x();
}
if y != 0 {
y_idx = y as usize - 1 + self.screen.y();
y_idx = y as usize - 1 + self.screen.scroll_y();
}
if is_selected(x.into(), y.into()) {
@@ -216,7 +216,7 @@ impl App {
frame.render_widget(Paragraph::new(format!("x/w y/h: cursor{:?} scroll({}, {}) cell({}, {}) screen({}, {})",
self.grid.selected_cell,
self.screen.scroll_x(),
self.screen.y(),
self.screen.scroll_y(),
self.screen.get_cell_width(&self.vars),
self.screen.get_cell_height(&self.vars),
body.width,
@@ -225,9 +225,6 @@ impl App {
}
fn handle_events(&mut self) -> io::Result<()> {
// make sure cursor is inside window
self.screen.scroll_based_on_cursor_location(self.grid.selected_cell, &self.vars);
match &mut self.mode {
Mode::Chord(chord) => match event::read()? {
event::Event::Key(key) => match key.code {
@@ -312,6 +309,9 @@ impl App {
},
}
// make sure cursor is inside window
self.screen.scroll_based_on_cursor_location(self.grid.selected_cell, &self.vars);
Ok(())
}
}