All Projects → nick-paul → Terminalmenus.jl

nick-paul / Terminalmenus.jl

Licence: other
Simple interactive menus for the terminal (Now ships with Julia!)

Programming Languages

julia
2034 projects

Labels

Projects that are alternatives of or similar to Terminalmenus.jl

Termloop
Terminal-based game engine for Go, built on top of Termbox
Stars: ✭ 1,190 (+1369.14%)
Mutual labels:  terminal
Tty Prompt
A beautiful and powerful interactive command line prompt
Stars: ✭ 1,210 (+1393.83%)
Mutual labels:  terminal
Window Size
Reliable way to to get the height and width of the terminal/console in a node.js environment.
Stars: ✭ 79 (-2.47%)
Mutual labels:  terminal
Revery Terminal
Barebones terminal emulator built with ReasonML + Revery + libvterm
Stars: ✭ 76 (-6.17%)
Mutual labels:  terminal
Term Web
📟 A simple Terminal UI that run on the web
Stars: ✭ 77 (-4.94%)
Mutual labels:  terminal
Mac Zsh Completions
macOS specific additional completion definitions for Zsh.
Stars: ✭ 79 (-2.47%)
Mutual labels:  terminal
Colors
List of 256 color codes for Xterm including an example of the color, Xterm Name, Xterm Number, HEX, RGB and HSL code.
Stars: ✭ 73 (-9.88%)
Mutual labels:  terminal
Turbo
An experimental text editor based on Scintilla and Turbo Vision.
Stars: ✭ 78 (-3.7%)
Mutual labels:  terminal
Taskline
Tasks, boards & notes for the command-line habitat
Stars: ✭ 78 (-3.7%)
Mutual labels:  terminal
Alfred Ssh
SSH workflow for Alfred for Mac with powerful hostname expansion/completion
Stars: ✭ 78 (-3.7%)
Mutual labels:  terminal
I3 Quickterm
A small drop-down terminal for i3 and sway
Stars: ✭ 76 (-6.17%)
Mutual labels:  terminal
Linuxspells
✨ Potter-ify your Linux experience! ::
Stars: ✭ 77 (-4.94%)
Mutual labels:  terminal
Javascript Terminal
JavaScript terminal emulator library that works in your browser and Node.js
Stars: ✭ 79 (-2.47%)
Mutual labels:  terminal
Navi
An interactive cheatsheet tool for the command-line
Stars: ✭ 10,055 (+12313.58%)
Mutual labels:  terminal
Mpb
multi progress bar for Go cli applications
Stars: ✭ 1,221 (+1407.41%)
Mutual labels:  terminal
Nodo
☑ Command line TODO app
Stars: ✭ 73 (-9.88%)
Mutual labels:  terminal
Xa
Beautiful & Customizable logger ❤️
Stars: ✭ 78 (-3.7%)
Mutual labels:  terminal
Lehar
Visualize data using relative ordering
Stars: ✭ 81 (+0%)
Mutual labels:  terminal
Awesome Terminals
Terminal Emulators
Stars: ✭ 80 (-1.23%)
Mutual labels:  terminal
Nord Terminator
An arctic, north-bluish clean and elegant Terminator color theme.
Stars: ✭ 78 (-3.7%)
Mutual labels:  terminal

Ships with Julia now!

This package has been merged into the Julia standard library. As such, you probably just want to using REPL.TerminalMenus and skip the Installation instructions below.

TerminalMenus

Build Status Build status

Demo

TerminalMenus.jl enables small, low-profile interactive menus in the terminal.

Installation

TerminalMenus requires Julia 0.6. Use Pkg to install:

Pkg.add("TerminalMenus")

Examples

using TerminalMenus

options = ["apple", "orange", "grape", "strawberry",
            "blueberry", "peach", "lemon", "lime"]

RadioMenu

The RadioMenu allows the user to select one option from the list. The request function displays the interactive menu and returns the index of the selected choice. If a user presses 'q' or ctrl-c, request will return a -1.

# `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:

Choose your favorite fruit:
^  grape
   strawberry
 > blueberry
v  peach
Your favorite fruit is blueberry!

MultiSelectMenu

The 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:

Select the fruits you like:
[press: d=done, a=all, n=none]
   [ ] apple
 > [X] orange
   [X] grape
   [ ] strawberry
   [ ] blueberry
   [X] peach
   [ ] lemon
   [ ] lime
You like the following fruits:
  - orange
  - grape
  - peach

Customization / Configuation

All interface customization is done through the keyword only TerminalMenus.config() function.

Arguments

  • charset::Symbol=:na: ui characters to use (:ascii or :unicode); overridden by other arguments
  • cursor::Char='>'|'→': character to use for cursor
  • up_arrow::Char='^'|'↑': character to use for up arrow
  • down_arrow::Char='v'|'↓': character to use for down arrow
  • checked::String="[X]"|"✓": string to use for checked
  • unchecked::String="[ ]"|"⬚"): string to use for unchecked
  • scroll::Symbol=:na: If :wrap then wrap the cursor around top and bottom, if :nowrap do not wrap cursor
  • supress_output::Bool=false: For testing. If true, menu will not be printed to console.
  • ctrl_c_interrupt::Bool=true: If false, return empty on ^C, if true throw InterruptException() on ^C

Examples

julia> 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

  • Nested menus
  • More customization?

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].