From: Junio C Hamano <gitster@pobox•com>
To: Duy Nguyen <pclouds@gmail•com>
Cc: Jiang Xin <worldhello.net@gmail•com>,
Brian Gesiak <modocache@gmail•com>,
Git List <git@vger•kernel.org>
Subject: Re: [PATCH] blame: add correct paddings in time_buf for align
Date: Fri, 18 Apr 2014 10:08:23 -0700 [thread overview]
Message-ID: <xmqqd2ged0qg.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <CACsJy8BTBwqFZUU3i3cuv40B6AHw5SRY9DZN2PoKL4XzgEL2eA@mail.gmail.com> (Duy Nguyen's message of "Fri, 18 Apr 2014 21:42:22 +0700")
Duy Nguyen <pclouds@gmail•com> writes:
> On Fri, Apr 18, 2014 at 3:44 PM, Jiang Xin <worldhello.net@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.net@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.
next prev parent reply other threads:[~2014-04-18 17:09 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-18 8:44 [PATCH] blame: add correct paddings in time_buf for align Jiang Xin
2014-04-18 14:42 ` Duy Nguyen
2014-04-18 17:08 ` Junio C Hamano [this message]
2014-04-19 0:20 ` Duy Nguyen
2014-04-20 16:13 ` [PATCH v2 0/2] peroper align of datetime filed of git-blame Jiang Xin
2014-04-20 16:13 ` [PATCH v2 1/2] bugfix: fix broken time_buf paddings for git-blame Jiang Xin
2014-04-20 20:28 ` Eric Sunshine
2014-04-20 16:13 ` [PATCH v2 2/2] blame: use different blame_date_width for different locale Jiang Xin
2014-04-20 21:40 ` Junio C Hamano
2014-04-21 6:02 ` [PATCH v3 0/2] peroper align of datetime filed of git-blame Jiang Xin
2014-04-21 6:02 ` [PATCH v3 1/2] bugfix: fix broken time_buf paddings for git-blame Jiang Xin
2014-04-21 6:02 ` [PATCH v3 2/2] blame: use a helper to get suitable blame_date_width Jiang Xin
2014-04-21 17:20 ` Junio C Hamano
2014-04-21 19:19 ` Junio C Hamano
2014-04-22 12:25 ` Jiang Xin
2014-04-22 14:39 ` [PATCH v4 0/2] peroper align of datetime filed of git-blame Jiang Xin
2014-04-22 14:39 ` [PATCH v4 1/2] bugfix: fix broken time_buf paddings for git-blame Jiang Xin
2014-04-22 14:39 ` [PATCH v4 2/2] blame: dynamic blame_date_width for different locales Jiang Xin
2014-04-22 10:01 ` [PATCH v2 2/2] blame: use different blame_date_width for different locale David Kastrup
2014-04-22 12:16 ` Jiang Xin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqd2ged0qg.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=modocache@gmail$(echo .)com \
--cc=pclouds@gmail$(echo .)com \
--cc=worldhello.net@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox