lib/ruco/style_map.rb in ruco-0.1.14 vs lib/ruco/style_map.rb in ruco-0.2.0.beta
- old
+ new
@@ -1,8 +1,8 @@
module Ruco
class StyleMap
- attr_accessor :lines
+ attr_accessor :lines, :foreground, :background
def initialize(lines)
@lines = Array.new(lines)
end
@@ -18,23 +18,22 @@
def flatten
@lines.map do |styles|
next unless styles
- # start and one after end of every column-range changes styles
- points_of_change = styles.map{|s,c| [c.first, c.last+1] }.flatten.uniq
+ # change to style at start and recalculate one after the end
+ points_of_change = styles.map{|s,c| [c.first, c.last_element+1] }.flatten.uniq
flat = []
- styles.each do |style, columns|
- points_of_change.each do |point|
+ points_of_change.each do |point|
+ flat[point] = :normal # set default
+ styles.each do |style, columns|
next unless columns.include?(point)
flat[point] = style
end
end
- max = styles.map{|_,columns| columns.last }.max
- flat[max+1] = :normal
flat
end
end
def left_pad!(offset)