class Window
Public Class Methods
create_color(code, r, g, b)
click to toggle source
# File lib/multish.rb, line 79 def self.create_color(code, r, g, b) @colors ||= {} new_index = 15 + @colors.count @colors[code] ||= [new_index, Curses.init_color(new_index, r, g, b)] @colors[code][0] end
create_color_pair(fg, bg)
click to toggle source
# File lib/multish.rb, line 86 def self.create_color_pair(fg, bg) index = "#{fg}/#{bg}" @pairs ||= {} new_index = 100 + @pairs.count @pairs[index] ||= [new_index, Curses.init_pair(new_index, fg, bg)] @pairs[index][0] end
new(height, width, top, left)
click to toggle source
# File lib/multish.rb, line 12 def initialize(height, width, top, left) @window = Curses::Window.new(height, width, top, left) @fgcolor = :black @bgcolor = :bright_white reset! end
screen_height()
click to toggle source
# File lib/multish.rb, line 23 def self.screen_height Curses.lines end
screen_width()
click to toggle source
# File lib/multish.rb, line 19 def self.screen_width Curses.cols end
Public Instance Methods
<<(str)
click to toggle source
# File lib/multish.rb, line 94 def <<(str) @window.addstr(str) end
bgcolor=(value)
click to toggle source
# File lib/multish.rb, line 44 def bgcolor=(value) @bgcolor = value update_color! end
bold=(value)
click to toggle source
# File lib/multish.rb, line 31 def bold=(value) if value @window.attron(Curses::A_BOLD) else @window.attroff(Curses::A_BOLD) end end
fgcolor=(value)
click to toggle source
# File lib/multish.rb, line 39 def fgcolor=(value) @fgcolor = value update_color! end
get_code(color)
click to toggle source
# File lib/multish.rb, line 56 def get_code(color) case color when :black Curses::COLOR_BLACK when :red Curses::COLOR_RED when :green Curses::COLOR_GREEN when :yellow Curses::COLOR_YELLOW when :blue Curses::COLOR_BLUE when :magenta Curses::COLOR_MAGENTA when :cyan Curses::COLOR_CYAN when :white Curses::COLOR_WHITE when :bright_white Window.create_color(:bright_white, 1000, 1000, 1000) end end
refresh!()
click to toggle source
# File lib/multish.rb, line 102 def refresh! @window.refresh end
reset!()
click to toggle source
# File lib/multish.rb, line 106 def reset! self.fgcolor = :black self.bgcolor = :bright_white self.bold = false end
scrollok(value)
click to toggle source
# File lib/multish.rb, line 98 def scrollok(value) @window.scrollok(value) end
setpos(x, y)
click to toggle source
# File lib/multish.rb, line 27 def setpos(x, y) @window.setpos(x, y) end
update_color!()
click to toggle source
# File lib/multish.rb, line 49 def update_color! fgcode = get_code(@fgcolor) bgcode = get_code(@bgcolor) code = Window.create_color_pair(fgcode, bgcode) @window.attron(Curses.color_pair(code)) end