Skip to content

Commit

Permalink
reinstate scroll to bottom on input behavior
Browse files Browse the repository at this point in the history
This was temporarily disabled as part of the mux datamodel changes
  • Loading branch information
wez committed Jan 6, 2020
1 parent 59de970 commit f38e391
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,13 @@ pub struct Config {
/// 10 seconds.
#[serde(default)]
pub periodic_stat_logging: u64,

/// If false, do not scroll to the bottom of the terminal when
/// you send input to the terminal.
/// The default is to scroll to the bottom when you send input
/// to the terminal.
#[serde(default = "default_true")]
pub scroll_to_bottom_on_input: bool,
}

#[derive(Deserialize, Clone, Copy, Debug)]
Expand Down
13 changes: 13 additions & 0 deletions src/frontend/gui/termwindow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ impl WindowCallbacks for TermWindow {
&& modifiers.contains(::termwiz::input::Modifiers::ALT)
&& tab.key_down(key, modifiers).is_ok()
{
self.maybe_scroll_to_bottom_for_input(&tab);
return true;
}
}
Expand All @@ -401,13 +402,15 @@ impl WindowCallbacks for TermWindow {
self.perform_key_assignment(&tab, &assignment).ok();
true
} else if tab.key_down(key, modifiers).is_ok() {
self.maybe_scroll_to_bottom_for_input(&tab);
true
} else {
false
}
}
Key::Composed(s) => {
tab.writer().write_all(s.as_bytes()).ok();
self.maybe_scroll_to_bottom_for_input(&tab);
true
}
Key::None => false,
Expand Down Expand Up @@ -2668,6 +2671,16 @@ impl TermWindow {
}
}
}

fn maybe_scroll_to_bottom_for_input(&mut self, tab: &Rc<dyn Tab>) {
if configuration().scroll_to_bottom_on_input {
self.scroll_to_bottom(tab);
}
}

fn scroll_to_bottom(&mut self, tab: &Rc<dyn Tab>) {
self.tab_state(tab.tab_id()).viewport = None;
}
}

fn rgbcolor_to_window_color(color: RgbColor) -> Color {
Expand Down

0 comments on commit f38e391

Please sign in to comment.