Class: Cliptic::Screen

Inherits:
Object
  • Object
show all
Extended by:
Curses
Defined in:
lib/cliptic.rb

Class Method Summary collapse

Class Method Details

.clearObject



31
32
33
34
# File 'lib/cliptic.rb', line 31

def self.clear
  stdscr.clear
  stdscr.refresh
end

.init_cursesObject



17
18
19
20
21
22
# File 'lib/cliptic.rb', line 17

def self.init_curses
  init_screen
  raw
  noecho
  curs_set(0)
end

.redraw(cb: nil) ⇒ Object



38
39
40
41
42
# File 'lib/cliptic.rb', line 38

def self.redraw(cb:nil)
  Interface::Resizer.new.show if Screen.too_small?
  Screen.clear
  cb.call if cb
end

.set_colorsObject



23
24
25
26
27
28
29
30
# File 'lib/cliptic.rb', line 23

def self.set_colors
  start_color
  use_default_colors
  1.upto(8) do |i|
    init_pair(i, i, -1)
    init_pair(i+8, 0, i)
  end
end

.setupObject



12
13
14
15
16
# File 'lib/cliptic.rb', line 12

def self.setup
  init_curses
  set_colors if has_colors?
  redraw
end

.too_small?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/cliptic.rb', line 35

def self.too_small?
  lines < 36 || cols < 61
end