From e3df7b775de899f9f49ef324249fab9e2859359f Mon Sep 17 00:00:00 2001 From: William Morgan Date: Sat, 30 May 2009 17:11:01 -0700 Subject: [PATCH] minor display optimization Don't blank to the right unless this is the last thing we're drawing in the line. Not sure how much of a speedup this will give, if any, but hey, precious milliseconds. --- lib/sup/modes/scroll-mode.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/sup/modes/scroll-mode.rb b/lib/sup/modes/scroll-mode.rb index 05fe201..7b21e57 100644 --- a/lib/sup/modes/scroll-mode.rb +++ b/lib/sup/modes/scroll-mode.rb @@ -219,8 +219,9 @@ protected def draw_line_from_array ln, a, opts xpos = 0 - a.each do |color, text| + a.each_with_index do |(color, text), i| raise "nil text for color '#{color}'" if text.nil? # good for debugging + no_fill = i != a.size - 1 if xpos + text.display_length < @leftcol buffer.write ln - @topline, 0, "", :color => color, @@ -230,11 +231,12 @@ protected ## partial buffer.write ln - @topline, 0, text[(@leftcol - xpos) .. -1], :color => color, - :highlight => opts[:highlight] + :highlight => opts[:highlight], :no_fill => no_fill xpos += text.display_length else buffer.write ln - @topline, xpos - @leftcol, text, - :color => color, :highlight => opts[:highlight] + :color => color, :highlight => opts[:highlight], + :no_fill => no_fill xpos += text.display_length end end -- 2.45.2