Make sure we always emit a cursor goto for the first update.

Otherwise, if the first update is to (1, 0) then no goto occurs.
pull/100/head
Ash 6 years ago committed by Florian Dehau
parent cc95c8cfb0
commit a2776dfc86

@ -59,9 +59,11 @@ impl Backend for CrosstermBackend {
let cursor = crossterm::cursor();
let mut last_y = 0;
let mut last_x = 0;
let mut first = true;
for (x, y, cell) in content {
if y != last_y || x != last_x + 1 {
if y != last_y || x != last_x + 1 || first {
cursor.goto(x, y);
first = false;
}
last_x = x;
last_y = y;

@ -70,7 +70,7 @@ where
let mut last_x = 0;
let mut inst = 0;
for (x, y, cell) in content {
if y != last_y || x != last_x + 1 {
if y != last_y || x != last_x + 1 || inst == 0 {
string.push_str(&format!("{}", termion::cursor::Goto(x + 1, y + 1)));
inst += 1;
}

Loading…
Cancel
Save