dynamic sizes

This commit is contained in:
2024-11-01 10:55:29 +01:00
parent bdec423a6f
commit 14261ab1e1
2 changed files with 51 additions and 29 deletions
+16
View File
@@ -65,11 +65,27 @@ impl App {
/// Render to the screen
pub fn render(&mut self) {
let (width, height) = crossterm::terminal::size().unwrap();
let mut data = self.element.get_data();
if data.width == 0 {
data.width = width as usize;
}
if data.height == 0 {
data.height = height as usize;
}
self.element.set_data(data);
let mut frame: Vec<String> = create_frame!(width as usize, height as usize);
utils::render_to_frame(&mut frame, &mut self.element);
utils::clear();
print!("{}", frame.join(""));
utils::flush();
let mut data = self.element.get_data();
if data.width == width as usize {
data.width = 0;
}
if data.height == height as usize {
data.height = 0;
}
self.element.set_data(data);
}
/// Run the screen