Skip to content

Commit

Permalink
fix: Keybinding c-f not working to enable follow mode
Browse files Browse the repository at this point in the history
  • Loading branch information
AMythicDev committed Dec 13, 2023
1 parent ed329b5 commit be82227
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/core/ev_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Expand Down
6 changes: 5 additions & 1 deletion src/core/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 5 additions & 3 deletions src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ pub enum InputEvent {
#[cfg(feature = "search")]
MoveToPrevMatch(usize),

ToggleFollowOutput,
FollowOutput(bool),
}

/// Classifies the input and returns the appropriate [`InputEvent`]
Expand Down Expand Up @@ -168,7 +168,9 @@ where
let position = ps.prefix_num.parse::<usize>().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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit be82227

Please sign in to comment.