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

https://github.com/jwodder/ratselect

TUI selection list forms in Rust with Ratatui
https://github.com/jwodder/ratselect

forms ratatui rust terminal tui

Last synced: about 1 month ago
JSON representation

TUI selection list forms in Rust with Ratatui

Awesome Lists containing this project

README

          

[![Project Status: Concept – Minimal or no implementation has been done yet, or the repository is only intended to be a limited example, demo, or proof-of-concept.](https://www.repostatus.org/badges/latest/concept.svg)](https://www.repostatus.org/#concept)
[![CI Status](https://github.com/jwodder/ratselect/actions/workflows/test.yml/badge.svg)](https://github.com/jwodder/ratselect/actions/workflows/test.yml)
[![codecov.io](https://codecov.io/gh/jwodder/ratselect/branch/main/graph/badge.svg)](https://codecov.io/gh/jwodder/ratselect)
[![Minimum Supported Rust Version](https://img.shields.io/badge/MSRV-1.88-orange)](https://www.rust-lang.org)
[![MIT License](https://img.shields.io/github/license/jwodder/ratselect.svg)](https://opensource.org/licenses/MIT)
[![Built With Ratatui](https://ratatui.rs/built-with-ratatui/badge.svg)](https://ratatui.rs/)

[GitHub](https://github.com/jwodder/ratselect) | [Issues](https://github.com/jwodder/ratselect/issues)

This is an experimental Rust library made using [Ratatui](https://ratatui.rs)
for presenting a user with a full-screen terminal interface consisting of a
series of *selection lists* (radio buttons and sets of checkboxes) and
capturing their choices.

![Screenshot of the `flavors` example on startup](screenshots/flavors.png)

Usage, in brief:

- Create a new `Form`

- Call `form.add(list_key, selector)` with each `RadioSelector` or
`MultiSelector` you wish to present to the user

- Call `form.run()` to run the interface and get the user's selections. If the
user cancelled/quit the interface, this method returns `None`; otherwise, it
returns `Some(selections)`, where `selections` is a `Vec<(T, Selection)>`
pairing the `list_key`'s supplied to `add()` with the choices the user made
for the respective selection lists.

The terminal interface supports the following keybindings:

| Key | Command |
| ------------------------------------------ | -------------------------------------------------------------------------- |
| j, Down | Move down one item |
| k, Up | Move up one item |
| h, Left | Move left one item |
| l, Right | Move right one item |
| g, Home | Go to first item |
| G, End | Go to start of last line (i.e., the "OK" button) |
| Tab | Go to start of next selection list or next button, wrapping around |
| Shift+Tab | Go to start of previous selection list or previous button, wrapping around |
| Enter, Space | Select/toggle/activate current selection |
| q, Q, Esc | Cancel & quit |

See Also
========

- [`curselect`](https://github.com/jwodder/curselect), a roughly-equivalent
implementation in Python made using the [urwid](https://urwid.org) library

- [`cursive-select`](https://github.com/jwodder/cursive-select), a
roughly-equivalent implementation in Rust made using the
[`cursive`](https://crates.io/crates/cursive) library