Expand description
A prelude for conveniently writing applications using this library.
The prelude module is no longer used universally in Ratatui, as it can make it harder to distinguish between library and non-library types, especially when viewing source code outside of an IDE (such as on GitHub or in a git diff). For more details and user feedback, see Issue #1150. However, the prelude is still available for backward compatibility and for those who prefer to use it.
§Examples
use ratatui::prelude::*;
Aside from the main types that are used in the library, this prelude also re-exports several modules to make it easy to qualify types that would otherwise collide. E.g.:
use ratatui::prelude::*;
use ratatui::widgets::*;
#[derive(Debug, Default, PartialEq, Eq)]
struct Line;
assert_eq!(Line::default(), Line);
assert_eq!(text::Line::default(), ratatui::text::Line::from(vec![]));
Modules§
- backend
- This module provides the backend implementations for different terminal libraries.
- buffer
- A module for the
Buffer
andCell
types. - layout
- Provides types and traits for working with layout and positioning in the terminal.
- style
style
contains the primitives used to control how your user interface will look.- symbols
- Symbols and markers for drawing various widgets.
- text
- Primitives for styled text.
Structs§
- Buffer
- A buffer that maps to the desired content of the terminal after the draw call
- Crossterm
Backend crossterm
- A
Backend
implementation that uses Crossterm to render to the terminal. - Frame
- A consistent view into the terminal state for rendering a single frame.
- Layout
- A layout is a set of constraints that can be applied to a given area to split it into smaller ones.
- Line
- A line of text, consisting of one or more
Span
s. - Margin
- Masked
- A wrapper around a string that is masked when displayed.
- Modifier
- Modifier changes the way a piece of text is displayed.
- Position
- Position in the terminal
- Rect
- A Rectangular area.
- Size
- A simple size struct
- Span
- Represents a part of a line that is contiguous and where all characters share the same style.
- Style
- Style lets you control the main characteristics of the displayed elements.
- Terminal
- An interface to interact and draw
Frame
s on the user’s terminal. - Termion
Backend Non-Windows and termion
- A
Backend
implementation that uses Termion to render to the terminal. - Termwiz
Backend termwiz
- A
Backend
implementation that uses Termwiz to render to the terminal. - Text
- A string split over one or more lines.
Enums§
- Color
- ANSI Color
- Constraint
- A constraint that defines the size of a layout element.
- Direction
- Horizontal
Alignment - A type representing horizontal alignment.
- Vertical
Alignment - A type representing vertical alignment.
Traits§
- Backend
- The
Backend
trait provides an abstraction over different terminal libraries. It defines the methods required to draw content, manipulate the cursor, and clear the terminal screen. - Block
Ext - An extension trait for
Block
that provides some convenience methods. - From
Crossterm crossterm
- A trait for converting a Crossterm type to a Ratatui type.
- From
Termion Non-Windows and termion
- A trait for converting a Termion type to a Ratatui type.
- From
Termwiz termwiz
- A trait for converting types from Termwiz to Ratatui.
- Into
Crossterm crossterm
- A trait for converting a Ratatui type to a Crossterm type.
- Into
Termion Non-Windows and termion
- A trait for converting a Ratatui type to a Termion type.
- Into
Termwiz termwiz
- A trait for converting types from Ratatui to Termwiz.
- Stateful
Widget - A
StatefulWidget
is a widget that can take advantage of some local state to remember things between two draw calls. - Stylize
- An extension trait for styling objects.
- Widget
- A
Widget
is a type that can be drawn on aBuffer
in a givenRect
.
Type Aliases§
- Alignment
- A type alias for
HorizontalAlignment
.