blob: e44e39fefe08454f6ef10ca9a1fe74eaf7b4a792 (
plain)
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
|
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
}
}
}
/// Helper method to quickly set the background of all cells inside the specified area.
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);
}
}
}
|