DummyTerminal

Struct DummyTerminal 

Source
pub struct DummyTerminal { /* private fields */ }
Expand description

A no-op terminal implementation useful for tests and headless operation.

This terminal implementation provides the TerminalInterface without actually performing any terminal operations. It’s designed for testing, headless environments, or situations where terminal control is not needed.

§Use Cases

  • Unit testing TUI applications without requiring a real terminal
  • Running applications in headless environments
  • Debugging and development scenarios
  • Performance testing without terminal I/O overhead

§Behavior

  • All terminal control methods return success without doing anything
  • render() writes to the output writer if provided, otherwise does nothing
  • size() returns (0, 0) as a placeholder

§Example

use bubbletea_rs::terminal::{DummyTerminal, TerminalInterface};
use bubbletea_rs::Error;
use std::sync::Arc;
use tokio::sync::Mutex;

// Create with no output (all operations are no-ops)
let mut dummy = DummyTerminal::new(None)?;

// These all succeed but do nothing
dummy.enter_raw_mode().await?;
dummy.hide_cursor().await?;
dummy.render("This won't be displayed").await?;

Trait Implementations§

Source§

impl TerminalInterface for DummyTerminal

Source§

fn new( output_writer: Option<Arc<Mutex<dyn AsyncWrite + Send + Unpin>>>, ) -> Result<Self, Error>

Construct a new terminal implementation. Read more
Source§

fn enter_raw_mode<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Enable raw mode (disables canonical input processing). Read more
Source§

fn exit_raw_mode<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Disable raw mode and restore canonical input processing. Read more
Source§

fn enter_alt_screen<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Enter the alternate screen buffer. Read more
Source§

fn exit_alt_screen<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Leave the alternate screen buffer. Read more
Source§

fn enable_mouse<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Enable basic mouse capture. Read more
Source§

fn enable_mouse_cell_motion<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Enable cell-motion mouse reporting. Read more
Source§

fn enable_mouse_all_motion<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Enable high-resolution mouse reporting. Read more
Source§

fn disable_mouse<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Disable all mouse capture modes. Read more
Source§

fn enable_focus_reporting<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Enable terminal focus change reporting. Read more
Source§

fn disable_focus_reporting<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Disable terminal focus change reporting. Read more
Source§

fn enable_bracketed_paste<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Enable bracketed paste mode. Read more
Source§

fn disable_bracketed_paste<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Disable bracketed paste mode. Read more
Source§

fn show_cursor<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Show the cursor if hidden. Read more
Source§

fn hide_cursor<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Hide the cursor if visible. Read more
Source§

fn clear<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Clear the visible screen contents. Read more
Source§

fn render<'life0, 'life1, 'async_trait>( &'life0 mut self, content: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Render the provided content to the terminal. Read more
Source§

fn size(&self) -> Result<(u16, u16), Error>

Get the current terminal size as (columns, rows). Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.