Struct Scene

Source
pub struct Scene { /* private fields */ }

Implementations§

Source§

impl Scene

Source

pub fn new( max_padding: i32, background: i16, is_closed: bool, speed: Duration, ) -> Self

Examples found in repository?
examples/threadtest.rs (line 12)
10fn testfull_push(spawn: i32) -> Duration {
11    let start_time = Instant::now();
12    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(0));
13
14    for _ in 0..spawn {
15	screen.push(Message::new_simple("Message", COLOR_PAIR_WHITE, ""));
16    }
17    
18    screen.kill();
19    start_time.elapsed()
20}
21
22fn testfull_append(spawn: i32) -> Duration {
23    let start_time = Instant::now();
24    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(0));
25
26    screen.append((0..spawn).into_iter().map(|_| Message::new_simple("Message", COLOR_PAIR_WHITE, "")).collect());
27    
28    screen.kill();
29    start_time.elapsed()
30}
More examples
Hide additional examples
examples/hello_world.rs (line 12)
10fn main() {
11    // creating a screne with [max_padding = 20, black background, reuse messages, move down every 50ms]:
12    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(50));
13
14    // initalize test color
15    screen.init_pair(WHITE_PAIR, COLOR_WHITE, COLOR_BLACK);
16
17    screen.start(); // forks into a new thread
18    
19    // Here's one way to add messages:
20    screen.push(Message::new_simple("Hello world", WHITE_PAIR, "0"));
21    
22    screen.join(); // wait for screen to die (user presses q)
23}
examples/stdin.rs (line 17)
14fn main() {
15
16    // creating a screne with [max_padding = 20, black background, reuse messages]:
17    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(25));
18    screen.init_pair(COLOR_PAIR_WHITE, COLOR_WHITE, COLOR_BLACK);
19    screen.start(); // forks into a new thread
20    
21    let stdin = io::stdin();
22    while screen.alive() {
23	for line in stdin.lock().lines() { // lock blocks q, so this it Control-C to exit
24            let line = line.expect("Could not read line from standard in");
25            screen.push(Message::new_simple(&line, COLOR_PAIR_WHITE, "0"));
26	}
27    }
28
29    screen.kill();
30}
examples/update.rs (line 13)
11fn main() {
12    
13    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(40));
14    screen.init_pair(COLOR_PAIR_WHITE, COLOR_WHITE, COLOR_BLACK);
15
16    // We'll add 10 messages with different IDs:
17    for i in 0..10 {
18	screen.push(Message::new_with_title(&("M".to_string()+&i.to_string()), "+0", COLOR_PAIR_WHITE, &i.to_string()));
19    }
20    
21    // we wait to start until we have a good chunk of messages stored
22    screen.start();
23    
24    // These are now being printed out to terminal
25    // Let's now update each message to have different contents
26
27    let mut j = 1;
28    while screen.alive() { // wait for screen to die (user presses q)
29	thread::sleep(Duration::from_millis(1000)); // update every second
30	screen.append_update((0..10).into_iter().map(|i| Message::new_with_title(&("M".to_string()+&i.to_string()), &("+".to_string()+&j.to_string()), COLOR_PAIR_WHITE, &i.to_string())).collect()); // update pre-existing messages, this time with a one-liner
31	j += 1;
32    }
33
34    // because we wait for the screen to die, we don't need to kill it here
35    // However, doing so won't cause an error:
36    screen.kill();
37}
examples/colors.rs (line 14)
12fn main() {
13    // Here, we set up a white background
14    let mut screen = Scene::new(20, COLOR_WHITE, true, Duration::from_millis(20));
15    screen.init_pair(COLOR_PAIR_BLACK, COLOR_BLACK, COLOR_WHITE);
16    screen.init_pair(COLOR_PAIR_GREEN, COLOR_BLACK, COLOR_GREEN);
17    screen.init_pair(COLOR_PAIR_RED,   COLOR_BLUE,  COLOR_RED  );
18
19    screen.start(); // forks into a new thread
20
21    // Black text on white background
22    screen.push(Message::new_with_title("Msg", "1", COLOR_PAIR_BLACK, "0"));
23    
24    // Black text on green background
25    screen.push(Message::new_with_title("Msg", "2", COLOR_PAIR_GREEN, "1"));
26    
27    // Black text on green background
28    screen.push(Message::new_with_title("Msg", "3", COLOR_PAIR_RED, "2"));
29
30    // 7-color rainbow using the most basic curses colors
31    let mut string = ColorString::new();
32    for i in 0..7 {
33	screen.init_pair(i+4, COLOR_BLACK+i, COLOR_BLACK+i); // create a color pair
34	string.push(ColorChar::new(' ' as u32, COLOR_PAIR(i as u32+4))); // and use it
35	// Note: COLOR_PAIR() is used here because ColorChar can hold more than just
36	//       colors. It can handle bold, italic, and other pancurses attributes too
37    }
38    screen.push(Message::new(string, "3")); // and turn it into a message
39    
40    screen.join(); // wait for screen to die (user presses q)
41}
Source

