pub struct ProcessSettings {
pub messages: MessageSettings,
pub scroll: ScrollSettings,
}
Fields§
§messages: MessageSettings
§scroll: ScrollSettings
Implementations§
Source§impl ProcessSettings
impl ProcessSettings
Sourcepub fn new(messages: MessageSettings) -> Self
pub fn new(messages: MessageSettings) -> Self
Examples found in repository?
examples/processes.rs (line 41)
9fn main() {
10 // Create a process that prints messages and sleeps.
11 let process_foo = create_printing_process(["hello", "world", "foo", "bar"], 1.0, 30);
12
13 // Add the process to the terminal.
14 // The first time `add_process` or `tprintln!` is called, the terminal is automatically initialized.
15 add_process(
16 "Foo",
17 process_foo,
18 ProcessSettings::new_with_scroll(
19 // Show only the output messages.
20 MessageSettings::Output,
21 // Enable scrolling with the Left and Right keys.
22 // Up and Down keys are reserved for `Main` output.
23 ScrollSettings::enable(KeyCode::Left, KeyCode::Right),
24 ),
25 )
26 .unwrap();
27
28 sleep(Duration::from_secs(2));
29
30 // Create another process
31 let process_bar = create_printing_process(
32 ["hello", "Err: this is an error! >&2", "foo", "bar"],
33 0.1,
34 8,
35 );
36
37 add_process(
38 "Bar",
39 process_bar,
40 // Show both output and error messages.
41 ProcessSettings::new(MessageSettings::All),
42 )
43 .unwrap();
44
45 sleep(Duration::from_secs(2));
46
47 // Similar to print! and println!, but it prints messages in the `Main` section of the terminal.
48 // I don't find a way to capture the stdout (like println!) and display them into `Main` section.
49 tprintln!("searching_message");
50 // Block the current thread until the message is found.
51 let msg = block_search_message("Foo", "llo").unwrap();
52 tprintln!("msg found: {}", msg);
53 assert_eq!(msg, "hello");
54
55 tprintln!("searching_message");
56 let msg = block_search_message("Bar", "ar").unwrap();
57 tprintln!("msg found: {}", msg);
58 assert_eq!(msg, "bar");
59
60 sleep(Duration::from_secs(20));
61
62 // Restore the terminal to its original state.
63 end_terminal();
64}
Sourcepub fn new_with_scroll(
messages: MessageSettings,
scroll: ScrollSettings,
) -> Self
pub fn new_with_scroll( messages: MessageSettings, scroll: ScrollSettings, ) -> Self
Examples found in repository?
examples/processes.rs (lines 18-24)
9fn main() {
10 // Create a process that prints messages and sleeps.
11 let process_foo = create_printing_process(["hello", "world", "foo", "bar"], 1.0, 30);
12
13 // Add the process to the terminal.
14 // The first time `add_process` or `tprintln!` is called, the terminal is automatically initialized.
15 add_process(
16 "Foo",
17 process_foo,
18 ProcessSettings::new_with_scroll(
19 // Show only the output messages.
20 MessageSettings::Output,
21 // Enable scrolling with the Left and Right keys.
22 // Up and Down keys are reserved for `Main` output.
23 ScrollSettings::enable(KeyCode::Left, KeyCode::Right),
24 ),
25 )
26 .unwrap();
27
28 sleep(Duration::from_secs(2));
29
30 // Create another process
31 let process_bar = create_printing_process(
32 ["hello", "Err: this is an error! >&2", "foo", "bar"],
33 0.1,
34 8,
35 );
36
37 add_process(
38 "Bar",
39 process_bar,
40 // Show both output and error messages.
41 ProcessSettings::new(MessageSettings::All),
42 )
43 .unwrap();
44
45 sleep(Duration::from_secs(2));
46
47 // Similar to print! and println!, but it prints messages in the `Main` section of the terminal.
48 // I don't find a way to capture the stdout (like println!) and display them into `Main` section.
49 tprintln!("searching_message");
50 // Block the current thread until the message is found.
51 let msg = block_search_message("Foo", "llo").unwrap();
52 tprintln!("msg found: {}", msg);
53 assert_eq!(msg, "hello");
54
55 tprintln!("searching_message");
56 let msg = block_search_message("Bar", "ar").unwrap();
57 tprintln!("msg found: {}", msg);
58 assert_eq!(msg, "bar");
59
60 sleep(Duration::from_secs(20));
61
62 // Restore the terminal to its original state.
63 end_terminal();
64}
Trait Implementations§
Source§impl Clone for ProcessSettings
impl Clone for ProcessSettings
Source§fn clone(&self) -> ProcessSettings
fn clone(&self) -> ProcessSettings
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl PartialEq for ProcessSettings
impl PartialEq for ProcessSettings
impl StructuralPartialEq for ProcessSettings
Auto Trait Implementations§
impl Freeze for ProcessSettings
impl RefUnwindSafe for ProcessSettings
impl Send for ProcessSettings
impl Sync for ProcessSettings
impl Unpin for ProcessSettings
impl UnwindSafe for ProcessSettings
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more