Class: Ruvi::StatusBar
Instance Attribute Summary collapse
Attributes inherited from Widget
#buffer, #cursor, #parent
Instance Method Summary
collapse
Methods inherited from Widget
#watch_buffer
Constructor Details
#initialize(app, buffer) ⇒ StatusBar
Returns a new instance of StatusBar.
135
136
137
138
139
140
|
# File 'lib/widgets.rb', line 135
def initialize app, buffer
super app, buffer
@text = ""
@highlight_progress = nil
@needs_update = true
end
|
Instance Attribute Details
#highlight_progress=(p) ⇒ Object
Sets the attribute highlight_progress
134
135
136
|
# File 'lib/widgets.rb', line 134
def highlight_progress=(value)
@highlight_progress = value
end
|
#needs_update ⇒ Object
Returns the value of attribute needs_update.
133
134
135
|
# File 'lib/widgets.rb', line 133
def needs_update
@needs_update
end
|
#text ⇒ Object
Returns the value of attribute text.
133
134
135
|
# File 'lib/widgets.rb', line 133
def text
@text
end
|
Instance Method Details
#height ⇒ Object
153
|
# File 'lib/widgets.rb', line 153
def height; 1; end
|
#invalidate ⇒ Object
149
150
151
|
# File 'lib/widgets.rb', line 149
def invalidate
@needs_update = true
end
|
#render(y) ⇒ Object
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
# File 'lib/widgets.rb', line 157
def render y
return unless @needs_update
screen = canvas
current = (@app.current_buffer == @buffer)
screen.setpos y, 0 hl_prog_str = @highlight_progress.nil? || !current ? "" : "HL:#{"%0.2f" % (@highlight_progress * 100)}% "
pos_str = ":B(#{@buffer.bnum}:#{@buffer.fname})- #{@buffer.x},#{@buffer.y}:"
desc_str = hl_prog_str + pos_str
max_len = WinDescs::instance.descs[self].sx - 1 - desc_str.length
fg = current ? Curses::COLOR_RED : Curses::COLOR_CYAN
screen.set_attr true, fg, Curses::COLOR_BLACK
str = current ? @text[0, max_len].ljust(max_len) : (" " * max_len)
screen.addstr str + desc_str
@needs_update = false
end
|
#width ⇒ Object
152
|
# File 'lib/widgets.rb', line 152
def width; nil; end
|