pub struct StringPrompt { /* private fields */ }
Implementations§
Source§impl StringPrompt
impl StringPrompt
Sourcepub fn new(text: String) -> Self
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
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
impl Prompt for StringPrompt
Source§fn prompt(&self) -> StyledBuffer
fn prompt(&self) -> StyledBuffer
The action that will return prompt with styles as StyledBuffer
Auto Trait Implementations§
impl Freeze for StringPrompt
impl RefUnwindSafe for StringPrompt
impl Send for StringPrompt
impl Sync for StringPrompt
impl Unpin for StringPrompt
impl UnwindSafe for StringPrompt
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