Skip to main content

Terminal

Struct Terminal 

Source
pub struct Terminal {
    inner: Arc<Inner>,
    thread: Mutex<Option<JoinHandle<()>>>,
}
Expand description

One terminal.

Fields§

§inner: Arc<Inner>§thread: Mutex<Option<JoinHandle<()>>>

Implementations§

Source§

impl Terminal

Source

pub fn spawn(config: &TerminalConfig) -> Result<Self, Error>

Spawn a shell on a fresh PTY.

Source

pub fn write_text(&self, text: &str) -> Result<(), Error>

Type text as-is.

Source

pub fn write_bytes(&self, bytes: &[u8]) -> Result<(), Error>

Type raw bytes as-is: a client’s own keystrokes, which are already the bytes the PTY wants.

Source

pub fn write_keys(&self, keys: &[Key]) -> Result<(), Error>

Press named keys, in order.

Source

pub fn resize(&self, cols: u16, rows: u16) -> Result<(), Error>

Resize the PTY and the model.

Source

pub fn close(&self)

End the terminal: kill the process group and let the loop finish.

Source

pub fn screen(&self) -> Screen

The visible screen as text.

Source

pub fn read( &self, since: Option<u64>, max_lines: usize, max_bytes: usize, ) -> ReadResult

A bounded read of the scrollback and the screen.

Source

pub fn repaint_and_seq(&self) -> (Vec<u8>, u32)

The visible screen as a VT stream, with the sequence the next chunk will carry - both read under the term’s lock, because the sequence is bumped under it after each parse. So every chunk below the sequence is already in the repaint, and no chunk at or above it is.

Source

pub fn state(&self) -> State

What the terminal is doing.

Source

pub fn subscribe(&self) -> Receiver<OutputChunk>

The output stream, from the next chunk.

Source

pub fn state_stream(&self) -> Receiver<State>

The state stream, from the current value.

Source

pub fn exit_stream(&self) -> Receiver<bool>

A stream that fires once, when the shell exits.

Source

pub fn is_alive(&self) -> bool

Whether the shell process is alive.

Source

pub fn shell_exit(&self) -> Option<Exit>

The shell’s own exit, once it has one.

Source

pub fn cols(&self) -> u16

Source

pub fn rows(&self) -> u16

Source

pub fn shell(&self) -> &str

Source

pub fn cwd(&self) -> &Path

Source

pub fn title(&self) -> String

The title the shell last set, when it set one.

Trait Implementations§

Source§

impl Drop for Terminal

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more