commit c89a592127fc203103563b6fe4ad36670da6da0d
parent 9ab475377047f0ab3df02dbc4446be0855247852
Author: William Morgan <wmorgan-sup@masanjin.net>
Date: Sun, 31 May 2009 08:59:19 -0700
Merge branch 'master' into next
Diffstat:
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
@@ -108,11 +108,16 @@ class Buffer
@w.attrset Colormap.color_for(opts[:color] || :none, opts[:highlight])
s ||= ""
- maxl = @width - x
- @w.mvaddstr y, x, s[0 ... maxl]
- l = s.display_length
- unless l >= maxl || opts[:no_fill]
- @w.mvaddstr(y, x + l, " " * (maxl - l))
+ maxl = @width - x # maximum display width width
+ stringl = maxl # string "length"
+ ## the next horribleness is thanks to ruby's lack of widechar support
+ stringl += 1 while stringl < s.length && s[0 ... stringl].display_length < maxl
+ @w.mvaddstr y, x, s[0 ... stringl]
+ unless opts[:no_fill]
+ l = s.display_length
+ unless l >= maxl
+ @w.mvaddstr(y, x + l, " " * (maxl - l))
+ end
end
end
diff --git a/lib/sup/modes/scroll-mode.rb b/lib/sup/modes/scroll-mode.rb
@@ -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