Struct VteTerminalParser

Source
pub struct VteTerminalParser { /* private fields */ }
Expand description

[vte] state-machine adapter for the supported terminal-state operations.

One instance represents one incremental byte stream. Reusing it for unrelated streams can carry an incomplete escape/UTF-8 sequence from the first stream into the next; create a fresh parser per terminal stream.

§Examples

use ailloli_ui_terminal_core::{TerminalParser, TerminalState, VteTerminalParser};

let mut parser = VteTerminalParser::new();
let mut state = TerminalState::new();
parser.advance(&mut state, b"A\x1b[31mB");
assert_eq!(state.screen.lines[0].cells[1].text, "B");

Implementations§

Source§

impl VteTerminalParser

Source

pub fn new() -> Self

Creates a parser with no buffered partial sequence.

§Examples
use ailloli_ui_terminal_core::{TerminalParser, TerminalState, VteTerminalParser};

let mut parser = VteTerminalParser::new();
let mut state = TerminalState::new();
parser.advance(&mut state, b"ok");
assert!(state.screen.lines[0].plain_text().starts_with("ok"));

Trait Implementations§

Source§

impl Default for VteTerminalParser

Source§

fn default() -> Self

Creates the same empty parser as Self::new.

§Examples
use ailloli_ui_terminal_core::VteTerminalParser;
let _parser = VteTerminalParser::default();
Source§

impl TerminalParser for VteTerminalParser

Source§

fn advance(&mut self, state: &mut TerminalState, bytes: &[u8])

Advances the internal [vte] machine with a temporary state performer.

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> 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 = Infallible

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

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

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.