Class: Eclair::Cell
Instance Attribute Summary collapse
Instance Method Summary
collapse
#config, included
Constructor Details
#initialize(*args) ⇒ Cell
Returns a new instance of Cell.
8
9
10
11
|
# File 'lib/eclair/cell.rb', line 8
def initialize *args
@current = false
@selected = false
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &blk) ⇒ Object
97
98
99
|
# File 'lib/eclair/cell.rb', line 97
def method_missing name, *args, &blk
object.send(name)
end
|
Instance Attribute Details
#column ⇒ Object
Returns the value of attribute column.
5
6
7
|
# File 'lib/eclair/cell.rb', line 5
def column
@column
end
|
#selected ⇒ Object
Returns the value of attribute selected.
6
7
8
|
# File 'lib/eclair/cell.rb', line 6
def selected
@selected
end
|
Instance Method Details
73
74
75
76
77
|
# File 'lib/eclair/cell.rb', line 73
def check_scroll
unless column.drawable? y
column.rescroll y
end
end
|
#color(*color) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/eclair/cell.rb', line 13
def color(*color)
if @current
color = config.current_color
elsif @selected
color = config.selected_color
end
if Grid.mode == :search && @current
color = config.search_color
end
Color.fetch(*color)
end
|
#current ⇒ Object
67
68
69
70
71
|
# File 'lib/eclair/cell.rb', line 67
def current
@current = true
check_scroll
redraw
end
|
#decurrent ⇒ Object
79
80
81
82
|
# File 'lib/eclair/cell.rb', line 79
def decurrent
@current = false
redraw
end
|
#deselect ⇒ Object
39
40
41
42
43
|
# File 'lib/eclair/cell.rb', line 39
def deselect
@selected = false
Grid.selected.delete self
redraw
end
|
#redraw ⇒ Object
84
85
86
87
|
# File 'lib/eclair/cell.rb', line 84
def redraw
render
refresh
end
|
#render(options = 0) ⇒ Object
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/eclair/cell.rb', line 27
def render options = 0
drawy = y - column.scroll
return if drawy < 0 || drawy >= Grid.maxy
w = Grid.cell_width
setpos(drawy + Grid::HEADER_ROWS, x * w)
str = format.slice(0, w).ljust(w)
attron(color) do
addstr(str)
end
Grid.
end
|
#select ⇒ Object
45
46
47
48
49
|
# File 'lib/eclair/cell.rb', line 45
def select
@selected = true
Grid.selected << self
redraw
end
|
#select_indicator ⇒ Object
89
90
91
92
93
94
95
|
# File 'lib/eclair/cell.rb', line 89
def select_indicator
if @selected
if Grid.mode == :select
"*"
end
end
end
|
#toggle_select ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/eclair/cell.rb', line 51
def toggle_select
if respond_to? :each
if all?(&:selected)
each(&:deselect)
else
each(&:select)
end
else
if @selected
deselect
else
select
end
end
end
|