pub struct FryingPan { /* private fields */ }Expand description
Builder struct for the Pancake struct.
Implementations§
Source§impl FryingPan
impl FryingPan
Sourcepub fn color(&mut self, enabled: bool) -> &mut FryingPan
pub fn color(&mut self, enabled: bool) -> &mut FryingPan
Whether to try to enable colors in the final pancake.
Examples found in repository?
examples/getting_started.rs (line 12)
7fn main() {
8 // cook pancake and init colors
9 let pancake = FryingPan::default()
10 .hide_cursor(true)
11 .no_delay(true)
12 .color(true)
13 .build()
14 .unwrap();
15 init_pair(BLUE_WHITE, COLOR_BLUE, COLOR_WHITE);
16
17 // make panel, position v v size
18 let mut panel = Panel::new(Point::from(1, 1), 10, 30);
19 panel.draw_box();
20
21 // printing does not move the cursor
22 panel.mv_print(Point::from(1, 0), "╴pancakes╶");
23 panel.mv_print(Point::from(1, 1), "hello");
24
25 // the cursor will be within bounds, unwrap is fine
26 panel.attr_on(A_ITALIC).unwrap();
27 panel.attr_on(color_pair(BLUE_WHITE)).unwrap();
28
29 loop {
30 if let Some(Input::Character('q')) = pancake.get_char() {
31 break;
32 }
33
34 pancake.erase();
35 pancake.render_panel(&panel);
36 pancake.refresh();
37
38 sleep(SLEEP_TIME);
39 }
40
41 pancake.quit();
42}Sourcepub fn hide_cursor(&mut self, enabled: bool) -> &mut FryingPan
pub fn hide_cursor(&mut self, enabled: bool) -> &mut FryingPan
Whether to hide the cursor.
Examples found in repository?
examples/getting_started.rs (line 10)
7fn main() {
8 // cook pancake and init colors
9 let pancake = FryingPan::default()
10 .hide_cursor(true)
11 .no_delay(true)
12 .color(true)
13 .build()
14 .unwrap();
15 init_pair(BLUE_WHITE, COLOR_BLUE, COLOR_WHITE);
16
17 // make panel, position v v size
18 let mut panel = Panel::new(Point::from(1, 1), 10, 30);
19 panel.draw_box();
20
21 // printing does not move the cursor
22 panel.mv_print(Point::from(1, 0), "╴pancakes╶");
23 panel.mv_print(Point::from(1, 1), "hello");
24
25 // the cursor will be within bounds, unwrap is fine
26 panel.attr_on(A_ITALIC).unwrap();
27 panel.attr_on(color_pair(BLUE_WHITE)).unwrap();
28
29 loop {
30 if let Some(Input::Character('q')) = pancake.get_char() {
31 break;
32 }
33
34 pancake.erase();
35 pancake.render_panel(&panel);
36 pancake.refresh();
37
38 sleep(SLEEP_TIME);
39 }
40
41 pancake.quit();
42}Sourcepub fn no_delay(&mut self, enabled: bool) -> &mut FryingPan
pub fn no_delay(&mut self, enabled: bool) -> &mut FryingPan
Whether to continue execution on get_char instead of stopping the thread and waiting.
Examples found in repository?
examples/getting_started.rs (line 11)
7fn main() {
8 // cook pancake and init colors
9 let pancake = FryingPan::default()
10 .hide_cursor(true)
11 .no_delay(true)
12 .color(true)
13 .build()
14 .unwrap();
15 init_pair(BLUE_WHITE, COLOR_BLUE, COLOR_WHITE);
16
17 // make panel, position v v size
18 let mut panel = Panel::new(Point::from(1, 1), 10, 30);
19 panel.draw_box();
20
21 // printing does not move the cursor
22 panel.mv_print(Point::from(1, 0), "╴pancakes╶");
23 panel.mv_print(Point::from(1, 1), "hello");
24
25 // the cursor will be within bounds, unwrap is fine
26 panel.attr_on(A_ITALIC).unwrap();
27 panel.attr_on(color_pair(BLUE_WHITE)).unwrap();
28
29 loop {
30 if let Some(Input::Character('q')) = pancake.get_char() {
31 break;
32 }
33
34 pancake.erase();
35 pancake.render_panel(&panel);
36 pancake.refresh();
37
38 sleep(SLEEP_TIME);
39 }
40
41 pancake.quit();
42}Sourcepub fn build(&mut self) -> Result<Pancake, Error>
pub fn build(&mut self) -> Result<Pancake, Error>
Build everything.
§Errors
Errors if terminal does not support color and color was enabled as an option
Examples found in repository?
examples/getting_started.rs (line 13)
7fn main() {
8 // cook pancake and init colors
9 let pancake = FryingPan::default()
10 .hide_cursor(true)
11 .no_delay(true)
12 .color(true)
13 .build()
14 .unwrap();
15 init_pair(BLUE_WHITE, COLOR_BLUE, COLOR_WHITE);
16
17 // make panel, position v v size
18 let mut panel = Panel::new(Point::from(1, 1), 10, 30);
19 panel.draw_box();
20
21 // printing does not move the cursor
22 panel.mv_print(Point::from(1, 0), "╴pancakes╶");
23 panel.mv_print(Point::from(1, 1), "hello");
24
25 // the cursor will be within bounds, unwrap is fine
26 panel.attr_on(A_ITALIC).unwrap();
27 panel.attr_on(color_pair(BLUE_WHITE)).unwrap();
28
29 loop {
30 if let Some(Input::Character('q')) = pancake.get_char() {
31 break;
32 }
33
34 pancake.erase();
35 pancake.render_panel(&panel);
36 pancake.refresh();
37
38 sleep(SLEEP_TIME);
39 }
40
41 pancake.quit();
42}Trait Implementations§
Auto Trait Implementations§
impl Freeze for FryingPan
impl RefUnwindSafe for FryingPan
impl Send for FryingPan
impl Sync for FryingPan
impl Unpin for FryingPan
impl UnwindSafe for FryingPan
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