Giter VIP home page Giter VIP logo

tui-builder's Introduction

Tui-builder

An opinionated model on quickly getting up and running with a Tui App - similar to redux toolkit.

Uses these defaults:

  • Model, View, Controller paradigm
  • Crossterm with multithreaded event system
  • ctrl-c to exit

Quickly build a tui app

fn main() -> Result<()> {
    let mut state = AppState {};

    let handler = move |state: &AppState, event: InputEvent| -> Result<()> {
        // Ingest input events and modify the state
    }

    let renderer = move |state: AppState| {
        // Render the state with tui
        let chunks = tui::layout::Layout::default();
        let block = tui::widgets::Block::default()
            .title("Block 3")
            .borders(tui::widgets::Borders::ALL);
    };

    // Override the state implementation (normally defaults to state default)
    TuiBuilder::<AppState>::with_state(state)
        // Set the default refresh rate on the terminal
        .tick_rate(250)
        // Provide a way of handling raw input events
        .event_handler()
        // Provide a key code used to kill the app
        .kill_signal(KeyCodes::(CtrlC))
        // Provide a way of rendering the state
        .renderer(renderer)
        // Launch the app
        .launch()
}

tui-builder's People

Contributors

jkelleyrtp avatar

Stargazers

invisageable avatar MS avatar Marcin Bielak avatar Márk Bartos avatar Julius avatar Aaron Leopold avatar Jeff Xun avatar Prabir Shrestha avatar Ashton Redd avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

c0d3-dump

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.