pub fn push(&mut self, message: Message)

Examples found in repository?
examples/threadtest.rs (line 15)
10fn testfull_push(spawn: i32) -> Duration {
11    let start_time = Instant::now();
12    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(0));
13
14    for _ in 0..spawn {
15	screen.push(Message::new_simple("Message", COLOR_PAIR_WHITE, ""));
16    }
17    
18    screen.kill();
19    start_time.elapsed()
20}
More examples
Hide additional examples
examples/hello_world.rs (line 20)
10fn main() {
11    // creating a screne with [max_padding = 20, black background, reuse messages, move down every 50ms]:
12    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(50));
13
14    // initalize test color
15    screen.init_pair(WHITE_PAIR, COLOR_WHITE, COLOR_BLACK);
16
17    screen.start(); // forks into a new thread
18    
19    // Here's one way to add messages:
20    screen.push(Message::new_simple("Hello world", WHITE_PAIR, "0"));
21    
22    screen.join(); // wait for screen to die (user presses q)
23}
examples/stdin.rs (line 25)
14fn main() {
15
16    // creating a screne with [max_padding = 20, black background, reuse messages]:
17    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(25));
18    screen.init_pair(COLOR_PAIR_WHITE, COLOR_WHITE, COLOR_BLACK);
19    screen.start(); // forks into a new thread
20    
21    let stdin = io::stdin();
22    while screen.alive() {
23	for line in stdin.lock().lines() { // lock blocks q, so this it Control-C to exit
24            let line = line.expect("Could not read line from standard in");
25            screen.push(Message::new_simple(&line, COLOR_PAIR_WHITE, "0"));
26	}
27    }
28
29    screen.kill();
30}
examples/update.rs (line 18)
11fn main() {
12    
13    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(40));
14    screen.init_pair(COLOR_PAIR_WHITE, COLOR_WHITE, COLOR_BLACK);
15
16    // We'll add 10 messages with different IDs:
17    for i in 0..10 {
18	screen.push(Message::new_with_title(&("M".to_string()+&i.to_string()), "+0", COLOR_PAIR_WHITE, &i.to_string()));
19    }
20    
21    // we wait to start until we have a good chunk of messages stored
22    screen.start();
23    
24    // These are now being printed out to terminal
25    // Let's now update each message to have different contents
26
27    let mut j = 1;
28    while screen.alive() { // wait for screen to die (user presses q)
29	thread::sleep(Duration::from_millis(1000)); // update every second
30	screen.append_update((0..10).into_iter().map(|i| Message::new_with_title(&("M".to_string()+&i.to_string()), &("+".to_string()+&j.to_string()), COLOR_PAIR_WHITE, &i.to_string())).collect()); // update pre-existing messages, this time with a one-liner
31	j += 1;
32    }
33
34    // because we wait for the screen to die, we don't need to kill it here
35    // However, doing so won't cause an error:
36    screen.kill();
37}
examples/colors.rs (line 22)
12fn main() {
13    // Here, we set up a white background
14    let mut screen = Scene::new(20, COLOR_WHITE, true, Duration::from_millis(20));
15    screen.init_pair(COLOR_PAIR_BLACK, COLOR_BLACK, COLOR_WHITE);
16    screen.init_pair(COLOR_PAIR_GREEN, COLOR_BLACK, COLOR_GREEN);
17    screen.init_pair(COLOR_PAIR_RED,   COLOR_BLUE,  COLOR_RED  );
18
19    screen.start(); // forks into a new thread
20
21    // Black text on white background
22    screen.push(Message::new_with_title("Msg", "1", COLOR_PAIR_BLACK, "0"));
23    
24    // Black text on green background
25    screen.push(Message::new_with_title("Msg", "2", COLOR_PAIR_GREEN, "1"));
26    
27    // Black text on green background
28    screen.push(Message::new_with_title("Msg", "3", COLOR_PAIR_RED, "2"));
29
30    // 7-color rainbow using the most basic curses colors
31    let mut string = ColorString::new();
32    for i in 0..7 {
33	screen.init_pair(i+4, COLOR_BLACK+i, COLOR_BLACK+i); // create a color pair
34	string.push(ColorChar::new(' ' as u32, COLOR_PAIR(i as u32+4))); // and use it
35	// Note: COLOR_PAIR() is used here because ColorChar can hold more than just
36	//       colors. It can handle bold, italic, and other pancurses attributes too
37    }
38    screen.push(Message::new(string, "3")); // and turn it into a message
39    
40    screen.join(); // wait for screen to die (user presses q)
41}
Source

