urushi_tui/terminal/mod.rs
1//! Synchronous full-screen presentation over terminal command primitives.
2//!
3//! [`Screen`] owns frame history and transactional presentation. It borrows a
4//! draw-scoped [`Frame`] to callers, lowers changed cells through
5//! [`urushi_terminal::CommandWriter`], and advances its committed baseline only
6//! after output and flushing succeed. Physical terminal connection, input,
7//! queries, raw mode, and session restoration remain responsibilities of
8//! [`urushi_terminal::TerminalBackend`] and higher-level callers.
9
10mod output;
11mod screen;
12
13use urushi_terminal::{Position, TerminalSize};
14
15pub(crate) use output::Cell;
16pub use screen::{Frame, Screen};
17
18/// A rectangular region in terminal cell coordinates.
19#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
20pub struct Rect {
21 origin: Position,
22 size: TerminalSize,
23}
24
25impl Rect {
26 /// Creates a rectangle from its origin and size.
27 pub const fn new(origin: Position, size: TerminalSize) -> Self {
28 Self { origin, size }
29 }
30
31 /// Creates a rectangle at the terminal origin.
32 pub const fn from_size(size: TerminalSize) -> Self {
33 Self::new(Position::new(0, 0), size)
34 }
35
36 /// Returns the rectangle's top-left cell.
37 pub const fn origin(self) -> Position {
38 self.origin
39 }
40
41 /// Returns the rectangle's cell dimensions.
42 pub const fn size(self) -> TerminalSize {
43 self.size
44 }
45}