From a70a1451c1a6e1c3c3e118c6c1a25f6bf89549fe Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Fri, 22 Nov 2024 18:57:57 -0500 Subject: [PATCH] chore: move input handling to pure method --- src/main.rs | 3 ++- src/ui/mod.rs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 82710c3..1794bc7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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 Workspace<'ws> { } /// Handle input in our ui loop. - pub fn handle_input(&mut self) -> Result> { + pub fn handle_input(&mut self, evt: Event) -> Result> { // 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)?,