nano-devel
[Top][All Lists]
Advanced

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

[Nano-devel] Softwrap navigation overhaul


From: David Ramsey
Subject: [Nano-devel] Softwrap navigation overhaul
Date: Wed, 25 Jan 2017 13:13:31 -0600

I've finally implemented the changes to how nano navigates softwrapped
lines, described in the thread starting here:

http://lists.gnu.org/archive/html/nano-devel/2016-12/msg00046.html

The attached patch set against current git, commit 4ed3591 (in a zip
file, because it's rather massive: 66 patches and over 300K), should do
this, including both movement changes and finally allowing edittop to be
partially scrolled offscreen.  It also fixes some long-standing
underlying issues with the softwrap code (for example, calling
need_horizontal_scroll(), which indirectly calls get_page_start(), makes
no sense in softwrap mode, since it doesn't do line scrolling at all).

There are a few cosmetic changes in there as well, but I've separated
them out as best I can.  Also, the changelog entries are not in the
preferred style yet, and don't reference bug numbers yet.  Finally,
there are some reverts of full commits (for example,
ensure_line_is_visible() and everything related to it is gone), and some
parts that are just removed.  The latter are effectively partial
reverts.  (I'm aware that git can do partial reverts, but doing them for
code that was originally written years ago in a now-vastly-changed
codebase, with changes to that code spread in pieces across multiple
commits, and with that code being somewhat unstable anyway, with things
being changed and then changed back and then changed again... it was
easier to just remove them for now.)

There are also no documentation updates, and there should be eventually
(for example, "dynamic" home and end in softwrap mode, which is what I'm
currently calling the KWrite-based Home and End behavior there, need to
be described somewhere).

The (mostly currently open) bugs this patchset affects are as follows:

----------

bug #47667: when softwrap is on, PageUp + PageDown is not immobile

(The overhaul fixes the problem properly by allowing edittop to be
partially scrolled, thus making making single-line scrolling stay on the
same line whenever possible.)

Bug #49100: with softwrap, a line that takes up more than one screenful
causes problems

(The overhaul fixes the problem properly by allowing edittop to be
partially scrolled, thus making making single-line scrolling stay on the
same line whenever possible.)

Bug #49298: when there are softwrapped lines, M-- behaves strangely

(Commit d716809 papers over the problem without actually fixing it.
Since edittop cannot be partially scrolled in the current codebase, any
attempt to do so will center the screen.  In a file containing many
softwrapped lines, the screen will be centered more often than not.
Commit d716809 centers the screen all the time to work around this.  The
overhaul reverts commit d716809 and fixes the problem properly by [a]
making do_gotolinecolumn() properly count lines in softwrap mode when
checking whether or not it's near the tail of the file, and [b] allowing
edittop to be partially scrolled, thus making making single-line
scrolling stay on the same line whenever possible.)

Bug #49374: with softwrap, a <Right> at end-of-line sometimes scrolls
too much

(Commit d66ea08 is an adjustment of current_y in do_right() in softwrap
mode.  The overhaul removes all current_y adjustments in softwrap mode
in the general movement functions as unnecessary, since it moves in
terms of softwrapped chunks instead of lines in softwrap mode.)

Bug #49384: with softwrap, holding down <Right> on a very long line is
annoyingly slow

(Commit 43f35fc is the original addition of ensure_line_is_visible().
The overhaul reverts commit 43f35fc and all subsequent commits adding
calls to ensure_line_is_visible() as unnecessary, since it moves in
terms of softwrapped chunks instead of lines in softwrap mode.
"Annoyingly slow" does not describe how slow, but after the overhaul,
only continually scrolling up or down gets annoyingly slow on a very
long line.)

Bug #49823: with softwrap, a line does not always become fully visible
when using M-=

(The overhaul makes the problem obsolete, as it allows partial scrolling
of all lines, so making the current line fully visible is undesirable in
that case.)

Unreported bugs (mostly because they're difficult to reproduce actual
problems with despite being incorrect, or because they deal with issues
that the current code doesn't have) that the overhaul fixes:

do_uncut_text() doesn't properly count lines in softwrap mode when
checking whether or not it's uncut less than editwinrows lines in order
to do a focused refresh.  In the current codebase, this is difficult to
count efficiently.

edit_scroll() tries to optimize display of the top and bottom lines of
the edit window under the assumption that those lines only take up
single rows, which is not always the case in softwrap mode.  In the
current codebase, this is papered over by calling
ensure_line_is_visible(), which does a full refresh, so I cannot
reproduce this without removing ensure_line_is_visible() first.

edit_scroll(), edit_redraw(), do_home(), do_end(), do_up(), do_down(),
do_left(), and do_right() all erroneously check for horizontally
scrolled lines even in softwrap mode.  I cannot reproduce actual
problems with this, but only because softwrap mode breaks lines at the
point at which they'd be horizontally scrolled, so it technically works,
but the logic is still incorrect.

main() changes the margin and the number of available columns when
toggling line numbering mode either on or off, but doesn't directly do a
refresh there in the latter case, instead relying on do_toggle() for
that.  In the current codebase, this makes it more difficult to
determine whether the number of available columns has just changed due
to line numbering mode's being turned off (which, in the overhaul, we
need to determine when softwrap mode is on and edittop is partially
scrolled off the screen: if the number of available columns has changed,
lines get softwrapped differently, and the beginning of the visible
portion of edittop may no longer be at the beginning of a softwrapped
chunk, which severely breaks the display).

----------

It seems to work so far, but probably needs more testing.  If anyone
feels like doing so, it'd be much appreciated.

Attachment: softwrap-navigation-overhaul.zip
Description: Zip archive


reply via email to

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