Skip to main content

LineTerminal

Struct LineTerminal 

Source
pub struct LineTerminal<R, W> { /* private fields */ }
Expand description

A line-driven Terminal over an injected reader and writer.

It uses the operating system’s cooked line discipline: the user types a whole line and presses Enter. It never enters raw mode, works over pipes, and needs no extra dependencies, so it is the default terminal. Bind it to real streams with LineTerminal::stdio, or to in-memory buffers with LineTerminal::new.

Implementations§

Source§

impl LineTerminal<BufReader<Stdin>, Stderr>

Source

pub fn stdio() -> Self

Build a line terminal bound to process stdin and stderr.

Source§

impl<R: BufRead, W: Write> LineTerminal<R, W>

Source

pub const fn new(reader: R, writer: W) -> Self

Build a line terminal from an explicit reader and writer.

Trait Implementations§

Source§

impl<R: BufRead, W: Write> Terminal for LineTerminal<R, W>

Source§

fn capabilities(&self) -> Capabilities

The interaction model this terminal supports.
Source§

fn read_line(&mut self) -> AppResult<Option<String>>

Read one whole line (line-driven terminals). Read more
Source§

fn read_key(&mut self) -> AppResult<Key>

Read one decoded keystroke (key-driven terminals). Read more
Source§

fn write(&mut self, text: &str) -> AppResult<()>

Write text verbatim (no trailing newline). Read more
Source§

fn write_line(&mut self, text: &str) -> AppResult<()>

Write text followed by a newline (a carriage return + line feed in raw mode). Read more
Source§

fn flush(&mut self) -> AppResult<()>

Flush any buffered output. Read more
Source§

fn clear_last_lines(&mut self, _count: u16) -> AppResult<()>

Move the cursor up count lines and clear from there down, so the next frame overwrites the previous one. A no-op for line-driven terminals. Read more
Source§

fn begin_interactive(&mut self) -> AppResult<()>

Enter interactive (raw) mode before a key-driven loop. A no-op for line-driven terminals. Read more
Source§

fn end_interactive(&mut self) -> AppResult<()>

Leave interactive (raw) mode after a key-driven loop. A no-op for line-driven terminals. Read more

Auto Trait Implementations§

§

impl<R, W> Freeze for LineTerminal<R, W>
where R: Freeze, W: Freeze,

§

impl<R, W> RefUnwindSafe for LineTerminal<R, W>

§

impl<R, W> Send for LineTerminal<R, W>
where R: Send, W: Send,

§

impl<R, W> Sync for LineTerminal<R, W>
where R: Sync, W: Sync,

§

impl<R, W> Unpin for LineTerminal<R, W>
where R: Unpin, W: Unpin,

§

impl<R, W> UnsafeUnpin for LineTerminal<R, W>
where R: UnsafeUnpin, W: UnsafeUnpin,

§

impl<R, W> UnwindSafe for LineTerminal<R, W>
where R: UnwindSafe, W: UnwindSafe,

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.