pub struct Panel {
pub position: Point,
pub cursor: Point,
/* private fields */
}Expand description
A panel.
Fields§
§position: PointThe current position of this panel.
cursor: PointThe current position of this panel’s cursor.
Implementations§
Source§impl Panel
impl Panel
Sourcepub fn new(position: Point, rows: usize, cols: usize) -> Self
pub fn new(position: Point, rows: usize, cols: usize) -> Self
Create a new empty panel with the position specified and the size specified.
Examples found in repository?
examples/getting_started.rs (line 18)
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 print<T>(&mut self, string: T)where
T: Display,
pub fn print<T>(&mut self, string: T)where
T: Display,
Write a string to the current cursor location. Does not wrap text. If cursor is out of bounds, does nothing.
Sourcepub fn mv_print<T>(&mut self, position: Point, string: T)where
T: Display,
pub fn mv_print<T>(&mut self, position: Point, string: T)where
T: Display,
Move the cursor to the specified location and call print.
Examples found in repository?
examples/getting_started.rs (line 22)
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 attr_on(&mut self, attr: chtype) -> Result<(), Error>
pub fn attr_on(&mut self, attr: chtype) -> Result<(), Error>
Enable an attribute for the character under the cursor.
Examples found in repository?
examples/getting_started.rs (line 26)
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 attr_off(&mut self, attr: chtype) -> Result<(), Error>
pub fn attr_off(&mut self, attr: chtype) -> Result<(), Error>
Disable an attribute for the character under the cursor.
Sourcepub fn draw_box(&mut self)
pub fn draw_box(&mut self)
Draw a box around the edge of the panel. This will overwrite things.
Examples found in repository?
examples/getting_started.rs (line 19)
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}Auto Trait Implementations§
impl Freeze for Panel
impl RefUnwindSafe for Panel
impl Send for Panel
impl Sync for Panel
impl Unpin for Panel
impl UnsafeUnpin for Panel
impl UnwindSafe for Panel
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