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

Builder struct for the Pancake struct.
Central data structure.
A panel.
A point in 2D space.

Enums

Errors used by this library.
Input enum, re-exported from pancurses.

Constants

Makes text blink.
Makes text bold.
Makes text dim.
Makes text italic.
Makes text underlined.

Functions

Converts a color pair ID into an attribute.
Change the definition of a color pair. Does not do anything if colors are disabled.

Type Definitions

Contains information about a character and/or an attribute.