A menu widget for tui-rs ecosystem

Overview

tui-menu

A menu widget for tui-rs ecosystem.

Features

  • Sub menu groups.
  • Intuitive movement.
  • Item's data is generic as long as it Cloneable.

Try

cargo run --example basic

Example

take a look at examples/basic.rs

Render

// menu should be draw at last, so it can stay on top of other content
let menu = Menu::new();
f.render_stateful_widget(menu, chunks[0], &mut app.menu);

Create nested menu tree

let menu = MenuState::new(vec![
    MenuItem::group(
        "File",
        vec![
            MenuItem::item("New", "file.new".into()),
            MenuItem::item("Open", "file.open".into()),
            MenuItem::group(
                "Open recent",
                vec!["file_1.txt", "file_2.txt"]
                    .into_iter()
                    .map(|f| MenuItem::item(f, format!("file.recent:{f}").into()))
                    .collect(),
            ),
            MenuItem::item("Save as", "file.save_as".into()),
            MenuItem::item("Exit", "exit".into()),
        ],
    ),
    MenuItem::group(
        "Edit",
        vec![
            MenuItem::item("Copy", "edit.new".into()),
            MenuItem::item("Cut", "edit.cut".into()),
            MenuItem::item("Paste", "edit.paste".into()),
        ],
    ),
    MenuItem::group(
        "About",
        vec![
            MenuItem::item("Author", "about.author".into()),
            MenuItem::item("Help", "about.help".into()),
        ],
    ),
]);

Consume events

for e in app.menu.drain_events() {
    match e {
        tui_menu::MenuEvent::Selected(item) => match item.as_ref() {
            "exit" => {
                return Ok(());
            }
            _ => {
                // println!("{} selected", item);
            }
        },
    }
}
You might also like...
A small program which makes a rofi game launcher menu possible by creating .desktop entries for games
A small program which makes a rofi game launcher menu possible by creating .desktop entries for games

rofi-games A small program which makes a `rofi` game launcher menu possible by creating `.desktop` entries for games Installation Manual Clone repo: g

Maccha is an extremely extensible and themable power menu for Windows, macOS, and Linux.

Maccha I hate coffee. Maccha is an extremely extensible and themable power menu for Windows, macOS, and Linux. Plugins Plugins are written in Rust (ot

Scriptable tool to read and write UEFI variables from EFI shell. View, save, edit and restore hidden UEFI (BIOS) Setup settings faster than with the OEM menu forms.
Scriptable tool to read and write UEFI variables from EFI shell. View, save, edit and restore hidden UEFI (BIOS) Setup settings faster than with the OEM menu forms.

UEFI Variable Tool (UVT) UEFI Variable Tool (UVT) is a command-line application that runs from the UEFI shell. It can be launched in seconds from any

Are we lang yet? A simple website providing information about the status of Rust's language development ecosystem.

Are We Lang Yet This project answers the question "Is the Rust ecosystem ready to use for language development yet?". arewelangyet.com What is this? C

A statically typed language that can deeply improve the Python ecosystem

The Erg Programming Language This is the main source code repository for Erg. This contains the compiler and documentation. 日本語 | 简体中文 | 繁體中文 Erg can

Trento checks' ecosystem linting tool

Rashomon Validation engine for Trento Checks DSL. Usage $ tlint -h tlint 0.9.0 USAGE: tlint [OPTIONS] OPTIONS: -f, --file FILE -h,

Putting a brain behind `cat`🐈‍⬛ Integrating language models in the Unix commands ecosystem through text streams.
Putting a brain behind `cat`🐈‍⬛ Integrating language models in the Unix commands ecosystem through text streams.

smartcat (sc) Puts a brain behind cat! CLI interface to bring language models in the Unix ecosystem and allow power users to make the most out of llms

A hackable, minimal, fast TUI file explorer, stealing ideas from nnn and fzf.
A hackable, minimal, fast TUI file explorer, stealing ideas from nnn and fzf.

xplr A hackable, minimal, fast TUI file explorer, stealing ideas from nnn and fzf. [Quickstart] [Features] [Plugins] [Documentation] [Upgrade Guide] [

Rust TUI client for steamcmd
Rust TUI client for steamcmd

Steam TUI About Just a simple TUI client for steamcmd. Allows for the graphical launching, updating, and downloading of steam games through a simple t

Owner
shuo
Rustacean. Ex MSer, Ex ByteDancer. Now individual developer seeking fun and maybe profit.
shuo
A template for bootstrapping a Rust TUI application with tui-rs & crossterm

rust-tui-template A template for bootstrapping a Rust TUI application with tui-rs & crossterm. tui-rs The library is based on the principle of immedia

Orhun Parmaksız 72 Dec 31, 2022
Slippy map (openstreetmap) widget for egui

Slippy maps widget for egui. Limitations There are couple of limitations when using this library. Some of them will might probably be lifted at some p

Piotr 13 Jun 14, 2023
Hotkey widget for egui!

egui-keybind, a hotkey library for egui crates.io | docs.rs | examples | changelogs This library provides a simple egui widget for keybindings (hotkey

null 4 Dec 19, 2023
A Ratatui widget to turn any image to a splash screen in your terminal ✨

ratatui-splash-screen A Ratatui widget to turn any image to a splash screen in your terminal ✨ See the demo of gpg-tui for a real world example. Featu

Orhun Parmaksız 57 Jul 25, 2024
A widget library built on top of bevy_ui.

Sickle UI A widget library built on top of bevy's internal bevy_ui. Example If you clone the repository, you can simply build and run the main example

UmbraLuminosa 226 Jul 26, 2024
A lightweight terminal menu for Rust

youchoose A simple, easy to use command line menu for Rust. Usage There are two methods you need to be familiar with to get started: Menu::new which t

Nathan Thomas 143 Dec 21, 2022
A small utility that moves the start menu to the top-center of the screen in Windows 11.

TopCenterStart11 A small utility that moves the start menu to the top-center of the screen in Windows 11. As of right now, this application can only p

Ryan de Jonge 12 Nov 12, 2022
Menu Utilities for Desktop Applications in Rust.

muda Menu Utilities for Desktop Applications. Example Create the root menu and add submenus and men items. let mut menu = Menu::new(); let file_menu

Amr Bashir 28 Dec 16, 2022
Easy configurable tmux display-menu

tmux-easy-menu Easy configurable tmux display-menu Setup cargo build And run with ./target/debug/tmux-menu show --menu {path-to-your-config} Configu

null 18 Jan 23, 2023
A launcher/menu program written in Rust for wlroots-based Wayland compositors

tehda tehda (ᴛᴀʏ-dah /ˈteɪ̯.dæ/ or /teh.da/; Finnish for "to do, perform, execute") is a launcher/menu program, like dmenu, rofi, or wofi, written in

Nadia 4 Jan 29, 2023