Add termion AlternateScreen support

This commit is contained in:
quininer kel 2017-04-26 14:20:52 +08:00
parent 381e2d9d73
commit 440578c7d1

View File

@ -7,6 +7,7 @@ use self::termion::event::Event as TEvent;
use self::termion::event::Key as TKey; use self::termion::event::Key as TKey;
use self::termion::input::TermRead; use self::termion::input::TermRead;
use self::termion::raw::IntoRawMode; use self::termion::raw::IntoRawMode;
use self::termion::screen::AlternateScreen;
use self::termion::style as tstyle; use self::termion::style as tstyle;
use backend; use backend;
use chan; use chan;
@ -20,7 +21,7 @@ use std::thread;
use theme; use theme;
pub struct Concrete { pub struct Concrete {
terminal: termion::raw::RawTerminal<::std::io::Stdout>, terminal: AlternateScreen<termion::raw::RawTerminal<::std::io::Stdout>>,
current_style: Cell<theme::ColorStyle>, current_style: Cell<theme::ColorStyle>,
colors: BTreeMap<i16, (Box<tcolor::Color>, Box<tcolor::Color>)>, colors: BTreeMap<i16, (Box<tcolor::Color>, Box<tcolor::Color>)>,
@ -81,7 +82,7 @@ impl backend::Backend for Concrete {
let resize = chan_signal::notify(&[chan_signal::Signal::WINCH]); 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(); let (sender, receiver) = chan::async();
thread::spawn(move || for key in ::std::io::stdin().events() { thread::spawn(move || for key in ::std::io::stdin().events() {