pub struct TerminalWriteGuard<'a>(_);
Expand description

Holds an exclusive lock for write operations on a Terminal

See Terminal documentation for details on locking.

Implementations§

source§

impl<'a> TerminalWriteGuard<'a>

source

pub fn flush(&mut self) -> Result<()>

Flush all output to the terminal device.

This is called automatically when the TerminalWriteGuard is dropped.

source

pub fn size(&self) -> Result<Size>

Returns the size of the terminal.

source

pub fn clear_screen(&mut self) -> Result<()>

Clears the terminal screen, placing the cursor at the first line and column.

If the terminal contains a scrolling window over a buffer, the window will be scrolled downward, preserving as much of the existing buffer as possible.

source

pub fn clear_to_line_end(&mut self) -> Result<()>

Clears the current line, starting at cursor position.

source

pub fn clear_to_screen_end(&mut self) -> Result<()>

Clears the screen, starting at cursor position.

source

pub fn move_up(&mut self, n: usize) -> Result<()>

Moves the cursor up n lines.

source

pub fn move_down(&mut self, n: usize) -> Result<()>

Moves the cursor down n lines.

source

pub fn move_left(&mut self, n: usize) -> Result<()>

Moves the cursor left n columns.

source

pub fn move_right(&mut self, n: usize) -> Result<()>

Moves the cursor right n columns.

source

pub fn move_to_first_column(&mut self) -> Result<()>

Moves the cursor to the first column of the current line

source

pub fn set_cursor_mode(&mut self, mode: CursorMode) -> Result<()>

Set the current cursor mode.

This setting is a visible hint to the user. It produces no change in behavior.

Notes

On some systems, this setting may have no effect.

source

pub fn add_style(&mut self, style: Style) -> Result<()>

Adds a set of Style flags to the current style setting.

source

pub fn remove_style(&mut self, style: Style) -> Result<()>

Removes a set of Style flags from the current style setting.

source

pub fn set_style<S>(&mut self, style: S) -> Result<()>where S: Into<Option<Style>>,

Sets the current style to the given set of flags.

source

pub fn set_theme(&mut self, theme: Theme) -> Result<()>

Sets all attributes for the terminal.

source

pub fn set_fg<C: Into<Option<Color>>>(&mut self, fg: C) -> Result<()>

Sets the background text color.

source

pub fn set_bg<C: Into<Option<Color>>>(&mut self, bg: C) -> Result<()>

Removes color and style attributes.

source

pub fn clear_attributes(&mut self) -> Result<()>

Adds bold to the current style setting.

source

pub fn bold(&mut self) -> Result<()>

Adds bold to the current style setting.

This is equivalent to self.add_style(Style::BOLD).

source

pub fn italic(&mut self) -> Result<()>

Adds italic to the current style setting.

This is equivalent to self.add_style(Style::ITALIC).

source

pub fn underline(&mut self) -> Result<()>

Adds underline to the current style setting.

This is equivalent to self.add_style(Style::UNDERLINE).

source

pub fn reverse(&mut self) -> Result<()>

Adds reverse to the current style setting.

This is equivalent to self.add_style(Style::REVERSE).

source

pub fn write_styled<F, B, S>( &mut self, fg: F, bg: B, style: S, s: &str ) -> Result<()>where F: Into<Option<Color>>, B: Into<Option<Color>>, S: Into<Option<Style>>,

Writes output to the terminal with the given color and style added.

All attributes are removed after the given text is written.

source

pub fn write_char(&mut self, ch: char) -> Result<()>

Writes a single character to the terminal using the current style and color settings.

source

pub fn write_str(&mut self, s: &str) -> Result<()>

Writes a string to the terminal using the current style and color settings.

source

pub fn write_fmt(&mut self, args: Arguments<'_>) -> Result<()>

Writes formatted text to the terminal using the current style and color settings.

This method enables TerminalWriteGuard to be used as the receiver to the write! and writeln! macros.

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for TerminalWriteGuard<'a>

§

impl<'a> !Send for TerminalWriteGuard<'a>

§

impl<'a> Sync for TerminalWriteGuard<'a>

§

impl<'a> Unpin for TerminalWriteGuard<'a>

§

impl<'a> UnwindSafe for TerminalWriteGuard<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.