aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2018-11-19 08:33:48 +0000
committerGitHub <noreply@github.com>2018-11-19 08:33:48 +0000
commit42d89899162164128364c503cee29dc65103d55d (patch)
tree8e1511b4a5438272d1e9e958107a04f061b720d5 /src
parente429b8dfdda3228838cd839783d17376a65b44fe (diff)
downloadalacritty-42d89899162164128364c503cee29dc65103d55d.tar.gz
alacritty-42d89899162164128364c503cee29dc65103d55d.zip
Add keybinding action for clearing warns/errors
Since running `clear` inside of tmux doesn't actually clear any part of the screen, but just resets the scrolling region, the warning and error notices can't be removed without quitting tmux or Alacritty. As a solution, a new action `ClearLogNotice` has been added which has been bound to Ctrl+L by default. As a result, Ctrl+L can be used inside of tmux to remove the messages, even though tmux doesn't clear the screen. This fixes #1811.
Diffstat (limited to 'src')
-rw-r--r--src/config.rs3
-rw-r--r--src/event.rs5
-rw-r--r--src/input.rs8
-rw-r--r--src/term/mod.rs14
4 files changed, 24 insertions, 6 deletions
diff --git a/src/config.rs b/src/config.rs
index 2028132f..d56e8578 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -746,7 +746,7 @@ impl<'a> de::Deserialize<'a> for ActionWrapper {
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Paste, Copy, PasteSelection, IncreaseFontSize, DecreaseFontSize, \
ResetFontSize, ScrollPageUp, ScrollPageDown, ScrollToTop, \
- ScrollToBottom, ClearHistory, Hide, or Quit")
+ ScrollToBottom, ClearHistory, Hide, ClearLogNotice or Quit")
}
fn visit_str<E>(self, value: &str) -> ::std::result::Result<ActionWrapper, E>
@@ -766,6 +766,7 @@ impl<'a> de::Deserialize<'a> for ActionWrapper {
"ClearHistory" => Action::ClearHistory,
"Hide" => Action::Hide,
"Quit" => Action::Quit,
+ "ClearLogNotice" => Action::ClearLogNotice,
_ => return Err(E::invalid_value(Unexpected::Str(value), &self)),
}))
}
diff --git a/src/event.rs b/src/event.rs
index ece8ec6f..f69136df 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -171,6 +171,11 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
fn hide_window(&mut self) {
self.window_changes.hide = true;
}
+
+ #[inline]
+ fn clear_log(&mut self) {
+ self.terminal.clear_log();
+ }
}
/// The ActionContext can't really have direct access to the Window
diff --git a/src/input.rs b/src/input.rs
index d2f8f6b5..051a38db 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -76,6 +76,7 @@ pub trait ActionContext {
fn clear_history(&mut self);
fn hide_window(&mut self);
fn url(&self, _: Point<usize>) -> Option<String>;
+ fn clear_log(&mut self);
}
/// Describes a state and action to take in that state
@@ -200,6 +201,9 @@ pub enum Action {
/// Quits Alacritty.
Quit,
+
+ /// Clears warning and error notices.
+ ClearLogNotice,
}
impl Action {
@@ -292,6 +296,9 @@ impl Action {
Action::ClearHistory => {
ctx.clear_history();
},
+ Action::ClearLogNotice => {
+ ctx.clear_log();
+ }
}
}
@@ -885,6 +892,7 @@ mod tests {
}
fn hide_window(&mut self) {
}
+ fn clear_log(&mut self) {}
}
macro_rules! test_clickstate {
diff --git a/src/term/mod.rs b/src/term/mod.rs
index 0f228f86..5107dc2d 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -877,6 +877,14 @@ impl Term {
&self.grid.selection
}
+ /// Clear displayed errors and warnings.
+ pub fn clear_log(&mut self) {
+ if let Some(ref mut logger_proxy) = self.logger_proxy {
+ logger_proxy.clear();
+ }
+ }
+
+
pub fn selection_mut(&mut self) -> &mut Option<Selection> {
&mut self.grid.selection
}
@@ -1831,11 +1839,7 @@ impl ansi::Handler for Term {
}
},
ansi::ClearMode::All => {
- // Clear displayed errors and warnings
- if let Some(ref mut logger_proxy) = self.logger_proxy {
- logger_proxy.clear();
- }
-
+ self.clear_log();
self.grid.region_mut(..).each(|c| c.reset(&template));
},
ansi::ClearMode::Above => {