Skip to content

Commit

Permalink
fps fix, cursor movement fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Kacperacy committed May 10, 2024
1 parent 8860b52 commit 0f09748
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ impl App {
}
}
}

if direction.y > 0 && self.cursor_position.y > 0 {
self.cursor_position.y -= 1;
if self.cursor_position.x > self.content[self.cursor_position.y].len() {
self.cursor_position.x = self.content[self.cursor_position.y].len();
}
} else if direction.y < 0 && self.cursor_position.y < self.content.len() - 1 {
} else if direction.y < 0 && self.cursor_position.y < self.content.len().saturating_sub(1) {
self.cursor_position.y += 1;
if self.cursor_position.x > self.content[self.cursor_position.y].len() {
self.cursor_position.x = self.content[self.cursor_position.y].len();
Expand Down
8 changes: 5 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ async fn main() -> AppResult<()> {
let events = EventHandler::new(250);
let mut tui = Tui::new(terminal, events);
tui.init()?;
tui.draw(&mut app)?;

while app.running {
tui.draw(&mut app)?;

match tui.events.next().await? {
Event::Tick => app.tick(),
Event::Key(key_event) => handle_key_events(key_event, &mut app)?,
Event::Key(key_event) => {
handle_key_events(key_event, &mut app)?;
tui.draw(&mut app)?;
}
Event::Mouse(_) => {}
Event::Resize(_, _) => {}
}
Expand Down

0 comments on commit 0f09748

Please sign in to comment.