pub fn push_update(&mut self, message: Message)

Source

pub fn append(&mut self, messages: Vec<Message>)

Examples found in repository?
examples/threadtest.rs (line 26)
22fn testfull_append(spawn: i32) -> Duration {
23    let start_time = Instant::now();
24    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(0));
25
26    screen.append((0..spawn).into_iter().map(|_| Message::new_simple("Message", COLOR_PAIR_WHITE, "")).collect());
27    
28    screen.kill();
29    start_time.elapsed()
30}
Source

pub fn append_update(&mut self, messages: Vec<Message>)

Examples found in repository?
examples/update.rs (line 30)
11fn main() {
12    
13    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(40));
14    screen.init_pair(COLOR_PAIR_WHITE, COLOR_WHITE, COLOR_BLACK);
15
16    // We'll add 10 messages with different IDs:
17    for i in 0..10 {
18	screen.push(Message::new_with_title(&("M".to_string()+&i.to_string()), "+0", COLOR_PAIR_WHITE, &i.to_string()));
19    }
20    
21    // we wait to start until we have a good chunk of messages stored
22    screen.start();
23    
24    // These are now being printed out to terminal
25    // Let's now update each message to have different contents
26
27    let mut j = 1;
28    while screen.alive() { // wait for screen to die (user presses q)
29	thread::sleep(Duration::from_millis(1000)); // update every second
30	screen.append_update((0..10).into_iter().map(|i| Message::new_with_title(&("M".to_string()+&i.to_string()), &("+".to_string()+&j.to_string()), COLOR_PAIR_WHITE, &i.to_string())).collect()); // update pre-existing messages, this time with a one-liner
31	j += 1;
32    }
33
34    // because we wait for the screen to die, we don't need to kill it here
35    // However, doing so won't cause an error:
36    screen.kill();
37}
Source

pub fn start(&mut self)

