Commit Graph

10373 Commits

Author SHA1 Message Date
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
Benno Schulenberg dd009e0bc7 tweaks: rename a function and variable, to describe better what they do 2024-03-17 17:18:48 +01:00
Benno Schulenberg 170e7d79e7 tweaks: express an 'if' more concisely, and add two blank lines
The calls of wnoutrefresh() after those new blank lines are not needed
for ncurses to show the cursor in the right place, but are logically
needed because things have been written to the screen in the preceding
code -- although nano seems to work correctly also without those calls.
2024-03-17 16:57:19 +01:00
Benno Schulenberg a7635ceb5d tweaks: rename a variable, to be a bit more indicative 2024-03-17 16:40:04 +01:00
Benno Schulenberg 64fb0be8b2 tweaks: add another translator hint, to help avoid overlong key tags 2024-03-16 16:28:16 +01:00
Benno Schulenberg a5a8487132 tweaks: improve three translator hints
The browser listing has a rigid format: longer translations
for "(dir)", "(parent dir)", and "(huge)" will be clipped.
2024-03-15 14:06:14 +01:00
Benno Schulenberg 8cf61af551 indicator: do not oversize the scroller when softwrapping
This fixes https://savannah.gnu.org/bugs/?65445.

Bug existed since version 5.7, commit 49d8b99e.
2024-03-11 11:18:28 +01:00
Benno Schulenberg 778f000a3b docs: use a space after #, like everywhere else in the sample nanorc
Also, use a more mnemonic example shortcut for copy-to-clipboard.
2024-03-10 17:32:09 +01:00
Benno Schulenberg 623ff4e1ed docs: trim stuff that is more than five years old from the changelog
A detailed list of changes is useful for a small number of users only,
and only when the changes are fairly recent.

The NEWS file, that contains a summary of user-visible changes and
will be useful for a larger number of users, is distributed in full.
2024-03-09 17:18:04 +01:00
Benno Schulenberg 260f00c76d screen: recalculate the multidata when detecting the need for it
This fixes https://savannah.gnu.org/bugs/?65435.
The issue was reported by `correctmost`.

Problem existed since version 6.3, commit 80c2000f.
2024-03-09 09:01:31 +01:00
Benno Schulenberg 0c8a3b5c3e tweaks: pull a fragment of code a bit forward, to enable the next commit 2024-03-09 08:32:47 +01:00
Benno Schulenberg e76068a2de docs: adjust an example help line in the README to the current state 2024-03-08 17:12:28 +01:00
Benno Schulenberg a12e45c355 help: show ^F/^B as primary shortcuts for search, not as secondary
This looks better in the help viewer (^F/^B matching the pair M-B/M-F),
and showing ^F instead of ^W for search in the main edit window will
prevent novice users from using ^W in situations where they shouldn't.
2024-03-08 11:50:20 +01:00
Benno Schulenberg 74b9dd6881 help: rebalance the help items when --preserve is used
As a backward search is now normally always bound (to ^B, instead of
conditionally to ^Q), ^L should always be shown in the help viewer.

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

Problem existed since commit 8a304bdf, since ^F/^B do a search.
2024-03-08 11:31:02 +01:00
Benno Schulenberg edd0823d96 docs: mention that --modernbindings overrides --preserve 2024-03-08 11:25:14 +01:00
Benno Schulenberg 4ef4eb4f12 options: make --modernbindings actually override --preserve
When modern bindings are requested, ^S should save and ^Q must exit,
so --preserve and 'set preserve' need to be cancelled.

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

Bug existed since commit 18b37c98, which introduced --modernbindings.
2024-03-08 11:04:48 +01:00
Benno Schulenberg 862574f381 undo: force a screen refresh also for the special case Bsp-at-EOF
Because meanwhile the cursor might be someplace where EOF is offscreen.

This effectively reverts commit 9ccf85ea from two years ago, but also
sets 'focusing' to false so that the last line of the buffer will be at
the bottom of the edit window, where it probably was when Bsp was typed.

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

