Sha256: 530105304fe148fd25deacaf4bd45e1a17cccfe7cb9c0e41a59e1145a0291f87
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
require "curses" Curses.init_screen Curses.cbreak Curses.noecho Curses.stdscr.keypad = true at_exit do Curses.close_screen end fields = [ Curses::Field.new(1, 10, 4, 18, 0, 0), Curses::Field.new(1, 10, 6, 18, 0, 0) ] fields.each do |field| field.set_back(Curses::A_UNDERLINE) field.opts_off(Curses::O_AUTOSKIP) end form = Curses::Form.new(fields) form.post Curses.setpos(4, 10) Curses.addstr("Value 1:") Curses.setpos(6, 10) Curses.addstr("Value 2:") while ch = Curses.get_char begin case ch when Curses::KEY_F1 break when Curses::KEY_DOWN form.driver(Curses::REQ_NEXT_FIELD) form.driver(Curses::REQ_END_LINE) when Curses::KEY_UP form.driver(Curses::REQ_PREV_FIELD) form.driver(Curses::REQ_END_LINE) when Curses::KEY_RIGHT form.driver(Curses::REQ_NEXT_CHAR) when Curses::KEY_LEFT form.driver(Curses::REQ_PREV_CHAR) when Curses::KEY_BACKSPACE form.driver(Curses::REQ_DEL_PREV) else form.driver(ch) end rescue Curses::RequestDeniedError, Curses::UnknownCommandError end end form.unpost
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
curses-1.4.7 | sample/form.rb |
curses-1.4.6 | sample/form.rb |
curses-1.4.5 | sample/form.rb |