class Rfd::CommandLineWindow
Public Class Methods
new()
click to toggle source
Calls superclass method
Rfd::Window::new
# File lib/rfd/windows.rb, line 140 def initialize super maxy: 1, maxx: Curses.cols, begy: Curses.lines - 1, begx: 0 end
Public Instance Methods
get_command(prompt: nil, default: nil)
click to toggle source
# File lib/rfd/windows.rb, line 181 def get_command(prompt: nil, default: nil) startx = prompt ? prompt.size : 1 setpos 0, startx s = getstr_with_echo default "#{prompt[1..-1] if prompt}#{s.strip}" end
getstr_with_echo(default = nil)
click to toggle source
# File lib/rfd/windows.rb, line 150 def getstr_with_echo(default = nil) str = default || ''.dup unless str.empty? self << str refresh end loop do case (c = Curses.getch) when 27, 3 # ESC, C-c raise Interrupt when 10, 13 break when 127, 263 # delete raise Interrupt if curx == 1 setpos cury, curx - 1 delch refresh str.chop! else Rfd.log "#{__method__}: #{c}" self << c refresh str << c end end str end
set_prompt(str)
click to toggle source
# 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)
click to toggle source
# File lib/rfd/windows.rb, line 188 def show_error(str) attron(Curses.color_pair(Curses::COLOR_RED) | Curses::A_BOLD) do writeln 0, str end noutrefresh end