summaryrefslogtreecommitdiffstats
path: root/src/interactive/app
diff options
context:
space:
mode:
authorPiotr Wach <pwach@bloomberg.net>2023-12-20 20:29:07 +0100
committerPiotr Wach <pwach@bloomberg.net>2023-12-20 20:30:43 +0100
commitaaa27e860508e564d82b43295baa4290b53eb87f (patch)
tree4cd326dafdb751667decb4643fe4d9a7026fc8f7 /src/interactive/app
parent49aecb9245054446ac1b338ea1cc29831e72d5e0 (diff)
Fix cursor rendering
Diffstat (limited to 'src/interactive/app')
-rw-r--r--src/interactive/app/eventloop.rs24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/interactive/app/eventloop.rs b/src/interactive/app/eventloop.rs
index 1379811..45d4441 100644
--- a/src/interactive/app/eventloop.rs
+++ b/src/interactive/app/eventloop.rs
@@ -27,6 +27,13 @@ pub enum FocussedPane {
}
#[derive(Default)]
+pub struct Cursor {
+ pub show: bool,
+ pub x: u16,
+ pub y: u16,
+}
+
+#[derive(Default)]
pub struct AppState {
pub normal_mode: NavigationState,
pub glob_mode: Option<NavigationState>,
@@ -70,7 +77,18 @@ impl AppState {
display,
state: self,
};
- draw_window(window, props, terminal)
+ let mut cursor = Cursor::default();
+
+ let result = draw_window(window, props, terminal, &mut cursor);
+
+ if cursor.show {
+ _ = terminal.show_cursor();
+ } else {
+ _ = terminal.hide_cursor();
+ }
+ _ = terminal.set_cursor(cursor.x, cursor.y);
+
+ result
}
pub fn process_events<B>(
@@ -316,13 +334,15 @@ pub fn draw_window<B>(
window: &mut MainWindow,
props: MainWindowProps,
terminal: &mut Terminal<B>,
+ cursor: &mut Cursor,
) -> Result<()>
where
B: Backend,
{
let area = terminal.pre_render()?;
- window.render(props, area, terminal);
+ window.render(props, area, terminal, cursor);
terminal.post_render()?;
+
Ok(())
}