Struct linefeed::memory::MemoryTerminal
[−]
[src]
pub struct MemoryTerminal { /* fields omitted */ }
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]
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
.
fn clear_all(&self)
Clears the terminal buffer and places the cursor at (0, 0)
.
fn clear_to_end(&self)
Clears all characters beginning at the cursor and ending at buffer end.
fn clear_input(&self)
Clears the input buffer.
fn has_input(&self) -> bool
Returns whether any input remains to be read.
fn lines(&self) -> Lines
Returns an iterator over lines in the buffer.
Note
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.
fn move_up(&self, n: usize)
Moves the cursor up n
cells.
fn move_down(&self, n: usize)
Moves the cursor down n
cells.
fn move_left(&self, n: usize)
Moves the cursor left n
cells.
fn move_right(&self, n: usize)
Moves the cursor right n
cells.
fn move_to_first_col(&self)
Moves the cursor to the first column of the current line.
fn push_input(&self, s: &str)
Pushes a character sequence to the back of the input queue.
fn read_input(&self, buf: &mut [u8]) -> usize
Reads some input from the input buffer.
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.
fn scroll_up(&self, n: usize)
Moves the contents of the buffer up n
lines.
The first n
lines of text will be erased.
fn cursor(&self) -> (usize, usize)
Returns the (line, column)
position of the cursor.
fn set_cursor_mode(&self, mode: CursorMode)
Sets the cursor mode.
fn cursor_mode(&self) -> CursorMode
Returns the cursor mode.
fn size(&self) -> Size
Returns the size of the terminal buffer.
fn write(&self, s: &str)
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 Clone for MemoryTerminal
[src]
fn clone(&self) -> MemoryTerminal
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Debug for MemoryTerminal
[src]
impl Default for MemoryTerminal
[src]
fn default() -> MemoryTerminal
Returns the "default value" for a type. Read more
impl Terminal for MemoryTerminal
[src]
type PrepareGuard = ()
Returned by prepare
and read_signals
. When dropped, the prior terminal state will be restored. Read more
fn new() -> Result<MemoryTerminal>
Initialize the terminal interface
fn eof_char(&self) -> char
Returns the character that indicates end-of-file
fn literal_char(&self) -> char
Returns the character that indicates literal quoting sequence
fn erase_char(&self) -> char
Returns the character that indicates backward character erase
fn word_erase_char(&self) -> char
Returns the character that indicates backward word erase
fn kill_char(&self) -> char
Returns the character that indicates backward kill line
fn delete_seq(&self) -> &str
Returns the key sequence that indicates forward delete character
fn insert_seq(&self) -> &str
Returns the key sequence that indicates switching to insert mode
fn name(&self) -> Option<&str>
Returns the name of the terminal, if one has been supplied
fn size(&self) -> Result<Size>
Returns the size of the terminal window
fn clear_screen(&self) -> Result<()>
Presents a clear terminal screen, with cursor at first row, first column. Read more
fn clear_to_screen_end(&self) -> Result<()>
Clears characters on the line occupied by the cursor, beginning with the cursor and ending at the end of the line. Also clears all characters on all lines after the cursor. Read more
fn move_up(&self, n: usize) -> Result<()>
Moves the cursor up n
cells; n
may be zero.
fn move_down(&self, n: usize) -> Result<()>
Moves the cursor down n
cells; n
may be zero.
fn move_left(&self, n: usize) -> Result<()>
Moves the cursor left n
cells; n
may be zero.
fn move_right(&self, n: usize) -> Result<()>
Moves the cursor right n
cells; n
may be zero.
fn move_to_first_col(&self) -> Result<()>
Moves the cursor to the first column of the current line
fn set_cursor_mode(&self, mode: CursorMode) -> Result<()>
Set the current cursor mode
fn wait_for_input(&self, _timeout: Option<Duration>) -> Result<bool>
Waits timeout
for user input. If timeout
is None
, waits indefinitely. Read more
fn prepare(
&self,
_catch_signals: bool,
_report_signals: SignalSet
) -> Result<()>
&self,
_catch_signals: bool,
_report_signals: SignalSet
) -> Result<()>
Prepares the terminal for line reading and editing operations. Read more
fn read_signals(&self) -> Result<()>
Configures the terminal to interpret signal-inducing characters as input without raising a signal. Read more
fn get_signal(&self) -> Option<Signal>
If the process received a signal since the last call to take_signal
, return it. Otherwise, return None
. Read more
fn take_signal(&self) -> Option<Signal>
If the process received a signal since the last call to take_signal
, consume and return it. Otherwise, return None
. Read more
fn read(&self, buf: &mut Vec<u8>) -> Result<usize>
Reads some input from the terminal and appends it to the given buffer. Read more
fn write(&self, s: &str) -> Result<()>
Writes output to the terminal and immediately flushes it to the device. Read more