Bug existed since version 6.3, commit 9ccf85ea.
2024-03-07 17:14:18 +01:00
Benno Schulenberg c67ea1ffc1 undo: recompute the multidata when a piece of text is replaced
When a justification (or even a spell check) is undone or redone,
this might affect the matching of multiline regexes, so... schedule
a recalculation of the multidata in those cases.

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

Problem existed since version 6.3, commit 80c2000f.
2024-03-07 16:51:08 +01:00
Benno Schulenberg 5bd5bcd06a docs: mention backreferences (for replacements with regular expressions)
Also mention that nano prompts for each occurrence, and that, when
a region is marked, replacements are made only within that region.
2024-03-05 15:50:15 +01:00
Benno Schulenberg a13cd6a177 execute: show "Older" and "Newer" in the help lines, to allow rebinding
Since commits c8363a0d and a75bf0a1 from seven years ago, the Execute
menu permits retrieving previously executed commands, but the help text
and help lines never showed the corresponding keystrokes.

Four years ago commit d3954901 made the Execute menu directly accessible,
but I preferred to not mention the ^P/^N keystrokes in the help lines,
to leave as much space as possible for the executable functions (added
in subsequent commits), thinking that no one would want to rebind those
keystrokes anyway, as the Up/Down arrows seem more logical and easier.

The issue was reported by Ivan Vorontsov:
  https://lists.gnu.org/archive/html/help-nano/2024-02/msg00003.html
2024-03-05 11:31:48 +01:00
Benno Schulenberg f60c6b25ad docs: delete a remark about libvte that is no longer relevant
Libvte 0.55 is more than five years old -- almost all users will
have upgraded by now to 0.55 or newer.
2024-03-05 08:44:04 +01:00
Benno Schulenberg c6a2664106 tweaks: delete a redundant fragment of code from do_replace_loop()
Since commit 50954a4b from a year and a half ago, a replacing session
will not ever change the final empty line, so a fresh magic line will
never be needed.
2024-03-04 16:30:09 +01:00
Benno Schulenberg 4ab80abb5e justify: recompute the multidata for paragraphs larger than the viewport
A freshly justified paragraph does not yet have any multidata,
and if this new paragraph has more lines than fit in the viewport
(minus one line for the cursor), then the line above the top of the
new viewport will be without multidata.  The coloring code cannot
handle this, so all the multidata then needs to be recalculated.

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

Problem existed since version 6.3, commit 80c2000f.
2024-03-04 12:52:18 +01:00
Benno Schulenberg f37d097c1c rcfile: avoid crashing on an include path that is way too long
The `gnulib` globbing module apparently does not handle an overload
of slashes well, so avoid feeding it more than it can take.

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

Problem probably existed since version 2.3.3,
since globbing was introduced.
2024-03-04 11:44:22 +01:00
Benno Schulenberg 191cf671be input: store keystroke in macro buffer only when about to interpret it
When the keystroke after the keystroke bound to `recordmacro` arrived
so quickly that the two got stored together in nano's keystroke buffer,
the main loop had not yet interpreted the `recordmacro` command and had
thus not yet set 'recording' to true, meaning that that second keystroke
would not get recorded.

Nano should record keystrokes into the macro buffer when fetching them
from its own keystroke buffer, not when fetching them from ncurses.

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

Bug existed since version 2.9.0, since macros were introduced.
2024-03-02 17:45:11 +01:00
Benno Schulenberg 3098315e05 replacing: stash the string to be replaced while asking for replacement
During the Replace-With prompt the user could search in its help text,
which would overwite the 'last_search' string.  Make therefore sure that
the latter gets restored to what it was before the Replace-With prompt.

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

Bug existed since version 2.8.2,
since searching in a help text became possible.
2024-02-28 11:44:03 +01:00
Benno Schulenberg 39db2e9d66 tweaks: implement the fix of the previous commit somewhat differently 2024-02-27 17:24:32 +01:00
Benno Schulenberg ee1a1306e2 search: avoid crashing after searching a help text during a regex replace
Searching in a help text does not support using regular expressions,
so when 'inhelp' is set, do not free a compiled regex -- because if
there is such a regex, it belongs to a replacement session that is
about to begin.

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

