commit a8869f951cf8ec3a4a50492290c9ca757c968f49
parent e47f06e891a073dbe7b8e66932923eb88bc5c3bd
Author: William Morgan <wmorgan-sup@masanjin.net>
Date: Sun, 31 May 2009 08:58:16 -0700
yet another utf8 bugfix: fix string subsetting
... with a HORRIBLE SLOW HACK!
Diffstat:
1 file changed, 10 insertions(+), 5 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