Class: VMTreeItemRenderer
- Inherits:
-
Object
- Object
- VMTreeItemRenderer
- Defined in:
- lib/VMTreeItemRenderer.rb
Instance Attribute Summary collapse
-
#display_length ⇒ Object
Returns the value of attribute display_length.
Instance Method Summary collapse
-
#initialize(parent, color_callback, w = nil) ⇒ VMTreeItemRenderer
constructor
A new instance of VMTreeItemRenderer.
- #repaint(graphic, r = nil, c = nil, idx = -1,, value = '', focussed = false, selected = false) ⇒ Object
Constructor Details
#initialize(parent, color_callback, w = nil) ⇒ VMTreeItemRenderer
Returns a new instance of VMTreeItemRenderer.
6 7 8 9 10 |
# File 'lib/VMTreeItemRenderer.rb', line 6 def initialize parent, color_callback, w=nil @parent = parent @color_callback = color_callback @display_length = w || 10 end |
Instance Attribute Details
#display_length ⇒ Object
Returns the value of attribute display_length.
4 5 6 |
# File 'lib/VMTreeItemRenderer.rb', line 4 def display_length @display_length end |
Instance Method Details
#repaint(graphic, r = nil, c = nil, idx = -1,, value = '', focussed = false, selected = false) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/VMTreeItemRenderer.rb', line 11 def repaint graphic, r=nil,c=nil, idx=-1,value='', focussed=false, selected=false return if r.nil? or c.nil? or idx == -1 attr = 'bold' bgcolor = focussed ? 'yellow' : 'black' fgcolor = @color_callback.call idx if fgcolor == 'grey' attr = nil fgcolor = 'white' end color_pair = ColorMap.get_color fgcolor, bgcolor # ensure we do not exceed if !@display_length.nil? value = value[0..@display_length-1] if value.length > @display_length end len = @display_length || value.length graphic.printstring r, c, '%-*s' % [len, value], color_pair, attr end |