Commit Graph

10321 Commits

Author SHA1 Message Date
Benno Schulenberg 2334dedba6 tweaks: make a comment more accurate, and unabbreviate a variable name 2024-05-05 10:27:21 +02:00
Benno Schulenberg e9c7dfa992 minibar: do not falsely report that a new, empty file is in Mac format
The 'openfile->fmt' element gets initialized to 'UNSPECIFIED',
so the code has to take that possibility into account.

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

Bug existed since version 8.0, commit fe4f74f6.
2024-05-03 12:12:09 +02:00
Benno Schulenberg 33eaf3e947 po: update translations and regenerate POT file and PO files 2024-05-01 10:42:51 +02:00
Benno Schulenberg ce5513b009 bump version numbers and add a news item for the 8.0 release 2024-05-01 10:10:15 +02:00
Benno Schulenberg a98b03e46e tweaks: rewrap two old news items 2024-04-28 16:49:09 +02:00
Benno Schulenberg e4c3ffcd38 tweaks: rename a variable, away from an abbreviation 2024-04-28 13:45:08 +02:00
Benno Schulenberg 5e7a3c2e7e files: run `chmod` and `chown` on the descriptor, not on the filename
This closes a window of opportunity where the emergency file could be
replaced by a malicious symlink.

The issue was reported by `MartinJM` and `InvisibleMeerkat`.

Problem existed since version 2.2.0, commit 123110c5, when chmodding
and chowning of the emergency .save file was added.
2024-04-28 10:56:21 +02:00
Benno Schulenberg c020d53e23 input: snip the `recordmacro` and `runmacro` keystrokes in a better way
When recording a macro over a laggy connection or on a slow, overloaded
computer, several keystrokes could be recorded in one burst, and if any
but the last of those keystrokes was the shortcut for `runmacro`, then
running the macro would lead to an infinite loop and nano would hang.

This new implementation of snipping the "last keystroke" will, however,
snip *too many* keystrokes when several of them were recorded at once
and `runmacro` or `recordmacro` was among them, resulting in a cropped
and thus misrecorded macro.  But... that's better than hanging.

In general, though, the user should be slow and deliberate when
recording a macro: waiting for nano to have processed the last
keystroke before typing the next.

This fixes https://savannah.gnu.org/bugs/?65649.
The issue was reported by `correctmost`.

Problem existed since version 2.9.0, since macros were introduced.
2024-04-27 17:17:03 +02:00
Benno Schulenberg cb02937714 wrapping: delete only single characters, not a possibly marked region
These calls of do_delete() were meant to delete just one character,
but over time do_delete() morphed into doing also other things...
Change the calls to invoke the correct function instead.

(This also avoids snipping any zero-width characters that come after
a snipped space, as that is probably not what the user wants.)

This fixes https://savannah.gnu.org/bugs/?65636.
The issue was reported by `correctmost`.

Bug existed since version 3.2, commit ae3ec178,
when --zap was introduced.
2024-04-25 11:01:42 +02:00
Benno Schulenberg 1327e296c2 tweaks: rename a function, for contrast, and update antiquated comments 2024-04-25 10:34:03 +02:00
Benno Schulenberg d53521a631 syntax: sh: recognize more shells than `sh` on a shebang line for busybox
Also, elide an unneeded pair of parentheses.

Original-patch-by: Sertonix <sertonix@posteo.net>
  https://lists.gnu.org/archive/html/nano-devel/2024-04/msg00026.html
2024-04-22 10:29:02 +02:00
Benno Schulenberg 5beb14cffe softwrap: realign start-of-screen when redoing an automatic hard-wrap
Redoing an automatic hard-wrap while one or more chunks of the affected
line are offscreen, can leave 'firstcolumn' with a value that doesn't
fit the situation.  So, make sure that it has a valid value.

This complements the previous commit.

This fixes https://savannah.gnu.org/bugs/?65611.
The issue was reported by `correctmost`.

