lib/sup/modes/scroll-mode.rb in sup-0.0.2 vs lib/sup/modes/scroll-mode.rb in sup-0.0.3

- old
+ new

@@ -75,25 +75,35 @@ @topline = @topline.clamp 0, lines - 1 @topline = 0 if @topline < 0 # empty @botline = [@topline + buffer.content_height, lines].min end + def resize *a + super *a + ensure_mode_validity + end + protected def draw_line ln, opts={} case(s = self[ln]) when String buffer.write ln - @topline, 0, s[@leftcol .. -1], :highlight => opts[:highlight] when Array xpos = 0 + + ## speed test + # str = s.map { |color, text| text }.join + # buffer.write ln - @topline, 0, str, :color => :none, :highlight => opts[:highlight] + # return + s.each do |color, text| - raise "nil text for color '#{color}'" if text.nil? + raise "nil text for color '#{color}'" if text.nil? # good for debugging if xpos + text.length < @leftcol buffer.write ln - @topline, 0, "", :color => color, :highlight => opts[:highlight] xpos += text.length - ## nothing elsif xpos < @leftcol ## partial buffer.write ln - @topline, 0, text[(@leftcol - xpos) .. -1], :color => color, :highlight => opts[:highlight]