From be822275be6c9a3412570b13906037143f59d950 Mon Sep 17 00:00:00 2001 From: Arijit Dey Date: Wed, 13 Dec 2023 17:00:07 +0530 Subject: [PATCH] fix: Keybinding c-f not working to enable follow mode --- src/core/ev_handler.rs | 5 ++++- src/core/init.rs | 6 +++++- src/input/mod.rs | 8 +++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/core/ev_handler.rs b/src/core/ev_handler.rs index 0cc565c..07b2df6 100644 --- a/src/core/ev_handler.rs +++ b/src/core/ev_handler.rs @@ -270,8 +270,11 @@ pub fn handle_event( Command::SetInputClassifier(clf) => p.input_classifier = clf, Command::AddExitCallback(cb) => p.exit_callbacks.push(cb), Command::ShowPrompt(show) => p.show_prompt = show, + Command::FollowOutput(follow_output) + | Command::UserInput(InputEvent::FollowOutput(follow_output)) => { + p.follow_output = follow_output + } Command::UserInput(_) => {} - Command::FollowOutput(follow_output) => p.follow_output = follow_output, } Ok(()) } diff --git a/src/core/init.rs b/src/core/init.rs index 5d4ca40..198d053 100644 --- a/src/core/init.rs +++ b/src/core/init.rs @@ -8,6 +8,8 @@ //! * The [`start_reactor`] function displays the displays the output and also polls //! the [`Receiver`] held inside the [`Pager`] for events. Whenever a event is //! detected, it reacts to it accordingly. +#[cfg(feature = "static_output")] +use crate::minus_core::utils::display; use crate::{ error::MinusError, input::InputEvent, @@ -300,7 +302,9 @@ fn start_reactor( RunMode::Static => { { let mut p = ps.lock(); - draw_for_change(&mut out_lock, &mut p, &mut (usize::MAX - 1)); + if p.follow_output { + display::draw_for_change(&mut out_lock, &mut p, &mut (usize::MAX - 1))?; + } } loop { diff --git a/src/input/mod.rs b/src/input/mod.rs index f29d105..db38123 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -139,7 +139,7 @@ pub enum InputEvent { #[cfg(feature = "search")] MoveToPrevMatch(usize), - ToggleFollowOutput, + FollowOutput(bool), } /// Classifies the input and returns the appropriate [`InputEvent`] @@ -168,7 +168,9 @@ where let position = ps.prefix_num.parse::().unwrap_or(1); InputEvent::UpdateUpperMark(ps.upper_mark.saturating_add(position)) }); - map.add_key_events(&["f"], |_, _| InputEvent::ToggleFollowOutput); + map.add_key_events(&["c-f"], |_, ps| { + InputEvent::FollowOutput(!ps.follow_output) + }); map.add_key_events(&["enter"], |_, ps| { if ps.message.is_some() { InputEvent::RestorePrompt @@ -314,7 +316,7 @@ impl InputClassifier for DefaultInputClassifier { code, modifiers: KeyModifiers::CONTROL, .. - }) if code == KeyCode::Char('f') => Some(InputEvent::ToggleFollowOutput), + }) if code == KeyCode::Char('f') => Some(InputEvent::FollowOutput(!ps.follow_output)), // For number keys Event::Key(KeyEvent {