Struct workflow_terminal::terminal::Terminal
source · 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
impl Terminal
sourcepub fn try_new(handler: Arc<dyn Cli>, prompt: &str) -> Result<Self>
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
.
sourcepub fn try_new_with_options(
handler: Arc<dyn Cli>,
options: Options
) -> Result<Self>
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.
sourcepub fn inner(&self) -> LockResult<MutexGuard<'_, Inner>>
pub fn inner(&self) -> LockResult<MutexGuard<'_, Inner>>
Access to the underlying terminal instance
pub fn reset_line_buffer(&self)
sourcepub fn get_prompt(&self) -> String
pub fn get_prompt(&self) -> String
Get the current terminal prompt string
sourcepub async fn run(self: &Arc<Self>) -> Result<()>
pub async fn run(self: &Arc<Self>) -> Result<()>
Execute the async terminal processing loop.
Once started, it should be stopped using
Terminal::exit
sourcepub async fn ask(
self: &Arc<Terminal>,
secure: bool,
prompt: &str
) -> Result<String>
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)
sourcepub fn inject(&self, text: String) -> Result<()>
pub fn inject(&self, text: String) -> Result<()>
Inject a string into the current cursor position
sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
pub fn update_theme(&self) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Terminal
impl Send for Terminal
impl Sync for Terminal
impl Unpin for Terminal
impl !UnwindSafe for Terminal
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more