1pub(crate) mod base64;
2pub mod escape;
3pub mod event;
4pub(crate) mod parse;
5pub mod style;
6mod terminal;
7
8use std::{fmt, num::NonZeroU16};
9
10pub use event::{reader::EventReader, Event};
11pub use parse::Parser;
12pub use terminal::{PlatformHandle, PlatformTerminal, Terminal};
13
14#[cfg(feature = "event-stream")]
15pub use event::stream::EventStream;
16
17#[derive(Debug, Clone, Copy, PartialEq, Eq)]
21pub struct OneBased(NonZeroU16);
24
25impl OneBased {
26 pub const fn new(n: u16) -> Option<Self> {
27 match NonZeroU16::new(n) {
28 Some(n) => Some(Self(n)),
29 None => None,
30 }
31 }
32
33 pub const fn from_zero_based(n: u16) -> Self {
34 Self(unsafe { NonZeroU16::new_unchecked(n + 1) })
35 }
36
37 pub const fn get(self) -> u16 {
38 self.0.get()
39 }
40
41 pub const fn get_zero_based(self) -> u16 {
42 self.get() - 1
43 }
44}
45
46impl Default for OneBased {
47 fn default() -> Self {
48 Self(unsafe { NonZeroU16::new_unchecked(1) })
49 }
50}
51
52impl fmt::Display for OneBased {
53 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
54 self.0.fmt(f)
55 }
56}
57
58impl From<NonZeroU16> for OneBased {
59 fn from(n: NonZeroU16) -> Self {
60 Self(n)
61 }
62}
63
64#[derive(Debug, Clone, Copy, PartialEq, Eq)]
69pub struct WindowSize {
70 #[doc(alias = "width")]
72 pub cols: u16,
73 #[doc(alias = "height")]
75 pub rows: u16,
76 pub pixel_width: Option<u16>,
78 pub pixel_height: Option<u16>,
80}