nano-devel
[Top][All Lists]
Advanced

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

Re: [Nano-devel] Softwrap navigation overhaul


From: Benno Schulenberg
Subject: Re: [Nano-devel] Softwrap navigation overhaul
Date: Wed, 08 Feb 2017 12:57:45 +0100

On Tue, Feb 7, 2017, at 21:13, David Ramsey wrote:
> On Tue, Feb 7, 2017 at 9:04 AM, Benno Schulenberg
> <address@hidden> wrote:
> > Is it possible for the chunk routines to get called with nrows = 0?
> 
> It probably shouldn't be.  Removed.

But the answer is yes.  There are three places where a chunks()
routine is called with editwinrows - 1, one place where it's called
with editwinrows - nrows, and once with editwinrows / 2.  They
all risk being zero.  The question then becomes: does the case
need special treatment?  It seems not: for nrows == zero, all
the ifs and fors just fall through and become noops.  Good.

+       for (i = nrows; i > 0; i--) {
+           size_t last_chunk = (strlenpt((*line)->data) / editwincols);
+
+           if (current_chunk < last_chunk) {
+               current_chunk++;
+               continue;
+           }
+ [...]

This is horrible.  For every chunk++ you recompute the line span
completely superfluously.  You have to duplicate the assignment
to last_chunk: once before the loop, and once at the tail of the
loop.  For a small optimization, you could conditionalize the latter
with an 'if (i > 0)', but for now just drive straight.

(Later on we will probably, a la Mark Majeres, want to simply store
the line span of each line in its linestruct (misnomed filestruct).
That should speed things up a bit.)

Also, I don't like the parenthesis around last_chunk computation.


Okay, just testing again, with the attached file, run:

    stty cols 44 && src/nano --soft +3 chinese.html

See how the cursor sits on the "<" of the <bottom> tag.
Now press <Up> ten times.  Notice how the cursor jumps
from left to right now and then.  Weird!  After ten presses
the cursor sits on the "<" of the <top> tag.  Now try pressing
<Down> ten times.  After the second press, nothing further
happens -- the cursor is stuck at the tail of the first chunk.

Now press and hold <Right>.  The cursor happily runs through
all of the chunks.  But after a while it gets stuck at the tail
of the last chunk.  Now press <Down>.  The cursor is after the
">" of the <bottom> tag.

Also notice how some of the chunks seem to start with two
blank columns.  But if you go there and select them, it selects
the two columns as a whole.  If you cut it and then paste it at
the top of the file, a character appears.  The same character
that suddenly appears when you type x instead of cutting it.

Now run:

    stty rows 1 && stty cols 44 && src/nano --soft +3 chinese.html

Press M-\ <Down> <Down> xxxxx  <Left> <Left> <Left> <Right>
<Right> <Right>...  The cursor seems to be completely stuck.

For a still more frustrating experience, run:

    stty rows 4 && stty cols 44 && src/nano --soft +3 chinese.html

Try <Up> <Up> <Up>...  Try all other directions...  No movement.


Well... this is complicated.  It has to do with double-width
characters sitting on the boundary between two chunks.  When
this happens, this character should not be included in the
lefthand chunk, and the righthand chunk should start a column
earlier -- I think.  But that makes the calculation of the number
of chunks wildly complicated.  Don't know how to solve that.

Maybe a "solution" would be to not use the last column of the
screen, so that a double-width character in the penultimate
column can "overflow" into this column instead of disappearing?

(Problem is related to https://savannah.gnu.org/bugs/?49440.)

Benno

-- 
http://www.fastmail.com - A no graphics, no pop-ups email service

色は匂へど散りぬるを我が世誰ぞ常ならむ有為 の奥山今日越えて浅き夢見じ酔ひもせず色は匂へど散りぬるを我が世誰ぞ常ならむ有為 色は匂へど散りぬるを我が世誰ぞ常ならむ有為 の奥山今日越えて浅き夢見じ酔ひもせず色は匂へど散りぬるを我が世誰ぞ常ならむ有為 色は匂へど散りぬるを我が世誰ぞ常ならむ有為 の奥山今日越えて浅き夢見じ酔ひもせず色は匂へど散りぬるを我が世誰ぞ常ならむ有為 色は匂へど散りぬるを我が世誰ぞ常ならむ有為 の奥山今日越えて浅き夢見じ酔ひもせず色は匂へど散りぬるを我が世誰ぞ常ならむ有為 の奥山今日越えて浅き夢見じ酔ひもせず色は匂へど散りぬるを我が世誰ぞ常ならむ有為 の奥山今日越えて浅き夢見じ酔ひもせず
reply via email to

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