[−][src]Struct linefeed::memory::MemoryTerminal
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.
Methods
impl MemoryTerminal
[src]
pub fn new() -> MemoryTerminal
[src]
Returns a new MemoryTerminal
with the default buffer size.
pub fn with_size(size: Size) -> MemoryTerminal
[src]
Returns a new MemoryTerminal
with the given buffer size.
Panics
If either of the lines
or columns
fields are 0
.
pub fn clear_all(&self)
[src]
Clears the terminal buffer and places the cursor at (0, 0)
.
pub fn clear_to_end(&self)
[src]
Clears all characters beginning at the cursor and ending at buffer end.
pub fn clear_input(&self)
[src]
Clears the input buffer.
pub fn has_input(&self) -> bool
[src]
Returns whether any input remains to be read.
pub fn lines(&self) -> Lines
[src]
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.
pub fn move_up(&self, n: usize)
[src]
Moves the cursor up n
cells.
pub fn move_down(&self, n: usize)
[src]
Moves the cursor down n
cells.
pub fn move_left(&self, n: usize)
[src]
Moves the cursor left n
cells.
pub fn move_right(&self, n: usize)
[src]
Moves the cursor right n
cells.
pub fn move_to_first_column(&self)
[src]
Moves the cursor to the first column of the current line.
pub fn push_input(&self, s: &str)
[src]
Pushes a character sequence to the back of the input queue.
pub fn read_input(&self, buf: &mut [u8]) -> usize
[src]
Reads some input from the input buffer.
pub fn resize(&self, new_size: Size)
[src]
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.
pub fn scroll_up(&self, n: usize)
[src]
Moves the contents of the buffer up n
lines.
The first n
lines of text will be erased.
pub fn cursor(&self) -> (usize, usize)
[src]
Returns the (line, column)
position of the cursor.
pub fn set_cursor_mode(&self, mode: CursorMode)
[src]
Sets the cursor mode.
pub fn cursor_mode(&self) -> CursorMode
[src]
Returns the cursor mode.
pub fn size(&self) -> Size
[src]
Returns the size of the terminal buffer.
pub fn write(&self, s: &str)
[src]
Writes some text into the buffer.
If the text extends beyond the length of the current line without a
newline character ('\n'
), the extraneous text will be dropped.
Trait Implementations
impl Terminal for MemoryTerminal
[src]
type PrepareState = ()
Returned by prepare
; passed to restore
to restore state.
fn name(&self) -> &str
[src]
fn lock_read<'a>(&'a self) -> Box<dyn TerminalReader<Self> + 'a>
[src]
fn lock_write<'a>(&'a self) -> Box<dyn TerminalWriter<Self> + 'a>
[src]
impl<'a> TerminalReader<MemoryTerminal> for MemoryReadGuard<'a>
[src]
fn wait_for_input(&mut self, _timeout: Option<Duration>) -> Result<bool>
[src]
fn prepare(
&mut self,
_block_signals: bool,
_report_signals: SignalSet
) -> Result<()>
[src]
&mut self,
_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<()>
[src]
&mut self,
_lock: &mut dyn TerminalWriter<MemoryTerminal>,
_block_signals: bool,
_report_signals: SignalSet
) -> Result<()>
fn restore(&mut self, _state: ()) -> Result<()>
[src]
unsafe fn restore_with_lock(
&mut self,
_lock: &mut dyn TerminalWriter<MemoryTerminal>,
_state: ()
) -> Result<()>
[src]
&mut self,
_lock: &mut dyn TerminalWriter<MemoryTerminal>,
_state: ()
) -> Result<()>
fn read(&mut self, buf: &mut Vec<u8>) -> Result<RawRead>
[src]
impl<'a> TerminalWriter<MemoryTerminal> for MemoryWriteGuard<'a>
[src]
fn size(&self) -> Result<Size>
[src]
fn clear_screen(&mut self) -> Result<()>
[src]
fn clear_to_screen_end(&mut self) -> Result<()>
[src]
fn move_up(&mut self, n: usize) -> Result<()>
[src]
fn move_down(&mut self, n: usize) -> Result<()>
[src]
fn move_left(&mut self, n: usize) -> Result<()>
[src]
fn move_right(&mut self, n: usize) -> Result<()>
[src]
fn move_to_first_column(&mut self) -> Result<()>
[src]
fn set_cursor_mode(&mut self, mode: CursorMode) -> Result<()>
[src]
fn write(&mut self, s: &str) -> Result<()>
[src]
fn flush(&mut self) -> Result<()>
[src]
impl Default for MemoryTerminal
[src]
fn default() -> MemoryTerminal
[src]
impl Clone for MemoryTerminal
[src]
fn clone(&self) -> MemoryTerminal
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for MemoryTerminal
[src]
Auto Trait Implementations
impl Send for MemoryTerminal
impl Sync for MemoryTerminal
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,