Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/joshka/ratatui-simple


https://github.com/joshka/ratatui-simple

Last synced: 20 days ago
JSON representation

Awesome Lists containing this project

README

        

# Ratatui Simple App

This is a WIP simple template app for [Ratatui]

## Todo

- [ ] Parameterize the template (authors, project name, desc, repo, username in copyright, license)
- [ ] Readme for end users
- [ ] VHS script
- [ ] github workflows
- [ ] add doc
- [ ] handle pausing the event threads

## Design choices

- License is MIT OR Apache-2.0 (both included)
- Uses color_eyre, crossterm
- Main is simple
- install error hooks
- creates terminal
- creates event handler
- App::new()::run(terminal, events)
- Error hooks
- init() - color_eyre error hook and panic hook
- App
- has a simple tick counter, header and footer
- run()
- loop controlled by app::mode
- calls self.draw and self.handle_events
- draw()
- just renders root as a widget
- handle_events()
- calls events.next()
- calls methods on app based on the action `Event::Tick => self.tick()`
- Root Widget
- uses layout and tailwind colors
- header, body, footer
- has a tick counter widget to show decomposition and interaction
- Tui module
- TerminalGuard impls `Deref`, `DerefMut`, `Drop`
- `fn tui::init() -> TerminalGuard` (and `restore` is there if needed, but shouldn't need to generally)
- Events
- mpsc::channel
- two threads
- tick (send Event::Tick every 100ms)
- crossterm_events (gets the relevant events and sends them)

[Ratatui]: https://ratatui.rs