8000 GitHub - rtthw/dreg: A simple, text-based UI library.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

rtthw/dreg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents


Crate Badge Docs Badge License Badge

Dreg

A simple text-based user interface library.

Quickstart

use dreg::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    Terminal::new().run(MyApp {
        shutdown: false,
    })
}

struct MyApp {
    shutdown: bool,
}

impl Program for MyApp {
    fn render(&mut self, frame: &mut Frame) {
        if self.shutdown {
            frame.should_exit = true;
            return;
        }

        Rectangle {
            area: frame.area(),
            fg: Color::from_rgb(89, 89, 109),
            style: RectangleStyle::Round,
        }.render(frame);

        let text_area = frame.area().inner_centered(13, 1);
        Text::new("Hello, World!")
            .with_position(text_area.x, text_area.y)
            .render(frame);
    }

    fn input(&mut self, input: Input) {
        match input {
            Input::KeyDown(Scancode::Q) => {
                self.shutdown = true;
            }
            _ => {}
        }
    }
}

License

MIT

About

A simple, text-based UI library.

Topics

Resources

License

Stars

Watchers

Forks

Languages

0