Commit Graph

1651 Commits (be87f110ce3bcb5ce7dfd5926c8d0088a51f3bcc)

Author SHA1 Message Date
Benno Schulenberg be87f110ce bindings: allow rebinding ^Z also on a Linux console (a VT)
Achieve this by translating KEY_SUSPEND back to ^Z.

(Strictly speaking, this is incorrect, as the terminfo entry
might specify some other keystroke for 'kspd', but... meh.)

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

Bug existed since before version 2.2.0, since keys became rebindable.
2021-11-27 16:53:05 +01:00
Benno Schulenberg 6a521da437 display: ensure feedback will be cleared also on a one-row terminal
This fixes https://savannah.gnu.org/bugs/?61548.

Bug existed since commit be61aad9 from earlier today.
2021-11-24 16:17:34 +01:00
Benno Schulenberg 6d828cf470 display: move some code for overwriting verbatim feedback with --zero
This code was meant to do just that.  So, put it where it's needed.

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

Bug existed since commit 511a2850 from earlier today.
2021-11-24 16:00:14 +01:00
Benno Schulenberg 511a2850a1 display: with --zero, redraw the bottom row instead of wiping a message
This fixes https://savannah.gnu.org/bugs/?61541.

Bug existed since commit 03637030 from two weeks ago.
2021-11-24 12:34:23 +01:00
Benno Schulenberg be61aad935 display: do not wipe the status bar when --zero or --minibar is active
With --zero, any message that was there will get overwitten by the
text window anyway as result of the current operation.  And with
--minibar, any message will get overwritten with the minibar.

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

Bug existed since commit 03637030 from two weeks ago.
2021-11-24 12:03:29 +01:00
Benno Schulenberg c06f7d43e9 tweaks: reshuffle a few lines, for Christmas and to group things better 2021-11-24 10:44:12 +01:00
Benno Schulenberg 3638fb9da4 tweaks: place the unsetting of a flag better, and rename a variable
The unsetting should happen after the three possible early returns,
to avoid leaving the flag unset.

Also, don't bother to exclude the setting and unsetting from the
tiny version, to get rid of some cluttering conditionals.
2021-11-24 10:40:05 +01:00
Benno Schulenberg 2fc1f08573 tweaks: fix a parentheses mistake -- found by a warning from Clang 2021-11-23 17:37:50 +01:00
Benno Schulenberg 3be4ea0dc1 tweaks: fold a special case into the general one 2021-11-23 10:10:23 +01:00
Benno Schulenberg 9c9de85afb tweaks: elide a variable that is confusing and has just one use case 2021-11-22 12:03:28 +01:00
Benno Schulenberg addac49465 tweaks: reshuffle some conditions, to have more balanced lines 2021-11-22 11:13:02 +01:00
Benno Schulenberg 839d29be3f feedback: with --zero, drop a message in a short while, as with --minibar
Only requested information (^C, M-D) and alerts stay onscreen until the
next keystroke, but less important messages are overwritten after 1.5
seconds (or 0.8 seconds with --quick).  This makes the behavior more
consistent with dropping a message when there is a spotlighted match.
2021-11-22 11:00:11 +01:00
Benno Schulenberg b2f0721b69 tweaks: drop a fragment of code that became functionless
This fragment suppressed the cursor when it was on the bottom row of
the terminal and a message was displayed on the status bar.  But since
commit a2a00577 from eight days ago, the cursor will be scrolled off
of the bottom row when there is a message.
2021-11-22 10:53:56 +01:00
Benno Schulenberg 8e7738e22e tweaks: adjust two values -- help lines need at least 6 rows to be shown
Commit 931bf96c from four days ago incremented the minimum height.
2021-11-21 16:52:13 +01:00
Benno Schulenberg c9fb1cf85a tweaks: don't redraw the help lines (if present), and normalize a brace 2021-11-21 11:05:59 +01:00
Benno Schulenberg bbed065fa8 tweaks: avoid redrawing the entire window when just a 'touch' will do 2021-11-21 10:47:44 +01:00
Benno Schulenberg 8aea8625be replacing: keep the spotlighted occurrence in view, also with --zero
Also when adjusting the viewport, after the cursor has gone offscreen
(by toggling the help lines, for example), should the SHIM be applied.

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

Bug existed since commit 03637030 from last week.
2021-11-18 12:32:47 +01:00
Benno Schulenberg 931bf96c1d display: make sure there are at least as many text lines as help lines
It's an editor -- the largest element should be the text to be edited,
not some part of the interface.

(It would be better if the edit window was always the largest element,
larger than or equal to all interface elements combined.  But that is
something for another time.)
2021-11-17 17:09:29 +01:00
Benno Schulenberg 2cbd4d29a0 search: with --zero, drop a message at the same time as the spotlight
Messages like "Search Wrapped" and "This is the only occurrence"
do not need to be shown until the next keystroke.  Dropping them
quickly gives a better fullscreen experience.
2021-11-15 15:10:20 +01:00
Benno Schulenberg f3fab1440f tweaks: shorten two comments, and fold two statements together 2021-11-11 16:06:43 +01:00
Benno Schulenberg affca9b523 statusbar: overwrite a message also when using --constant with --zero
This needlessly wipes the status bar when --constantshow is active,
but it already needlessly wiped it when --minibar is active, so...
It is not a performance issue.  It was just a small optimization.
(Plus, with --zero, nano does a full edit_refresh() when in fact
only the bottom row needs to be redrawn, but there is no easy way
to do that when --softwrap is active, so...)

(Using --constantshow with --zero doesn't make sense, but the user
might want to have the --constantshow when they toggle --zero off.)
2021-11-11 16:02:58 +01:00
Benno Schulenberg 0363703073 new feature: option --zero for an interface without bars
With --zero or 'set zero', nano will hide the title bar or the minibar
(whichever is active) and will use all rows of the terminal for showing
the text of the buffer.  Only when there is an important message will
it be shown on the bottom row -- until the next keystroke.

This feature can be toggled with M-Z.

The feedback at startup ("Read nnn lines") is suppressed with --zero,
because it disrupts the fullscreen experience (and is hardly useful).
The "Reading..." message then needs to be suppressed too, otherwise
it creates an annoying little flash.

There are still some issues that need to be addressed:

* In the browser, when the highlighted item is on the bottom row, it
  will get obscured by the prompt bar or the "Search Wrapped" message.

* In the edit window, when the search occurrence is on the bottom row,
  it can get obscured by the "This is the only occurrence" message.

* When tabbing at a prompt shows possible completions, they are shown
  a row too low.
2021-11-09 11:50:40 +01:00
Benno Schulenberg fc5d58ad97 tweaks: add two spaces and two comments, and drop an internal check 2021-10-31 16:45:43 +01:00
Benno Schulenberg 8762e04631 replacing: keep the spotlighting, also after toggling the help lines
The spotlighting should only be dropped when in the main menu, like in
the code thirty lines up, where 'timed' became TRUE only for MMAIN.

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

Bug existed since version 5.8, commit 3f340836.
2021-10-29 10:28:00 +02:00
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