Bug existed since version 2.8.2,
since searching in a help text became possible.
2024-02-26 13:20:24 +01:00
Benno Schulenberg db72774458 verbatim: avoid referencing an uninitialized value
Only check input bytes when their count is nonzero.

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

The problem existed since version 5.7, commit c75a3839,
but occurred more easily since version 7.0, commit 75e5f885.
2024-02-26 10:48:51 +01:00
Benno Schulenberg 3d727266c3 input: for one bump of the mousewheel scroll two lines, not three
Scrolling three lines at a time goes too fast: it feels erratic.
Whereas scrolling two lines at a time still feels like scrolling.
2024-02-25 16:14:44 +01:00
Andy Koppe 4673e709b2 input: scroll on mousewheel events instead of moving the cursor
Translate mousewheel events into Alt+Up/Down key presses instead of
into plain Up/Down key presses, as the latter only start scrolling
once the cursor reaches the top or bottom.

Scrolling rather than moving the cursor is the standard behavior for
mousewheel events in GUI editors such as Gedit and Kate, as well as
in the mouse mode of terminal editors such as vim, joe, and mcedit.

Signed-off-by: Andy Koppe <andy.koppe@gmail.com>
2024-02-23 16:06:33 +01:00
Benno Schulenberg f1a04f780a syntax: javascript: recognize also the .mjs extension
The V8 JavaScript-engine developers recommend using this extension:
  https://v8.dev/features/modules#mjs

Also, add the fairly new "JavaScript source" as magic description.

This fulfills https://savannah.gnu.org/bugs/?65334.
Requested-by: Matt Whitlock <gnu@mattwhitlock.name>
2024-02-20 17:00:48 +01:00
Benno Schulenberg eca5856d99 tweaks: remove two pairs of unneeded braces, and normalize a line 2024-02-18 15:02:51 +01:00
Benno Schulenberg 190221c91c justify: set `x = 0` for the undo item, for when using --cutfromcursor
When --cutfromcursor is active, 'current_x' needs to be set to zero when
doing a justification, so that the correct starting position gets stored
in the undo item.  (Without --cutfromcursor, the value of 'current_x'
does not matter.)

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

Bug existed in this form since version 5.0, commit ae5a4ece.

Between versions 4.0 and 5.0, nano would not eat a line but would
instead crash when undoing a justification that was done with the
cursor away from the left edge.
2024-02-16 15:56:22 +01:00
Benno Schulenberg 77d74b5d81 input: flush the keystroke buffer upon any kind of error condition
This stops the execution of a macro or a string bind whenever something
unexpected happens, to prevent the waiting keystrokes from doing things
that were not intended.

Especially this prevents an infinite loop: when during the recording
of a macro the `runmacro` keystroke is typed in some menu (where the
keystroke is not bound), and the macro is later replayed in a way that
results in exiting from that menu before the `runmacro` keystroke gets
replayed...

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

Bug existed since version 2.9.0, since the macro feature was introduced.
2024-02-14 09:23:18 +01:00
Benno Schulenberg 0e44752ba1 justify: set the correct starting point also with --cutfromcursor
When --cutfromcursor is active, 'current_x' does need to be zero for
the segment extraction to do the right thing.

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

Bug existed since version 4.0, commit 2500debb.
2024-02-11 16:31:20 +01:00
Benno Schulenberg 20692e0c29 browser: restore typing position at prompt after "^R name ^T ^F ^V ^C"
When going back from the browser to a file prompt, restore the typing
position also after a 'to_first_file' (^Y) and 'to_last_file (^V).

The cursor misplacement existed since version 5.9, commit 508301a2.
2024-02-11 16:05:56 +01:00
Benno Schulenberg 206b4e2a7e search: avoid a crash after a nested search, reported by `correctmost`
When going back to a previous prompt, restore the typing position
also for 'to_first_line' (^Y) and 'to_last_line (^V).

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

