Struct linefeed::memory::MemoryTerminal
source · 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
sourceimpl 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
sourceimpl Clone for MemoryTerminal
impl Clone for MemoryTerminal
sourcefn clone(&self) -> MemoryTerminal
fn clone(&self) -> MemoryTerminal
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for MemoryTerminal
impl Debug for MemoryTerminal
sourceimpl Default for MemoryTerminal
impl Default for MemoryTerminal
sourcefn default() -> MemoryTerminal
fn default() -> MemoryTerminal
sourceimpl Terminal for MemoryTerminal
impl Terminal for MemoryTerminal
type PrepareState = ()
type PrepareState = ()
prepare
; passed to restore
to restore state.sourcefn lock_read<'a>(&'a self) -> Box<dyn TerminalReader<Self> + 'a>
fn lock_read<'a>(&'a self) -> Box<dyn TerminalReader<Self> + 'a>
sourcefn lock_write<'a>(&'a self) -> Box<dyn TerminalWriter<Self> + 'a>
fn lock_write<'a>(&'a self) -> Box<dyn TerminalWriter<Self> + 'a>
sourceimpl<'a> TerminalReader<MemoryTerminal> for MemoryReadGuard<'a>
impl<'a> TerminalReader<MemoryTerminal> for MemoryReadGuard<'a>
sourcefn prepare(
&mut self,
_block_signals: bool,
_report_signals: SignalSet
) -> Result<()>
fn prepare(
&mut self,
_block_signals: bool,
_report_signals: SignalSet
) -> Result<()>
sourceunsafe 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 moresourcefn restore(&mut self, _state: ()) -> Result<()>
fn restore(&mut self, _state: ()) -> Result<()>
sourceunsafe 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 moresourceimpl<'a> TerminalWriter<MemoryTerminal> for MemoryWriteGuard<'a>
impl<'a> TerminalWriter<MemoryTerminal> for MemoryWriteGuard<'a>
sourcefn clear_screen(&mut self) -> Result<()>
fn clear_screen(&mut self) -> Result<()>
sourcefn clear_to_screen_end(&mut self) -> Result<()>
fn clear_to_screen_end(&mut self) -> Result<()>
sourcefn move_right(&mut self, n: usize) -> Result<()>
fn move_right(&mut self, n: usize) -> Result<()>
n
cells; n
may be zero.