Class: Ifilter::Window

Inherits:
Curses::Window
  • Object
show all
Defined in:
lib/ifilter/window.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Window

Returns a new instance of Window.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/ifilter/window.rb', line 5

def initialize(*args)
  @previous_colors = []

  Curses.init_screen
  Curses.start_color
  Curses.crmode
  Curses.noecho
  Curses.curs_set(0) # invisible
  Curses.init_pair(1, Curses::COLOR_WHITE, Curses::COLOR_BLACK) # default
  Curses.init_pair(2, Curses::COLOR_BLACK, Curses::COLOR_CYAN) # cursor position
  Curses.init_pair(3, Curses::COLOR_BLACK, Curses::COLOR_MAGENTA) # match string

  super

  self.keypad(true)
end

Instance Method Details

#attrset(color_pair) ⇒ Object



22
23
24
25
# File 'lib/ifilter/window.rb', line 22

def attrset(color_pair)
  @previous_colors << color_pair
  super
end

#attrunset(color_pair) ⇒ Object



27
28
29
30
# File 'lib/ifilter/window.rb', line 27

def attrunset(color_pair)
  @previous_colors.delete(color_pair)
  self.attrset(@previous_colors.pop)
end

#closeObject



32
33
34
# File 'lib/ifilter/window.rb', line 32

def close
  Curses.close_screen
end