From eca12225303303334cf66ccea796c71eefc16046 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 1 Jan 2024 09:13:38 +0000 Subject: [PATCH] Make the Examine prompt chain to another activity. Doesn't _work_, because I haven't actually implemented that activity yet. We now panic in a FIXME in tui.rs. But it's a start. --- src/editor.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/editor.rs b/src/editor.rs index 43c11f8..5d3c5e6 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -1,5 +1,6 @@ use unicode_width::UnicodeWidthChar; +use super::activity_stack::UtilityActivity; use super::client::Client; use super::coloured_string::ColouredString; use super::tui::{ @@ -526,15 +527,19 @@ struct BottomLineEditorOverlay { prompt: ColouredString, promptwidth: usize, ed: SingleLineEditor, + result: Box LogicalAction>, } impl BottomLineEditorOverlay { - fn new(prompt: ColouredString) -> Self { + fn new(prompt: ColouredString, result: Box LogicalAction>) + -> Self + { let promptwidth = prompt.width(); BottomLineEditorOverlay { prompt: prompt, promptwidth, ed: SingleLineEditor::new(), + result: result, } } } @@ -562,7 +567,7 @@ impl ActivityState for BottomLineEditorOverlay { LogicalAction { if self.ed.handle_keypress(key) { - LogicalAction::Beep // FIXME: do something! + (self.result)(&self.ed.core.text) } else { LogicalAction::Nothing } @@ -571,5 +576,8 @@ impl ActivityState for BottomLineEditorOverlay { pub fn get_user_to_examine() -> Box { Box::new(BottomLineEditorOverlay::new( - ColouredString::plain("Examine User: "))) + ColouredString::plain("Examine User: "), + Box::new(move |s| LogicalAction::Goto( + UtilityActivity::ExamineUser(s.to_owned()).into())) + )) } -- 2.30.2