fix for grey lines from the left that should be black, and re-show cursor

This commit is contained in:
lifning 2021-11-26 18:52:36 -08:00
parent 01a1b790ae
commit d8a403110f

View file

@ -89,6 +89,12 @@ impl Default for AnsiVideoComponent {
} }
} }
impl Drop for AnsiVideoComponent {
fn drop(&mut self) {
write!(self.screen, "{}", termion::cursor::Show).unwrap();
}
}
impl RetroCallbacks for AnsiVideoComponent { impl RetroCallbacks for AnsiVideoComponent {
fn video_refresh(&mut self, frame: &VideoFrame) { fn video_refresh(&mut self, frame: &VideoFrame) {
match frame { match frame {
@ -141,8 +147,9 @@ impl RetroCallbacks for AnsiVideoComponent {
let processed = processor.process(&rgba_img).into_iter().next().unwrap().1; let processed = processor.process(&rgba_img).into_iter().next().unwrap().1;
write!(self.screen, "{}", termion::cursor::Goto(1, 1)).unwrap(); write!(self.screen, "{}", termion::cursor::Goto(1, 1)).unwrap();
for line in self.encode_frame(&processed).lines() { for line in self.encode_frame(&processed).lines() {
write!(self.screen, "{}\x1B[0m\r\n", line).unwrap(); write!(self.screen, "{}{}\r\n", line, termion::color::Fg(termion::color::Black)).unwrap();
} }
write!(self.screen, "\x1B[0m").unwrap();
self.screen.flush().unwrap(); self.screen.flush().unwrap();
} else if force_redraw { } else if force_redraw {
// TODO: draw last copy // TODO: draw last copy