ratatui/terminal.rs
1#![deny(missing_docs)]
2//! Provides the [`Terminal`], [`Frame`] and related types.
3//!
4//! The [`Terminal`] is the main interface of this library. It is responsible for drawing and
5//! maintaining the state of the different widgets that compose your application.
6//!
7//! The [`Frame`] is a consistent view into the terminal state for rendering. It is obtained via
8//! the closure argument of [`Terminal::draw`]. It is used to render widgets to the terminal and
9//! control the cursor position.
10//!
11//! # Example
12//!
13//! ```rust,no_run
14//! use std::io::stdout;
15//!
16//! use ratatui::{backend::CrosstermBackend, widgets::Paragraph, Terminal};
17//!
18//! let backend = CrosstermBackend::new(stdout());
19//! let mut terminal = Terminal::new(backend)?;
20//! terminal.draw(|frame| {
21//! let area = frame.area();
22//! frame.render_widget(Paragraph::new("Hello world!"), area);
23//! })?;
24//! # std::io::Result::Ok(())
25//! ```
26//!
27//! [Crossterm]: https://crates.io/crates/crossterm
28//! [Termion]: https://crates.io/crates/termion
29//! [Termwiz]: https://crates.io/crates/termwiz
30//! [`backend`]: crate::backend
31//! [`Backend`]: crate::backend::Backend
32//! [`Buffer`]: crate::buffer::Buffer
33
34mod frame;
35#[cfg(feature = "crossterm")]
36mod init;
37mod terminal;
38mod viewport;
39
40pub use frame::{CompletedFrame, Frame};
41#[cfg(feature = "crossterm")]
42pub use init::{
43 init, init_with_options, restore, try_init, try_init_with_options, try_restore, DefaultTerminal,
44};
45pub use terminal::{Options as TerminalOptions, Terminal};
46pub use viewport::Viewport;