Lines
100 %
Functions
57.14 %
Branches
//! Arranging the windows as a set: Tile, Cascade and Close all.
use super::App;
use crate::window::WindowId;
use ratatui::layout::Rect;
use tvui::Desktop;
impl App {
/// Lays the windows out side by side over the desktop.
pub(crate) fn tile_windows(&mut self) {
self.arrange(Desktop::tile);
}
/// Stacks the windows from the desktop corner.
pub(crate) fn cascade_windows(&mut self) {
self.arrange(Desktop::cascade);
/// Closes every window, the rearmost first so that none is loaded just to be closed.
pub(crate) fn close_all_windows(&mut self) {
for id in self.window_ids_back_to_front() {
self.close_window(id);
fn window_ids_back_to_front(&self) -> Vec<WindowId> {
let slots = self.desktop.iter_back_to_front();
slots.map(|slot| slot.id).collect()
/// Moves every window with `layout`; the windows keep their place when it finds no room.
fn arrange(&mut self, layout: fn(&mut Desktop<WindowId>, Rect) -> bool) {
let ids = self.window_ids_back_to_front();
let area = self.desktop_rect();
if !layout(&mut self.desktop, area) {
self.set_status("too many windows");
return;
for id in ids {
self.window_resized(id);
self.load_visible();
/// Drops the kitty image of window `id` and fetches its chart again: the pane changed size.
pub(super) fn window_resized(&mut self, id: WindowId) {
self.delete_image(id);
self.refetch_report_chart(id);