From 8b4297d925a7566ec623424b8a6173fa6918f6c8 Mon Sep 17 00:00:00 2001 From: Ferran Basora Date: Sat, 2 May 2020 19:47:20 +0000 Subject: [PATCH] Avoid extra clear --- src/view.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/view.rs b/src/view.rs index a324fbc..23dfb57 100644 --- a/src/view.rs +++ b/src/view.rs @@ -5,7 +5,7 @@ use termion::async_stdin; use termion::event::Key; use termion::input::TermRead; use termion::raw::IntoRawMode; -use termion::{clear, color, cursor}; +use termion::{color, cursor}; pub struct View<'a> { state: &'a mut state::State<'a>, @@ -82,9 +82,6 @@ impl<'a> View<'a> { } fn render(&self, stdout: &mut dyn Write) -> () { - println!("{}{}", clear::All, cursor::Hide); - stdout.flush().unwrap(); - for (index, line) in self.state.lines.iter().enumerate() { let clean = line.trim_end_matches(|c: char| c.is_whitespace()); @@ -251,6 +248,8 @@ impl<'a> View<'a> { let mut stdin = async_stdin(); let mut stdout = stdout().into_raw_mode().unwrap(); + println!("{}", cursor::Hide); + let hints = match self.listen(&mut stdin, &mut stdout) { CaptureEvent::Exit => vec![], CaptureEvent::Hint(chosen) => chosen,