Module: RTask::UI::CursesInterface::Display
- Defined in:
- lib/rtask/ui/curses.rb
Overview
Display window for showing messages.
Instance Method Summary collapse
-
#<<(msg) ⇒ Object
Show the message.
- #draw ⇒ Object
-
#input(msg, val = "") ⇒ Object
Wait to input a line.
-
#input_char(msg) ⇒ Object
Wait to input a character.
Instance Method Details
#<<(msg) ⇒ Object
Show the message.
82 83 84 85 86 87 |
# File 'lib/rtask/ui/curses.rb', line 82 def <<(msg) clear setpos(0, 0) addstr(msg.to_s.ljust(maxx)) refresh end |
#draw ⇒ Object
79 |
# File 'lib/rtask/ui/curses.rb', line 79 def draw; clear; end |
#input(msg, val = "") ⇒ Object
Wait to input a line.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/rtask/ui/curses.rb', line 90 def input(msg, val = "") clear setpos(0, 0) refresh # setup io config tio = Termios.getattr(STDIN) tio.lflag |= Termios::ECHO Termios.setattr(STDIN, Termios::TCSANOW, tio) # read Readline::HISTORY << val.to_s res = Readline.readline("> #{msg}: ") # restore io config tio.lflag &= ~Termios::ECHO Termios.setattr(STDIN, Termios::TCSANOW, tio) return res end |
#input_char(msg) ⇒ Object
Wait to input a character.
112 113 114 115 116 117 118 |
# File 'lib/rtask/ui/curses.rb', line 112 def input_char(msg) clear setpos(0, 0) addstr("> #{msg}: ") refresh return echo { getch } end |