pub struct Terminal {
    pub running: Arc<AtomicBool>,
    pub prompt: Arc<Mutex<String>>,
    pub term: Arc<Interface>,
    pub handler: Arc<dyn Cli>,
    pub terminate: Arc<AtomicBool>,
    pub pipe_raw: Channel<String>,
    pub pipe_crlf: Channel<String>,
    pub pipe_ctl: DuplexChannel<()>,
    /* private fields */
}
Expand description

Terminal interface

Fields§

§running: Arc<AtomicBool>§prompt: Arc<Mutex<String>>§term: Arc<Interface>§handler: Arc<dyn Cli>§terminate: Arc<AtomicBool>§pipe_raw: Channel<String>§pipe_crlf: Channel<String>§pipe_ctl: DuplexChannel<()>

Implementations§

source§

impl Terminal

source

pub fn try_new(handler: Arc<dyn Cli>, prompt: &str) -> Result<Self>

Create a new default terminal instance bound to the supplied command-line processor Cli.

source

pub fn try_new_with_options( handler: Arc<dyn Cli>, options: Options ) -> Result<Self>

Create a new terminal instance bound to the supplied command-line processor Cli. Receives options::Options that allow terminal customization.

source

pub async fn init(self: &Arc<Self>) -> Result<()>

Init the terminal instance

source

pub fn inner(&self) -> LockResult<MutexGuard<'_, Inner>>

Access to the underlying terminal instance

source

pub fn history(&self) -> Vec<String>

Get terminal command line history list as Vec<String>

source

pub fn reset_line_buffer(&self)

source

pub fn get_prompt(&self) -> String

Get the current terminal prompt string

source

pub fn prompt(&self)

Render the current prompt in the terminal

source

pub fn crlf(&self)

Output CRLF sequence

source

pub fn write<S>(&self, s: S)where S: Into<String>,

Write a string

source

pub fn writeln<S>(&self, s: S)where S: Into<String>,

Write a string ending with CRLF sequence

source

pub fn term(&self) -> Arc<Interface>

Get a clone of Arc of the underlying terminal instance

source

pub async fn run(self: &Arc<Self>) -> Result<()>

Execute the async terminal processing loop. Once started, it should be stopped using Terminal::exit

source

pub async fn exit(self: &Arc<Self>)

Exits the async terminal processing loop (async fn)

source

pub fn abort(self: &Arc<Self>)

Exits the async terminal processing loop (sync fn)

source

pub async fn ask( self: &Arc<Terminal>, secure: bool, prompt: &str ) -> Result<String>

Ask a question (input a string until CRLF). secure argument suppresses echoing of the user input (useful for password entry)

source

pub fn inject(&self, text: String) -> Result<()>

Inject a string into the current cursor position

source

pub fn is_running(&self) -> bool

Indicates that the terminal has received command input and has not yet returned from the processing. This flag is set to true when delivering the user command to the Cli handler and is reset to false when the Cli handler returns.

source

pub fn update_theme(&self) -> Result<()>

Trait Implementations§

source§

impl Clone for Terminal

source§

fn clone(&self) -> Terminal

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Any for Twhere T: Any,

§

fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync + 'static>

source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V