nano-devel
[Top][All Lists]
Advanced

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

Re: [Nano-devel] problems when chunks are of variable length


From: Benno Schulenberg
Subject: Re: [Nano-devel] problems when chunks are of variable length
Date: Thu, 30 Mar 2017 19:52:41 +0200

On Thu, Mar 30, 2017, at 16:28, David Ramsey wrote:
> On Thu, Mar 30, 2017 at 5:06 AM, Benno Schulenberg
> <address@hidden> wrote:
> > Well, when chunks are of variable length, and if placewewant is beyond
> > the actual span of the current line, nano should assume that the
> > virtual chunks that would be needed to make the current line reach
> > beyond placewewant are each of size editwincols. In other words, in
> > that case target_column is not placewewant - leftdege, but
> > (placewewant - leftedge) % editwincols.
> 
> So even if the % editwincols formula doesn't quite add up to the right
> column, it's okay because we can't do anything else, and the
> target_column needs to be in screen range?

The % editwincols formula will always yield the correct column:
the correct /intended/ column if the relevant chunk were long
enough.  It's the same as in current git when the last chunk of
a line does not reach until the column where we want to be: then
we put the cursor after the last character of that chunk /but/
remember the target_column as the place we would like to be.

An example: a file has two lines, one of 90 columns, one of 75,
on a terminal of 80 columns.  So the first line occupies two rows
and the second line one row.  Let's put the cursor at the end of
the second line and press <Up>.  There is no column 75 in the
second chunk of line one, so the cursor goes to the end of the
chunk, column 10, but as placewewant we remember the leftedge
(in this case 80) plus the target_column (75): 155.

Now assume that atblanks is in effect and the first line of the
file had to be softwrapped at column 70.  In that case an <Up>
from the end of the second line still has 75 as target_column,
but when arrived on the second chunk of line 1 the placewewant
is now 70 (leftedge) + 75 = 145.  Another <Up> brings us to the
first chunk of line 1, and the placewewant is 0 + 75 = 75, but
this chunk doesn't have 75 columns, so we put the cursor at the
tail of the chunk, column 70.  The difficult part (it seems to me)
is that actual_x() cannot be computed simply from placewewant
but has to be computed from the minimum of placewewant and
the end of the current chunk.

Benno

-- 
http://www.fastmail.com - Faster than the air-speed velocity of an
                          unladen european swallow




reply via email to

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