From a8869f951cf8ec3a4a50492290c9ca757c968f49 Mon Sep 17 00:00:00 2001 From: William Morgan Date: Sun, 31 May 2009 08:58:16 -0700 Subject: [PATCH] yet another utf8 bugfix: fix string subsetting ... with a HORRIBLE SLOW HACK! --- lib/sup/buffer.rb | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb index 5672e3d..8eedf96 100644 --- 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 -- 2.45.2