Examples found in repository?
examples/hello_world.rs (line 17)
10fn main() {
11    // creating a screne with [max_padding = 20, black background, reuse messages, move down every 50ms]:
12    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(50));
13
14    // initalize test color
15    screen.init_pair(WHITE_PAIR, COLOR_WHITE, COLOR_BLACK);
16
17    screen.start(); // forks into a new thread
18    
19    // Here's one way to add messages:
20    screen.push(Message::new_simple("Hello world", WHITE_PAIR, "0"));
21    
22    screen.join(); // wait for screen to die (user presses q)
23}
More examples
Hide additional examples
examples/stdin.rs (line 19)
14fn main() {
15
16    // creating a screne with [max_padding = 20, black background, reuse messages]:
17    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(25));
18    screen.init_pair(COLOR_PAIR_WHITE, COLOR_WHITE, COLOR_BLACK);
19    screen.start(); // forks into a new thread
20    
21    let stdin = io::stdin();
22    while screen.alive() {
23	for line in stdin.lock().lines() { // lock blocks q, so this it Control-C to exit
24            let line = line.expect("Could not read line from standard in");
25            screen.push(Message::new_simple(&line, COLOR_PAIR_WHITE, "0"));
26	}
27    }
28
29    screen.kill();
30}
examples/update.rs (line 22)
11fn main() {
12    
13    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(40));
14    screen.init_pair(COLOR_PAIR_WHITE, COLOR_WHITE, COLOR_BLACK);
15
16    // We'll add 10 messages with different IDs:
17    for i in 0..10 {
18	screen.push(Message::new_with_title(&("M".to_string()+&i.to_string()), "+0", COLOR_PAIR_WHITE, &i.to_string()));
19    }
20    
21    // we wait to start until we have a good chunk of messages stored
22    screen.start();
23    
24    // These are now being printed out to terminal
25    // Let's now update each message to have different contents
26
27    let mut j = 1;
28    while screen.alive() { // wait for screen to die (user presses q)
29	thread::sleep(Duration::from_millis(1000)); // update every second
30	screen.append_update((0..10).into_iter().map(|i| Message::new_with_title(&("M".to_string()+&i.to_string()), &("+".to_string()+&j.to_string()), COLOR_PAIR_WHITE, &i.to_string())).collect()); // update pre-existing messages, this time with a one-liner
31	j += 1;
32    }
33
34    // because we wait for the screen to die, we don't need to kill it here
35    // However, doing so won't cause an error:
36    screen.kill();
37}
examples/colors.rs (line 19)
12fn main() {
13    // Here, we set up a white background
14    let mut screen = Scene::new(20, COLOR_WHITE, true, Duration::from_millis(20));
15    screen.init_pair(COLOR_PAIR_BLACK, COLOR_BLACK, COLOR_WHITE);
16    screen.init_pair(COLOR_PAIR_GREEN, COLOR_BLACK, COLOR_GREEN);
17    screen.init_pair(COLOR_PAIR_RED,   COLOR_BLUE,  COLOR_RED  );
18
19    screen.start(); // forks into a new thread
20
21    // Black text on white background
22    screen.push(Message::new_with_title("Msg", "1", COLOR_PAIR_BLACK, "0"));
23    
24    // Black text on green background
25    screen.push(Message::new_with_title("Msg", "2", COLOR_PAIR_GREEN, "1"));
26    
27    // Black text on green background
28    screen.push(Message::new_with_title("Msg", "3", COLOR_PAIR_RED, "2"));
29
30    // 7-color rainbow using the most basic curses colors
31    let mut string = ColorString::new();
32    for i in 0..7 {
33	screen.init_pair(i+4, COLOR_BLACK+i, COLOR_BLACK+i); // create a color pair
34	string.push(ColorChar::new(' ' as u32, COLOR_PAIR(i as u32+4))); // and use it
35	// Note: COLOR_PAIR() is used here because ColorChar can hold more than just
36	//       colors. It can handle bold, italic, and other pancurses attributes too
37    }
38    screen.push(Message::new(string, "3")); // and turn it into a message
39    
40    screen.join(); // wait for screen to die (user presses q)
41}
Source

