class RSpecLive::Screen
Public Class Methods
new()
click to toggle source
# File lib/rspec-live/screen.rb, line 6 def initialize reset_curses Signal.trap("SIGWINCH", proc { reset_curses; @update_required = true }) end
Public Instance Methods
end_frame()
click to toggle source
# File lib/rspec-live/screen.rb, line 20 def end_frame Curses.refresh end
print(text, options = {})
click to toggle source
# File lib/rspec-live/screen.rb, line 24 def print(text, options = {}) color = options[:color] options[:width] = @width if options[:wrap] text = FormattedText.new(text, options).text if options.any? if color Curses.attron(color_attribute color) { Curses.addstr text } else Curses.addstr text end end
start_frame()
click to toggle source
# File lib/rspec-live/screen.rb, line 15 def start_frame Curses.clear Curses.setpos 0, 0 end
update_required?()
click to toggle source
# File lib/rspec-live/screen.rb, line 11 def update_required? @update_required end
Private Instance Methods
available_colors()
click to toggle source
# File lib/rspec-live/screen.rb, line 52 def available_colors [:blue, :green, :red, :yellow, :white] end
color_attribute(name)
click to toggle source
# File lib/rspec-live/screen.rb, line 60 def color_attribute(name) Curses.color_pair(color_constant name) | Curses::A_NORMAL end
color_constant(name)
click to toggle source
# File lib/rspec-live/screen.rb, line 56 def color_constant(name) Curses.const_get "COLOR_#{name.to_s.upcase}" end
reset_curses()
click to toggle source
# File lib/rspec-live/screen.rb, line 37 def reset_curses Curses.init_screen Curses.curs_set 0 Curses.clear Curses.refresh Curses.start_color Curses.use_default_colors available_colors.each do |name| Curses.init_pair color_constant(name), color_constant(name), -1 end @width = `tput cols`.to_i @height = `tput lines`.to_i Curses.resizeterm @height, @width end