Fix last line clear
This commit is contained in:
parent
dff33cbe88
commit
0772938b3e
17
src/tile.rs
17
src/tile.rs
|
@ -406,7 +406,7 @@ impl Tile {
|
||||||
|
|
||||||
/// Renders the content of the tile.
|
/// Renders the content of the tile.
|
||||||
pub fn render_content(&self) -> String {
|
pub fn render_content(&self) -> String {
|
||||||
const DELETE_CHAR: char = '-';
|
const DELETE_CHAR: char = ' ';
|
||||||
|
|
||||||
let (x, y) = self.inner_position;
|
let (x, y) = self.inner_position;
|
||||||
let (w, h) = self.inner_size;
|
let (w, h) = self.inner_size;
|
||||||
|
@ -417,16 +417,21 @@ impl Tile {
|
||||||
let mut line_index = 0;
|
let mut line_index = 0;
|
||||||
let mut old_current_char_index = 0;
|
let mut old_current_char_index = 0;
|
||||||
let mut current_char_index = 0;
|
let mut current_char_index = 0;
|
||||||
|
let mut last_char = ' ';
|
||||||
let scroll = self.scroll as u16;
|
let scroll = self.scroll as u16;
|
||||||
|
|
||||||
buffer.push(format!("{}", cursor::Goto(x, y)));
|
buffer.push(format!("{}", cursor::Goto(x, y)));
|
||||||
|
|
||||||
for c in self.stdout.chars() {
|
for c in self.stdout.chars() {
|
||||||
|
last_char = c;
|
||||||
if c == '\x1b' {
|
if c == '\x1b' {
|
||||||
counting = false;
|
counting = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if line_index >= scroll && line_index <= h + scroll {
|
||||||
old_current_char_index = current_char_index;
|
old_current_char_index = current_char_index;
|
||||||
|
}
|
||||||
|
|
||||||
match c {
|
match c {
|
||||||
'\n' => {
|
'\n' => {
|
||||||
line_index += 1;
|
line_index += 1;
|
||||||
|
@ -449,6 +454,7 @@ impl Tile {
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
|
if line_index >= scroll && line_index <= h + scroll {
|
||||||
if counting {
|
if counting {
|
||||||
current_char_index += 1;
|
current_char_index += 1;
|
||||||
}
|
}
|
||||||
|
@ -465,7 +471,6 @@ impl Tile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if line_index >= scroll && line_index <= h + scroll {
|
|
||||||
buffer.push(format!("{}", c));
|
buffer.push(format!("{}", c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -476,8 +481,14 @@ impl Tile {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let index = if last_char == '\n' {
|
||||||
|
old_current_char_index
|
||||||
|
} else {
|
||||||
|
current_char_index
|
||||||
|
};
|
||||||
|
|
||||||
let mut spaces = String::new();
|
let mut spaces = String::new();
|
||||||
for _ in old_current_char_index..w {
|
for _ in index..w {
|
||||||
spaces.push(DELETE_CHAR);
|
spaces.push(DELETE_CHAR);
|
||||||
}
|
}
|
||||||
buffer.push(spaces);
|
buffer.push(spaces);
|
||||||
|
|
Loading…
Reference in New Issue