Struct console::Term [−][src]
pub struct Term { /* fields omitted */ }
Abstraction around a terminal.
Methods
impl Term
[src]
impl Term
ⓘImportant traits for Termpub fn stdout() -> Term
[src]
pub fn stdout() -> Term
Return a new unbuffered terminal
ⓘImportant traits for Termpub fn stderr() -> Term
[src]
pub fn stderr() -> Term
Return a new unbuffered terminal to stderr
ⓘImportant traits for Termpub fn buffered_stdout() -> Term
[src]
pub fn buffered_stdout() -> Term
Return a new buffered terminal
ⓘImportant traits for Termpub fn buffered_stderr() -> Term
[src]
pub fn buffered_stderr() -> Term
Return a new buffered terminal to stderr
pub fn target(&self) -> TermTarget
[src]
pub fn target(&self) -> TermTarget
Returns the targert
pub fn write_line(&self, s: &str) -> Result<()>
[src]
pub fn write_line(&self, s: &str) -> Result<()>
Writes a string to the terminal and adds a newline.
pub fn read_char(&self) -> Result<char>
[src]
pub fn read_char(&self) -> Result<char>
Read a single character from the terminal
This does not echo the character and blocks until a single character is entered.
pub fn read_key(&self) -> Result<Key>
[src]
pub fn read_key(&self) -> Result<Key>
Read a single key form the terminal.
This does not echo anything. If the terminal is not user attended the return value will always be the unknown key.
pub fn read_line(&self) -> Result<String>
[src]
pub fn read_line(&self) -> Result<String>
Read one line of input.
This does not include the trailing newline. If the terminal is not user attended the return value will always be an empty string.
pub fn read_secure_line(&self) -> Result<String>
[src]
pub fn read_secure_line(&self) -> Result<String>
Read securely a line of input.
This is similar to read_line
but will not echo the output. This
also switches the terminal into a different mode where not all
characters might be accepted.
pub fn flush(&self) -> Result<()>
[src]
pub fn flush(&self) -> Result<()>
Flushes internal buffers.
This forces the contents of the internal buffer to be written to the terminal. This is unnecessary for unbuffered terminals which will automatically flush.
pub fn is_term(&self) -> bool
[src]
pub fn is_term(&self) -> bool
Checks if the terminal is indeed a terminal.
Alternatively you can use the user_attended
function which does
the same.
pub fn want_emoji(&self) -> bool
[src]
pub fn want_emoji(&self) -> bool
Checks if this terminal wants emoji output.
pub fn size(&self) -> (u16, u16)
[src]
pub fn size(&self) -> (u16, u16)
Returns the terminal size or gets sensible defaults.
pub fn size_checked(&self) -> Option<(u16, u16)>
[src]
pub fn size_checked(&self) -> Option<(u16, u16)>
Returns the terminal size in rows and columns.
If the size cannot be reliably determined None is returned.
pub fn move_cursor_up(&self, n: usize) -> Result<()>
[src]
pub fn move_cursor_up(&self, n: usize) -> Result<()>
Moves the cursor up n
lines
pub fn move_cursor_down(&self, n: usize) -> Result<()>
[src]
pub fn move_cursor_down(&self, n: usize) -> Result<()>
Moves the cursor down n
lines
pub fn clear_line(&self) -> Result<()>
[src]
pub fn clear_line(&self) -> Result<()>
Clears the current line.
The positions the cursor at the beginning of the line again.
pub fn clear_last_lines(&self, n: usize) -> Result<()>
[src]
pub fn clear_last_lines(&self, n: usize) -> Result<()>
Clear the last n
lines.
This positions the cursor at the beginning of the first line that was cleared.
Trait Implementations
impl AsRawFd for Term
[src]
impl AsRawFd for Term
impl Write for Term
[src]
impl Write for Term
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn write(&mut self, buf: &[u8]) -> Result<usize>
Write a buffer into this object, returning how many bytes were written. Read more
fn flush(&mut self) -> Result<()>
[src]
fn flush(&mut self) -> Result<()>
Flush this output stream, ensuring that all intermediately buffered contents reach their destination. Read more
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this write. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0[src]
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
Writes a formatted string into this writer, returning any error encountered. Read more
ⓘImportant traits for &'a mut Rfn by_ref(&mut self) -> &mut Self
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
Creates a "by reference" adaptor for this instance of Write
. Read more
impl Read for Term
[src]
impl Read for Term
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
[src]
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
unsafe fn initializer(&self) -> Initializer
[src]
unsafe fn initializer(&self) -> Initializer
read_initializer
)Determines if this Read
er can work with buffers of uninitialized memory. Read more
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
1.0.0[src]
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
Read all bytes until EOF in this source, placing them into buf
. Read more
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
Read all bytes until EOF in this source, appending them to buf
. Read more
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0[src]
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
Read the exact number of bytes required to fill buf
. Read more
ⓘImportant traits for &'a mut Rfn by_ref(&mut self) -> &mut Self
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
Creates a "by reference" adaptor for this instance of Read
. Read more
ⓘImportant traits for Bytes<R>fn bytes(self) -> Bytes<Self>
1.0.0[src]
fn bytes(self) -> Bytes<Self>
Transforms this Read
instance to an [Iterator
] over its bytes. Read more
ⓘImportant traits for Chars<R>fn chars(self) -> Chars<Self>
[src]
fn chars(self) -> Chars<Self>
: Use str::from_utf8 instead: https://doc.rust-lang.org/nightly/std/str/struct.Utf8Error.html#examples
🔬 This is a nightly-only experimental API. (io
)
the semantics of a partial read/write of where errors happen is currently unclear and may change
Transforms this Read
instance to an [Iterator
] over [char
]s. Read more
ⓘImportant traits for Chain<T, U>fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0[src]
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
Creates an adaptor which will chain this stream with another. Read more
ⓘImportant traits for Take<T>fn take(self, limit: u64) -> Take<Self>
1.0.0[src]
fn take(self, limit: u64) -> Take<Self>
Creates an adaptor which will read at most limit
bytes from it. Read more