Class: Rfd::CommandLineWindow

Inherits:
Window
  • Object
show all
Defined in:
lib/rfd/windows.rb

Instance Attribute Summary

Attributes inherited from Window

#window

Instance Method Summary collapse

Methods inherited from Window

#begx, #begy, #draw_border, #maxx, #maxy, #mvwaddstr, #subwin, #waddstr, #wclear, #wclrtoeol, #wmove, #wrefresh

Constructor Details

#initializeCommandLineWindow

Returns a new instance of CommandLineWindow.



211
212
213
# File 'lib/rfd/windows.rb', line 211

def initialize
  @window = subwin 1, Curses.COLS, Curses.LINES - 1, 0
end

Instance Method Details

#get_command(prompt: nil) ⇒ Object



223
224
225
226
227
228
229
230
231
# File 'lib/rfd/windows.rb', line 223

def get_command(prompt: nil)
  Curses.echo
  startx = prompt ? prompt.size : 1
  s = ' ' * 100
  Curses.mvwgetstr window, 0, startx, s
  "#{prompt[1..-1] if prompt}#{s.strip}"
ensure
  Curses.noecho
end

#set_prompt(str) ⇒ Object



215
216
217
218
219
220
221
# File 'lib/rfd/windows.rb', line 215

def set_prompt(str)
  Curses.wattr_set window, Curses::A_BOLD, Curses::COLOR_WHITE, nil
  wmove 0
  wclrtoeol
  waddstr str
  Curses.wstandend window
end

#show_error(str) ⇒ Object



233
234
235
236
237
238
239
240
# File 'lib/rfd/windows.rb', line 233

def show_error(str)
  Curses.wattr_set window, Curses::A_BOLD, Curses::COLOR_RED, nil
  wmove 0
  wclrtoeol
  waddstr str
  wrefresh
  Curses.wstandend window
end