Crate termenu

Source
Expand description

A fzf-like library for terminal applications

You can use it to build a menu for selecting items from a list in terminal with ui. It supports both normal mode and query mode, and you can customize the colorscheme.

§Demo

demo

§Key Mapping

  • j/k or down/up to move the cursor
  • enter to select the item
  • / to enter query mode just like vim
  • ctrl-n/ctrl-p to move the cursor in query mode
  • esc to exit query mode or the menu
  • ctrl-c to exit the menu

§Examples

let mut menu = termenu::Menu::new().unwrap();
let mut item_list = Vec::new();
for i in 1..=10 {
   item_list.push(Item::new(format!("{}th item", i).as_str(), i));
}
let selection = menu
    .set_title("test selection:")
    .add_list(item_list)
    .select()
    .unwrap();
if let Some(selection) = selection {
   println!("You selected: {}", selection);
}

Check the examples folder for more details.

Structs§

Enums§