Take &self in TermionBackend::clear()

This commit is contained in:
Alexandre Bury 2016-10-09 16:03:49 -07:00
parent ad7606ca55
commit 686de0831c

View File

@ -1,5 +1,3 @@
use ::backend; use ::backend;
use ::event::{Event, Key}; use ::event::{Event, Key};
use std::io::Write; use std::io::Write;
@ -15,18 +13,19 @@ pub struct TermionBackend {
impl backend::Backend for TermionBackend { impl backend::Backend for TermionBackend {
fn init() -> Self { fn init() -> Self {
print!("{}", termion::cursor::Hide); print!("{}", termion::cursor::Hide);
Self::clear();
let backend = TermionBackend {
TermionBackend {
terminal: ::std::io::stdout().into_raw_mode().unwrap(), terminal: ::std::io::stdout().into_raw_mode().unwrap(),
} };
backend.clear();
backend
} }
fn finish(&mut self) { fn finish(&mut self) {
// Maybe we should clear everything? // Maybe we should clear everything?
print!("{}{}", termion::cursor::Show, termion::cursor::Goto(1, 1)); print!("{}{}", termion::cursor::Show, termion::cursor::Goto(1, 1));
Self::clear(); self.clear();
} }
fn init_color_style(&mut self, style: ColorStyle, foreground: &Color, fn init_color_style(&mut self, style: ColorStyle, foreground: &Color,
@ -58,7 +57,7 @@ impl backend::Backend for TermionBackend {
(x as usize, y as usize) (x as usize, y as usize)
} }
fn clear() { fn clear(&self) {
print!("{}", termion::clear::All); print!("{}", termion::clear::All);
} }