Bug existed since version 2.8.6, commit e375995d.
2024-04-19 16:11:14 +02:00
Benno Schulenberg 7b07e1ee5c softwrap: adjust start-of-screen when the 'edittop' line is hard-wrapped
When one or more chunks of the current line are above the viewport,
and this line gets hard-wrapped, then 'edittop' needs to be advanced,
otherwise the first row could be blank -- representing a chunk that
doesn't exist any more.

This fixes https://savannah.gnu.org/bugs/?65604.
The issue was reported by `correctmost`.

Bug existed since version 2.8.6, commit e375995d.
2024-04-17 17:12:09 +02:00
Benno Schulenberg c02aec557c syntax: makefile, sh: recognize also a fresh Makefile and fresh .profile
When opening a nonexistent file with nano, it likely consists of only a
name without any path component, and thus without any slash.  So when a
file regex checks for a slash, it should check also for start-of-string.

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

Problem existed for the Makefile since version 2.9.8, commit 22663f8a,
and for .profile since version 3.0, commit 4a268678 (but earlier, nano
did not recognize .profile files at all).
2024-04-14 12:09:36 +02:00
Benno Schulenberg c695d49a86 editing: adjust the mark before trimming redundant blanks
When an entirely blank line is trimmed (when --autoindent is active and
Enter is pressed while the cursor is at the end of the current indent),
the mark needs be adjusted *before* 'current_x' is zeroed, otherwise the
mark gets moved too much to the right, which causes the region to become
bigger than what the user intended, or leads to accessing unallocated
memory.

This fixes https://savannah.gnu.org/bugs/?65586.
The issue was reported by `correctmost`.

Bug existed since version 2.8.1, commit 005ee8ed.
2024-04-13 16:24:18 +02:00
Benno Schulenberg 3cd3ba0397 gnulib: update to its current upstream state 2024-04-12 10:57:03 +02:00
Benno Schulenberg 829ab5e72d syntax: nanorc: colorize {toprow} and {bottomrow} for string binds 2024-04-07 15:55:38 +02:00
Benno Schulenberg 4ae8082552 files: do not allow M-U to remove text read from standard input
This fixes https://savannah.gnu.org/bugs/?65565.

Problem existed since version 2.1.8, commit 25d459aa,
since reading from standard input was introduced.
2024-04-07 11:33:34 +02:00
Benno Schulenberg 2c8d57fbb2 docs: document the new bindable functions 'toprow' and 'bottomrow' 2024-04-07 10:57:07 +02:00
Benno Schulenberg e51a28e492 rcfile: add bindable functions for moving the cursor to top or bottom row 2024-04-07 10:47:03 +02:00
Benno Schulenberg 72c83badf6 feedback: lowercase a letter, as the phrase is not a full sentence
It could also have been after a comma (instead of between parentheses).
2024-04-07 10:39:06 +02:00
Benno Schulenberg fe4f74f631 minibar: mention the file format when it's DOS or Mac
This provides feedback about the file format in a better way than
how it was done until the previous commit.
2024-04-07 10:27:21 +02:00
Benno Schulenberg 2b335060b0 feedback: suppress format-conversion messages for --zero and --mini
A "Read xx lines (converted from...)" message should be suppressed when
--zero or --minibar are active (just like the normal "Read xx lines"),
as otherwise it gets shown at a confusing moment when multiple files
are opened at the same time.  The message should get shown, however,
when inserting a file into the current buffer.

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

Bug existed since version 6.0, commit f147131e.
2024-04-06 17:55:29 +02:00
Benno Schulenberg c3fc3ec73d tweaks: slightly reword the help text for the Replace-With prompt
To avoid the vague impression that the characters typed at the two
prompts should correspond one to one.
2024-03-31 14:02:29 +02:00
Benno Schulenberg be14fc593f tweaks: rename two variables, to be clearer and to match others
Also trim a verbose comment.
2024-03-30 12:39:15 +01:00
Benno Schulenberg f2bfa53b61 tweaks: elide a redundant variable 2024-03-30 12:39:04 +01:00
Benno Schulenberg 25d07b422d tweaks: rename a variable, to better indicate what it represents
And also to get away from the abundance of the word "current".
2024-03-30 11:35:41 +01:00
Benno Schulenberg 8610857015 feedback: drop an unnecessary warning, to not bother the user
The idea of the warning was that `row < 0 || row >= editwinrows` would
never be true: that the check was redundant and could be removed.

