Working command system
This commit is contained in:
Generated
+1
@@ -309,6 +309,7 @@ name = "pulse-trader"
|
||||
version = "0.1.0-alpha.0"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"crossterm",
|
||||
"pulse-ui",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
@@ -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"]
|
||||
|
||||
+12
-3
@@ -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();
|
||||
|
||||
ctx.close().await;
|
||||
drop(command);
|
||||
self.execute_command(ctx, command_text.trim()).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn layout(&self) -> pulse_ui::layout::LayoutItem {
|
||||
|
||||
Reference in New Issue
Block a user