Reputation: 1282
I have an array of Names and URLs and would like to present the user with a list of the names in form of an up-/down-scrollable menu. Basically what dialog
allows within the shell.
I have looked into ncurses-ruby
, rdialog
and HighLine
but they all seem to be either abandoned as a project or throw errors even from their examples (if at all existent).
Could someone kindly point me to either a nice, usable gem that does TUI menus or a simple (I'll be new to this then...) introduction on how to to this in Rails (ie. presentation of available data (=what I have in my array)) and how to handle the user's choice?
Thank you!
Upvotes: 2
Views: 2229
Reputation: 4716
I think all of your proposals are valid, then there come more (n)curses wrappers, and more evolved framworks like rutui, rbcurse (unfortunately not active), vedeu and probably some others.
However, my take for now would be hirb or highline which are both stable and actively maintained.
Upvotes: 2
Reputation: 42207
Green shoes is a nice gem for this kind of work, it has menu's, selects, editboxes, filedialogs, checkboxes etc while being simple and having no dependencies other than Ruby itself.
There is a small but very active community with a mailing list to ask for help.
See http://vgoff.posterous.com/green-shoes for more info.
Installation is with gem install green_shoes
Here a small example
Shoes.app title: 'Selecteer vakantie', height: 600 do
background lightgreen..lightskyblue, :angle => 30
@list = ["choice1","choice2"]
@result = []
stack do
para "Make your choice.", font: "sans", size: 10
flow do
button "Ok" do
selected = @list.map{|c, n| n if c.checked?}.compact
@result[0].text = "you selected #{selected}"
end
button("End") {exit}
end
@list.map! do |name|
flow { @c = check; para name, width: 500, font: "sans", size: 10 }
[@c, name]
end
@result << para('', :stroke => forestgreen)
end
end
Upvotes: 1