summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlara Modin <kasm@kasm.eu>2018-05-17 01:42:02 +0200
committerKlara Modin <kasm@kasm.eu>2018-05-17 01:42:02 +0200
commitcd450a56eba1ecdee1280224c9838039a067762b (patch)
tree4f242b15b6fc30f766f80c94640abd4f5feaae7f
parentaa6692ebf9d78e7663da7c730d960cb77d6aa0f2 (diff)
fix bug where line appears on header
-rw-r--r--src/ui.rs22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/ui.rs b/src/ui.rs
index 730c136..a0894e4 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -19,7 +19,7 @@ impl UI {
input_x: 0,
input_y: 0,
output_x: 0,
- output_y: 0,
+ output_y: 1,
chan: String::new(),
nick: String::new(),
buffer: String::new(),
@@ -69,17 +69,17 @@ impl UI {
let mut max_y = 0;
getmaxyx(stdscr(), &mut max_y, &mut max_x);
+ if self.output_y >= max_y-1 {
+ self.scroll(1);
+ }
let mut chars = text.chars();
while let Some(ch) = chars.next() {
if self.output_x >= max_x {
self.output_x = 0;
self.output_y += 1;
- }
- if self.output_y >= max_y-1 {
- mv(1, 0);
- deleteln();
- self.output_y-=1;
- mv(self.output_y, 0);
+ if self.output_y >= max_y-1 {
+ self.scroll(1);
+ }
}
mv(self.output_y, self.output_x);
printw(&ch.to_string());
@@ -179,4 +179,12 @@ impl UI {
self.put_str("\n");
}
+ fn scroll(&mut self, len: i32) {
+ mv(1, 0);
+ for i in 0..len {
+ deleteln();
+ }
+ self.output_y-=len;
+ mv(self.output_y, 0);
+ }
}