class Pompom::NCursesScreen
Public Instance Methods
color_pair_mapping()
click to toggle source
# File lib/pompom.rb, line 229 def color_pair_mapping {:green => 1,:yellow => 2,:red => 3 } end
display(str, color=:green, blinking=false)
click to toggle source
# File lib/pompom.rb, line 212 def display(str, color=:green, blinking=false) clear text_style = blinking ? A_BLINK : A_NORMAL attr_set text_style, color_pair_mapping[color], nil y, x = getmaxyx(stdscr) lines = str.split("\n") padding = (x - lines.first.size) / 2 ((y - lines.size - 1) / 2).times { addstr("\n") } lines.each do |line| addstr(" " * padding) addstr(line + "\n") end refresh end
run() { || ... }
click to toggle source
# File lib/pompom.rb, line 196 def run begin initscr cbreak noecho start_color init_pair(1, COLOR_GREEN, COLOR_BLACK) init_pair(2, COLOR_YELLOW, COLOR_BLACK) init_pair(3, COLOR_RED, COLOR_BLACK) curs_set 0 yield ensure endwin end end