Struct ProcessSettings

Source
pub struct ProcessSettings {
    pub messages: MessageSettings,
    pub scroll: ScrollSettings,
}

Fields§

§messages: MessageSettings§scroll: ScrollSettings

Implementations§

Source§

impl ProcessSettings

Source

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}
Source

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

Source§

fn clone(&self) -> ProcessSettings

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl PartialEq for ProcessSettings

Source§

fn eq(&self, other: &ProcessSettings) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for ProcessSettings

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.