Struct StringPrompt

Source
pub struct StringPrompt { /* private fields */ }

Implementations§

Source§

impl StringPrompt

Source

pub fn new(text: String) -> Self

Examples found in repository?
examples/text_prompt.rs (line 6)
5fn main() {
6    let prompt = StringPrompt::new("prompt> ".to_string());
7    let mut line_editor = LineEditor::new(Box::new(prompt));
8
9    let bindings = line_editor.keybinding();
10    bindings.register_common_control_bindings();
11
12    match line_editor.read_line() {
13        Ok(LineEditorResult::Success(line)) => {
14            println!("Line {}", line);
15        }
16        _ => {}
17    }
18}
More examples
Hide additional examples
examples/keyword_hinter.rs (line 38)
37fn main() {
38    let prompt = StringPrompt::new("prompt> ".to_string());
39    let mut line_editor = LineEditor::new(Box::new(prompt));
40    line_editor.add_hinter(Box::<GitQLHinter>::default());
41
42    let bindings = line_editor.keybinding();
43    bindings.register_common_control_bindings();
44
45    match line_editor.read_line() {
46        Ok(LineEditorResult::Success(line)) => {
47            println!("Line {}", line);
48        }
49        _ => {}
50    }
51}
examples/keyword_highlighter.rs (line 74)
73fn main() {
74    let prompt = StringPrompt::new("prompt> ".to_string());
75    let mut line_editor = LineEditor::new(Box::new(prompt));
76
77    let bindings = line_editor.keybinding();
78    bindings.register_common_control_bindings();
79
80    line_editor.add_highlighter(Box::<GitQLHighlighter>::default());
81
82    match line_editor.read_line() {
83        Ok(LineEditorResult::Success(line)) => {
84            println!("Line {}", line);
85        }
86        _ => {}
87    }
88}
examples/cursor_style.rs (line 7)
6fn main() {
7    let prompt = StringPrompt::new("prompt> ".to_string());
8    let mut line_editor = LineEditor::new(Box::new(prompt));
9    line_editor.set_cursor_style(Some(SetCursorStyle::BlinkingBlock));
10
11    let bindings = line_editor.keybinding();
12    bindings.register_common_control_bindings();
13
14    match line_editor.read_line() {
15        Ok(LineEditorResult::Success(line)) => {
16            println!("Line {}", line);
17        }
18        _ => {}
19    }
20}
examples/auto_pair.rs (line 7)
6fn main() {
7    let prompt = StringPrompt::new("prompt> ".to_string());
8    let mut line_editor = LineEditor::new(Box::new(prompt));
9    line_editor.set_auto_pair(Some(Box::<DefaultAutoPair>::default()));
10
11    let bindings = line_editor.keybinding();
12    bindings.register_common_control_bindings();
13
14    match line_editor.read_line() {
15        Ok(LineEditorResult::Success(line)) => {
16            println!("Line {}", line);
17        }
18        _ => {}
19    }
20}
examples/matching_brackets_highlighters.rs (line 74)
73fn main() {
74    let prompt = StringPrompt::new("gql> ".to_string());
75    let mut line_editor = LineEditor::new(Box::new(prompt));
76    line_editor.add_highlighter(Box::<MatchingBracketsHighlighter>::default());
77
78    let bindings = line_editor.keybinding();
79    bindings.register_common_control_bindings();
80
81    match line_editor.read_line() {
82        Ok(LineEditorResult::Success(line)) => {
83            println!("Line {}", line);
84        }
85        _ => {}
86    }
87}

Trait Implementations§

Source§

impl Prompt for StringPrompt

Source§

fn prompt(&self) -> StyledBuffer

The action that will return prompt with styles as StyledBuffer

Auto Trait Implementations§

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.