Commit Graph

8976 Commits (bafcc19b7a565c0bbe3f5c3a6b18acb28eabb5d7)

Author SHA1 Message Date
Benno Schulenberg d729edaeda bindings: make ^L (Refresh) work at all the prompts too
(Unfortunately, this means that ^L cannot be used for the
Linter in the "Execute Command" menu.)

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

Bug existed since around version 2.1.0.
2020-06-04 09:10:48 +02:00
Benno Schulenberg bc92e28b30 tweaks: elide an unused parameter, and rename the other and a variable
Also, regroup a few lines.
2020-06-03 18:45:14 +02:00
Benno Schulenberg c5b0e1958a feedback: beep also at a prompt when receiving an unknown escape sequence
Nano would beep (and report "Unknown sequence") only when in the main
edit window, in the help viewer, or in the file browser.  But the same
keystroke at a prompt would be enigmatically silent.

Also, in the file browser, nano would leave the cursor at the end of
the "Unknown sequence" message when --showcursor was used.

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

Bug existed (in this form) since around version 2.7.4,
and in a worse form since around version 2.3.5.
2020-06-03 17:15:51 +02:00
Benno Schulenberg da43cc0959 display: reposition the cursor after an error message also in a help text
A help text is contained in a normal buffer (since quite a while now),
so cursor placement should work like in a regular edit window.

Also, remove an unneeded switching on of the cursor -- it is already on
as nano is waiting for keyboard input.

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

Bug existed since version 3.2, commit 10d9742c, since --showcursor
shows the cursor also in the help viewer.
2020-06-03 10:38:08 +02:00
Benno Schulenberg 506f617d5b tweaks: remove an unneeded call of wnoutrefresh()
On NetBSD, nano requires ncurses nowadays.  With ncurses, cursor
placement works fine without the extra call of wnoutrefresh().
2020-06-03 10:14:50 +02:00
Benno Schulenberg e81e18dd14 tweaks: recalculate the multiline info just once when doing "Replace All" 2020-06-02 19:14:36 +02:00
Benno Schulenberg 569d00564b replacing: recalculate the multiline coloring info when needed
If a replacement changed the matching of a multiline coloring regex,
then wipe the existing multiline data and recalculate it for the whole
buffer.

There is no need to redraw the current line (let alone the whole window)
directly after a replacement, because if there is a next occurrence, the
edit window will be redrawn then in order to spotlight that occurrence;
and if there is no other occurrence, the edit window will be redrawn in
the main loop because there has been at least one replacement.

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

Bug existed (in this form) since version 2.7.5.  Before that,
the miscoloring could happen even without scrolling.
2020-06-02 18:52:40 +02:00
Benno Schulenberg 881106c487 tweaks: drop two unneeded wnoutrefresh() calls in the spotlight routines
The call will be made at the end of edit_refresh() or in the main loop.
2020-06-01 20:28:07 +02:00
Benno Schulenberg 2a44cb2ed8 tweaks: rename a function, to leave the old names behind
What the function does has changed, so better change the name too.
2020-06-01 09:43:08 +02:00
Benno Schulenberg 19a124e806 display: avoid an additional redrawing when redrawing the screen
When resizing the screen or toggling the help lines or refreshing
the screen with ^L, what used to be total_refresh() would first call
what used to be total_redraw(), to tell ncurses to redraw whatever
had been on the screen so far, before proceeding to fully redraw the
content of the title bar and the edit window and the bottom bars.
That was duplicate work.

