List for cgit developers and users
 help / color / mirror / Atom feed
From: whydoubt at gmail.com (Jeffrey Smith)
Subject: [PATCH 4/4] ui-blame: Allow syntax highlighting
Date: Sat, 21 Oct 2017 16:53:15 -0500	[thread overview]
Message-ID: <CAPX7N=7MRMpiUchLb2Qxq2kG3L_02GvPDnjjxrO_fTfXaXEkag@mail.gmail.com> (raw)
In-Reply-To: <20171021144325.GF2393@john.keeping.me.uk>

On Sat, Oct 21, 2017 at 9:43 AM, John Keeping <john at keeping.me.uk> wrote:
>
> This doesn't account for tabs, which is noticable in long lines (I
> happened to test with cgit.c where line 615 is quite a bit longer than
> average).
>
> It is fixed by using:
>
>         const char *start = blame_nth_line(sb, line);
>         const char *end = blame_nth_line(sb, line + 1);
>
>         html("\n");
>         len = end - start;
>         while (start < end)
>                 if (*(start++) == '\t')
>                         len += 7;
>

Nice catch.  Since '\t' is 'advance to next tab-stop' not 'advance # spaces',
that calculation could give a len larger than necessary.  I will add the code
to handle tabs properly.

>> +             if (len > maxlen)
>> +                     maxlen = len;
>> +     }
>>
>> -     html_ntxt(cp, cpend - cp);
>> +     for (len = 0; len < maxlen - 1; len++)
>> +             html(" ");
>
> Should this use &nbsp; or is a plain space guaranteed to be okay here?

This is inside of a 'pre' block, so spaces will do the right thing.


  reply	other threads:[~2017-10-21 21:53 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-18  4:17 [PATCH 0/4] Add ui-blame " whydoubt
2017-10-18  4:17 ` [PATCH 1/4] ui-blame: Distinguish hashes column from lines column whydoubt
2017-10-21 14:33   ` john
2017-10-18  4:17 ` [PATCH 2/4] ui-blame: Break out emit_blame_entry into component methods whydoubt
2017-10-21 14:33   ` john
2017-10-18  4:17 ` [PATCH 3/4] ui-blame: Make each column into a single table cell whydoubt
2017-10-21 14:34   ` john
2017-10-18  4:17 ` [PATCH 4/4] ui-blame: Allow syntax highlighting whydoubt
2017-10-21 14:43   ` john
2017-10-21 21:53     ` whydoubt [this message]
2017-10-24 14:30       ` Jason
2017-10-29  2:23         ` [PATCH 4/4 v2] " whydoubt
2017-10-29  2:26           ` whydoubt
2017-10-29  2:43             ` [PATCH 4/4 v3] " whydoubt
2017-10-29 22:23               ` Jason
2017-11-05 12:36                 ` john
2018-01-19 10:41 ` [PATCH 0/4] Add ui-blame " Jason

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='CAPX7N=7MRMpiUchLb2Qxq2kG3L_02GvPDnjjxrO_fTfXaXEkag@mail.gmail.com' \
    --to=cgit@lists.zx2c4.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).