pub fn init_pair(&self, pair: i16, c1: i16, c2: i16)

Examples found in repository?
examples/hello_world.rs (line 15)
10fn main() {
11    // creating a screne with [max_padding = 20, black background, reuse messages, move down every 50ms]:
12    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(50));
13
14    // initalize test color
15    screen.init_pair(WHITE_PAIR, COLOR_WHITE, COLOR_BLACK);
16
17    screen.start(); // forks into a new thread
18    
19    // Here's one way to add messages:
20    screen.push(Message::new_simple("Hello world", WHITE_PAIR, "0"));
21    
22    screen.join(); // wait for screen to die (user presses q)
23}
More examples
Hide additional examples
examples/stdin.rs (line 18)
14fn main() {
15
16    // creating a screne with [max_padding = 20, black background, reuse messages]:
17    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(25));
18    screen.init_pair(COLOR_PAIR_WHITE, COLOR_WHITE, COLOR_BLACK);
19    screen.start(); // forks into a new thread
20    
21    let stdin = io::stdin();
22    while screen.alive() {
23	for line in stdin.lock().lines() { // lock blocks q, so this it Control-C to exit
24            let line = line.expect("Could not read line from standard in");
25            screen.push(Message::new_simple(&line, COLOR_PAIR_WHITE, "0"));
26	}
27    }
28
29    screen.kill();
30}
examples/update.rs (line 14)
11fn main() {
12    
13    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(40));
14    screen.init_pair(COLOR_PAIR_WHITE, COLOR_WHITE, COLOR_BLACK);
15
16    // We'll add 10 messages with different IDs:
17    for i in 0..10 {
18	screen.push(Message::new_with_title(&("M".to_string()+&i.to_string()), "+0", COLOR_PAIR_WHITE, &i.to_string()));
19    }
20    
21    // we wait to start until we have a good chunk of messages stored
22    screen.start();
23    
24    // These are now being printed out to terminal
25    // Let's now update each message to have different contents
26
27    let mut j = 1;
28    while screen.alive() { // wait for screen to die (user presses q)
29	thread::sleep(Duration::from_millis(1000)); // update every second
30	screen.append_update((0..10).into_iter().map(|i| Message::new_with_title(&("M".to_string()+&i.to_string()), &("+".to_string()+&j.to_string()), COLOR_PAIR_WHITE, &i.to_string())).collect()); // update pre-existing messages, this time with a one-liner
31	j += 1;
32    }
33
34    // because we wait for the screen to die, we don't need to kill it here
35    // However, doing so won't cause an error:
36    screen.kill();
37}
examples/colors.rs (line 15)
12fn main() {
13    // Here, we set up a white background
14    let mut screen = Scene::new(20, COLOR_WHITE, true, Duration::from_millis(20));
15    screen.init_pair(COLOR_PAIR_BLACK, COLOR_BLACK, COLOR_WHITE);
16    screen.init_pair(COLOR_PAIR_GREEN, COLOR_BLACK, COLOR_GREEN);
17    screen.init_pair(COLOR_PAIR_RED,   COLOR_BLUE,  COLOR_RED  );
18
19    screen.start(); // forks into a new thread
20
21    // Black text on white background
22    screen.push(Message::new_with_title("Msg", "1", COLOR_PAIR_BLACK, "0"));
23    
24    // Black text on green background
25    screen.push(Message::new_with_title("Msg", "2", COLOR_PAIR_GREEN, "1"));
26    
27    // Black text on green background
28    screen.push(Message::new_with_title("Msg", "3", COLOR_PAIR_RED, "2"));
29
30    // 7-color rainbow using the most basic curses colors
31    let mut string = ColorString::new();
32    for i in 0..7 {
33	screen.init_pair(i+4, COLOR_BLACK+i, COLOR_BLACK+i); // create a color pair
34	string.push(ColorChar::new(' ' as u32, COLOR_PAIR(i as u32+4))); // and use it
35	// Note: COLOR_PAIR() is used here because ColorChar can hold more than just
36	//       colors. It can handle bold, italic, and other pancurses attributes too
37    }
38    screen.push(Message::new(string, "3")); // and turn it into a message
39    
40    screen.join(); // wait for screen to die (user presses q)
41}
Source

