From 9da0866e91251c5e04225cef56e8adcf065bdb9a Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Fri, 29 Dec 2023 16:05:30 +0000 Subject: [PATCH] Pass client through to handle_keypress. --- src/file.rs | 4 +++- src/menu.rs | 5 ++++- src/tui.rs | 8 +++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/file.rs b/src/file.rs index 1719fe3..da20f71 100644 --- a/src/file.rs +++ b/src/file.rs @@ -57,7 +57,9 @@ impl ActivityState for FeedFile { (lines, CursorPosition::None) // FIXME } - fn handle_keypress(&mut self, _key: OurKey) -> LogicalAction { + fn handle_keypress(&mut self, _key: OurKey, _client: &mut Client) -> + LogicalAction + { LogicalAction::Nothing // FIXME } } diff --git a/src/menu.rs b/src/menu.rs index d5be77a..18c4fe4 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -3,6 +3,7 @@ use std::cmp::max; use itertools::Itertools; use super::activity_stack::{NonUtilityActivity, UtilityActivity}; +use super::client::Client; use super::coloured_string::ColouredString; use super::text::*; use super::tui::{ @@ -169,7 +170,9 @@ impl ActivityState for Menu { (lines, CursorPosition::End) } - fn handle_keypress(&mut self, key: OurKey) -> LogicalAction { + fn handle_keypress(&mut self, key: OurKey, _client: &mut Client) -> + LogicalAction + { match self.actions.get(&key) { Some(action) => action.clone(), None => LogicalAction::Nothing, diff --git a/src/tui.rs b/src/tui.rs index ab11d73..c7869cd 100644 --- a/src/tui.rs +++ b/src/tui.rs @@ -338,8 +338,10 @@ pub enum LogicalAction { } pub trait ActivityState { - fn draw(&self, w: usize, h: usize) -> (Vec, CursorPosition); - fn handle_keypress(&mut self, key: OurKey) -> LogicalAction; + fn draw(&self, w: usize, h: usize) -> + (Vec, CursorPosition); + fn handle_keypress(&mut self, key: OurKey, client: &mut Client) -> + LogicalAction; } struct TuiLogicalState { @@ -414,7 +416,7 @@ impl TuiLogicalState { OurKey::Escape => LogicalAction::Goto( UtilityActivity::UtilsMenu.into()), - _ => self.activity_state.handle_keypress(key), + _ => self.activity_state.handle_keypress(key, client), }; match logact { -- 2.30.2