From feb9166c30bc93f9640e9f45faf81f9a36b5f27d Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Wed, 15 Jul 2026 22:32:49 +0200 Subject: [PATCH] Working command system --- Cargo.lock | 1 + Cargo.toml | 1 + src/main.rs | 13 +++++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a6cda8f..44c8c16 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -309,6 +309,7 @@ name = "pulse-trader" version = "0.1.0-alpha.0" dependencies = [ "chrono", + "crossterm", "pulse-ui", "tokio", ] diff --git a/Cargo.toml b/Cargo.toml index 3c627d6..4ea732d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ edition = "2024" chrono = "0.4.45" pulse-ui = { workspace = true } tokio = { workspace = true, features = ["rt-multi-thread", "macros"] } +crossterm = { workspace = true } [workspace] members = ["pulse-ui"] diff --git a/src/main.rs b/src/main.rs index 57033ff..35882a4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +pub mod command; pub mod formatting; pub mod types; @@ -141,10 +142,18 @@ impl App for PulseTradeApp { if let Some(event) = event.downcast_ref() { if self.command.value.lock().await.handle_event(event) { return; + } else if let crossterm::event::Event::Key(key) = event { + if key.code.is_enter() { + let mut command = self.command.lock().await; + let command_text = command.text.clone(); + command.cursor = 0; + command.text.clear(); + + drop(command); + self.execute_command(ctx, command_text.trim()).await; + } } } - - ctx.close().await; } async fn layout(&self) -> pulse_ui::layout::LayoutItem {