Command Input

This commit is contained in:
2026-07-15 10:55:47 +02:00
parent 23a79f2db6
commit eb670ffe8c
4 changed files with 124 additions and 10 deletions
+20 -10
View File
@@ -3,16 +3,19 @@ use std::any::Any;
use pulse_ui::{
App,
layout::{LayoutItem, layout},
state::Refresh,
state::{Refresh, State},
unit::Size,
widget::{
align::Center,
input::{Input, InputState},
outline::{Outline, VLine},
spaced::{SpacedColumns, SpacedRows},
spaced::SpacedColumns,
},
};
pub struct PulseTradeApp {}
pub struct PulseTradeApp {
command: State<InputState>,
}
impl App for PulseTradeApp {
async fn init(&mut self, ctx: &pulse_ui::state::Context) {}
@@ -22,6 +25,12 @@ impl App for PulseTradeApp {
return;
}
if let Some(event) = event.downcast_ref() {
if self.command.value.lock().await.handle_event(event) {
return;
}
}
ctx.close().await;
}
@@ -117,12 +126,8 @@ impl App for PulseTradeApp {
(
LayoutItem::Widget(Size::Flex(1)),
Box::new(
vec![
"SIGNALS",
"BUY BTC LIM 118,800.12",
"STL BTC 120,00.00",
]
.join("\n"),
vec!["SIGNALS", "BUY BTC LIM 118,800.12", "STL BTC 120,00.00"]
.join("\n"),
),
),
(
@@ -140,10 +145,15 @@ impl App for PulseTradeApp {
),
]),
);
layout.draw(6, Input("> ", &*self.command.lock().await));
}
}
#[tokio::main]
async fn main() {
pulse_ui::run(|_ctx| PulseTradeApp {}).await;
pulse_ui::run(|ctx| PulseTradeApp {
command: ctx.use_state(InputState::new()),
})
.await;
}