Struct kaspa_cli_lib::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<Terminal, Error>
pub fn try_new(handler: Arc<dyn Cli>, prompt: &str) -> Result<Terminal, Error>
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<Terminal, Error>
pub fn try_new_with_options( handler: Arc<dyn Cli>, options: Options ) -> Result<Terminal, Error>
Create a new terminal instance bound to the supplied command-line processor Cli.
Receives options::Options that allow terminal customization.
sourcepub fn inner(
&self
) -> Result<MutexGuard<'_, Inner>, PoisonError<MutexGuard<'_, Inner>>>
pub fn inner( &self ) -> Result<MutexGuard<'_, Inner>, PoisonError<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)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, H>( &self, list: &[(S, H)], separator: Option<&str> ) -> Result<(), Error>where S: ToString, H: ToString,
sourcepub async fn run(self: &Arc<Terminal>) -> Result<(), Error>
pub async fn run(self: &Arc<Terminal>) -> Result<(), Error>
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, Error>
pub async fn ask( self: &Arc<Terminal>, secret: bool, prompt: &str ) -> Result<String, Error>
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, Error>
sourcepub fn inject_unicode_string(&self, text: UnicodeString) -> Result<(), Error>
pub fn inject_unicode_string(&self, text: UnicodeString) -> Result<(), Error>
Inject a string into the current cursor position
pub fn inject<S>(&self, text: S) -> Result<(), Error>where S: ToString,
pub fn inject_char(&self, ch: char) -> Result<(), Error>
sourcepub fn is_running(&self) -> bool
pub fn is_running(&self) -> bool
pub async fn exec<S>(self: &Arc<Terminal>, cmd: S) -> Result<(), Error>where S: ToString,
pub fn set_theme(&self, _theme: Theme) -> Result<(), Error>
pub fn update_theme(&self) -> Result<(), Error>
pub fn clipboard_copy(&self) -> Result<(), Error>
pub fn clipboard_paste(&self) -> Result<(), Error>
pub fn increase_font_size(&self) -> Result<Option<f64>, Error>
pub fn decrease_font_size(&self) -> Result<Option<f64>, Error>
pub fn set_font_size(&self, font_size: f64) -> Result<(), Error>
pub fn get_font_size(&self) -> Result<Option<f64>, Error>
pub fn cols(&self) -> Option<usize>
pub async fn select<T>( self: &Arc<Terminal>, prompt: &str, list: &[T] ) -> Result<Option<T>, Error>where T: Display + Clone,
pub fn register_event_handler( self: &Arc<Terminal>, _handler: Arc<Box<dyn Fn(Event)>> ) -> Result<(), Error>
pub fn register_link_matcher( &self, _regexp: &RegExp, _handler: Arc<Box<dyn Fn(Modifiers, &str)>> ) -> Result<(), Error>
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
§impl<T> CastFrom for Twhere
T: Any + 'static,
impl<T> CastFrom for Twhere T: Any + 'static,
§fn ref_any(&self) -> &(dyn Any + 'static)
fn ref_any(&self) -> &(dyn Any + 'static)
Any, which is backed by the type implementing this trait.§fn mut_any(&mut self) -> &mut (dyn Any + 'static)
fn mut_any(&mut self) -> &mut (dyn Any + 'static)
Any, which is backed by the type implementing this trait.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.