As it appears to be too hard to make sure in advance that a chunk will
not fall outside the viewport, just drop the warning and leave the check
in place.

This also addresses https://savannah.gnu.org/bugs/?64168.
Reported-by: Matteo Raso <matteo_luigi_raso@protonmail.com>
2024-03-30 11:15:32 +01:00
Benno Schulenberg 17abce073f display: do not attempt to draw a line that is outside the viewport
When we're on the last row in the viewport, it is unwise to try and draw
the next line.

This fixes https://savannah.gnu.org/bugs/?65539.
The issue was reported by `correctmost`.

Bug existed since commit c2322f85 from three days ago.
2024-03-30 10:49:29 +01:00
Benno Schulenberg 02d50bd4aa help: mention M-Home and M-End in the help text and help lines
Make these new keystrokes discoverable for people who read help texts.
2024-03-29 12:56:15 +01:00
Benno Schulenberg 67d459b262 bindings: let <Alt+Home/End> move the cursor to top/bottom of viewport
For now these are hidden keystrokes -- they are not listed anywhere,
and the functions are not bindable by the user.
2024-03-28 16:04:34 +01:00
Benno Schulenberg 5ecefb8766 moving: preserve horizontal position when jumping to top or bottom row 2024-03-28 16:04:34 +01:00
Benno Schulenberg 52eb0e992d new feature: functions that jump to the top or bottom of the viewport
(The next commit will preserve the horizontal cursor position.)
2024-03-28 16:04:34 +01:00
Benno Schulenberg 19ddc081c1 tweaks: rename a variable, to be more readable 2024-03-28 16:01:48 +01:00
Benno Schulenberg 8e91e26cc5 tweaks: reshuffle three fragments of code, moving related things together
And avoid calling xplustabs() twice in a row.
2024-03-28 15:58:28 +01:00
Benno Schulenberg c2322f8563 display: draw a new magic line rightaway when there are multiline regexes
Drawing a line will allocate multidata for it (even when the line is
actually empty), so that this multidata will not be missing later on
when the next line gets drawn in the same burst of keystrokes.

(This also removes the triggering of a full refresh when line numbers
are active: only the new magic line needs to be additionally drawn, in
order to get the line number printed.)

This fixes https://savannah.gnu.org/bugs/?65516.
The issue was reported by `correctmost`.

Problem existed since version 6.3, commit 80c2000f.
2024-03-27 11:12:47 +01:00
Benno Schulenberg 4f0683a481 docs: add an example binding for normalizing Unicode to the sample nanorc
This requires `uconv` from the 'icu-devtools' package (on Debian).
2024-03-26 11:37:29 +01:00
Benno Schulenberg b9449de5cf docs: improve the description of the 'flipexecute' bindable function
It is bindable only in the Insert menu -- in the Execute menu it has
a "blind", unadvertised binding (because I consider toggling between
menus somewhat of a misfeature).
2024-03-26 11:29:56 +01:00
Benno Schulenberg c3a9578b82 feedback: raise the level of "Macro is empty", to match similar messages
The other three "... is empty" messages use the AHEM error level too.
2024-03-26 11:27:38 +01:00
Benno Schulenberg 6351dab3e6 bindings: let M-" place/remove an anchor, and let M-' jump to one
On my current laptop, typing <Alt+Insert> is awkward because it requires
holding down <Fn> too.  Also, M-" and M-' are in the normal symbols area
of the keyboard, which makes them easier to type and more discoverable.
Furthermore, being next to M-: and M-; (on a US keyboard) reinforces the
meanings: start/place, stop/remove, run/goto.
2024-03-25 11:01:14 +01:00
Benno Schulenberg 3ef6399d56 tweaks: rename a variable, away from an abbreviation
And rename its sister too.
2024-03-24 10:46:46 +01:00
Benno Schulenberg f4754bfb5a memory: prevent a leak by freeing a possibly already existing color combo
This fixes https://savannah.gnu.org/bugs/?65505.

