Commit Graph

1627 Commits (7e807cdd2ff73f45087b56e318dfb6f5117c0ece)

Author SHA1 Message Date
Benno Schulenberg 7e807cdd2f memory: avoid leaking the filename when dottifying it on the minibar
This fixes https://savannah.gnu.org/bugs/?61334.

Bug existed since version 5.5, since the minibar was introduced.
2021-10-12 12:49:08 +02:00
Benno Schulenberg 5512c63bdd copyright: update to the current year for significantly changed files 2021-09-24 11:01:41 +02:00
Benno Schulenberg 239c794503 feedback: use a smaller diamond to represent an anchor, to not overflow
In the terminal font that I use nowadays (that deals well with
combining characters), the normal diamond exceeded the boundaries
of a single cell and thus partly covered the first character of
the relevant line.
2021-09-19 12:03:12 +02:00
Benno Schulenberg 6b9c24f7dd feedback: when not in curses mode, write error messages to the terminal
No errors ought to occur when not in curses mode, but when they *do*
occur, increase the chances that we can figure out what happened.
2021-07-14 10:16:31 +02:00
Benno Schulenberg 5954eeaff2 tweaks: reshuffle a fragment of code, to prepare for the next change 2021-07-14 10:08:32 +02:00
Benno Schulenberg 8d1a666dcf input: give up on the input stream only after millions of errors
This mitigates a problem seen sometimes among the Red Hat crash reports:
somehow wgetch() keeps returning ERR, as if it were in nodelay mode.
(I've seen this happen once after nano came out of suspension.)

Using a much larger error-count value gives the user a few seconds
to type something and hopefully get out of the error condition.
2021-06-29 14:31:22 +02:00
Benno Schulenberg fc01c5a10e feedback: when not in curses mode, just skip displaying any message
Calling die() could trigger another call of emergency_save(), which
could fail and cause another call to statusline(), which would call
die() again...  Spiralling until stack space runs out.

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

Bug existed since version 5.1, commit 7942dab0.

Original report was in https://bugzilla.redhat.com/1976410.
Reported-by: Souptik Dutta Roy <duttaroy.souptik@gmail.com>
2021-06-29 13:07:41 +02:00
Benno Schulenberg 45420968ee tweaks: correct two typos and a spello [codespell] 2021-06-17 10:55:23 +02:00
Benno Schulenberg 984c9e1078 tweaks: redraw only the affected line instead of doing a full refresh
When the spotlighting needs to be cancelled, there is no need to do a
full refresh of the edit window -- redrawing just the relevant line is
enough.  (And when there is just one row, it is enough too.)
2021-06-11 16:52:56 +02:00
Benno Schulenberg e2e8bf0a3e options: accept 'set minicolor' for setting the color of the minibar
When it is not specified, it defaults to the value for 'titlecolor'.

When not using --minibar, I want the title bar to be blue (as that is
how I've always had it), but with --minibar, I want this mini bar to
be grey, as otherwise it reminds me too much of the prompt bar.

Also, colorize 'set minicolor' as valid in a nanorc file.
2021-06-08 09:25:02 +02:00
Benno Schulenberg 3f340836a6 search: automatically drop the spotlighting after a few moments
Even though I know that spotlighted text is not selected, I still
regularly think for a fleeting instant that the spotlighted text
can be cut with a ^K.  Mitigate this by dropping the spotlighting
after 1.5 seconds (or 0.8 seconds when using --quick).
2021-06-03 12:02:04 +02:00
Benno Schulenberg f857959b8e startup: suppress "Search Wrapped" when using +? to search from EOF
When using +/ or +?, any minor feedback should be cleared,
to not distract from the highligted search result.

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

Bug existed since version 5.5, commit b86f7868,
since the manner of grading status-bar messages changed.
2021-05-25 14:51:03 +02:00
Benno Schulenberg 6472a6b828 display: when a message gets overwritten, note that it is cleared
When on a one-row terminal a message gets automatically "dropped"
after a few moments, the subsequent waiting for a keystroke should
not think that there is still a message on the status bar.

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

Bug existed since commit 8d974cd2 from two days ago.
2021-05-12 16:00:11 +02:00
Benno Schulenberg 8d974cd292 statusbar: on a one-row terminal, drop light messages after a few moments
Only important error messages (ALERT) and information that the user
requested (^C, M-D) should stay put until the next keystroke.  Other
messages should be overwritten by the text of the buffer after just
a few moments, to make a one-row terminal slightly more friendly.

This addresses https://savannah.gnu.org/bugs/?60570.
2021-05-10 20:08:49 +02:00
Benno Schulenberg 2cf28f9db7 statusbar: suppress the cursor when the terminal has just one row
When showing a message on the status bar, the cursor should be off.

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

Bug existed since version 2.7.0, since nano allows very flat terminals.
2021-05-10 12:27:56 +02:00
Benno Schulenberg 36ffb5f0ac statusbar: suppress --constantshow when the terminal has just one row
When there is just one row, the text to be edited needs to be shown
there, not some meta information about the cursor position.

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

Bug existed since version 2.7.0, since nano allows very flat terminals.
2021-05-09 19:16:03 +02:00
Benno Schulenberg eb3cc3a32d minibar: stay out of sight when the terminal has just one row
When there is just one row, the user wants to see text on this row,
not a bar with some meta info.

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

Bug existed since version 5.5, since the minibar was introduced
with commit d31cc373.
2021-05-03 15:52:15 +02:00
Benno Schulenberg af90f03ac5 tweaks: condense three comments, drop another, and rewrap a line 2021-04-23 12:04:19 +02:00
Benno Schulenberg f54bc6c7d6 indicator: adjust the size to the number of visible lines, not chunks
Since two commits ago, the position of the indicator shows the position
of the viewport relative to the full buffer in terms of actual lines,
not of visual chunks (to avoid excessive computation).  But the size of
the indicator stayed constant, as if it always covered as many lines as
the edit window has rows.  But the latter will not be the case when
softwrapping occurs.  Therefore, when softwrapping, compute how many
actual lines are visible in the viewport, and adjust the size of the
indicator accordingly.
2021-04-22 11:52:57 +02:00
Benno Schulenberg 2cdff6c32c tweaks: adjust two comments, and reshuffle two fragments
Also rename two variables, to be more fitting.
2021-04-21 16:52:35 +02:00
Benno Schulenberg 49d8b99e4f softwrap: avoid time-consuming computations, to burden large files less
Whenever softwrap was toggled on or line numbers were toggled on/off or
the window was resized, the extra rows per line needed to be recomputed
for ALL the lines.  For large files with many long lines this was too
costly.

(This change causes the indicator to have an incorrect size when there
are many softwrapped chunks onscreen, but that will be addressed later.)

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

Problem existed since version 5.0, since the indicator was introduced.
2021-04-21 16:40:20 +02:00
Benno Schulenberg 018a8e12ca build: fix compilation for --enable-tiny plus --enable-multibuffer
This will not show the error messages for other buffers when using
a tiny build, but... one cannot have everything.
2021-04-10 12:01:34 +02:00
Benno Schulenberg d6ed174d09 tweaks: morph a function into what it is actually used for
Since the previous commit, mbwidth() is used only to determine whether
a character is either double width or zero width.  There is no need to
return the actual width of the character; a simple yes or no is enough.

Transforming mbwidth() into is_doublewidth() also allows streamlining
it and is_zerowidth() a bit, so that they become slightly faster.
2021-04-09 16:38:23 +02:00
Benno Schulenberg f11931a0dd tweaks: rename a variable, for contrast with another
The 'start_index' was in index in the given text, while 'index' is an
index in the displayable string.  Having both of them using 'index' in
their name was somewhat confusing.
2021-04-08 12:19:34 +02:00
Benno Schulenberg 31a6931be9 tweaks: elide a call of strlen() for every row
For a normal file (without overlong lines) the strlen() wasn't much
of a problem.  But when there are very long lines, it wasted time
counting stuff that wouldn't be displayed on the current row anyway,
and reserved *far* too much memory for the displayable string.

Problem existed since commit cf0eed6c from five years ago that traded
a continuous comparison (of the used space with the reserved space)
against a one-time big reservation up front involving a strlen().
In retrospect that was not a good trade-off when softwrapping.

The extra check (charwidth == 0) is incurred only by characters that
have their high bit set, so the average file (with only ASCII) is not
affected by this -- it just loses an unneeded call of strlen().
2021-04-08 12:15:12 +02:00
Benno Schulenberg c75a3839da tweaks: elide a small function that is used just once 2021-04-07 17:08:05 +02:00
Benno Schulenberg 09e4c86606 tweaks: improve a couple of comments 2021-04-07 12:28:48 +02:00
Benno Schulenberg 20eb422829 tweaks: avoid converting a file name for more than will fit on screen 2021-04-07 12:12:06 +02:00
Benno Schulenberg 90c6b572d0 display: avoid determining twice from and until where to draw each row
The two calls of draw_row() are each immediately preceded by a call to
display_string(), which has already determined from which x position
and until which x position in the relevant line the current row will
be drawn -- doing this again in draw_row() is a waste of time.  Even
though it is ugly, pass the two data points from one function to the
other via global variables.

For normal files (without overlong lines), this saves on average some
fifty calls of advance_over() per row.  When softwrapping a file with
overlong lines, the savings for each softwrapped chunk are much higher.
2021-04-07 11:27:10 +02:00
Benno Schulenberg 712b574fb7 tweaks: rename a variable, away from an abbreviation 2021-04-06 16:27:46 +02:00
Benno Schulenberg 9c16be32d7 tweaks: reshuffle two conditions, to have the most unlikely one first
This also better fits the preceding comment.
2021-04-05 16:10:44 +02:00
Benno Schulenberg 929770191e chars: work around a UTF-8 bug in glibc, to display invalid codes right
The mblen() and mbtowc() functions will happily return 4 or 5 or 6
for byte sequences that start with 0xF4 0x90 or higher.  But those
sequences encode for U+110000 or higher, which are not valid Unicode
code points.  The libc of FreeBSD and OpenBSD and Alpine correctly
return -1 for such sequences.  Make nano behave correctly also when
linked against glibc, so that invalid sequences are always presented
as a series of invalid bytes and never as a single invalid code.

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

Bug existed since before version 2.0.0.
2021-03-26 11:07:05 +01:00
Benno Schulenberg 66d9d6c6d2 tweaks: elide the pointless is_valid_unicode() function
The call of this function in make_mbchar() does not add anything,
because wctomb() already returns -1 for codes U+D800 to U+DFFF,
and parse_verbatim_kbinput() already rejects anything that starts
with U+11.... or higher, so make_mbchar() is never called for codes
beyond U+10FFFF.

And the call in display_string() just needs to check for wc <= 0x10FFFF
because mbtowc() already returns -1 for codes U+D800 to U+DFFF.
2021-03-25 11:24:41 +01:00
Benno Schulenberg 77da54c6c6 startup: do not store an error message in the record of another buffer
Set the 'format' of a file only when it has been fully read in,
so that this field can be used to indicate that any later error
message cannot be meant for this buffer.

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

Bug existed since commit 6bf52dcc from yesterday.
2021-03-23 16:19:07 +01:00
Benno Schulenberg 6bf52dcc8d startup: do not crash when trying to open a device or directory
Make sure there is an 'openfile' record before trying to save an
error message in this record.

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

Bug existed since commit ede64d7e from yesterday.
2021-03-22 15:50:31 +01:00
Benno Schulenberg ede64d7ea0 feedback: upon first switch to a buffer, show its error message (if any)
When opening multiple files and some of them had an error, only the
first message was shown and the others were lost -- indicated only
by three dots.  Improve upon this by storing the first error message
for each buffer and showing this message when the buffer is first
switched to.

Requested-by: Mike Frysinger <vapier@gentoo.org>
2021-03-21 16:52:29 +01:00
Benno Schulenberg e8db390d6f tweaks: reshuffle a fragment of code, to prepare for the next change
Also, don't reserve MAXCHARLEN bytes for the terminating NUL byte.
2021-03-21 16:52:29 +01:00
Benno Schulenberg 0c1bf429e8 display: make the output of --constantshow less jittery
That is: reserve for the current line and current character the number
of positions needed for the total number of lines and characters, and
reserve two positions for both the current column and the total number
of columns.  This will keep all nine numbers in the output in the same
place -- as long as there are no lines with more than 99 columns.  In
this latter case there will still be some jitter, but all-in-all the
output is much stabler than it was.

Suggested-by: Mike Frysinger <vapier@gentoo.org>
2021-03-18 16:20:04 +01:00
Benno Schulenberg a9ccd99b90 tweaks: rename a symbol, to better match the corresponding option 2021-03-03 09:39:49 +01:00
Benno Schulenberg a543f8cd8f search: correctly colorize a match also when softwrapping is active
This fixes https://savannah.gnu.org/bugs/?60149.
Reported-by: Peter Passchier <peter@passchier.net>
Reported-by: Liu Hao <lh_mouse@126.com>

Bug existed since version 5.6, since a special color for highlighting
search matches was introduced in commit 87fe73dd.
2021-03-01 10:43:28 +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 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 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 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 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 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 3ea2694d9c tweaks: rename six symbols, to be more straightforward 2021-01-28 16:11:57 +01:00
Benno Schulenberg befe4ea5de tweaks: frob some comments, and adjust indentation after previous change 2021-01-28 11:57:33 +01:00