pub struct TerminaBackend<T>where
T: Terminal,{ /* private fields */ }Expand description
A Backend implementation that renders through a termina::Terminal.
TerminaBackend writes typed Termina escape sequences for drawing, cursor control, clearing,
and terminal-size queries.
This backend does not automatically enable raw mode or switch to the alternate screen. Use Termina’s terminal APIs and typed escape sequences to configure those application-level modes before drawing.
§Example
use ratatui::Terminal;
use ratatui::backend::TerminaBackend;
use ratatui::termina::{PlatformTerminal, Terminal as _};
let mut output = PlatformTerminal::new()?;
output.enter_raw_mode()?;
let backend = TerminaBackend::new(output);
let mut terminal = Terminal::new(backend)?;
terminal.draw(|frame| {
// -- snip --
})?;Implementations§
Source§impl<T> TerminaBackend<T>where
T: Terminal,
impl<T> TerminaBackend<T>where
T: Terminal,
Sourcepub const fn new(terminal: T) -> Self
pub const fn new(terminal: T) -> Self
Creates a backend that writes to the given Termina terminal.
Sourcepub const fn terminal(&self) -> &T
Available on crate feature unstable-backend-writer only.
pub const fn terminal(&self) -> &T
unstable-backend-writer only.Returns the wrapped terminal.
§Stability
This API is marked as unstable and is only available when the unstable-backend-writer
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
The tracking issue is: https://github.com/ratatui/ratatui/pull/991.
Sourcepub const fn terminal_mut(&mut self) -> &mut T
Available on crate feature unstable-backend-writer only.
pub const fn terminal_mut(&mut self) -> &mut T
unstable-backend-writer only.Returns the wrapped terminal as a mutable reference.
Direct writes can desynchronize Ratatui’s diffing buffers from the visible terminal. Clear the terminal or force a full redraw before relying on Ratatui’s next diff.
§Stability
This API is marked as unstable and is only available when the unstable-backend-writer
crate feature is enabled. This comes with no stability guarantees, and could be changed
or removed at any time.
The tracking issue is: https://github.com/ratatui/ratatui/pull/991.
Trait Implementations§
Source§impl<T> Backend for TerminaBackend<T>where
T: Terminal,
impl<T> Backend for TerminaBackend<T>where
T: Terminal,
Source§fn draw<'a, I>(&mut self, content: I) -> Result<()>
fn draw<'a, I>(&mut self, content: I) -> Result<()>
Source§fn get_cursor_position(&mut self) -> Result<Position>
fn get_cursor_position(&mut self) -> Result<Position>
Source§fn set_cursor_position<P: Into<Position>>(&mut self, position: P) -> Result<()>
fn set_cursor_position<P: Into<Position>>(&mut self, position: P) -> Result<()>
Source§fn clear(&mut self) -> Result<()>
fn clear(&mut self) -> Result<()>
Source§fn append_lines(&mut self, n: u16) -> Result<()>
fn append_lines(&mut self, n: u16) -> Result<()>
n line breaks to the terminal screen. Read moreSource§fn window_size(&mut self) -> Result<WindowSize>
fn window_size(&mut self) -> Result<WindowSize>
WindowSize. Read moreSource§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn scroll_region_up(&mut self, region: Range<u16>, amount: u16) -> Result<()>
fn scroll_region_up(&mut self, region: Range<u16>, amount: u16) -> Result<()>
scrolling-regions only.Source§fn scroll_region_down(&mut self, region: Range<u16>, amount: u16) -> Result<()>
fn scroll_region_down(&mut self, region: Range<u16>, amount: u16) -> Result<()>
scrolling-regions only.Source§impl<T> Debug for TerminaBackend<T>
impl<T> Debug for TerminaBackend<T>
Source§impl<T> Write for TerminaBackend<T>where
T: Terminal,
impl<T> Write for TerminaBackend<T>where
T: Terminal,
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)Auto Trait Implementations§
impl<T> Freeze for TerminaBackend<T>where
T: Freeze,
impl<T> RefUnwindSafe for TerminaBackend<T>where
T: RefUnwindSafe,
impl<T> Send for TerminaBackend<T>where
T: Send,
impl<T> Sync for TerminaBackend<T>where
T: Sync,
impl<T> Unpin for TerminaBackend<T>where
T: Unpin,
impl<T> UnsafeUnpin for TerminaBackend<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for TerminaBackend<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more