pub fn alive(&self) -> bool

Examples found in repository?
examples/stdin.rs (line 22)
14fn main() {
15
16    // creating a screne with [max_padding = 20, black background, reuse messages]:
17    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(25));
18    screen.init_pair(COLOR_PAIR_WHITE, COLOR_WHITE, COLOR_BLACK);
19    screen.start(); // forks into a new thread
20    
21    let stdin = io::stdin();
22    while screen.alive() {
23	for line in stdin.lock().lines() { // lock blocks q, so this it Control-C to exit
24            let line = line.expect("Could not read line from standard in");
25            screen.push(Message::new_simple(&line, COLOR_PAIR_WHITE, "0"));
26	}
27    }
28
29    screen.kill();
30}
More examples
Hide additional examples
examples/update.rs (line 28)
11fn main() {
12    
13    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(40));
14    screen.init_pair(COLOR_PAIR_WHITE, COLOR_WHITE, COLOR_BLACK);
15
16    // We'll add 10 messages with different IDs:
17    for i in 0..10 {
18	screen.push(Message::new_with_title(&("M".to_string()+&i.to_string()), "+0", COLOR_PAIR_WHITE, &i.to_string()));
19    }
20    
21    // we wait to start until we have a good chunk of messages stored
22    screen.start();
23    
24    // These are now being printed out to terminal
25    // Let's now update each message to have different contents
26
27    let mut j = 1;
28    while screen.alive() { // wait for screen to die (user presses q)
29	thread::sleep(Duration::from_millis(1000)); // update every second
30	screen.append_update((0..10).into_iter().map(|i| Message::new_with_title(&("M".to_string()+&i.to_string()), &("+".to_string()+&j.to_string()), COLOR_PAIR_WHITE, &i.to_string())).collect()); // update pre-existing messages, this time with a one-liner
31	j += 1;
32    }
33
34    // because we wait for the screen to die, we don't need to kill it here
35    // However, doing so won't cause an error:
36    screen.kill();
37}
Source

pub fn kill(&mut self)

Examples found in repository?
examples/threadtest.rs (line 18)
10fn testfull_push(spawn: i32) -> Duration {
11    let start_time = Instant::now();
12    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(0));
13
14    for _ in 0..spawn {
15	screen.push(Message::new_simple("Message", COLOR_PAIR_WHITE, ""));
16    }
17    
18    screen.kill();
19    start_time.elapsed()
20}
21
22fn testfull_append(spawn: i32) -> Duration {
23    let start_time = Instant::now();
24    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(0));
25
26    screen.append((0..spawn).into_iter().map(|_| Message::new_simple("Message", COLOR_PAIR_WHITE, "")).collect());
27    
28    screen.kill();
29    start_time.elapsed()
30}
More examples
Hide additional examples
examples/stdin.rs (line 29)
14fn main() {
15
16    // creating a screne with [max_padding = 20, black background, reuse messages]:
17    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(25));
18    screen.init_pair(COLOR_PAIR_WHITE, COLOR_WHITE, COLOR_BLACK);
19    screen.start(); // forks into a new thread
20    
21    let stdin = io::stdin();
22    while screen.alive() {
23	for line in stdin.lock().lines() { // lock blocks q, so this it Control-C to exit
24            let line = line.expect("Could not read line from standard in");
25            screen.push(Message::new_simple(&line, COLOR_PAIR_WHITE, "0"));
26	}
27    }
28
29    screen.kill();
30}
examples/update.rs (line 36)
11fn main() {
12    
13    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(40));
14    screen.init_pair(COLOR_PAIR_WHITE, COLOR_WHITE, COLOR_BLACK);
15
16    // We'll add 10 messages with different IDs:
17    for i in 0..10 {
18	screen.push(Message::new_with_title(&("M".to_string()+&i.to_string()), "+0", COLOR_PAIR_WHITE, &i.to_string()));
19    }
20    
21    // we wait to start until we have a good chunk of messages stored
22    screen.start();
23    
24    // These are now being printed out to terminal
25    // Let's now update each message to have different contents
26
27    let mut j = 1;
28    while screen.alive() { // wait for screen to die (user presses q)
29	thread::sleep(Duration::from_millis(1000)); // update every second
30	screen.append_update((0..10).into_iter().map(|i| Message::new_with_title(&("M".to_string()+&i.to_string()), &("+".to_string()+&j.to_string()), COLOR_PAIR_WHITE, &i.to_string())).collect()); // update pre-existing messages, this time with a one-liner
31	j += 1;
32    }
33
34    // because we wait for the screen to die, we don't need to kill it here
35    // However, doing so won't cause an error:
36    screen.kill();
37}
Source

