mirror of
https://github.com/zaphar/sheetsui.git
synced 2025-07-22 21:09:48 -04:00
chore: move input handling to pure method
This commit is contained in:
parent
25a8160f0a
commit
a70a1451c1
@ -1,6 +1,7 @@
|
||||
use std::{path::PathBuf, process::ExitCode};
|
||||
|
||||
use clap::Parser;
|
||||
use crossterm::event;
|
||||
use ratatui;
|
||||
use ui::Workspace;
|
||||
|
||||
@ -23,7 +24,7 @@ fn run(terminal: &mut ratatui::DefaultTerminal, args: Args) -> anyhow::Result<Ex
|
||||
|
||||
loop {
|
||||
terminal.draw(|frame| ui::render::draw(frame, &mut ws))?;
|
||||
if let Some(code) = ws.handle_input()? {
|
||||
if let Some(code) = ws.handle_input(event::read()?)? {
|
||||
return Ok(code);
|
||||
}
|
||||
}
|
||||
|
@ -163,10 +163,10 @@ impl<'ws> Workspace<'ws> {
|
||||
}
|
||||
|
||||
/// Handle input in our ui loop.
|
||||
pub fn handle_input(&mut self) -> Result<Option<ExitCode>> {
|
||||
pub fn handle_input(&mut self, evt: Event) -> Result<Option<ExitCode>> {
|
||||
// TODO(jwall): We probably want to separate this out into
|
||||
// a pure function so we can script various testing scenarios.
|
||||
if let Event::Key(key) = event::read()? {
|
||||
if let Event::Key(key) = evt {
|
||||
let result = match self.state.modality() {
|
||||
Modality::Navigate => self.handle_navigation_input(key)?,
|
||||
Modality::CellEdit => self.handle_edit_input(key)?,
|
||||
|
Loading…
x
Reference in New Issue
Block a user