1 stable release
new 2.0.2 | Oct 30, 2024 |
---|---|
2.0.1 |
|
1.1.2 |
|
0.1.4 |
|
0.1.3 |
|
#174 in Command-line interface
243 downloads per month
33KB
781 lines
Termenu
fzf-like terminal ui api for rust
Demo
Examples
check examples folder
# basic example
cargo run --example basic
# complex example
cargo run --example complex
Basic Usage
fn main() {
let mut menu = termenu::Menu::new().unwrap();
let mut item_list = Vec::new();
for i in 1..=10 {
item_list.push(termenu::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);
}
}
NOTE
- Currently, termenu does not support window resizing.
lib.rs
:
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
Key Mapping
j
/k
ordown
/up
to move the cursorenter
to select the item/
to enter query mode just like vimctrl-n
/ctrl-p
to move the cursor in query modeesc
to exit query mode or the menuctrl-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.
Dependencies
~4–12MB
~166K SLoC