1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//! Geometry primitives for the cell grid.
//!
//! Three `Copy`, zero-cost wrappers describe points and extents on the
//! terminal grid:
//!
//! - [`Position`] - an `(x, y)` point.
//! - [`Size`] - a `width × height` extent.
//! - [`Rect`] - an axis-aligned rectangle, `(x, y, width, height)`.
//!
//! ## Coordinate system
//!
//! The origin is the **top-left** corner of the grid. `x` increases to the
//! right and `y` increases **downward**, so `(0, 0)` is the first cell and a
//! larger `y` is further down the screen. A [`Rect`] covers the half-open
//! ranges `x..x + width` (columns) and `y..y + height` (rows):
//!
//! ```text
//! x: 0 1 2 3 4
//! ┌───┬───┬───┬───┬───┐
//! y: 0 │ │ │ │ │ │
//! ├───┼───┼───┼───┼───┤
//! 1 │ │ ▓ │ ▓ │ │ │ Rect::new(1, 1, 2, 2)
//! ├───┼───┼───┼───┼───┤ origin (1, 1), 2 × 2 cells,
//! 2 │ │ ▓ │ ▓ │ │ │ covering x ∈ 1..3, y ∈ 1..3
//! ├───┼───┼───┼───┼───┤
//! 3 │ │ │ │ │ │
//! └───┴───┴───┴───┴───┘
//! ```
//!
//! ## Tuple shorthand
//!
//! Most positional APIs accept `impl Into<Position>`, `impl Into<Size>`, and
//! `impl Into<Rect>`, so plain tuples work as ergonomic shorthand:
//!
//! ```
//! use uncurses::layout::{Position, Rect};
//!
//! let p: Position = (3, 5).into();
//! assert_eq!(p, Position::new(3, 5));
//!
//! let r: Rect = (3, 5, 10, 2).into();
//! assert_eq!(r, Rect::new(3, 5, 10, 2));
//! ```
pub use Position;
pub use Rect;
pub use Size;
/// Whether a run `w` columns wide, placed at column `x`, reaches past the
/// exclusive right edge `right`.
///
/// A cell can claim up to 255 columns, and [`Rect::right`] saturates, so a
/// row near the end of the address space can put `x` close enough to
/// `u16::MAX` that `x + w` does not fit in a `u16`. A run that cannot be
/// addressed runs past any edge, so an overflow answers yes.
///
/// Saturating the sum instead would answer no at the last addressable
/// column, because `u16::MAX > u16::MAX` is false, and let a write land
/// outside the edge it was checked against.
pub