在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:nick-paul/TerminalMenus.jl开源软件地址:https://github.com/nick-paul/TerminalMenus.jl开源编程语言:Julia 100.0%开源软件介绍:Ships with Julia now!This package has been
merged
into the Julia standard
library.
As such, you probably just want to TerminalMenusTerminalMenus.jl enables small, low-profile interactive menus in the terminal. InstallationTerminalMenus requires Julia 0.6. Use
Examplesusing TerminalMenus
options = ["apple", "orange", "grape", "strawberry",
"blueberry", "peach", "lemon", "lime"]
RadioMenuThe RadioMenu allows the user to select one option from the list. The # `pagesize` is the number of items to be displayed at a time.
# The UI will scroll if the number of options is greater
# than the `pagesize`
menu = RadioMenu(options, pagesize=4)
# `request` displays the menu and returns the index after the
# user has selected a choice
choice = request("Choose your favorite fruit:", menu)
if choice != -1
println("Your favorite fruit is ", options[choice], "!")
else
println("Menu canceled.")
end
Output:
MultiSelectMenuThe MultiSelectMenu allows users to select many choices from a list. # here we use the default `pagesize` 10
menu = MultiSelectMenu(options)
# `request` returns a `Set` of selected indices
# if the menu us canceled (ctrl-c or q), return an empty set
choices = request("Select the fruits you like:", menu)
if length(choices) > 0
println("You like the following fruits:")
for i in choices
println(" - ", options[i])
end
else
println("Menu canceled.")
end Output:
Customization / ConfiguationAll interface customization is done through the keyword only
Arguments
Examplesjulia> menu = MultiSelectMenu(options, pagesize=5);
julia> request(menu) # ASCII is used by default
[press: d=done, a=all, n=none]
[ ] apple
[X] orange
[ ] grape
> [X] strawberry
v [ ] blueberry
Set([4, 2])
julia> TerminalMenus.config(charset=:unicode)
julia> request(menu)
[press: d=done, a=all, n=none]
⬚ apple
✓ orange
⬚ grape
→ ✓ strawberry
↓ ⬚ blueberry
Set([4, 2])
julia> TerminalMenus.config(checked="YEP!", unchecked="NOPE", cursor='⧐')
julia> request(menu)
[press: d=done, a=all, n=none]
NOPE apple
YEP! orange
NOPE grape
⧐ YEP! strawberry
↓ NOPE blueberry
Set([4, 2])
TODO
The interactive menu has been tested on Ubuntu 16.04 and windows 7, 8, & 10. If there are any issues on your platform, please submit an issue or a pull request. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论