From 440578c7d1be4193a535ff28863de492664b6bea Mon Sep 17 00:00:00 2001 From: quininer kel Date: Wed, 26 Apr 2017 14:20:52 +0800 Subject: [PATCH 1/2] Add termion AlternateScreen support --- src/backend/termion.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/backend/termion.rs b/src/backend/termion.rs index 5ae7851..8776fe3 100644 --- a/src/backend/termion.rs +++ b/src/backend/termion.rs @@ -7,6 +7,7 @@ use self::termion::event::Event as TEvent; use self::termion::event::Key as TKey; use self::termion::input::TermRead; use self::termion::raw::IntoRawMode; +use self::termion::screen::AlternateScreen; use self::termion::style as tstyle; use backend; use chan; @@ -20,7 +21,7 @@ use std::thread; use theme; pub struct Concrete { - terminal: termion::raw::RawTerminal<::std::io::Stdout>, + terminal: AlternateScreen>, current_style: Cell, colors: BTreeMap, Box)>, @@ -81,7 +82,7 @@ impl backend::Backend for Concrete { let resize = chan_signal::notify(&[chan_signal::Signal::WINCH]); - let terminal = ::std::io::stdout().into_raw_mode().unwrap(); + let terminal = AlternateScreen::from(::std::io::stdout().into_raw_mode().unwrap()); let (sender, receiver) = chan::async(); thread::spawn(move || for key in ::std::io::stdin().events() { From f34e1d9a028cb64c756c556575b1772e97f28202 Mon Sep 17 00:00:00 2001 From: quininer kel Date: Wed, 26 Apr 2017 18:35:01 +0800 Subject: [PATCH 2/2] Fix `VecExt::splice` conflict with `Vec::splice` --- src/views/text_area.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/text_area.rs b/src/views/text_area.rs index f6c5fe7..4f1d6ea 100644 --- a/src/views/text_area.rs +++ b/src/views/text_area.rs @@ -356,7 +356,7 @@ impl TextArea { let affected_rows = first_row..last_row; let replacement_rows = new_rows.into_iter() .map(|row| row.shifted(first_byte)); - self.rows.splice(affected_rows, replacement_rows); + VecExt::splice(&mut self.rows, affected_rows, replacement_rows); self.fix_ghost_row(); self.scrollbase.set_heights(size.y, self.rows.len()); }