pub enum ScrollSettings {
Disable,
Enable {
up: KeyCode,
down: KeyCode,
},
}
Variants§
Implementations§
Source§impl ScrollSettings
impl ScrollSettings
Sourcepub fn enable(up: KeyCode, down: KeyCode) -> Self
pub fn enable(up: KeyCode, down: KeyCode) -> Self
Examples found in repository?
examples/fast_output.rs (line 23)
6fn main() {
7 tprintln!("Starting...");
8
9 std::thread::sleep(std::time::Duration::from_secs(2));
10
11 let process_foo = create_printing_process([" helloooohelloooohelloooohelloooohelloooohelloooohelloooohelloooohelloooo", "world", "foo", "bar"], 0.2, 50);
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 loop {
29 std::thread::sleep(std::time::Duration::from_secs(1));
30 }
31}
More examples
examples/processes.rs (line 23)
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 ScrollSettings
impl Clone for ScrollSettings
Source§fn clone(&self) -> ScrollSettings
fn clone(&self) -> ScrollSettings
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 ScrollSettings
impl PartialEq for ScrollSettings
impl StructuralPartialEq for ScrollSettings
Auto Trait Implementations§
impl Freeze for ScrollSettings
impl RefUnwindSafe for ScrollSettings
impl Send for ScrollSettings
impl Sync for ScrollSettings
impl Unpin for ScrollSettings
impl UnwindSafe for ScrollSettings
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