Class: Rfd::CommandLineWindow
- Defined in:
- lib/rfd/windows.rb
Instance Method Summary collapse
- #get_command(prompt: nil) ⇒ Object
- #getstr_with_echo ⇒ Object
-
#initialize ⇒ CommandLineWindow
constructor
A new instance of CommandLineWindow.
- #set_prompt(str) ⇒ Object
- #show_error(str) ⇒ Object
Methods inherited from Window
Constructor Details
#initialize ⇒ CommandLineWindow
Returns a new instance of CommandLineWindow.
140 141 142 |
# File 'lib/rfd/windows.rb', line 140 def initialize super maxy: 1, maxx: Curses.cols, begy: Curses.lines - 1, begx: 0 end |
Instance Method Details
#get_command(prompt: nil) ⇒ Object
167 168 169 170 171 172 |
# File 'lib/rfd/windows.rb', line 167 def get_command(prompt: nil) startx = prompt ? prompt.size : 1 setpos 0, startx s = getstr_with_echo "#{prompt[1..-1] if prompt}#{s.strip}" end |
#getstr_with_echo ⇒ Object
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/rfd/windows.rb', line 150 def getstr_with_echo str = "" loop do case (c = Curses.getch) when 27 raise Interrupt when 10, 13 break else self << c refresh str << c end end str end |
#set_prompt(str) ⇒ Object
144 145 146 147 148 |
# File 'lib/rfd/windows.rb', line 144 def set_prompt(str) attron(Curses.color_pair(Curses::COLOR_WHITE) | Curses::A_BOLD) do writeln 0, str end end |
#show_error(str) ⇒ Object
174 175 176 177 178 179 |
# File 'lib/rfd/windows.rb', line 174 def show_error(str) attron(Curses.color_pair(Curses::COLOR_RED) | Curses::A_BOLD) do writeln 0, str end noutrefresh end |