pub struct MemoryTerminal { /* private fields */ }Expand description
Implements an in-memory Terminal interface
The contents of a MemoryTerminal are shared. That is, cloning
a MemoryTerminal value will share the contained terminal buffer.
Implementations§
Source§impl MemoryTerminal
impl MemoryTerminal
Sourcepub fn new() -> MemoryTerminal
pub fn new() -> MemoryTerminal
Returns a new MemoryTerminal with the default buffer size.
Sourcepub fn with_size(size: Size) -> MemoryTerminal
pub fn with_size(size: Size) -> MemoryTerminal
Returns a new MemoryTerminal with the given buffer size.
§Panics
If either of the lines or columns fields are 0.
Sourcepub fn clear_to_end(&self)
pub fn clear_to_end(&self)
Clears all characters beginning at the cursor and ending at buffer end.
Sourcepub fn clear_input(&self)
pub fn clear_input(&self)
Clears the input buffer.
Sourcepub fn lines(&self) -> Lines<'_>
pub fn lines(&self) -> Lines<'_>
Returns an iterator over lines in the buffer.
§Notes
The returned iterator immutably borrows the contents of the
MemoryTerminal. Attempting to perform a mutating operation on the
parent MemoryTerminal while the Lines iterator lives will cause
a panic.
Sourcepub fn move_right(&self, n: usize)
pub fn move_right(&self, n: usize)
Moves the cursor right n cells.
Sourcepub fn move_to_first_column(&self)
pub fn move_to_first_column(&self)
Moves the cursor to the first column of the current line.
Sourcepub fn push_input(&self, s: &str)
pub fn push_input(&self, s: &str)
Pushes a character sequence to the back of the input queue.
Sourcepub fn read_input(&self, buf: &mut [u8]) -> usize
pub fn read_input(&self, buf: &mut [u8]) -> usize
Reads some input from the input buffer.
Sourcepub fn resize(&self, new_size: Size)
pub fn resize(&self, new_size: Size)
Changes the size of the terminal buffer. The buffer will be truncated or filled with spaces, as necessary.
§Panics
If either of the lines or columns fields are 0 or if the area
exceeds usize maximum.
Sourcepub fn scroll_up(&self, n: usize)
pub fn scroll_up(&self, n: usize)
Moves the contents of the buffer up n lines.
The first n lines of text will be erased.
Sourcepub fn set_cursor_mode(&self, mode: CursorMode)
pub fn set_cursor_mode(&self, mode: CursorMode)
Sets the cursor mode.
Sourcepub fn cursor_mode(&self) -> CursorMode
pub fn cursor_mode(&self) -> CursorMode
Returns the cursor mode.
Trait Implementations§
Source§impl Clone for MemoryTerminal
impl Clone for MemoryTerminal
Source§fn clone(&self) -> MemoryTerminal
fn clone(&self) -> MemoryTerminal
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MemoryTerminal
impl Debug for MemoryTerminal
Source§impl Default for MemoryTerminal
impl Default for MemoryTerminal
Source§fn default() -> MemoryTerminal
fn default() -> MemoryTerminal
Source§impl Terminal for MemoryTerminal
impl Terminal for MemoryTerminal
Source§type PrepareState = ()
type PrepareState = ()
prepare; passed to restore to restore state.Source§fn lock_read<'a>(&'a self) -> Box<dyn TerminalReader<Self> + 'a>
fn lock_read<'a>(&'a self) -> Box<dyn TerminalReader<Self> + 'a>
Source§fn lock_write<'a>(&'a self) -> Box<dyn TerminalWriter<Self> + 'a>
fn lock_write<'a>(&'a self) -> Box<dyn TerminalWriter<Self> + 'a>
Source§impl<'a> TerminalReader<MemoryTerminal> for MemoryReadGuard<'a>
impl<'a> TerminalReader<MemoryTerminal> for MemoryReadGuard<'a>
Source§fn prepare(
&mut self,
_block_signals: bool,
_report_signals: SignalSet,
) -> Result<()>
fn prepare( &mut self, _block_signals: bool, _report_signals: SignalSet, ) -> Result<()>
Source§unsafe fn prepare_with_lock(
&mut self,
_lock: &mut dyn TerminalWriter<MemoryTerminal>,
_block_signals: bool,
_report_signals: SignalSet,
) -> Result<()>
unsafe fn prepare_with_lock( &mut self, _lock: &mut dyn TerminalWriter<MemoryTerminal>, _block_signals: bool, _report_signals: SignalSet, ) -> Result<()>
prepare, but called when the write lock is already held. Read moreSource§fn restore(&mut self, _state: ()) -> Result<()>
fn restore(&mut self, _state: ()) -> Result<()>
Source§unsafe fn restore_with_lock(
&mut self,
_lock: &mut dyn TerminalWriter<MemoryTerminal>,
_state: (),
) -> Result<()>
unsafe fn restore_with_lock( &mut self, _lock: &mut dyn TerminalWriter<MemoryTerminal>, _state: (), ) -> Result<()>
restore, but called when the write lock is already held. Read moreSource§impl<'a> TerminalWriter<MemoryTerminal> for MemoryWriteGuard<'a>
impl<'a> TerminalWriter<MemoryTerminal> for MemoryWriteGuard<'a>
Source§fn clear_screen(&mut self) -> Result<()>
fn clear_screen(&mut self) -> Result<()>
Source§fn clear_to_screen_end(&mut self) -> Result<()>
fn clear_to_screen_end(&mut self) -> Result<()>
Source§fn move_right(&mut self, n: usize) -> Result<()>
fn move_right(&mut self, n: usize) -> Result<()>
n cells; n may be zero.