3 releases

0.1.2 Oct 23, 2022
0.1.1 Oct 23, 2022
0.1.0 Oct 23, 2022

#685 in Command-line interface

MIT/Apache

11KB
207 lines

A TUI library based on pancurses.

To get started, run:

$ cargo add fryingpan

Then you can consult the documentation or examples to learn how to use the library

Examples

$ git clone https://git.whodiduexpect.com/placeholder/pancakes.git
$ cd pancakes 
$ cargo run --example getting_started

(The library was originally named pancakes.)


lib.rs:

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();
}

Dependencies

~0.7–1.8MB
~37K SLoC