2017-11-27 05:45:24 -05:00
|
|
|
# frozen_string_literal: true
|
2012-11-26 23:28:14 -05:00
|
|
|
##
|
|
|
|
# An array of attributes which parallels the characters in a string.
|
|
|
|
|
|
|
|
class RDoc::Markup::AttrSpan
|
|
|
|
|
|
|
|
##
|
|
|
|
# Creates a new AttrSpan for +length+ characters
|
|
|
|
|
2021-03-14 05:26:19 -04:00
|
|
|
def initialize(length, exclusive)
|
2012-11-26 23:28:14 -05:00
|
|
|
@attrs = Array.new(length, 0)
|
2021-03-14 05:26:19 -04:00
|
|
|
@exclusive = exclusive
|
2012-11-26 23:28:14 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Toggles +bits+ from +start+ to +length+
|
|
|
|
def set_attrs(start, length, bits)
|
2021-03-14 05:26:19 -04:00
|
|
|
updated = false
|
2012-11-26 23:28:14 -05:00
|
|
|
for i in start ... (start+length)
|
2021-03-16 06:01:50 -04:00
|
|
|
if (@exclusive & @attrs[i]) == 0 || (@exclusive & bits) != 0
|
2021-03-14 05:26:19 -04:00
|
|
|
@attrs[i] |= bits
|
|
|
|
updated = true
|
|
|
|
end
|
2012-11-26 23:28:14 -05:00
|
|
|
end
|
2021-03-14 05:26:19 -04:00
|
|
|
updated
|
2012-11-26 23:28:14 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Accesses flags for character +n+
|
|
|
|
|
|
|
|
def [](n)
|
|
|
|
@attrs[n]
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|