6 # We manage a set of attributes. Each attribute has a symbol name and a bit
12 @@name_to_bitmap = { :_SPECIAL_ => SPECIAL }
15 def self.bitmap_for(name)
16 bitmap = @@name_to_bitmap[name]
18 bitmap = @@next_bitmap
20 @@name_to_bitmap[name] = bitmap
25 def self.as_string(bitmap)
26 return "none" if bitmap.zero?
28 @@name_to_bitmap.each do |name, bit|
29 res << name if (bitmap & bit) != 0
34 def self.each_name_of(bitmap)
35 @@name_to_bitmap.each do |name, bit|
36 next if bit == SPECIAL
37 yield name.to_s if (bitmap & bit) != 0
42 AttrChanger = Struct.new(:turn_on, :turn_off)
45 # An AttrChanger records a change in attributes. It contains a bitmap of the
46 # attributes to turn on, and a bitmap of those to turn off.
50 "Attr: +#{Attribute.as_string(@turn_on)}/-#{Attribute.as_string(@turn_on)}"
55 # An array of attributes which parallels the characters in a string.
58 def initialize(length)
59 @attrs = Array.new(length, 0)
62 def set_attrs(start, length, bits)
63 for i in start ... (start+length)
74 # Hold details of a special sequence
80 def initialize(type, text)
81 @type, @text = type, text
85 self.text == o.text && self.type == o.type
89 "#<RDoc::Markup::Special:0x%x @type=%p, name=%p @text=%p>" % [
90 object_id, @type, RDoc::Markup::Attribute.as_string(type), text.dump]
94 "Special: type=#{type}, name=#{RDoc::Markup::Attribute.as_string type}, text=#{text.dump}"
101 require 'rdoc/markup/attribute_manager'