[tui] Move default input logic into ClideComponent.

This commit is contained in:
Shaun Reed 2026-01-18 11:02:41 -05:00
parent fe6390c1cd
commit ce6c12f068
4 changed files with 16 additions and 60 deletions

47
Cargo.lock generated
View File

@ -159,12 +159,6 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
[[package]]
name = "bytes"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3"
[[package]] [[package]]
name = "castaway" name = "castaway"
version = "0.2.4" version = "0.2.4"
@ -263,7 +257,6 @@ dependencies = [
"ratatui", "ratatui",
"structopt", "structopt",
"syntect", "syntect",
"tokio",
"tui-tree-widget", "tui-tree-widget",
"uuid", "uuid",
] ]
@ -668,9 +661,9 @@ dependencies = [
[[package]] [[package]]
name = "edtui" name = "edtui"
version = "0.11.0" version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "417b85aa75bedb1da51eeed2d7a9241a061ddc6a0212e80057968ba34256fad8" checksum = "e49905ece098e793ca21a019598e9efc9a66459ad1d76bd7619e771a42dae2fc"
dependencies = [ dependencies = [
"arboard", "arboard",
"crossterm", "crossterm",
@ -1485,12 +1478,6 @@ dependencies = [
"siphasher", "siphasher",
] ]
[[package]]
name = "pin-project-lite"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
[[package]] [[package]]
name = "pkg-config" name = "pkg-config"
version = "0.3.32" version = "0.3.32"
@ -2211,32 +2198,6 @@ dependencies = [
"time-core", "time-core",
] ]
[[package]]
name = "tokio"
version = "1.49.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86"
dependencies = [
"bytes",
"libc",
"mio",
"pin-project-lite",
"signal-hook-registry",
"tokio-macros",
"windows-sys 0.61.2",
]
[[package]]
name = "tokio-macros"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.114",
]
[[package]] [[package]]
name = "tui-tree-widget" name = "tui-tree-widget"
version = "0.24.0" version = "0.24.0"
@ -2666,9 +2627,9 @@ dependencies = [
[[package]] [[package]]
name = "zmij" name = "zmij"
version = "1.0.14" version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd8f3f50b848df28f887acb68e41201b5aea6bc8a8dacc00fb40635ff9a72fea" checksum = "94f63c051f4fe3c1509da62131a678643c5b6fbdc9273b2b79d4378ebda003d2"
[[package]] [[package]]
name = "zune-core" name = "zune-core"

View File

@ -15,7 +15,6 @@ ratatui = "0.30.0"
anyhow = "1.0.100" anyhow = "1.0.100"
tui-tree-widget = "0.24.0" tui-tree-widget = "0.24.0"
uuid = { version = "1.19.0", features = ["v4"] } uuid = { version = "1.19.0", features = ["v4"] }
tokio = { version = "1.49.0", features = ["rt-multi-thread", "macros", "process"] }
edtui = "0.11.0" edtui = "0.11.0"
[build-dependencies] [build-dependencies]

View File

@ -42,21 +42,10 @@ impl<'a> App<'a> {
self.editor self.editor
.event_handler .event_handler
.on_event(event.clone(), &mut self.editor.state); .on_event(event.clone(), &mut self.editor.state);
match self.handle_event(event) {
match event { Action::Noop => {}
Event::FocusGained => {} Action::Quit => break,
Event::FocusLost => {} Action::Pass => {}
Event::Key(key_event) => {
// Handle main application key events.
match self.handle_key_events(key_event) {
Action::Noop => {}
Action::Quit => break,
Action::Pass => {}
}
}
Event::Mouse(_) => {}
Event::Paste(_) => {}
Event::Resize(_, _) => {}
} }
} }
} }

View File

@ -1,4 +1,4 @@
use ratatui::crossterm::event::{KeyEvent, MouseEvent}; use ratatui::crossterm::event::{Event, KeyEvent, MouseEvent};
pub enum Action { pub enum Action {
Noop, Noop,
@ -7,6 +7,13 @@ pub enum Action {
} }
pub trait ClideComponent { pub trait ClideComponent {
fn handle_event(&mut self, event: Event) -> Action {
match event {
Event::Key(key_event) => self.handle_key_events(key_event),
_ => Action::Noop,
}
}
fn handle_key_events(&mut self, _key: KeyEvent) -> Action { fn handle_key_events(&mut self, _key: KeyEvent) -> Action {
Action::Noop Action::Noop
} }