dynamic device activation

This commit is contained in:
🪞👃🪞 2024-06-16 19:13:50 +03:00
parent b73aa8a0dc
commit e4f3942757
9 changed files with 484 additions and 587 deletions

View file

@ -38,9 +38,9 @@ pub fn draw_leaf (buffer: &mut Buffer, area: Rect, y: u16, x: u16, text: &str) {
buffer.set_string(area.x + x, area.y + 1 + y, bottom, border);
}
pub fn draw_box (buffer: &mut Buffer, area: Rect) {
pub fn draw_box (buffer: &mut Buffer, area: Rect) -> Rect {
if area.width < 1 || area.height < 1 {
return
return area
}
let border = Style::default().gray().dim();
let top = format!("{}", "".repeat((area.width - 2).into()));
@ -51,11 +51,12 @@ pub fn draw_box (buffer: &mut Buffer, area: Rect) {
buffer.set_string(area.x + area.width - 1, y, format!(""), border);
}
buffer.set_string(area.x, area.y + area.height - 1, bottom, border);
area
}
pub fn draw_box_styled (buffer: &mut Buffer, area: Rect, style: Option<Style>) {
pub fn draw_box_styled (buffer: &mut Buffer, area: Rect, style: Option<Style>) -> Rect {
if area.width < 1 || area.height < 1 {
return
return area
}
let style = style.unwrap_or(Style::default());
let top = format!("{}", "".repeat((area.width - 2).into()));
@ -66,14 +67,20 @@ pub fn draw_box_styled (buffer: &mut Buffer, area: Rect, style: Option<Style>) {
buffer.set_string(area.x + area.width - 1, y, format!(""), style);
}
buffer.set_string(area.x, area.y + area.height - 1, bottom, style);
area
}
pub fn draw_focus_corners (buffer: &mut Buffer, area: Rect) {
let focus = Style::default().yellow().bold().not_dim();
buffer.set_string(area.x, area.y, "", focus);
buffer.set_string(area.x + area.width - 1, area.y, "", focus);
buffer.set_string(area.x, area.y + area.height - 1, "", focus);
buffer.set_string(area.x + area.width - 1, area.y + area.height - 1, "", focus);
pub fn draw_corners (buffer: &mut Buffer, area: Rect, style: Option<Style>) -> Rect {
let style = style.unwrap_or(Style::default());
buffer.set_string(area.x, area.y, "", style);
buffer.set_string(area.x + area.width - 1, area.y, "", style);
buffer.set_string(area.x, area.y + area.height - 1, "", style);
buffer.set_string(area.x + area.width - 1, area.y + area.height - 1, "", style);
area
}
pub fn draw_focus_corners (buffer: &mut Buffer, area: Rect) -> Rect {
draw_corners(buffer, area, Some(Style::default().yellow().bold().not_dim()))
}
//pub fn render_toolbar_vertical (