Class: Pompom::NCursesScreen
- Inherits:
-
Object
- Object
- Pompom::NCursesScreen
- Includes:
- FFI::NCurses
- Defined in:
- lib/pompom.rb
Instance Method Summary collapse
Instance Method Details
#color_pair_mapping ⇒ Object
229 230 231 |
# File 'lib/pompom.rb', line 229 def color_pair_mapping {:green => 1,:yellow => 2,:red => 3 } end |
#display(str, color = :green, blinking = false) ⇒ Object
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
# 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 ⇒ Object
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# 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 |