class PPCurses::RadioMenu
noinspection RubyResolve
Public Class Methods
new( menu_items, action_items=nil )
click to toggle source
TODO - duplicate code from Menu
…
# File lib/ppcurses/menu/RadioMenu.rb, line 6 def initialize( menu_items, action_items=nil ) @items = Array.new @actions = Array.new @menu_length = 0 menu_items.each do |item| @items.push item @menu_length += item.length + 5 end @selection = 0 unless action_items.nil? action_items.each do |item| @actions.push item end end w_width = @menu_length + 4 @win = Window.new(3, w_width ,0, (Curses.cols - w_width) / 2) @win.timeout=-1 # Enables reading arrow keys in getch @win.keypad(true) end
Public Instance Methods
show()
click to toggle source
# File lib/ppcurses/menu/RadioMenu.rb, line 35 def show @win.box('|', '-') y = 1 x = 2 @win.setpos(y, x) for i in 0...@items.length @win.addstr( @items[i] ) if @selection == i then @win.addstr(' [*] ') else @win.addstr(' [ ] ') end end @win.refresh end