The parameter 'cols', that indicates how many columns to indent or
unindent, is changed to be always positive, so the check for being
negative can go. And it could never be zero anyway.
This should eliminate all cases where the newline is pushed off the edge
of the screen in non-atblanks softwrap mode. Also, it allows the use of
the last column of the screen in atblanks softwrap mode when a piece of
text does not contain any blanks.
This avoids the unreachable end-of-line reported on the mailing list:
http://lists.gnu.org/archive/html/nano-devel/2017-06/msg00011.html.
Extend get_softwrap_breakpoint() to break softwrapped lines on
whitespace when a flag is set. This flag is controlled by the new
rcfile option "atblanks". The '>' characters marking two-column
characters at the edge of the screen are disabled when it's on.
If get_softwrap_breakpoint() can't find whitespace in screen range, it
will break the line on the screen edge. (In this case, a blank can be
on the last column of the screen, but text can't, so that a blank on the
last column doesn't become invisible and possibly break the display.)
This fulfills https://savannah.gnu.org/bugs/index.php?49959.
Requested-by: Nicholas Boel <axxisd@gmail.com>
spotlight() now displays softwrapped lines chunk by chunk instead of all
at once. Since softwrapped lines are no longer of constant width, the
latter approach would fail if softwrapping breaks the spotlighted text.
Instead of taking a string, spotlight() now takes the starting and ending
columns of that string. Also, its handling of softwrapped lines is now
split off into a separate function, spotlight_softwrapped().
get_chunk_row() and get_chunk_leftedge() now become wrappers around
get_chunk(); the latter is only used directly in place_the_cursor()
when we need to get both the row and the leftedge. get_chunk() now
uses the proper formula to implement varying chunk width.
Since chunk width now varies, place_the_cursor() sets the x position
relative to the leftedge in a different way that works regardless
of chunk width, update_softwrapped_line() loops until it gets all
softwrap breakpoints instead of calculating the full length in
advance and getting one full row at a time, the chunk iterators
now count leftedges instead of rows, and fix_firstcolumn() does a
full recalculation of the chunk that firstcolumn is on instead of
simply shifting it back.
Also, in update_softwrapped_line(), when a line's softwrap breakpoint
is before the last column of the edit window, a ">" is now added to
the end of it.
The workaround in place_the_cursor() for when two-column characters
straddle the edge of the screen is removed, as it's no longer needed
now that chunks end before such characters.
Furthermore, do_home() and do_end() use xplustabs() instead of
placewewant again when calculating the leftedge, since placewewant
refers to a column that may or may not be available (if it's not,
the cursor will be placed wrongly). Make get_edge_and_target() use
xplustabs() instead of placewewant for the same reason; this also lets
us simplify get_edge_and_target(), since xplustabs() will never be
greater than strlenpt(). Finally, since do_end() now has to calculate
rightedge as well as rightedge_x, use the former to implement the same
time-saving optimizations as in do_home().
The cursor is not yet adjusted when we try to go directly to a column
past the end of a softwrap breakpoint, and placewewant handling in the
vertical movement code is not yet adjusted for varying chunk lengths,
but fixes for these are forthcoming.
This fixes https://savannah.gnu.org/bugs/?49440.
get_chunk_row() replaces the formula "column / editwincols".
get_chunk_leftedge() replaces "(column / editwincols) * editwincols".
get_last_chunk_row() replaces "strlenpt() / editwincols".
get_last_chunk_leftedge() replaces "(strlenpt() / editwincols) * editwincols".
This prepares us for any changes in those formulas, and for more such
functions later.
The new function find_softwrap_breakpoint() returns the column number
of the last position in screen range where we can wrap the given text
without breaking a two-column character in half (as was done until now).
The returned column number is the leftedge of the next softwrapped chunk.
If the end of the text is reached while searching for a wrapping point,
the parameter end_of_line is set to TRUE.
The new function get_chunk() uses find_softwrap_breakpoint() to find the
row and leftedge corresponding to a given column of a given line.
If the position of the cursor changes horizontally,
placewewant should change with it.
This fixes https://savannah.gnu.org/bugs/?51407.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
Dereferencing a NULL pointer is never a good idea.
This fixes https://savannah.gnu.org/bugs/?51405.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
Eradicate the need for backslashes, so that the start of the nanorc
manual becomes true, where it says that quotes inside strings don't
need to be escaped. In the bargain achieve that the empty string
always switches commenting off.
This fixes https://savannah.gnu.org/bugs/?51370,
and fixes https://savannah.gnu.org/bugs/?51394.
This avoids some warnings when compiled with -pedantic:
ISO C forbids comparison of ‘void *’ with function pointer
ISO C forbids empty initializer braces
When the active syntax contains a comment command that specifies the
empty string, this should override the default comment of "#" and
should disable the Meta-3 keystroke.
To achieve this, the comment string is now set by default to "#" for
all syntaxes, so that it will be set when no comment command is given
(including for the "none" syntax), and is unset only by explicitly
specifying «comment ""» in a syntax file.
This fixes https://savannah.gnu.org/bugs/?51355.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
When also --nohelp is active and the terminal is so narrow that the
message that --constantshow displays on the bottom row does not fit,
this causes the cursor to be pushed "offscreen". Some terminal
emulators don't handle this case correctly, and leave the cursor
in an invisible or mistaken position. Compensate for this by
moving the cursor back to the start of the row.
This fixes https://savannah.gnu.org/bugs/?51335.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>