Commit Graph

9498 Commits (0a57da42e0162a8ce7ed3a07e62d81caf930344b)

Author SHA1 Message Date
Benno Schulenberg 0a57da42e0 docs: correct the description of --quickblank for the changed base value
And mention that --minibar overrides the option too.
2021-02-22 12:24:06 +01:00
Benno Schulenberg 73067e0e16 build: include a workaround only for versions of ncurses that need it
The cursor-misplacement bug has been fixed in ncurses-6.2-20210220:

  https://lists.gnu.org/archive/html/bug-ncurses/2021-02/msg00010.html

See also https://savannah.gnu.org/bugs/?59808.
2021-02-21 12:00:28 +01:00
Benno Schulenberg b9328d0eac feedback: make Full Justify show a message also when using --minibar
Full justification (like justification of a selection) is probably
a rather rare action -- and possibly even an unintended action --
so it's good to give feedback about what happened also when using
the minibar.
2021-02-20 12:11:43 +01:00
Benno Schulenberg 0596b875f0 painting: trigger a refresh when a second start match appears on a line
When a line is marked as JUSTONTHIS, there should be no second start
match on that line, because otherwise the line would have been marked
as STARTSHERE (unless there is also a second end match -- but it's
fine to do unnecessary refreshes in this unlikely case, as long as
the necessary refreshes are made).

This fixes https://savannah.gnu.org/bugs/?60074.

Bug existed since version 2.5.0, but has been masked (for the C syntax)
by unnecessary refreshes since version 4.1, commit c9605e73.
2021-02-18 17:15:24 +01:00
Benno Schulenberg b94dcfd34b painting: trigger fewer unneeded full-screen refreshes
When a line is marked as NOTHING, then the existence or the appearance
of an end match is irrelevant: there is no unpaired start match, so no
recoloring would occur, so there is no need to refresh.

When a line is marked as WOULDBE, then the existence or the appearance
of a start match is irrelevant (for the lines after the first WOULDBE
line): there already is an unpaired start match, so another one will
not change anything, so no refresh is needed.  Only the appearance of
an end match would recolor things and thus require a refresh.  However,
start and end regexes could match the same thing, so an end might get
misinterpreted as a start.  So the rule has to check for the absence
of both a start and an end match, like for WHOLELINE.

This addresses https://savannah.gnu.org/bugs/?60072.
2021-02-18 12:21:37 +01:00
Benno Schulenberg 4238564673 tweaks: rewrap two lines, for esthetics 2021-02-16 16:52:41 +01:00
Benno Schulenberg 764ab96bda tweaks: make a skipping condition more precise
A step forward needs to be forced not when both start match and
end match have zero length, but when the "full match" (all text
from the start of the start match to the end of the end match)
covers zero bytes.  In other words: the start and end match are
both of zero length AND are at the same spot.
2021-02-16 16:12:41 +01:00
Benno Schulenberg f0cc59bead color: use inverse video for highlighting when there are no colors
When a terminal has no colors but has the ability to hide the cursor
(like a VT320), then using --bold would make a search match too hard
to see.
2021-02-16 11:28:22 +01:00
Benno Schulenberg 282f438967 color: use bright yellow to highlight a search match
Plain yellow is too dark (more like brown) on some machines.
Lightyellow is a bit loud, but... very visible.
2021-02-15 12:29:15 +01:00
Benno Schulenberg 1b01adfa9f docs: mention the new 'set highlightcolor' option 2021-02-14 12:51:09 +01:00
Benno Schulenberg 87fe73ddaa color: give highlighted text its own color, to not look like marked text
Now that a search match gets highlighted, the unsuspecting user might
think that the text is selected, because it is colorized the same way
as selected text.  Avoid this by colorizing a highlighted search match
with its own specific color, black on yellow by default.
2021-02-14 12:51:09 +01:00
Benno Schulenberg c2746c0bb2 tweaks: reshuffle some code, and reduce the scope of a variable 2021-02-08 12:33:10 +01:00
Benno Schulenberg 399a024857 minibar: suppress the toggling feedback for M-C, but show it for M-Y/M-P
In addition, suppress the feedback for M-C also when --minibar
isn't used, as the feedback obscures the effect of the toggle:
showing information about the cursor position on the status bar.

