Improved title and input

This commit is contained in:
2026-07-15 16:19:48 +02:00
parent 0aff5b1c7b
commit f9ab9b7712
2 changed files with 26 additions and 3 deletions
+24 -1
View File
@@ -22,7 +22,12 @@ pub struct Input<'a>(pub &'a str, pub &'a InputState);
impl<'a> Widget for Input<'a> {
fn render(&self, scope: &mut crate::render::RenderScope) {
let mut text = self.1.text.clone();
text.insert_str(self.1.cursor, "❘");
if self.1.cursor == text.len() {
text.insert_str(self.1.cursor, "\x1b[47m \x1b[0m");
} else {
text.insert_str(self.1.cursor + 1, "\x1b[0m");
text.insert_str(self.1.cursor, "\x1b[47m\x1b[30m");
}
scope.draw_text(0, format!("{}{text}", self.0));
}
}
@@ -102,6 +107,24 @@ impl InputState {
true
}
Event::Key(KeyEvent {
code: KeyCode::Char('d'),
modifiers,
..
}) if modifiers.contains(KeyModifiers::CONTROL) => {
if self.cursor < self.text.len() {
let prev = self.text[..self.cursor + 1]
.char_indices()
.last()
.map(|(i, _)| i)
.unwrap();
self.text.remove(prev);
self.cursor = prev;
}
true
}
Event::Key(KeyEvent {
code: KeyCode::Char(c),
modifiers,
+1 -1
View File
@@ -147,7 +147,7 @@ impl App for PulseTradeApp {
async fn render(&mut self, layout: pulse_ui::layout::Allocation) {
layout.draw_frame(0, Outline);
layout.draw(0, format!(" PULSE TRADER v0.1.0"));
layout.draw(0, format!(" PULSE TRADER v{}", env!("CARGO_PKG_VERSION")));
layout.draw(1, Center("LIVE".to_string()));
layout.draw(2, Center(format!("14:32:51 UTC")));
layout.draw_frame(3, VLine);