aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <chrisduerr@users.noreply.github.com>2018-01-18 17:27:07 +0000
committerGitHub <noreply@github.com>2018-01-18 17:27:07 +0000
commitb396a9a75350c5b1c82f5aae06a68dbd035df83c (patch)
tree78237c0335b4440f3e656ea9d096e528dd7979a7
parent692cdef9e3104aa0d0df21608499f70e36a8b846 (diff)
downloadalacritty-b396a9a75350c5b1c82f5aae06a68dbd035df83c.tar.gz
alacritty-b396a9a75350c5b1c82f5aae06a68dbd035df83c.zip
Implement `reset_state` of Term struct (#1035)
Up to this point the `reset_state` method of the `Term` struct has been just a placeholder. This has been changed and all important state has been reset. The only state that has not been reset is stuff which is retrieved from the config and isn't stored as default on the `Term` struct either. From what I can tell these are all never changed though. This fixes jwilm/alacritty#1033. After doing some more testing trying to figure out how to fix that all glyphs are messed up after doing `cat /dev/urandom`, I was able to confirm that resetting `Term::cursor` fixes the glyphs and restores everything to normal. So this also fixes jwilm/alacritty#804.
-rw-r--r--src/term/color.rs1
-rw-r--r--src/term/mod.rs16
2 files changed, 16 insertions, 1 deletions
diff --git a/src/term/color.rs b/src/term/color.rs
index 0284bee9..d25f2f3d 100644
--- a/src/term/color.rs
+++ b/src/term/color.rs
@@ -13,6 +13,7 @@ pub const COUNT: usize = 268;
/// the configured foreground color, item 257 is the configured background
/// color, item 258 is the cursor foreground color, item 259 is the cursor
/// background color. Following that are 8 positions for dim colors.
+#[derive(Copy, Clone)]
pub struct List([Rgb; COUNT]);
impl<'a> From<&'a Colors> for List {
diff --git a/src/term/mod.rs b/src/term/mod.rs
index 5d4260fb..79101540 100644
--- a/src/term/mod.rs
+++ b/src/term/mod.rs
@@ -1756,9 +1756,23 @@ impl ansi::Handler for Term {
}
}
+ // Reset all important fields in the term struct
#[inline]
fn reset_state(&mut self) {
- trace!("[unimplemented] reset_state");
+ self.input_needs_wrap = false;
+ self.next_title = None;
+ self.next_mouse_cursor = None;
+ self.alt = false;
+ self.cursor = Default::default();
+ self.active_charset = Default::default();
+ self.mode = Default::default();
+ self.font_size = self.original_font_size;
+ self.next_is_urgent = None;
+ self.cursor_save = Default::default();
+ self.cursor_save_alt = Default::default();
+ self.colors = self.original_colors;
+ self.color_modified = [false; color::COUNT];
+ self.cursor_style = None;
}
#[inline]