line_ui/element.rs
1/*
2 * Copyright (c) 2025 Jasmine Tai. All rights reserved.
3 */
4
5//! The [`Element`] trait, and various elements.
6
7mod cursor;
8mod fixed_width;
9mod gap;
10mod impls;
11mod into;
12mod styled;
13mod text;
14
15use crate::render::RenderChunk;
16
17pub use cursor::*;
18pub use fixed_width::*;
19pub use gap::*;
20pub use into::*;
21pub use styled::*;
22pub use text::*;
23
24/// A particular widget that can be rendered to the TUI.
25pub trait Element {
26 /// The width of the element, in columns.
27 fn width(&self) -> usize;
28
29 /// Renders the element into a sequence of chunks.
30 fn render(&self) -> impl DoubleEndedIterator<Item = RenderChunk<'_>>;
31}