Skip to main content

TermState

Struct TermState 

Source
pub struct TermState {
    pub prompt: String,
    pub mode: u8,
    pub flags: u32,
    pub font: Option<u32>,
    pub size_pt: f32,
    pub pager_text: String,
    pub page_len: u16,
    /* private fields */
}
Expand description

the state of one console (see the module header); the app keeps it between frames

Fields§

§prompt: String

the text before the input (SGR allowed)

§mode: u8

TM_LINE, TM_BUSY, TM_RAW, TM_SECRET

§flags: u32

TF_* added to the flags of ui.terminal

§font: Option<u32>

a font id for this console (None: ui.mono_font)

§size_pt: f32

the text size in points (default 10)

§pager_text: String

the pager’s line (default “ –More– “)

§page_len: u16

lines of output per page of the pager (0, the default: the screen minus one line)

Implementations§

Source§

impl TermState

Source

pub fn new(scrollback: usize) -> TermState

a console keeping scrollback lines (at least 100)

Source

pub fn write(&mut self, s: &[u8])

output: UTF-8 with the ANSI subset of the module header (paged while the pager is on)

Source

pub fn write_str(&mut self, s: &str)

write(s.as_bytes())

Source

pub fn clear(&mut self)

drop the scrollback and the current line (the history stays)

Source

pub fn set_prompt(&mut self, s: &str)

the prompt before the input (SGR allowed)

Source

pub fn set_mode(&mut self, mode: u8)

TM_LINE, TM_BUSY, TM_RAW or TM_SECRET

Source

pub fn input_set(&mut self, s: &str, caret: usize)

replace the input line; caret: a byte index (clamped to a character start)

Source

pub fn input(&self) -> &str

the input line as typed so far

Source

pub fn history(&self) -> &[String]

the lines submitted so far (oldest first)

Source

pub fn complete_reply<S: AsRef<str>>(&mut self, line: &str, list: &[S])

the answer to TermEv::Complete: the new input line (caret at its end); a non-empty list is shown in columns below the line as typed

Source

pub fn pager(&mut self, on: bool)

on: the following output pages (see the module header); off: the app wrote all of it

Source

pub fn pager_waiting(&self) -> bool

the pager holds output and waits for a key

Source

pub fn grid(&self) -> (u16, u16)

the character grid of the last layout (columns, rows; 0 before the first)

Source

pub fn text(&self) -> String

the scrollback and the current line as plain text (lines joined with ‘\n’)

Source

pub fn line_count(&self) -> usize

lines kept in the scrollback

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> ErasedDestructor for T
where T: 'static,

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, 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.