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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
//! Backend integration between the widget library and
//! [`uncurses::program::Program`].
//!
//! ## What this backend is
//!
//! [`UncursesBackend`] implements [`ratatui::backend::Backend`] by wrapping a
//! single [`Program`](uncurses::program::Program). The program owns the
//! terminal handle and the input source, and the [`Screen`](uncurses::screen::Screen)
//! inside it owns the diffing renderer. The backend's job is to adapt
//! frame drawing, cursor operations, clearing, size queries, and event access
//! to that one program.
//!
//! ## Rendering path
//!
//! A frame is rendered into the widget library's buffer first. During
//! [`Backend::draw`](ratatui::backend::Backend::draw), every visible buffer
//! cell is converted into an uncurses cell and staged into the screen's
//! buffer; no I/O happens yet.
//! [`Backend::flush`](ratatui::backend::Backend::flush) then calls
//! [`Screen::render`](uncurses::screen::Screen::render), which diffs the
//! staged frame and writes the minimal escape bytes.
//!
//! ```text
//! ┌──────────────────────┐
//! │ widgets render Frame │
//! └──────────┬───────────┘
//! │ ratatui::buffer::Cell values
//! ▼
//! ┌──────────────────────┐
//! │ UncursesBackend │
//! │ draw: Cell → Cell │
//! └──────────┬───────────┘
//! │ set_cell (stage only)
//! ▼
//! ┌──────────────────────┐
//! │ Screen │
//! │ renderer diff bytes │
//! └──────────┬───────────┘
//! │ flush → Screen::render
//! ▼
//! terminal
//! ```
//!
//! ## Setup and restore helpers
//!
//! Use [`try_init`] / [`init`] for the standard fullscreen session over
//! process stdio. Use [`try_init_with_options`] / [`init_with_options`] when
//! you need explicit [`ratatui::TerminalOptions`] or [`ProgramOptions`]. Pair
//! those helpers with [`try_restore`] or [`restore`] on exit.
//!
//! The helpers enter raw mode, apply screen options, hide the cursor, and set
//! up the requested viewport. They enter the alternate screen for fullscreen
//! and fixed viewports; inline viewports stay on the main screen so scrollback
//! around the application is preserved.
//!
//! ```rust,ignore
//! use ratatui::widgets::Paragraph;
//!
//! fn main() -> std::io::Result<()> {
//! let mut terminal = uncurses_ratatui::try_init()?;
//! terminal.draw(|frame| {
//! frame.render_widget(Paragraph::new("drawn through uncurses"), frame.area());
//! })?;
//! uncurses_ratatui::try_restore(&mut terminal)
//! }
//! ```
//!
//! ## Viewports
//!
//! [`ratatui::Viewport::Fullscreen`] and [`ratatui::Viewport::Fixed`] are
//! rendered on the alternate screen by the setup helpers. For
//! [`ratatui::Viewport::Inline`], the backend keeps an inline origin in the
//! main screen, resizes the screen buffer to the inline height, and translates
//! absolute frame rows into that buffer before staging cells.
//!
//! ## Reading input through the backend
//!
//! The backend owns the same input source as the wrapped program. Synchronous
//! event loops can call [`UncursesBackend::poll_event`],
//! [`UncursesBackend::try_read_event`], or [`UncursesBackend::read_event`] on
//! `terminal.backend_mut()`. Those reads keep capability tracking alive on
//! their own.
//!
//! With the `async` feature, use [`UncursesBackend::event_stream`] when an
//! asynchronous loop is more convenient. The stream bypasses the backend, so
//! that is the one path where you call [`UncursesBackend::observe_event`]
//! yourself.
//!
//! ## Manual setup
//!
//! The constructors are inert: they do not enter raw mode, choose a viewport,
//! enter the alternate screen, or hide the cursor. Use them when you need a
//! prebuilt [`Program`](uncurses::program::Program), a controlling terminal
//! instead of stdio, or custom setup ordering.
//!
//! ```rust,ignore
//! use uncurses_ratatui::{ProgramOptions, UncursesBackend};
//!
//! fn main() -> std::io::Result<()> {
//! let mut backend = UncursesBackend::stdio()?;
//! backend.init_with(ProgramOptions::default())?;
//! // Build ratatui::Terminal with `backend`, then restore the backend
//! // when the session ends.
//! Ok(())
//! }
//! ```
pub use ;
pub use ;
pub use ;
pub use ;