Buglet existed in this form since version 2.9.3, commit 4b24ce1c.
2024-03-23 11:04:23 +01:00
Benno Schulenberg 3fb8efc8f2 input: prevent 'macro_length' from underflowing when hammering M-:
Normally, when recording a macro, users will make their keystrokes
slowly and carefully, and will most likely wait to see the effect
of the previous keystroke before making the next.  So, the chances
of two `recordmacro` keystrokes coming in in quick succession is
normally nil.  The 'macro_length' variable just needs a guard to
prevent it from underflowing when someone is hammering the keys.

This fixes https://savannah.gnu.org/bugs/?65394 in a better way.
2024-03-22 16:27:34 +01:00
Benno Schulenberg 9ae84071eb input: store key codes in the macro buffer as they come in from ncurses
Otherwise the leading ESC of keystrokes like M-A does not get recorded.

This reverts commit 191cf671 from three weeks ago.

This fixes https://savannah.gnu.org/bugs/?65507.
2024-03-22 16:27:11 +01:00
Benno Schulenberg c2b4c2ae0e docs: mention that 'light' background colors do not work on Linux console
This addresses https://savannah.gnu.org/bugs/?65501.
Reported-by: Alan Cristhian Ruiz <alancristhian@protonmail.com>
2024-03-22 11:23:05 +01:00
Benno Schulenberg 9f1431be17 justify: keep as much of the marked region onscreen as possible
When the justified region fits in its entirety onscreen, then it should
be shown in its entirety, because the user is probably curious what the
region looks like after justification.  This behavior will mean that
the line above the topline of the screen will still have multidata
(when the syntax has multiline regexes).  When the justified region
does not fit onscreen, then as much as possible should be shown --
meaning that the cursor should be either at the top or the bottom
of the viewport, meaning that it should not be centered.

This fixes https://savannah.gnu.org/bugs/?65482.
The issue was reported by `correctmost`.

Bug existed since version 4.0, since justifying a region was introduced.
2024-03-19 17:18:18 +01:00
Benno Schulenberg e1c6ae7cf3 justify: keep the cursor at the original end of a marked region
When justifying a region that was marked backwards, the cursor
should stay at the beginning of this region.  The old logic was
faulty because mark_is_before_cursor() does not give the correct
result *after* the justification has been done: for some reason
the mark ends up always before the cursor.

Bug existed since version 5.2, commit 0f8423eb,
which mistakenly removed the auxiliary variable.  :/
2024-03-19 16:45:02 +01:00
Benno Schulenberg bb7a9fe7d2 tweaks: ungettextize three strings, to make a translator hint right again
The strings are gettextized further down, for the non-tiny version,
so they will get translated anyhow.  The relevant translator hint
is the earlier one about "the next thirteen strings".

Also adjust an indentation, and ungettextize another string for
consistency.
2024-03-19 11:56:33 +01:00
Benno Schulenberg d77263d8ed bindings: let M-& show the ncurses version+patch, as a small Easter egg 2024-03-18 10:33:40 +01:00
Benno Schulenberg fdd92af3ac display: add a wnoutrefresh() call for NetBSD, to force a cursor update
With NetBSD curses, when only the cursor is moved (without writing any
text), then a call of wnoutrefresh() is needed to make doupdate() move
the cursor.  Ncurses does not need this.

This addresses https://savannah.gnu.org/patch/?10438.
2024-03-18 10:02:11 +01:00