Improved title and input
This commit is contained in:
@@ -22,7 +22,12 @@ pub struct Input<'a>(pub &'a str, pub &'a InputState);
|
|||||||
impl<'a> Widget for Input<'a> {
|
impl<'a> Widget for Input<'a> {
|
||||||
fn render(&self, scope: &mut crate::render::RenderScope) {
|
fn render(&self, scope: &mut crate::render::RenderScope) {
|
||||||
let mut text = self.1.text.clone();
|
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));
|
scope.draw_text(0, format!("{}{text}", self.0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -90,7 +95,25 @@ impl InputState {
|
|||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
if self.cursor < self.text.len() {
|
if self.cursor < self.text.len() {
|
||||||
let prev = self.text[..self.cursor+1]
|
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('d'),
|
||||||
|
modifiers,
|
||||||
|
..
|
||||||
|
}) if modifiers.contains(KeyModifiers::CONTROL) => {
|
||||||
|
if self.cursor < self.text.len() {
|
||||||
|
let prev = self.text[..self.cursor + 1]
|
||||||
.char_indices()
|
.char_indices()
|
||||||
.last()
|
.last()
|
||||||
.map(|(i, _)| i)
|
.map(|(i, _)| i)
|
||||||
|
|||||||
+1
-1
@@ -147,7 +147,7 @@ impl App for PulseTradeApp {
|
|||||||
|
|
||||||
async fn render(&mut self, layout: pulse_ui::layout::Allocation) {
|
async fn render(&mut self, layout: pulse_ui::layout::Allocation) {
|
||||||
layout.draw_frame(0, Outline);
|
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(1, Center("LIVE".to_string()));
|
||||||
layout.draw(2, Center(format!("14:32:51 UTC")));
|
layout.draw(2, Center(format!("14:32:51 UTC")));
|
||||||
layout.draw_frame(3, VLine);
|
layout.draw_frame(3, VLine);
|
||||||
|
|||||||
Reference in New Issue
Block a user