From: Eric Sunshine <sunshine@sunshineco.com>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: Git List <git@vger.kernel.org>,
Christian Couder <christian.couder@gmail.com>,
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH v9 03/11] ref-filter: implement an `align` atom
Date: Sun, 9 Aug 2015 04:04:00 -0400 [thread overview]
Message-ID: <CAPig+cT=uUp5T1W1-CBrx4ZMsTSdpoghg57affU3JZ3Uvq20Pw@mail.gmail.com> (raw)
In-Reply-To: <CAOLa=ZQW1HBACAb4V_jMky4=54=rxqS=nyYMBX1CUUvA2c0s9A@mail.gmail.com>
On Sun, Aug 9, 2015 at 2:55 AM, Karthik Nayak <karthik.188@gmail.com> wrote:
> On Sun, Aug 9, 2015 at 9:12 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
>> On Sat, Aug 8, 2015 at 2:35 AM, Karthik Nayak <karthik.188@gmail.com> wrote:
>>> On Fri, Aug 7, 2015 at 8:57 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
>>>> On Wed, Aug 5, 2015 at 2:54 PM, Karthik Nayak <karthik.188@gmail.com> wrote:
>>>>> + else if (align->align_type == ALIGN_MIDDLE) {
>>>>> + int right = (align->align_value - buf_len)/2;
>>>>> + strbuf_addf(final, "%*s%-*s", align->align_value - right + len,
>>>>> + value->buf, right, "");
>>>>
>>>> An aesthetic aside: When (align_value - buf_len) is an odd number,
>>>> this implementation favors placing more whitespace to the left of the
>>>> string, and less to the right. In practice, this often tends to look a
>>>> bit more awkward than the inverse of placing more whitespace to the
>>>> right, and less to the left (but that again is subjective).
>>>
>>> I know that, maybe we could add an additional padding to even out the value
>>> given?
>>
>> I don't understand your question. I was merely suggesting (purely
>> subjectively), for the "odd length" case, putting the extra space
>> after the centered text rather than before it. For instance:
>>
>> int left = (align->align_value - buf_len) / 2;
>> strbuf_addf(final, "%*s%-*s", left, "",
>> align->align_value - left + len, value->buf);
>>
>> or any similar variation which would give the same result.
>
> I get this could be done, what I was asking was, Consider given a alignment
> width of 25 would be better to make that 26 so that we have even padding on
> both sides. But I don't like the adding of manipulating user given data.
I thought you might be asking that, but wasn't certain. I do agree
with your conclusion that second-guessing the user is a bad idea, and
that you should give the user exactly what was requested.
>> That raises another question. Why are 'struct ref_formatting_state',
>> 'struct align', 'struct atom_value', etc. defined in ref-filter.h at
>> all? Aren't those private implementation details of ref-filter.c, or
>> do you expect other code to be using them?
>
> I guess struct ref_formatting_state and struct align could be moved to
> ref-filter.c. About struct atom_value its referenced by ref_array_item()
> so any reader reading about this, would find it easier if atom_value()
> is at the same place.
Do you expect callers ever to be manipulating or otherwise accessing
the atom_value of ref_array_item? If callers have no business mucking
with atom_value, then one option would be to simply forward declare
atom_value in the header:
struct atom_value;
struct ref_array_item {
...
struct atom_value *value;
...
};
which makes atom_value opaque to clients of ref-filter. The actual
declaration of atom_value would then be moved to ref-filter.c, thus
kept private.
next prev parent reply other threads:[~2015-08-09 8:04 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAOLa=ZRnnMBKpsq1ANBVgF2=xwK=A2EsPKKrGS0R4mZ8iATKfA@mail.gmail.com>
2015-08-05 18:54 ` [PATCH v9 03/11] ref-filter: implement an `align` atom Karthik Nayak
2015-08-07 3:27 ` Eric Sunshine
2015-08-08 6:35 ` Karthik Nayak
2015-08-09 3:42 ` Eric Sunshine
2015-08-09 6:55 ` Karthik Nayak
2015-08-09 8:04 ` Eric Sunshine [this message]
2015-08-09 8:09 ` Karthik Nayak
2015-08-09 8:19 ` Eric Sunshine
2015-08-09 12:54 ` Karthik Nayak
2015-08-07 4:04 ` Eric Sunshine
2015-08-08 7:03 ` Karthik Nayak
2015-08-09 8:00 ` Matthieu Moy
2015-08-09 8:10 ` Karthik Nayak
2015-08-04 12:39 [PATCH v9 0/11] Port tag.c over to use ref-filter APIs Karthik Nayak
2015-08-04 12:42 ` [PATCH v9 01/11] ref-filter: print output to strbuf for formatting Karthik Nayak
2015-08-04 12:43 ` [PATCH v9 03/11] ref-filter: implement an `align` atom Karthik Nayak
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='CAPig+cT=uUp5T1W1-CBrx4ZMsTSdpoghg57affU3JZ3Uvq20Pw@mail.gmail.com' \
--to=sunshine@sunshineco.com \
--cc=Matthieu.Moy@grenoble-inp.fr \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=karthik.188@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).