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]
impl MemoryTerminal
pub fn with_size(size: Size) -> MemoryTerminal
[src]
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
.
pub fn clear_all(&self)
[src]
pub fn clear_all(&self)
Clears the terminal buffer and places the cursor at (0, 0)
.
pub fn clear_to_end(&self)
[src]
pub fn clear_to_end(&self)
Clears all characters beginning at the cursor and ending at buffer end.
pub fn clear_input(&self)
[src]
pub fn clear_input(&self)
Clears the input buffer.
pub fn has_input(&self) -> bool
[src]
pub fn has_input(&self) -> bool
Returns whether any input remains to be read.
pub fn lines(&self) -> Lines
[src]
pub 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.
pub fn move_up(&self, n: usize)
[src]
pub fn move_up(&self, n: usize)
Moves the cursor up n
cells.
pub fn move_down(&self, n: usize)
[src]
pub fn move_down(&self, n: usize)
Moves the cursor down n
cells.
pub fn move_left(&self, n: usize)
[src]
pub fn move_left(&self, n: usize)
Moves the cursor left n
cells.
pub fn move_right(&self, n: usize)
[src]
pub fn move_right(&self, n: usize)
Moves the cursor right n
cells.
pub fn move_to_first_col(&self)
[src]
pub fn move_to_first_col(&self)
Moves the cursor to the first column of the current line.
pub fn push_input(&self, s: &str)
[src]
pub fn push_input(&self, s: &str)
Pushes a character sequence to the back of the input queue.
pub fn read_input(&self, buf: &mut [u8]) -> usize
[src]
pub fn read_input(&self, buf: &mut [u8]) -> usize
Reads some input from the input buffer.
pub fn resize(&self, new_size: Size)
[src]
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.
pub fn scroll_up(&self, n: usize)
[src]
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.
pub fn cursor(&self) -> (usize, usize)
[src]
pub fn cursor(&self) -> (usize, usize)
Returns the (line, column)
position of the cursor.
pub fn set_cursor_mode(&self, mode: CursorMode)
[src]
pub fn set_cursor_mode(&self, mode: CursorMode)
Sets the cursor mode.
pub fn cursor_mode(&self) -> CursorMode
[src]
pub fn cursor_mode(&self) -> CursorMode
Returns the cursor mode.
pub fn size(&self) -> Size
[src]
pub fn size(&self) -> Size
Returns the size of the terminal buffer.
pub fn write(&self, s: &str)
[src]
pub 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]
impl Clone for MemoryTerminal
fn clone(&self) -> MemoryTerminal
[src]
fn clone(&self) -> MemoryTerminal
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for MemoryTerminal
[src]
impl Debug for MemoryTerminal
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Default for MemoryTerminal
[src]
impl Default for MemoryTerminal
fn default() -> MemoryTerminal
[src]
fn default() -> MemoryTerminal
Returns the "default value" for a type. Read more
impl Terminal for MemoryTerminal
[src]
impl Terminal for MemoryTerminal
type PrepareGuard = ()
Returned by prepare
and read_signals
. When dropped, the prior terminal state will be restored. Read more
fn new() -> Result<MemoryTerminal>
[src]
fn new() -> Result<MemoryTerminal>
Initialize the terminal interface
fn eof_char(&self) -> char
[src]
fn eof_char(&self) -> char
Returns the character that indicates end-of-file
fn literal_char(&self) -> char
[src]
fn literal_char(&self) -> char
Returns the character that indicates literal quoting sequence
fn erase_char(&self) -> char
[src]
fn erase_char(&self) -> char
Returns the character that indicates backward character erase
fn word_erase_char(&self) -> char
[src]
fn word_erase_char(&self) -> char
Returns the character that indicates backward word erase
fn kill_char(&self) -> char
[src]
fn kill_char(&self) -> char
Returns the character that indicates backward kill line
fn delete_seq(&self) -> &str
[src]
fn delete_seq(&self) -> &str
Returns the key sequence that indicates forward delete character
fn insert_seq(&self) -> &str
[src]
fn insert_seq(&self) -> &str
Returns the key sequence that indicates switching to insert mode
fn name(&self) -> Option<&str>
[src]
fn name(&self) -> Option<&str>
Returns the name of the terminal, if one has been supplied
fn size(&self) -> Result<Size>
[src]
fn size(&self) -> Result<Size>
Returns the size of the terminal window
fn clear_screen(&self) -> Result<()>
[src]
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<()>
[src]
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<()>
[src]
fn move_up(&self, n: usize) -> Result<()>
Moves the cursor up n
cells; n
may be zero.
fn move_down(&self, n: usize) -> Result<()>
[src]
fn move_down(&self, n: usize) -> Result<()>
Moves the cursor down n
cells; n
may be zero.
fn move_left(&self, n: usize) -> Result<()>
[src]
fn move_left(&self, n: usize) -> Result<()>
Moves the cursor left n
cells; n
may be zero.
fn move_right(&self, n: usize) -> Result<()>
[src]
fn move_right(&self, n: usize) -> Result<()>
Moves the cursor right n
cells; n
may be zero.
fn move_to_first_col(&self) -> Result<()>
[src]
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<()>
[src]
fn set_cursor_mode(&self, mode: CursorMode) -> Result<()>
Set the current cursor mode
fn wait_for_input(&self, _timeout: Option<Duration>) -> Result<bool>
[src]
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<()>
[src]
fn prepare(
&self,
_catch_signals: bool,
_report_signals: SignalSet
) -> Result<()>
Prepares the terminal for line reading and editing operations. Read more
fn read_signals(&self) -> Result<()>
[src]
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>
[src]
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>
[src]
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>
[src]
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<()>
[src]
fn write(&self, s: &str) -> Result<()>
Writes output to the terminal and immediately flushes it to the device. Read more
Auto Trait Implementations
impl !Send for MemoryTerminal
impl !Send for MemoryTerminal
impl !Sync for MemoryTerminal
impl !Sync for MemoryTerminal