Smarter buffer drawing
Better handling for some/none
This commit is contained in:
parent
4c54639518
commit
b3f7321b90
1 changed files with 9 additions and 5 deletions
14
src/main.rs
14
src/main.rs
|
@ -14,6 +14,11 @@ struct Nuudel {
|
|||
buffer: String,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct Buffer {
|
||||
lines: Vec<String>,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
// Setup panic handling
|
||||
let default_panic = panic::take_hook();
|
||||
|
@ -113,12 +118,11 @@ impl Nuudel {
|
|||
let mut lines = self.buffer.lines();
|
||||
while y < terminal::size()?.1-1 {
|
||||
stdout.execute(terminal::Clear(terminal::ClearType::CurrentLine))?;
|
||||
let line = lines.next();
|
||||
if line.is_none() {
|
||||
if let Some(line) = lines.next() {
|
||||
write!(stdout, "{}", line)?;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
write!(stdout, "{}", line.unwrap())?;
|
||||
stdout.execute(cursor::MoveToNextLine(1))?;
|
||||
} stdout.execute(cursor::MoveToNextLine(1))?;
|
||||
y += 1;
|
||||
}
|
||||
print!("Press Q to quit");
|
||||
|
|
Loading…
Reference in a new issue