diff options
author | Klara Modin <kasm@kasm.eu> | 2018-05-17 01:42:02 +0200 |
---|---|---|
committer | Klara Modin <kasm@kasm.eu> | 2018-05-17 01:42:02 +0200 |
commit | cd450a56eba1ecdee1280224c9838039a067762b (patch) | |
tree | 4f242b15b6fc30f766f80c94640abd4f5feaae7f | |
parent | aa6692ebf9d78e7663da7c730d960cb77d6aa0f2 (diff) |
fix bug where line appears on header
-rw-r--r-- | src/ui.rs | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -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); + } } |