Method: HackerTerm::UI#initialize

Defined in:
lib/hacker_term/ui.rb

#initialize(opts = {}) ⇒ UI

Returns a new instance of UI.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/hacker_term/ui.rb', line 7

def initialize(opts={})

  opts = defaults.merge(opts) # Ununsed for now

  raw # Intercept everything
  noecho # Do not echo user input to stdout
  stdscr.keypad(true) # Enable arrows

  if can_change_color?
    start_color
    # foreground / background colours
    init_pair(0, COLOR_WHITE, COLOR_BLACK)
    init_pair(1, COLOR_WHITE, COLOR_BLUE)
    init_pair(2, COLOR_WHITE, COLOR_RED)
    init_pair(3, COLOR_BLACK, COLOR_GREEN)
  end

  @total_width = cols
  @total_height = lines
  @padding_left = 2
  @title_width = 0
  @cols  = ['rank', 'title', 'score', 'comments']
  @line_num = -1

  clear!
end