From: William Morgan Date: Sun, 31 May 2009 15:58:16 +0000 (-0700) Subject: yet another utf8 bugfix: fix string subsetting X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=a8869f951cf8ec3a4a50492290c9ca757c968f49;p=sup yet another utf8 bugfix: fix string subsetting ... with a HORRIBLE SLOW HACK! --- 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