sup

A curses threads-with-tags style email client

sup.git

git clone https://supmua.dev/git/sup/
commit 31b9521aeccfbf183e519cec4b6b72f8a1d51ca0
parent f2890e0faa465fad4cefb06e70b8b7f1a51de237
Author: Michael Stapelberg <michael@stapelberg.de>
Date:   Tue,  9 Mar 2010 18:01:49 +0100

Correctly pad date strings, as they might contain utf-8 characters

sprintf is not utf8-aware and thus the output gets a wrong padding
(correct in terms of bytes, not correct in terms of visible characters).
You can notice this using a german locale (de_DE) and viewing mails
from march (abbreviated "M\xc3\xa4r" in german).

Diffstat:
M lib/sup/modes/thread-index-mode.rb | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/sup/modes/thread-index-mode.rb b/lib/sup/modes/thread-index-mode.rb
@@ -878,8 +878,11 @@ protected
 
     snippet = t.snippet + (t.snippet.empty? ? "" : "...")
 
-    size_widget_text = sprintf "%#{ @size_widget_width}s", size_widget
-    date_widget_text = sprintf "%#{ @date_widget_width}s", date_widget
+    size_padding = @size_widget_width - size_widget.display_length
+    size_widget_text = sprintf "%#{size_padding}s%s", "", size_widget
+
+    date_padding = @date_widget_width - date_widget.display_length
+    date_widget_text = sprintf "%#{date_padding}s%s", "", date_widget
 
     [ 
       [:tagged_color, @tags.tagged?(t) ? ">" : " "],