Prompt

Struct Prompt 

Source
pub struct Prompt { /* private fields */ }
Expand description

Manages the whole prompt.

Implementations§

Source§

impl Prompt

Source

pub fn add_keybind( &mut self, key: Key, callback: impl FnMut(&mut Buffer, Document<'_>) -> KeyAction + 'static, )

Adds a new keybind to the prompt. If you use one of the keys assigned to the default keybinds, it will override that command.

Source

pub fn remove_keybind(&mut self, key: Key)

Removes a keybind

Source

pub fn run(&mut self)

Runs the prompt, can be exited via ctrl-c or ctrl-d

Examples found in repository?
examples/basic.rs (line 42)
35fn main() {
36    let chr = ColoredChar::builder().ch('>' as u8).foreground_color(Color::Yellow).build();
37    let prefix = ColoredString::new_from_inner(&[
38        chr, chr, chr,
39        ColoredChar::builder().ch(' ' as u8).build()
40    ]);
41    let mut prompt: Prompt = PromptBuilder::builder().prefix(prefix).app(Box::new(Cli {})).build().into();
42    prompt.run();
43}
Source

pub fn run_one(&mut self)

Only get the next line. This allows you to implement your own runtime. Be aware that signals are not processed.

Trait Implementations§

Source§

impl From<PromptBuilder> for Prompt

Source§

fn from(b: PromptBuilder) -> Self

Use PromptBuilder::into() to convert into a Prompt

Auto Trait Implementations§

§

impl Freeze for Prompt

§

impl !RefUnwindSafe for Prompt

§

impl !Send for Prompt

§

impl !Sync for Prompt

§

impl Unpin for Prompt

§

impl !UnwindSafe for Prompt

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.