pub struct TerminalTermion { /* private fields */ }Implementations§
Source§impl TerminalTermion
impl TerminalTermion
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/prompt.rs (line 9)
6fn main() {
7 let options = PromptBufferOptions { echo: true, ..Default::default() };
8
9 let mut term = TerminalTermion::new();
10 let mut prompt = PromptBuffer::new(options);
11 prompt.print_prompt(&mut term);
12
13 let mut counter = 1;
14 let mut switch = false;
15
16 loop {
17
18 let key_result = prompt.handle_terminal_key(&mut term, |m| {
19 if let Some(mut m) = m.with_prefix("p3/") {
20 if let Some(mut ctx) = m.command("hello") {
21 ctx.get_terminal().print_line("Hello world - P3");
22 }
23
24 if let Some(mut ctx) = m.command("ping") {
25 ctx.get_terminal().print_line("Pong");
26 }
27
28 if let Some(mut m) = m.with_prefix("more/") {
29 if let Some(mut ctx) = m.command("here") {
30 ctx.get_terminal().print_line("Yep, here");
31 }
32 }
33 }
34
35 if let Some(mut ctx) = m.property("counter", validate_property_min_max(1, 100)) {
36 ctx.apply(&mut counter);
37 }
38 if let Some(mut ctx) = m.property("switch", ValueBool) {
39 ctx.apply(&mut switch);
40 }
41 if let Some(mut ctx) = m.command("p1/hello") {
42 ctx.get_terminal().print_line("Hello world - P1");
43 }
44 if let Some(mut ctx) = m.command("p1/s1/hello") {
45 ctx.get_terminal().print_line("Hello world - P1 S1");
46 }
47 if let Some(mut ctx) = m.command("p1/s1/reset") {
48 ctx.get_terminal().print_line("Reset.");
49 }
50 if let Some(mut ctx) = m.command("p2/hello") {
51 ctx.get_terminal().print_line("Hello world - P2");
52 }
53
54 if let Some(mut ctx) = m.command("lines") {
55 ctx.get_terminal().print_line("Line 1");
56 ctx.get_terminal().print_line("Line 2");
57 println!("Line 3");
58 println!("Line 4");
59 }
60 });
61
62 match key_result {
63 Ok(PromptEvent::Break) => {
64 break;
65 },
66 _ => ()
67 }
68 }
69
70 println!("Exit.");
71}Trait Implementations§
Source§impl Drop for TerminalTermion
impl Drop for TerminalTermion
Auto Trait Implementations§
impl Freeze for TerminalTermion
impl RefUnwindSafe for TerminalTermion
impl Send for TerminalTermion
impl Sync for TerminalTermion
impl Unpin for TerminalTermion
impl UnwindSafe for TerminalTermion
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