Struct workflow_terminal::terminal::Terminal
source · pub struct Terminal {
pub running: Arc<AtomicBool>,
pub prompt: Arc<Mutex<String>>,
pub term: Arc<Crossterm>,
pub handler: Arc<dyn Cli>,
pub terminate: Arc<AtomicBool>,
pub pipe_raw: Channel<String>,
pub pipe_crlf: Channel<String>,
pub pipe_ctl: DuplexChannel<()>,
pub para_width: Arc<AtomicUsize>,
/* private fields */
}
Expand description
Terminal interface
Fields§
§running: Arc<AtomicBool>
§prompt: Arc<Mutex<String>>
§term: Arc<Crossterm>
§handler: Arc<dyn Cli>
§terminate: Arc<AtomicBool>
§pipe_raw: Channel<String>
§pipe_crlf: Channel<String>
§pipe_ctl: DuplexChannel<()>
§para_width: Arc<AtomicUsize>
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
sourcepub fn history(&self) -> Vec<UnicodeString>
pub fn history(&self) -> Vec<UnicodeString>
Get terminal command line history list as Vec<String>
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 fn refresh_prompt(&self)
pub fn refresh_prompt(&self)
Refreshes the prompt and the user input buffer. This function is useful when the prompt is handled externally and contains data that should be updated.
pub fn para<S>(&self, text: S)
pub fn para_with_options<'a, S, Opt>(&self, width_or_options: Opt, text: S)
pub fn help<S: ToString, H: ToString>( &self, list: &[(S, H)], separator: Option<&str>, ) -> Result<()>
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>,
secret: bool,
prompt: &str,
) -> Result<String>
pub async fn ask( self: &Arc<Terminal>, secret: bool, prompt: &str, ) -> Result<String>
Ask a question (input a string until CRLF).
secret
argument suppresses echoing of the
user input (useful for password entry)
pub async fn kbhit(self: &Arc<Terminal>, prompt: Option<&str>) -> Result<String>
sourcepub fn inject_unicode_string(&self, text: UnicodeString) -> Result<()>
pub fn inject_unicode_string(&self, text: UnicodeString) -> Result<()>
Inject a string into the current cursor position