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: Thu, 09 Feb 2017 13:12:51 +0100

On Wed, Feb 8, 2017, at 23:26, David Ramsey wrote:
> > Additionally, while trying to get the read_file() changes right
> > yesterday, I noted that read_file() seems to only be used to read into
> > empty buffers, except for do_insertfile(), but do_insertfile() uses
> > partition_filestruct() to make the buffer *appear* empty first, so if
> > I'm reading things right, read_file() could probably be simplified.

Yes, I've long thought that there is something superfluous going on with
all this partitioning and unpartitioning, especially since replacing in a
marked region doesn't use it any more.

> read_file() currently assumes that we're inserting a file starting at
> the beginning of the line before current,

Not the beginning of the line /before/ current, but simply the beginning
of the current line.

> and tacks current's text onto
> the end if necessary (it's old code).  To fix the aforementioned problem
> properly, it should actually be adapted to insert a file starting at
> current[current_x], and tack current's remaining text onto the end if
> necessary;

Right.

> after this, its direct use of partition_filestruct() should
> be removed.  In short, it needs to behave more like the uncutting code
> if it's going to properly count softwrapped lines like the uncutting
> code: maybe read the file into a new temporary buffer, and then use
> copy_from_filestruct() to put it in place,

The latter sounds like the right approach.  Then we can finally get
rid of all this partitioning.

> And would that break undoing inserts?

Surely that can be adjusted, to be made to work.

> As for the Chinese two-column Unicode character problems, determining
> whether the line ends with a partial two-column character is more
> difficult than I thought.

Yes, this is far from easy.

> Although, after some thought, patch 0032 in the set might count as
> separate from the overhaul?

It could.  But the logic is incorrect.  You do this:

        int needed_margin = 0;

        if (ISSET(LINE_NUMBERS) && needed_margin < COLS - 3)
            needed_margin = digits(openfile->filebot->lineno) + 1;

This is kind of silly: first you set needed_margin to zero, and then
compare it with COLS minus three.  So what you're in fact checking is
whether COLS is at least four, and then you will show line numbers.
But the idea is: to only show line numbers if they leave at least four
columns of text visible.  So this 'needed_margin < COLS - 3' test will
have to come later.

Benno

-- 
http://www.fastmail.com - Email service worth paying for. Try it for free




reply via email to

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