Crates.io | dreg |
lib.rs | dreg |
version | 0.2.2 |
source | src |
created_at | 2024-08-07 12:50:20.123638 |
updated_at | 2024-10-18 12:49:47.804899 |
description | A simple text-based user interface library |
homepage | https://rtthw.github.io/dreg |
repository | https://github.com/rtthw/dreg |
max_upload_size | |
id | 1328398 |
size | 6,026 |
A simple text-based user interface library that will run on just about anything.
use dreg::prelude::*;
fn main() -> Result<()> {
let program = MyProgram {
should_quit: false,
};
let platform = CrosstermPlatform::new()?;
run_program(program, platform)?;
Ok(())
}
struct MyProgram {
should_quit: bool,
}
impl Program for MyProgram {
fn update(&mut self, frame: Frame) {
// When the user pressed `q`, the program safely exits.
if frame.context.keys_down().contains(&Scancode::Q) {
self.should_quit = true;
return; // No need to render anything past this point.
}
frame.buffer.set_string(
1, // Column index.
1, // Row index.
format!("KEYS DOWN: {:?}", frame.context.keys_down()),
Style::new(), // No styling.
);
}
fn should_exit(&self) -> bool {
self.should_quit
}
}
The design of Dreg has been radical simplicity from the very start.
It's not gonna run on your toaster, but it might run on your smart fridge. ↩