def ask_getch question, accept=nil
raise "impossible!" if @asking
accept = accept.split(//).map { |x| x.ord } if accept
status, title = get_status_and_title @focus_buf
Ncurses.sync do
draw_screen :sync => false, :status => status, :title => title
Ncurses.mvaddstr Ncurses.rows - 1, 0, question
Ncurses.move Ncurses.rows - 1, question.length + 1
Ncurses.curs_set 1
Ncurses.refresh
end
@asking = true
ret = nil
done = false
until done
key = Ncurses.safe_nonblocking_getch or next
if key == Ncurses::KEY_CANCEL
done = true
elsif accept.nil? || accept.empty? || accept.member?(key)
ret = key
done = true
end
end
@asking = false
Ncurses.sync do
Ncurses.curs_set 0
draw_screen :sync => false, :status => status, :title => title
end
ret
end