mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
49 lines
1.6 KiB
Rust
49 lines
1.6 KiB
Rust
mod focus; pub use self::focus::*;
|
|
mod container; pub use self::container::*;
|
|
mod scroll; pub use self::scroll::*;
|
|
mod table; pub use self::table::*;
|
|
mod lozenge; pub use self::lozenge::*;
|
|
|
|
use crate::core::*;
|
|
|
|
pub trait MaxHeight: Device {
|
|
fn max_height (&self) -> u16 {
|
|
u16::MAX
|
|
}
|
|
}
|
|
|
|
impl<T: Device> MaxHeight for T {}
|
|
|
|
pub fn draw_box (buffer: &mut Buffer, area: Rect) -> Rect {
|
|
draw_box_styled(buffer, area, Some(Style::default().gray().dim()))
|
|
}
|
|
|
|
pub fn draw_box_styled (buffer: &mut Buffer, area: Rect, style: Option<Style>) -> Rect {
|
|
if area.width < 1 || area.height < 1 {
|
|
return area
|
|
}
|
|
format!("╭{}╮", "─".repeat((area.width - 2).into()))
|
|
.blit(buffer, area.x, area.y, style);
|
|
for y in (area.y + 1)..(area.y + area.height - 1) {
|
|
"│".blit(buffer, area.x, y, style);
|
|
"│".blit(buffer, area.x + area.width - 1, y, style);
|
|
}
|
|
format!("╰{}╯", "─".repeat((area.width - 2).into()))
|
|
.blit(buffer, area.x, area.y + area.height - 1, style);
|
|
area
|
|
}
|
|
|
|
pub fn draw_box_styled_dotted (buffer: &mut Buffer, area: Rect, style: Option<Style>) -> Rect {
|
|
if area.width < 1 || area.height < 1 {
|
|
return area
|
|
}
|
|
format!("╭{}╮", "┅".repeat((area.width - 2).into()))
|
|
.blit(buffer, area.x, area.y, style);
|
|
for y in (area.y + 1)..(area.y + area.height - 1) {
|
|
"┇".blit(buffer, area.x, y, style);
|
|
"┇".blit(buffer, area.x + area.width - 1, y, style);
|
|
}
|
|
format!("╰{}╯", "┅".repeat((area.width - 2).into()))
|
|
.blit(buffer, area.x, area.y + area.height - 1, style);
|
|
area
|
|
}
|