pub fn join(&self)

Examples found in repository?
examples/hello_world.rs (line 22)
10fn main() {
11    // creating a screne with [max_padding = 20, black background, reuse messages, move down every 50ms]:
12    let mut screen = Scene::new(20, COLOR_BLACK, true, Duration::from_millis(50));
13
14    // initalize test color
15    screen.init_pair(WHITE_PAIR, COLOR_WHITE, COLOR_BLACK);
16
17    screen.start(); // forks into a new thread
18    
19    // Here's one way to add messages:
20    screen.push(Message::new_simple("Hello world", WHITE_PAIR, "0"));
21    
22    screen.join(); // wait for screen to die (user presses q)
23}
More examples
Hide additional examples
examples/colors.rs (line 40)
12fn main() {
13    // Here, we set up a white background
14    let mut screen = Scene::new(20, COLOR_WHITE, true, Duration::from_millis(20));
15    screen.init_pair(COLOR_PAIR_BLACK, COLOR_BLACK, COLOR_WHITE);
16    screen.init_pair(COLOR_PAIR_GREEN, COLOR_BLACK, COLOR_GREEN);
17    screen.init_pair(COLOR_PAIR_RED,   COLOR_BLUE,  COLOR_RED  );
18
19    screen.start(); // forks into a new thread
20
21    // Black text on white background
22    screen.push(Message::new_with_title("Msg", "1", COLOR_PAIR_BLACK, "0"));
23    
24    // Black text on green background
25    screen.push(Message::new_with_title("Msg", "2", COLOR_PAIR_GREEN, "1"));
26    
27    // Black text on green background
28    screen.push(Message::new_with_title("Msg", "3", COLOR_PAIR_RED, "2"));
29
30    // 7-color rainbow using the most basic curses colors
31    let mut string = ColorString::new();
32    for i in 0..7 {
33	screen.init_pair(i+4, COLOR_BLACK+i, COLOR_BLACK+i); // create a color pair
34	string.push(ColorChar::new(' ' as u32, COLOR_PAIR(i as u32+4))); // and use it
35	// Note: COLOR_PAIR() is used here because ColorChar can hold more than just
36	//       colors. It can handle bold, italic, and other pancurses attributes too
37    }
38    screen.push(Message::new(string, "3")); // and turn it into a message
39    
40    screen.join(); // wait for screen to die (user presses q)
41}

Auto Trait Implementations§

§

impl Freeze for Scene

§

impl !RefUnwindSafe for Scene

§

impl Send for Scene

§

impl Sync for Scene

§

impl Unpin for Scene

§

impl !UnwindSafe for Scene

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V