nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] Nano with Line Numbering


From: Faissal Bensefia
Subject: Re: [Nano-devel] Nano with Line Numbering
Date: Mon, 19 Sep 2016 15:43:04 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0

On 18/09/16 19:09, Benno Schulenberg wrote:
> 
> On Sun, Sep 18, 2016, at 12:05, Faissal Bensefia wrote:
>> Should all be done, attached.
> 
> Your patch submissions are too terse -- they lack an explanation
> for the changes that are made.  For example:
> 
> -       for (index += COLS; index <= full_length && line < editwinrows - 1; 
> index += COLS) {
> +       for (index += COLS - margin; index < full_length && line < 
> editwinrows - 1; index += COLS - margin) {
> 
> In case of /no/ line numbers, margin will be zero, and you will have
> effectively changed a "<=" to a "<": you have changed the default
> behavior of nano.  Why?  Is there a bug?  Is nano doing it wrong at
> the moment?  If so, you must explain how.  If not, then you may not
> change anything when margin == 0.
> 
> You can see this go wrong when running:
>   stty cols 44 && src/nano --ignore --soft --linenum +1 README.GIT
> and looking at the tail of line 11.  The "g" is missing after "followin".
> 
> 
>     for (n = 0; n < editwinrows && foo; n++) {
>         maxrows++;
> -       n += strlenpt(foo->data) / COLS;
> +       n += (strlenpt(foo->data) + margin) / COLS;
>         foo = foo->next;
>      }
> 
> This is wrong.  This tries to compute how many screen lines a
> softwrapped real line takes up.  When there is a margin, the
> space for wrapping each line is smaller: COLS - margin.  So the
> computattion becomes: n += strlenpt(foo->data)/ (COLS - margin);
> 
> I haven't looked further than those two issues.
> 
> Upon your next patch submission, please explain the reason
> for the changes compared to your previous version.
> 
> Benno
> 
The fix for my horrendous maths also fixed the issue. I changed a few
occurrences of
(strlenpt(foo->data) + margin) / COLS
to
strlenpt(foo->data) / (COLS - margin)

I have also reverted the <= to < issue, I did that because it seemed to
work, there was no real logic behind it.

I have attached the new patch.

Sorry about being too terse, I hope this is a bit better.
~Faissal Bensefia

Attachment: 0001-Added-line-numbering.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]