Bug existed since version 5.9, commit 6d5b1656, which allowed exiting
from a Search-in-help prompt with ^Y or ^V.
2024-02-11 14:57:24 +01:00
Benno Schulenberg 8fefee2d41 undo: prevent a use-after-free, reported by `correctmost`
When the cursor is on the last line, and an undo removes this line,
do not let 'openfile->current' become invalid.

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

Bug existed since version 6.3, commit eea3e1f0.

(It should have been fixed in commit 9410a556, more than a year ago.)
2024-02-10 12:14:52 +01:00
Benno Schulenberg cdaa43b396 syntax: makefile: ensure that the <Tab> key always produces a tab
Making it independent from the `tabstospaces` setting.

And remove the now-redundant suggestion from the sample nanorc.
2024-02-05 17:17:37 +01:00
Benno Schulenberg a0eebf20db bindings: in the tiny version, bind M-6 only in main, not at the prompts
This prevents M-6 from unexpectedly exiting from the prompt
and then copying a line in the edit window.
2024-01-31 08:34:02 +01:00
Benno Schulenberg b84f6fc15f general: include the Copy function (M-6 or ^C) into the tiny version
When using --modernbindings with the tiny version, it was strange that
^X cuts and ^V pastes but ^C complains about being unbound.  Fix that.
2024-01-31 08:21:28 +01:00
Benno Schulenberg d0a1bc361a help: restore ^H and ^D as the primary shortcuts for Backspace and Delete
Commit 18b37c98 moved the bindings of ^H and ^D further down.  Now move
the bindings of <Bsp> and <Del> to after those, so that ^H and ^D will
be shown again first in the help text (when not using --modernbindings).
2024-01-30 08:13:23 +01:00
Benno Schulenberg d35650b034 docs: document the new --modernbindings option 2024-01-29 10:40:48 +01:00
Benno Schulenberg 580eaf29d6 bindings: set up modern bindings also when binary's name starts with "e"
This allows activating the "modern" bindings without having to pass an
option, by simply invoking nano through a symlink -- for example: `en`
(short for "editor nano"), or `et` (short for "edit"), or just `e`.
2024-01-29 10:40:48 +01:00
Benno Schulenberg a27da0d75b bindings: with --modern, do not let ^Q^Q quit nano without saving
With --modernbindings, instead accept ^Q^X for abandoning any changes
-- the inverse of the normal (but undocumented) ^X^Q.

This prevents the unintentional loss of work when the user hits ^Q twice
by accident.
2024-01-29 10:40:48 +01:00
Benno Schulenberg 26c75a6828 bindings: with --modern, use ^H for Help when the terminal allows it
Also, allow using ^H (or ^N) for exiting from Help too.
2024-01-29 10:40:48 +01:00
Benno Schulenberg c32828bb13 tweaks: normalize the indentation after the previous change 2024-01-29 10:40:48 +01:00
Benno Schulenberg 18b37c980a new feature: option --modernbindings sets up more widespread key bindings
With --modernbindings, ^Q quits, ^F finds, ^B finds backwards, ^G finds
again, ^D finds again backwards, ^X cuts, ^C copies, ^V pastes, ^A sets
the mark, ^R replaces, ^O opens a file, ^W writes out a file, ^S saves,
^Z undoes, ^Y redoes, ^P shows the position, ^T goes to a given line,
and ^E executes.

Note that with --modernbindings ^Q and ^S are always bound, meaning that
--preserve / 'set preserve' is ignored.  This is necessary because ^Q is
an essential keystroke in the modern bindings.

Also note that these "modern bindings" are effective only in the main
edit window, not in the various menus.  In all menus ^C means Cancel,
and I can't think of a good alternative default keystroke for that
(in order for ^C to mean Copy).  And in a few menus ^V has a meaning,
and there is no good alternative for that either.  So... in the menus
the user has to use M-6 for Copy and ^U for Paste (and ^K for Erase --
Cut does not exist in the menus), like with the default bindings.
2024-01-29 10:40:48 +01:00