pub struct Screen(_);
Expand description

Provides operations on an underlying terminal device in screen mode.

Screen uses an internal buffer to store rendered text, colors, and style.

Each set of changes must be followed by a call to refresh to flush these changes to the terminal device.

Concurrency

Access to read and write operations is controlled by two internal locks: One for reading and one for writing. Each lock may be held independently of the other.

If any one thread wishes to hold both locks, the read lock must be acquired first, in order to prevent deadlocks.

Implementations

Opens a new screen interface on stdout.

Opens a new screen interface on stderr.

Begins a new screen session using the given Terminal instance.

Returns the name of the terminal.

Notes

On Unix, this method returns the contents of the TERM environment variable.

On Windows, this method always returns the string "windows-console".

Attempts to acquire an exclusive lock on terminal read operations.

The current thread will block until the lock can be acquired.

Attempts to acquire an exclusive lock on terminal write operations.

The current thread will block until the lock can be acquired.

Attempts to acquire an exclusive lock on terminal read operations.

If the lock cannot be acquired immediately, Err(_) is returned.

Attempts to acquire an exclusive lock on terminal write operations.

If the lock cannot be acquired immediately, Err(_) is returned.

Locking

The following methods internally acquire the read lock.

The lock is released before the method returns.

These methods are also implemented on ScreenReadGuard, which holds the Screen read lock until the value is dropped.

Waits for an event from the terminal.

Returns Ok(false) if timeout elapses without an event occurring.

If timeout is None, this method will wait indefinitely.

Notes

Some low-level terminal events may not generate an Event value. Therefore, this method may return Ok(true), while a follow-up call to read_event may not immediately return an event.

Reads an event from the terminal.

If timeout elapses without an event occurring, this method will return Ok(None).

If timeout is None, this method will wait indefinitely.

Locking

The following methods internally acquire the write lock.

The lock is released before the method returns.

These methods are also implemented on ScreenWriteGuard, which holds the Screen write lock until the value is dropped.

Returns the current size of the terminal screen.

Returns the current cursor position.

Sets the cursor position.

Moves the cursor to the given column on the next line.

Set the current cursor mode.

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

Notes

On Unix systems, this setting may have no effect.

Clears the internal screen buffer.

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

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

Sets the current style setting to the given set of flags.

Sets or removes foreground text color.

Sets or removes background text color.

Sets all attributes for the screen.

Removes color and style attributes.

Adds bold to the current style setting.

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

Adds italic to the current style setting.

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

Adds underline to the current style setting.

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

Adds reverse to the current style setting.

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

Renders the internal buffer to the terminal screen.

Writes text at the given position within the screen buffer.

Any non-printable characters, such as escape sequences, will be ignored.

Writes text with the given attributes at the current cursor position.

Any non-printable characters, such as escape sequences, will be ignored.

Writes text with the given attributes at the given position within the screen buffer.

Any non-printable characters, such as escape sequences, will be ignored.

Writes a single character at the cursor position using the current style and color settings.

If the character is a non-printable character, it will be ignored.

Writes a string at the cursor position using the current style and color settings.

Any non-printable characters, such as escape sequences, will be ignored.

Writes formatted text at the cursor position using the current style and color settings.

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

Any non-printable characters, such as escape sequences, will be ignored.

Examples
let screen = Screen::new(Default::default())?;

writeln!(screen, "Hello, world!");

Trait Implementations

Reads raw data from the terminal. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.