From 1113c197f726dfaa50248985ecfb9785d519d8d3 Mon Sep 17 00:00:00 2001 From: Joscha Date: Mon, 13 Jun 2022 23:14:38 +0200 Subject: [PATCH] Center cursor with z --- cove-tui/src/chat/tree.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cove-tui/src/chat/tree.rs b/cove-tui/src/chat/tree.rs index a2ddb36..f9e3e46 100644 --- a/cove-tui/src/chat/tree.rs +++ b/cove-tui/src/chat/tree.rs @@ -405,6 +405,12 @@ impl TreeView { } } + async fn center_cursor(&mut self, cursor: &mut Option>) { + if let Some(cursor) = cursor { + cursor.proportion = 0.5; + } + } + pub async fn handle_key_event>( &mut self, store: &mut S, @@ -416,6 +422,7 @@ impl TreeView { ) { match event.code { KeyCode::Char('k') => self.move_to_prev_msg(store, room, cursor).await, + KeyCode::Char('z') => self.center_cursor(cursor).await, _ => {} } }