Expand description
A TUI library based on pancurses.
§Example
use fryingpan::{FryingPan, Input, Panel, Point, A_ITALIC, init_pair, COLOR_BLUE, color_pair, COLOR_WHITE};
use std::{thread::sleep, time::Duration};
const BLUE_WHITE: i16 = 1;
const SLEEP_TIME: Duration = Duration::from_millis(50);
fn main() {
// cook pancake and init colors
let pancake = FryingPan::default()
.hide_cursor(true)
.no_delay(true)
.color(true)
.build()
.unwrap();
init_pair(BLUE_WHITE, COLOR_BLUE, COLOR_WHITE);
// make panel, position v v size
let mut panel = Panel::new(Point::from(1, 1), 10, 30);
panel.draw_box();
// printing does not move the cursor
panel.mv_print(Point::from(1, 0), "╴pancakes╶");
panel.mv_print(Point::from(1, 1), "hello");
// the cursor will be within bounds, unwrap is fine
panel.attr_on(A_ITALIC).unwrap();
panel.attr_on(color_pair(BLUE_WHITE)).unwrap();
loop {
if let Some(Input::Character('q')) = pancake.get_char() {
break;
}
pancake.erase();
pancake.render_panel(&panel);
pancake.refresh();
sleep(SLEEP_TIME);
}
pancake.quit();
}
Structs§
- Frying
Pan - Builder struct for the
Pancake
struct. - Pancake
- Central data structure.
- Panel
- A panel.
- Point
- A point in 2D space.
Enums§
Constants§
- A_BLINK
- Makes text blink.
- A_BOLD
- Makes text bold.
- A_DIM
- Makes text dim.
- A_
ITALIC - Makes text italic.
- A_
UNDERLINE - Makes text underlined.
- COLOR_
BLACK - COLOR_
BLUE - COLOR_
CYAN - COLOR_
GREEN - COLOR_
MAGENTA - COLOR_
RED - COLOR_
WHITE - COLOR_
YELLOW
Functions§
- color_
pair - Converts a color pair ID into an attribute.
- init_
pair - Change the definition of a color pair. Does not do anything if colors are disabled.
Type Aliases§
- chtype
- Contains information about a character and/or an attribute.