This fixes https://savannah.gnu.org/bugs/?60019.

Bug existed since commit 7545eb5b from one week ago.
2021-02-08 10:27:29 +01:00
Benno Schulenberg d131c2d438 minibar: show a message a little longer when --quickblank isn't used
The --minibar option made --quickblank a no-op.  Now the use of the
latter together with --minibar still has some effect.
2021-02-07 12:09:38 +01:00
Benno Schulenberg eb0962fb06 docs: remove all mentions of --markmatch and 'set markmatch' 2021-02-07 09:18:15 +01:00
Benno Schulenberg 7bf253702e options: remove --markmatch and 'set markmatch', as the behavior is gone 2021-02-07 09:18:15 +01:00
Benno Schulenberg 76742cc193 search: make highlighting the standard, non-changeable behavior
Highlighting an occurrence is so much clearer than just putting the
cursor on it.  People seem to like it.  So let's make this how nano
behaves by default.
2021-02-07 09:18:15 +01:00
Benno Schulenberg 37717baeed search: just highlight the found occurrence, instead of marking it
Requested-by: Peter Passchier <peter@passchier.net>
2021-02-07 09:18:15 +01:00
Benno Schulenberg ade2fafbd3 tweaks: remove a strangely placed warning
(After some trying, I haven't seen the warning displayed, but...
I'm not yet sure that it could never occur, so I keep the 'if'.)
2021-02-06 19:12:43 +01:00
Benno Schulenberg 53fe7ba26a tweaks: be slightly more efficient in marking lines as WOULDBE
Take two conditions that are relevant only for a rather unlikely case
(a start match without a corresponding end match) out of an inner loop.
Give the case its own, dedicated loop.
2021-02-06 17:01:02 +01:00
Benno Schulenberg 7e04fea92b painting: when finding an end match, set its multidata right away
When leaving the multidata unset (as was done until now) and the
end match is offscreen, then this could lead to miscolorings later
when jumping over this end match instead of scrolling past it.

This fixes https://savannah.gnu.org/bugs/?60012.

Bug existed since before version 2.1.10.
2021-02-05 17:25:03 +01:00
Benno Schulenberg 1fdd23d347 display: for a large paste or insertion, recalculate the multiline cache
When a large piece of text or code is pasted or inserted, it could
contain matches for start= and end= regexes, and backtracking from
the current screen could mistake an end for a start and could thus
miscolor things.  Avoid this by recalculating the multiline cache
for pastes and insertions that cover more than a screenful.

This fixes https://savannah.gnu.org/bugs/?59982.

Bug existed since version 2.6.0, but existed also before 2.4.3.
2021-02-03 17:00:28 +01:00
Benno Schulenberg 5ea930e25f build: detect a build from git also when building out of tree
Reported-by: Hans-Bernhard Bröker <HBBroeker@t-online.de>

Bug existed since version 2.6.0, commit ec295f5e.
2021-02-02 12:00:24 +01:00
Benno Schulenberg 45defd25f3 build: avoid a warning about duplicate symbol when building from tarball
Reported-by: Hans-Bernhard Bröker <HBBroeker@t-online.de>

Bug existed since commit 3ea2694d from last week.
2021-02-02 11:39:26 +01:00
Benno Schulenberg 0d11964503 docs: say that --minibar is modified by --constantshow and --stateflags
The previous two commits reduced what is shown by default on the minibar.
Mention which extra options are needed to show the extra information.
2021-02-02 11:10:09 +01:00
Benno Schulenberg 7545eb5bbf minibar: show the state flags only when --stateflags is used
For users who always have auto-indent or hardwrap or softwrap on
and do not need to see this continuously advertised at the bottom.
2021-02-02 11:10:09 +01:00
Benno Schulenberg 878bd53d11 minibar: show cursor position + character code only with --constantshow
This allows having an even leaner interface, and gives the M-C toggle
an appropriate function (instead of leaving it a "dead" keystroke).

Suggested-by: Sébastien Desreux <seb@h-k.fr>
2021-02-02 11:10:09 +01:00
Benno Schulenberg e0a4ee0148 scrolling: keep centering after large paste, also when line numbers widen
If a paste (or insertion) is more than a screenful, it will not set
'focusing' to FALSE.  In that case, and when line numbers are already
active, then 'focusing' should be kept set to TRUE, despite it getting
set to FALSE by ensure_firstcolumn_is_aligned().  That latter action
is meant to cushion size changes of the edit window, but in this case
the large paste (or insertion) should trump the size change.

This fixes https://savannah.gnu.org/bugs/?59981.

Bug existed since version 2.8.3, commit 2b385478.
2021-02-01 12:42:55 +01:00
Benno Schulenberg d3fbc4d498 tweaks: remove an old fix that was made superfluous by a recent fix
Commit 43d94692 fixed a miscoloring bug [1] by doing proper backtracking
for multiline regexes.  But this change also solves an older miscoloring
issue [2] without needing to recalculate all the multiline data.  So...
just drop the old fix.  (This isn't perfect: it's probably possible to
cook up a replacement scheme where things get miscolored, but... until
then, this is good enough.)

  [1] https://savannah.gnu.org/bugs/?59948
  [2] https://savannah.gnu.org/bugs/?58481

Also, there is no need to set 'refresh_needed' in do_replace_loop(),
because each replacement prompt will call edit_refresh() anyway, and
the functions that call do_replace_loop() will set it afterward.
2021-01-29 16:57:11 +01:00
Benno Schulenberg a8e2a24f60 tweaks: frob a condition, to be more concise, and reshuffle another 2021-01-29 10:58:09 +01:00
Benno Schulenberg 36855544d1 tweaks: rewrap and reindent a few lines 2021-01-29 10:52:40 +01:00
Benno Schulenberg dc745c0b77 tweaks: elide a function that is now just one line 2021-01-29 10:30:05 +01:00
Benno Schulenberg a8ed1d7a9a tweaks: don't bother wiping the multidata before recomputing it
The precalc_multicolorinfo() routine will assign a value to every
element for every line without looking at any current value, so
wiping the data first is a waste of time.
2021-01-29 10:25:27 +01:00
Benno Schulenberg 94c371a38f tweaks: don't bother initializing freshly allocated multidata
After having been allocated, the multidata will get computed
immediately, in precalc_multicolorinfo() and draw_row(), so
first setting each element to -1 is a small waste of time.
2021-01-29 10:18:39 +01:00
Benno Schulenberg 36618f1dca tweaks: don't bother comparing virgin multidata with current situation
The initialization of -1 cannot possibly match with NOTHING or
WHOLELINE or the other available values.

(Also, put in a warning, as I don't think an onscreen line without
a multidata cache can occur at all.)
2021-01-29 10:06:03 +01:00
Benno Schulenberg 3ea2694d9c tweaks: rename six symbols, to be more straightforward 2021-01-28 16:11:57 +01:00
Benno Schulenberg 85cc99a2a3 tweaks: frob some comments, and reshuffle two fragments of code 2021-01-28 15:44:54 +01:00
Benno Schulenberg befe4ea5de tweaks: frob some comments, and adjust indentation after previous change 2021-01-28 11:57:33 +01:00
Benno Schulenberg 43d94692ce painting: always do backtracking for the first row of the screen
Backtracking from the first row is needed in case a start match was
added recently somewhere offscreen and the user jumped to the current
location (instead of scrolling) so that the CWOULDBE markings did not
reach the current lines.

Also, search for an end match only for the first screen row.  For the
other rows, rely on the CENDAFTER, CWHOLELINE, and CWOULDBE values to
indicate whether there *is* an end match (the first two values) or not.
This saves considerable time when there is no end match in the large
remainder of a buffer: it will search in vain for the end match just
once, instead of for every row of the screen.

This fixes https://savannah.gnu.org/bugs/?59948,
and addresses https://savannah.gnu.org/bugs/?59945.

Bug existed since version 2.7.5, commit b3bcc8ee.
2021-01-27 17:01:17 +01:00
Benno Schulenberg 1364b41dc9 debug: add timing instruments to cache precalculation and screen refresh 2021-01-26 16:06:31 +01:00
Benno Schulenberg 7d3a555464 tweaks: avoid the vague possibility of advancing beyond end-of-line
Like the other two fragments that advance over a zero-length match,
also this fragment should avoid the possibility of stepping beyond
the end of the line.
2021-01-24 17:19:44 +01:00
Benno Schulenberg 0508520b47 tweaks: reshuffle three conditions into a better order
When a zero-length match is beyond the width of the screen, there
is no point in continuing evaluating the rule, so the check for
"offscreen to the right" needs to come first.  The check for a
zero-width match needs to come second because otherwise we would
get stuck on such a match when it is offscreen to the left.
2021-01-24 17:19:37 +01:00
Benno Schulenberg 6cbb7bc443 tweaks: frob two fragments of code, to be more readable 2021-01-24 16:44:38 +01:00
Benno Schulenberg 055e262b56 tweaks: stop evaluating a rule when the match is offscreen to the right
When the match of a coloring regex is beyond the width of the screen,
there is no point in continuing to evaluate the regex for the rest of
the line, because any other matches will be offscreen too.

This will save some time when there are several overlong lines.
2021-01-24 12:40:34 +01:00
Benno Schulenberg 9d8388e836 tweaks: call wattron()/wattroff() only when actually painting something
A syntax has on average a dozen coloring rules, but on average maybe
three or four pieces of text (rough estimate) in a line get painted.
So, on average, it is cheaper to call wattron() and wattroff() only
when actually coloring a piece of text, instead of calling wattron()
before starting to evaluate each rule and wattroff() after finishing
its evaluation.
2021-01-23 19:28:08 +01:00
Benno Schulenberg 895de17a58 color: do not look for another 'end' match after already finding one
When reaching end-of-line after having found a zero-width end match,
nano should not continue at 'seek-an-end' but instead at 'step_two':
going on to seek a start match in the current line.

(There is no bug report, because I cannot figure out how to trigger
this issue and cause nano to misbehave.  The problem was found while
reviewing the comments.)

Bug existed since commit 9a4a5454 from four years ago,
but the behavior was poorer before that commit.
2021-01-22 16:40:53 +01:00
Benno Schulenberg b202966d30 tweaks: correct a comment, improve another, and trim some verbosity 2021-01-22 11:58:53 +01:00
Benno Schulenberg a19a7820f9 color: recompile the file-probing regexes a little faster with REG_NOSUB
When the filename, header-line, and magic regexes are first compiled
while reading in the rc files (to check their validity), REG_NOSUB is
used, but for some reason this wasn't done when each of these regexes
gets recompiled in order to be used.  Fix this oversight.  It shaves
some twenty percent off of each of these regexes' compiling time.
2021-01-21 12:35:16 +01:00
Benno Schulenberg 0122119a44 docs: correct the word order for Alt+D in the cheat sheet -- it changed 2021-01-20 19:25:29 +01:00
Benno Schulenberg 64bf03b0d9 docs: correct the formatting of a comment in the sample nanorc 2021-01-15 10:05:04 +01:00