Duy Nguyen <pclo...@gmail.com> writes:

> On Fri, Apr 18, 2014 at 3:44 PM, Jiang Xin <worldhello....@gmail.com> wrote:
>> When show blame information with relative time, the UTF-8 characters in
>> `time_str` will break the alignment of columns after the date field.
>> This is because the `time_buf` padding with spaces should have a
>> constant display width, not a fixed strlen size.  So we should call
>> utf8_strwidth() instead of strlen() for calibration.
>>
>> Signed-off-by: Jiang Xin <worldhello....@gmail.com>
>> ---
>>
>> Before applying this patch:
>>
>>         5817da01 builtin-blame.c   (Pierre Habouzit             6 年前         
>>                 21) #include "parse-options.h"
>>         ffaf9cc0 builtin-blame.c   (Geoffrey Thomas             5 年前         
>>                 22) #include "utf8.h"
>>         3b8a12e8 builtin/blame.c   (Axel Bonnet                 3 年 10 个月之前  
>>           23) #include "userdiff.h"
>>         25ed3412 builtin/blame.c   (Bo Yang                     1 年 1 个月之前   
>>           24) #include "line-range.h"
>>         58dbfa2e builtin/blame.c   (Eric Sunshine               9 个月之前       
>>             25) #include "line-log.h"
>>         cee7f245 builtin-pickaxe.c (Junio C Hamano              8 年前         
>>                 26)
>>
>> After applying this patch:
>>
>>         5817da01 builtin-blame.c   (Pierre Habouzit             6 年前         
>>                   21) #include "parse-options.h"
>>         ffaf9cc0 builtin-blame.c   (Geoffrey Thomas             5 年前         
>>                   22) #include "utf8.h"
>>         3b8a12e8 builtin/blame.c   (Axel Bonnet                 3 年 10 个月之前  
>>                23) #include "userdiff.h"
>>         25ed3412 builtin/blame.c   (Bo Yang                     1 年 1 个月之前   
>>                24) #include "line-range.h"
>>         58dbfa2e builtin/blame.c   (Eric Sunshine               9 个月之前       
>>                 25) #include "line-log.h"
>>         cee7f245 builtin-pickaxe.c (Junio C Hamano              8 年前         
>>                   26)
>
>
> The numbers 21..26 still do not look aligned, both in gmail raw
> message view and gmane.

Interesting.  In my GNUS/Emacs on a fixed-column terminal where an
CJK occupies two display columns, they do look aligned, but in my
Chrome showing news.gmane.org/gmane.comp.version-control.git/, they
do look jagged.  When these lines shown in the browser get copied
and pasted to gedit, they still look jagged, but after saving it to
a file and catting it to the same fixed-column terminal, they are
perfectly aligned.

Font issues, I guess?

>> +               /*
>> +                * Add space paddings to time_buf to display a fixed width
>> +                * string, and use time_col for display width calibration.
>> +                */
>> +               time_col = utf8_strwidth(time_str);
>> +               memset(time_buf + time_len, ' ', blame_date_width - 
>> time_col);
>> +               *(time_buf + time_len + blame_date_width - time_col) = 0;
>
> And you may want to turn time_buf[128] to strbuf as well while you're at it.

Good eyes.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to