Skip to main content

TerminalMode

Enum TerminalMode 

Source
#[non_exhaustive]
pub enum TerminalMode {
Show 15 variants BracketedPaste, ReportFocus, MouseCellMotion, MouseAllMotion, KeyboardEnhancements(u8), KeyboardFlags(u8), AltScreen, NoAutowrap, UnicodeCore, SavedTitle, CursorStyle(u8), ForegroundColor(Rgb), BackgroundColor(Rgb), CursorColor(Rgb), ProgressBar(ProgressBar),
}
Expand description

A terminal mode a program can turn on and off. Bubble Tea turns them on and off from each View’s fields; a Backend writes them.

use petitcarnets as tea;
use tea::TerminalMode;

assert_eq!(TerminalMode::AltScreen.sequence(true), b"\x1b[?1049h");
assert_eq!(TerminalMode::AltScreen.sequence(false), b"\x1b[?1049l");
assert_eq!(TerminalMode::CursorStyle(5).sequence(true), b"\x1b[5 q");

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

BracketedPaste

Bracketed paste (mode 2004): pasted text arrives as one paste.

§

ReportFocus

Focus reports (mode 1004).

§

MouseCellMotion

Mouse clicks, wheel and drags (modes 1002 and 1006).

§

MouseAllMotion

Every mouse event, plain motion included (modes 1003 and 1006).

§

KeyboardEnhancements(u8)

xterm’s modifyOtherKeys level 2 and a kitty keyboard entry with these flags pushed on the terminal’s stack.

§

KeyboardFlags(u8)

New flags for the kitty keyboard entry already pushed by TerminalMode::KeyboardEnhancements, set in place. Turning it off does nothing: turn off KeyboardEnhancements instead.

§

AltScreen

The alternate screen (mode 1049), saving the main screen’s cursor.

§

NoAutowrap

Autowrap turned off (DECAWM, mode 7): on writes CSI ?7l, off CSI ?7h. On while a program draws, so writing the last column never wraps or scrolls.

§

UnicodeCore

Grapheme cluster widths (mode 2027), where the terminal has them.

§

SavedTitle

The window title saved on the terminal’s title stack (XTWINOPS 22 and 23): off clears the title, then pops the saved one back.

§

CursorStyle(u8)

A cursor shape (DECSCUSR 1 to 6); off is the terminal’s default.

§

ForegroundColor(Rgb)

The terminal’s default text colour (OSC 10); off resets it.

§

BackgroundColor(Rgb)

The terminal’s default background colour (OSC 11); off resets it.

§

CursorColor(Rgb)

The cursor’s colour (OSC 12); off resets it.

§

ProgressBar(ProgressBar)

A progress bar (OSC 9;4); off removes it.

Implementations§

Source§

impl TerminalMode

Source

pub fn sequence(self, on: bool) -> Vec<u8> ⓘ

The bytes that turn the mode on (on) or off.

Trait Implementations§

Source§

impl Clone for TerminalMode

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for TerminalMode

Source§

impl Debug for TerminalMode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for TerminalMode

Source§

impl Hash for TerminalMode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for TerminalMode

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TerminalMode

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.