Class: Rfd::CommandLineWindow
Constant Summary
Constants inherited from Window
Window::ACS_BTEE, Window::ACS_HLINE, Window::ACS_LLCORNER, Window::ACS_LRCORNER, Window::ACS_LTEE, Window::ACS_RTEE, Window::ACS_TTEE, Window::ACS_ULCORNER, Window::ACS_URCORNER, Window::ACS_VLINE
Instance Attribute Summary
Attributes inherited from Window
Instance Method Summary collapse
- #get_command(prompt: nil) ⇒ Object
-
#initialize ⇒ CommandLineWindow
constructor
A new instance of CommandLineWindow.
- #set_prompt(str) ⇒ Object
- #show_error(str) ⇒ Object
Methods inherited from Window
#begx, #begy, draw_borders, #maxx, #maxy, #waddstr, #wclear, #wmove, #wrefresh
Constructor Details
#initialize ⇒ CommandLineWindow
Returns a new instance of CommandLineWindow.
236 237 238 |
# File 'lib/rfd/windows.rb', line 236 def initialize @window = Curses.stdscr.subwin 1, Curses.cols, Curses.lines - 1, 0 end |
Instance Method Details
#get_command(prompt: nil) ⇒ Object
248 249 250 251 252 253 254 255 256 |
# File 'lib/rfd/windows.rb', line 248 def get_command(prompt: nil) Curses.echo startx = prompt ? prompt.size : 1 window.setpos 0, startx s = window.getstr "#{prompt[1..-1] if prompt}#{s.strip}" ensure Curses.noecho end |
#set_prompt(str) ⇒ Object
240 241 242 243 244 245 246 |
# File 'lib/rfd/windows.rb', line 240 def set_prompt(str) window.attron(Curses.color_pair(Curses::COLOR_WHITE) | Curses::A_BOLD) do wmove 0 window.clrtoeol waddstr str end end |
#show_error(str) ⇒ Object
258 259 260 261 262 263 264 265 |
# File 'lib/rfd/windows.rb', line 258 def show_error(str) window.attron(Curses.color_pair(Curses::COLOR_RED) | Curses::A_BOLD) do wmove 0 window.clrtoeol waddstr str end wrefresh end |