use crate::{state::*, terminal::*};
mod utilities;
pub use utilities::*;
mod kernel;
pub use kernel::*;
pub mod processes;
use std::{
collections::{HashMap, VecDeque},
fmt,
fmt::{Debug, Display},
};
pub use processes::*;
use super::{Key, UIEvent};
pub type ShortcutMap = HashMap<&'static str, (u8, Key)>;
pub type ShortcutMaps = HashMap<String, ShortcutMap>;
pub trait Component: Display + Debug + Send {
fn draw(
&mut self,
grid: &mut CellBuffer,
area: Area,
dirty_areas: &mut VecDeque<Area>,
tick: bool,
);
fn process_event(&mut self, event: &mut UIEvent, ui_mode: &mut UIMode);
fn is_dirty(&self) -> bool {
true
}
fn set_dirty(&mut self);
fn get_shortcuts(&self) -> ShortcutMaps {
Default::default()
}
}
pub fn create_box(grid: &mut CellBuffer, area: Area) {
if !is_valid_area!(area) {
return;
}
let upper_left = upper_left!(area);
let bottom_right = bottom_right!(area);
for y in get_y(upper_left)..=get_y(bottom_right) {
grid[(get_x(bottom_right), y)]
.set_ch('▒')
.set_fg(Color::Byte(240));
}
}