Module: Curses

Defined in:
lib/cursesx.rb

Defined Under Namespace

Classes: Window

Class Method Summary collapse

Class Method Details

.color(name) ⇒ Object



73
74
75
# File 'lib/cursesx.rb', line 73

def color(name)
  color_pair(@@color[name])
end

.color_of(name) ⇒ Object

Symbol to color.



78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/cursesx.rb', line 78

def color_of(name)
  case name
  when :black; COLOR_BLACK
  when :red; COLOR_RED
  when :green; COLOR_GREEN
  when :yellow; COLOR_YELLOW
  when :blue; COLOR_BLUE
  when :magenta; COLOR_MAGENTA
  when :cyan; COLOR_CYAN
  when :white; COLOR_WHITE
  else raise ArgumentError, name
  end
end

.define_color(name, fg, bg) ⇒ Object



64
65
66
67
68
69
70
71
# File 'lib/cursesx.rb', line 64

def define_color(name, fg, bg)
  @@color ||= Hash.new
  val = @@color.values.sort.last || 0
  @@color[name] = val + 1
  fg = color_of(fg) if fg.kind_of?(Symbol)
  bg = color_of(bg) if bg.kind_of?(Symbol)
  init_pair(@@color[name], fg, bg)
end

.echoObject

Echo within the block.



41
42
43
44
45
46
47
48
49
50
# File 'lib/cursesx.rb', line 41

def echo
  if block_given?
    echo_orig
    res = yield
    noecho_orig
    return res
  else
    echo_orig
  end
end

.echo_origObject



35
# File 'lib/cursesx.rb', line 35

alias :echo_orig :echo

.noechoObject

Noecho within the block.



53
54
55
56
57
58
59
60
61
62
# File 'lib/cursesx.rb', line 53

def noecho
  if block_given?
    noecho_orig
    res = yield
    echo_orig
    return res
  else
    noecho_orig
  end
end

.noecho_origObject



36
# File 'lib/cursesx.rb', line 36

alias :noecho_orig :noecho

.standendObject

Standend within the block.



25
26
27
28
29
30
31
32
33
# File 'lib/cursesx.rb', line 25

def standend
  if block_given?
    standend_orig
    yield
    standout_orig
  else
    standend_orig
  end
end

.standend_origObject



11
# File 'lib/cursesx.rb', line 11

alias :standend_orig :standend

.standoutObject

Standout within the block.



14
15
16
17
18
19
20
21
22
# File 'lib/cursesx.rb', line 14

def standout
  if block_given?
    standout_orig
    yield
    standend_orig
  else
    standout_orig
  end
end

.standout_origObject



10
# File 'lib/cursesx.rb', line 10

alias :standout_orig :standout