]> git.cworth.org Git - sup/commitdiff
minor display_length optimization
authorWilliam Morgan <wmorgan-sup@masanjin.net>
Sun, 31 May 2009 15:57:56 +0000 (08:57 -0700)
committerWilliam Morgan <wmorgan-sup@masanjin.net>
Sun, 31 May 2009 15:59:09 +0000 (08:59 -0700)
lib/sup/modes/scroll-mode.rb

index 7b21e5755a6ab9bfa1a5f087f030a6f60a993576..63b48ec00edd6e7b7cc50bd82b51d8b00c7c7ed9 100644 (file)
@@ -221,24 +221,23 @@ protected
     xpos = 0
     a.each_with_index do |(color, text), i|
       raise "nil text for color '#{color}'" if text.nil? # good for debugging
+      l = text.display_length
       no_fill = i != a.size - 1
       
-      if xpos + text.display_length < @leftcol
+      if xpos + l < @leftcol
         buffer.write ln - @topline, 0, "", :color => color,
                      :highlight => opts[:highlight]
-        xpos += text.display_length
       elsif xpos < @leftcol
         ## partial
         buffer.write ln - @topline, 0, text[(@leftcol - xpos) .. -1],
                      :color => color,
                      :highlight => opts[:highlight], :no_fill => no_fill
-        xpos += text.display_length
       else
         buffer.write ln - @topline, xpos - @leftcol, text,
                      :color => color, :highlight => opts[:highlight],
                      :no_fill => no_fill
-        xpos += text.display_length
       end
+      xpos += l
     end
   end