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
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)where S: Into<String>,
pub fn para_with_options<'a, S, Opt>(&self, width_or_options: Opt, text: S)where S: Into<String>, Opt: Into<Options<'a>>,
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>,
echo: bool,
prompt: &str
) -> Result<String>
pub async fn ask( self: &Arc<Terminal>, echo: 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)
pub async fn kbhit(self: &Arc<Terminal>, prompt: Option<&str>) -> Result<String>
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 async fn exec<S: ToString>(self: &Arc<Terminal>, cmd: S) -> Result<()>
pub fn set_theme(&self, _theme: Theme) -> Result<()>
pub fn update_theme(&self) -> Result<()>
pub fn clipboard_copy(&self) -> Result<()>
pub fn clipboard_paste(&self) -> Result<()>
pub fn increase_font_size(&self) -> Result<Option<f64>>
pub fn decrease_font_size(&self) -> Result<Option<f64>>
pub fn set_font_size(&self, font_size: f64) -> Result<()>
pub fn get_font_size(&self) -> Result<Option<f64>>
pub fn cols(&self) -> Option<usize>
pub async fn select<T>( self: &Arc<Terminal>, prompt: &str, list: &[T] ) -> Result<Option<T>>where T: Display + Clone,
pub fn register_event_handler( self: &Arc<Self>, _handler: EventHandlerFn ) -> Result<()>
pub fn register_link_matcher( &self, _regexp: &RegExp, _handler: LinkMatcherHandlerFn ) -> 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