Class: Kang::Tags

Inherits:
Object
  • Object
show all
Defined in:
lib/kang/tags.rb

Instance Method Summary collapse

Constructor Details

#initialize(view) ⇒ Tags

Returns a new instance of Tags.



17
18
19
20
21
# File 'lib/kang/tags.rb', line 17

def initialize(view)
  @view=view
  @colors = Colors.new(5,range: 65545)
  @tags = {}
end

Instance Method Details

#[](i) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/kang/tags.rb', line 23

def[](i)
  tag = nil
  begin
    tag_name = "color#{i}"
    tag =  @tags.fetch(tag_name)
  rescue KeyError
    c = @colors[i]
    color = Gdk::Color.new(*c)
    tag = Gtk::TextTag.new(tag_name)
    tag.foreground='black'
    tag.background_gdk=color
    @tags[tag_name] = tag
    @view.buffer.tag_table.add(tag)
  end
  tag
end