1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#![forbid(unsafe_code)]
mod list;
mod terminal;
pub use list::*;
pub use terminal::*;
use std::iter::repeat;
use tui::{self, buffer::Buffer, layout::Rect, style::Color};
pub fn fill_background_to_right(mut s: String, entire_width: u16) -> String {
match (s.len(), entire_width as usize) {
(x, y) if x >= y => s,
(x, y) => {
s.extend(repeat(' ').take(y - x));
s
}
}
}
pub fn fill_background(area: Rect, buf: &mut Buffer, color: Color) {
for y in area.top()..area.bottom() {
for x in area.left()..area.right() {
buf.get_mut(x, y).set_bg(color);
}
}
}