Thus, rename total_redraw() to total_refresh(), so that ^L in the
edit window, help viewer, and file browser will redraw the screen
just once.  This also preserves whatever was on the status bar
(when --quickblank isn't used).

Rename the old total_refresh() to draw_all_subwindows() and call
this routine when resizing the screen or toggling the help lines
or returning from the credits crawl.
2020-06-01 09:40:09 +02:00
Benno Schulenberg d9106abfda rcfile: rename 'extcmd' to 'execute', to be more readable and fitting
Also, improve its description in the documentation.
2020-05-31 12:04:58 +02:00
Benno Schulenberg bc0ea5ea71 help: describe what has been added to the "Execute Command" menu 2020-05-30 19:21:44 +02:00
Benno Schulenberg ee03c4b857 bindings: remove the Full-Justify function from the Search menu
It was out of place there and found a new home in the Execute menu.
2020-05-30 18:58:41 +02:00
Benno Schulenberg 6d7ff17901 help: put the two toggles first in the "Execute Command" menu
This makes that the M-F toggle stays roughly in the same place when
toggling between "Read File" and "Execute Command", and groups the
six special commands together.
2020-05-30 18:57:04 +02:00
Benno Schulenberg 7bad92c50b bindings: add ^Z (Suspend) to the "Execute Command" menu
This makes suspension more discoverable, and allows the user to rebind
^Z in the main menu without losing the ability to suspend nano.

This drops the ^X (Flip Execute) toggle from the menu -- keeping it
would make an ugly uneven number and would reduce the space for each
menu item too much (clipping "Full Justify" and "Cut Till End") --
but it is still present as a blind toggle.
2020-05-30 18:56:58 +02:00
Benno Schulenberg d3954901a9 bindings: make ^T invoke the "Execute Command" menu, and ^T^T the Speller
Make the "Execute Command" menu accessible also with a single keystroke
(^T), not just with a double one (^R^X).  This is useful, because no one
will suspect that "Execute Command" can be found behind "Read File".

To not disturb muscle memory too much for people who are used to ^T
invoking the Spell Checker, a second ^T will invoke it.
2020-05-30 18:56:55 +02:00
Benno Schulenberg cd594b85f4 general: make five tools accessible through the "Execute Command" menu
Instead of creating a special Tools menu, add the five functions that
affect the whole buffer to the "Execute Command" menu.  There is room
for these five functions there, and they kind of fit in because three
of them (Speller, Linter, and Formatter) actually invoke an external
command, and Full Justify could have been implemented externally, and
the destructive Cut Till End ought to have required a double keystroke
since the beginning.
2020-05-30 18:56:51 +02:00
Benno Schulenberg 933dd567de tweaks: separate a symbol from its definition by two spaces
It's a little clearer, and new ones were like that already.
2020-05-29 18:45:14 +02:00
Benno Schulenberg 248d392c4d tweaks: rename a symbol, and actually use it where it is needed 2020-05-29 17:19:38 +02:00
Benno Schulenberg e1f80b9707 tweaks: move a function to a more logical place
Initialization should come first.
2020-05-29 17:12:45 +02:00
Benno Schulenberg 6b4e7d0f78 tweaks: reshuffle a declaration and six calls of free(), to avoid a leak
If the user chose to skip making a backup,
'backupname' would not be freed.
2020-05-29 13:57:38 +02:00
Benno Schulenberg 4b4a8be58b files: before prompting, show also the reason why the backup failed
Also, do not prompt when there is no space left on the device,
because then trying to save the actual file would likely lead
to truncating it, resulting in an empty file.
2020-05-29 11:57:33 +02:00
Benno Schulenberg 512b0fd32d files: take into account that also closing a backup file can fail
Only when fclose() is called, does the data get flushed out to disk,
and maybe only then the system realizes that there is no space left on
the device, as Chris noted in: https://savannah.gnu.org/bugs/?24000.
2020-05-29 11:40:27 +02:00
Benno Schulenberg 586d22109b files: show a warning when writing a backup fails, before prompting
Make the behavior similar to that of the other failure cases.

Also, plug a tiny memory leak.
2020-05-29 11:22:57 +02:00
Benno Schulenberg 47953bd6ac files: also when creating a backup fails, ask the user whether to proceed
When asking this question when deleting fails or writing fails,
it should be asked too when creating fails.  Otherwise the user
is blocked from saving the file -- until she realizes that maybe
toggling off backups would help.
2020-05-29 10:58:11 +02:00
Benno Schulenberg 11d3b01050 files: give a more precise warning when deleting an existing backup fails
This addresses https://savannah.gnu.org/bugs/?58410.
2020-05-29 10:48:01 +02:00
Benno Schulenberg eddd8963e7 files: ask the user whether to proceed every time a backup fails
If the user answered "No" or "Cancel" the first time, they should
be allowed to answer "Yes" the next time -- possibly after fixing
the necessary permissions in another terminal.

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

Bug existed since version 2.3.0, commit 3d411188.
2020-05-29 10:23:54 +02:00
Benno Schulenberg 160f07baba tweaks: simplify an error message, by mentioning just the main point
Also, correct a comment.
2020-05-28 19:30:09 +02:00
Benno Schulenberg 822d764d27 files: ignore errors when calling futimens() on a backup file
Access control lists can permit read and write access to a file
but not permit to manipulate any attributes of the file.  So it
is quite possible for futimens() to fail, just like chown() and
chmod() can fail, but this should be no cause for alarm: as long
as writing the backup file worked, then writing the file itself
will probably work too.
2020-05-28 17:19:45 +02:00
Benno Schulenberg 6d00e75dc2 tweaks: rename a function, to be more correct 2020-05-28 16:59:50 +02:00
Benno Schulenberg 90772ad05b backup: do not understand ^C as "Yes" when asking whether to continue
This fixes https://savannah.gnu.org/bugs/?58443.

Bug existed since version 2.3.0, commit 3d411188.
2020-05-28 14:58:05 +02:00
Benno Schulenberg 756b95748b tweaks: rename a struct element, to be shorter and preciser
And anyway, there are too many occurrences of 'current'.
2020-05-28 14:38:48 +02:00
Benno Schulenberg 8d31ad8a70 files: ignore errors when calling chmod() on a backup file
First, it is very unlikely that chmod() would fail as the user just
created the file herself.  Second, even if chmod() would fail, this
is not a problem, because we have created the file with read+write
permissions for the owner only, so the file cannot accidentally be
left accessible to unintended others.

But most of all, such a failure should not stop nano from trying to
write the backup file.  Only when the actual *writing* fails, should
we bother the user with a prompt.
2020-05-28 14:35:42 +02:00
Ryan Westlund 3480518a5c syntax: go: highlight the chan keyword, and the special +build comment
This fixes https://savannah.gnu.org/bugs/?58424
Reported-by: Ryan Westlund <rlwestlund@gmail.com>

Signed-off-by: Ryan Westlund <rlwestlund@gmail.com>
2020-05-26 16:50:31 +02:00
Benno Schulenberg b48dfde3b2 files: remove two superfluous calls for shielding temp files from others
If there are still systems where mkstemp() creates world-readable
temporary files, then please holler.  On current BSDs and on GNU,
I've verified that mkstemp() creates files with 0600 permissions.
2020-05-26 13:40:11 +02:00
Benno Schulenberg f8366cd5c9 tweaks: remove two calls of umask() by specifying permissions directly 2020-05-26 12:36:18 +02:00
Benno Schulenberg 423105e371 tweaks: improve some comments and whitespace, and reshuffle a few lines
Also, silence a compiler warning.
2020-05-25 19:49:17 +02:00
Benno Schulenberg 5a7cdacf46 startup: allow presetting case-sensitive search also in the tiny version
If nanorc-file support is re-enabled (--enable-tiny --enable-nanorc),
then it ought to be possible to set case sensitivity at startup.
2020-05-25 19:08:00 +02:00
Benno Schulenberg d909291b0c tweaks: rename one of the flag symbols, to be clearer
I kept understanding 'BACKUP_FILE' as a noun instead of as an imperative.
2020-05-25 18:52:09 +02:00
Benno Schulenberg b30522463a files: do not append but truncate when allowing insecure backups
When deleting an existing backup file failed, we do not want to
append to this file, but want instead to overwrite it (when the
user has put 'set allow_insecure_backup' in their nanorc file).

Also, when using O_EXCL (in the normal, secure case), O_APPEND
is pointless, because the file will be created and thus empty.

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

Bug existed since version 2.2.5, commit 461519cc.
2020-05-25 12:22:15 +02:00
Benno Schulenberg 5449d1e6a5 files: ignore errors when calling chown() on a backup file
A normal user can change the group of a file (if the user is a member
of that group), but cannot change the owner of that file.  So, when a
user edits a file that belongs to a different user, the call of fchown()
will fail.  But there is no harm in that.  Also when the user is root,
there is no harm in fchown() failing -- it will simply mean that the
backup file will remain owned by root and will not be writable by the
intended owner (when root has the normal umask of 0022).

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

Bug existed since version 2.2.5, commit 86be3af7.
2020-05-24 16:08:05 +02:00
Benno Schulenberg d7743b05f0 tweaks: correct a comment, and drop a redundant (because nested) #ifdef
Also, drop an unneeded case-insensivity when comparing two strings,
as all commands in a nanorc file have to be in lower case.
2020-05-24 12:30:40 +02:00
Benno Schulenberg 8089f5ad54 build: do not let --disable-speller exclude also the formatter code
In the past, when Speller and Linter and Formatter were all bound
to ^T (later ones taking priority), it was easier to exclude also
the formatter code when --disable-speller was used.  But since the
formatter was reintroduced (in commit 34170611) and bound to its
own keystroke (M-F), this is no longer the case.
2020-05-24 12:08:50 +02:00
Benno Schulenberg 2579b105da tweaks: slightly improve the grouping of shortcuts in some help texts 2020-05-24 11:54:02 +02:00
Benno Schulenberg 09a004cad9 tweaks: order three menu names in the documentation slightly better 2020-05-24 11:24:49 +02:00
Benno Schulenberg 3162e73540 docs: copy the 4.9.3 news item from the release branch 2020-05-24 09:01:53 +02:00
Benno Schulenberg 2c5045bfce feedback: skip wiping the prompt bar when the shortcut printed a message
When, at a prompt, the user chose a function shortcut instead of typing
an answer, and this function printed some message to the status bar,
then we do not want to wipe this message.  Also: the message overwrote
and cleared the prompt bar, so there is no need to wipe the latter.

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

Bug existed since version 4.0, since justifying started giving feedback
(or rather since version 4.1, since M-J no longer crashed).
2020-05-22 12:12:36 +02:00
Benno Schulenberg 53c5ace8c3 tweaks: rename a symbol, away from a double abbreviation 2020-05-22 10:04:33 +02:00
Benno Schulenberg e0d00bc750 tweaks: avoid a compiler warning 2020-05-21 10:47:04 +02:00
Benno Schulenberg b72f3b10ba prompt: at Yes-No, do not treat a screen resize as an invalid keystroke
Commit 12cf1c99 added a beep() for every invalid keystroke at the
Yes-No prompt, but overlooked that KEY_WINCH is not invalid.

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

Bug existed since version 4.8, commit 12cf1c99.
2020-05-21 09:50:13 +02:00