sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 2a76b64f19a08d8ddb912a6004f5a31dfe1a7c5f
parent b0db013fc3bb4a004c195072588a36388a7bfb55
Author: Whyme Lyu <callme5long@gmail.com>
Date:   Sun, 30 Jun 2013 16:03:25 +0800

Use slice_by_display_length in Buffer#write

Diffstat:
M lib/sup/buffer.rb | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/lib/sup/buffer.rb b/lib/sup/buffer.rb
@@ -126,14 +126,11 @@ class Buffer
     @w.attrset Colormap.color_for(opts[:color] || :none, opts[:highlight])
     s ||= ""
     maxl = @width - x # maximum display width width
-    stringl = maxl    # string "length"
 
     # fill up the line with blanks to overwrite old screen contents
     @w.mvaddstr y, x, " " * maxl unless opts[:no_fill]
 
-    ## 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]
+    @w.mvaddstr y, x, s.slice_by_display_length(maxl)
   end
 
   def clear