10495 Commits

Author SHA1 Message Date
Benno Schulenberg
a0918c5e98 tweaks: random unimportant edits here and there 2025-05-18 12:34:07 +02:00
Benno Schulenberg
879885a736 tweaks: use reallocations, instead of new allocations plus frees
Probably more than half of the reallocations will be no-ops, so
this should be faster.
2025-05-18 12:27:18 +02:00
Benno Schulenberg
155258e06e docs: add a suggested key combo for wiping all anchors to sample nanorc 2025-05-18 09:42:41 +02:00
Benno Schulenberg
06e48df8a3 feedback: report the setting and removing of an anchor just once
When line numbers or the mini bar are active, there is no need for
the status-bar messages.  Only when both line numbers and mini bar
are absent, the feedback messages are needed.
2025-05-17 17:51:25 +02:00
Benno Schulenberg
88776e0eee docs: mention that --positionlog also saves the positions of anchors 2025-05-17 17:51:25 +02:00
Benno Schulenberg
9be62a6964 build: fix compilation when configured with --disable-utf8
Always include the function using_utf8(), to be able to avoid
the cluttering #ifdef that was removed in the previous commit.
2025-05-17 17:51:11 +02:00
Benno Schulenberg
c000917cda anchor: change the aspect of any anchor to a dagger (†)
Now that anchors are always saved, there is no need to differentiate
anchors that are saved (■) from anchors that will evaporate (⬥).

Choose a new appearance (†) to signal the changed behavior.
(And because I didn't much like the look of the block.)
2025-05-17 11:32:57 +02:00
Benno Schulenberg
76b87890d8 history: always save the positions of any anchors
Let the saving of anchors not depend on the presence of an anchor
on the first line.  That was a clever mechanism to allow avoiding
the unnecessary saving-of-anchors, but... it was awkward and ugly.
2025-05-17 11:32:57 +02:00
Benno Schulenberg
d0796bde4f history: always save the last cursor position, also for line=1,column=1
This may seem a little wasteful, as line=1,column=1 is the default
cursor position, but this change enables the next commit: always
saving any anchors.  In the bargain, the position-history file now
contains a list of all files that were recently opened with nano.
2025-05-17 11:31:48 +02:00
Benno Schulenberg
a6e7d5c99b tweaks: elide an auxiliary variable that is no longer needed 2025-05-17 09:14:28 +02:00
Benno Schulenberg
b37cc32de0 history: reverse the order in the file-positions list, to latest first
Putting the record for the last-edited file at the top of the list
ensures that (in case of a duplicate entry) the newest entry will
be encountered first and thus reused.  It also makes searching the
list faster, because the files that the user is likely to soon edit
again will be near the top of the list instead of near the end.

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

Problem existed since version 2.3.0, since position logging was
introduced, but was aggravated by the recent anchor-saving code.
2025-05-17 08:55:45 +02:00
Benno Schulenberg
6d724f6d07 feedback: show in mini bar the presence of an anchor on the cursor line
And as the presence of an anchor is now visible in the mini bar,
the "Placed anchor"/"Removed anchor" messages are no longer needed
when the mini bar is active.
2025-05-14 15:51:45 +02:00
Benno Schulenberg
1cc19c8c6a feedback: change the appearance of anchors when they will be saved
When an anchor is present on the first line of the buffer, make any
anchors appear as little blocks (■) instead of the usual diamonds (⬥).

This different appearance lets the user know whether a placed anchor
anywhere in the file will be saved or not -- when line numbers are
active.  (In an 8-bit locale an = replaces the usual +).
2025-05-14 15:51:45 +02:00
Benno Schulenberg
60e2f2baf2 new feature: save and restore anchors when the first line has an anchor
When an anchor is placed on the first line in a buffer and --positionlog
is active, nano will now save the positions of the anchors when the file
is closed, and will restore the anchors when the file is reopened.

(The positions are stored in the file-positions history file, along
with the cursor position.)

This fulfills https://savannah.gnu.org/bugs/?62269.
Requested-by: Shi Yanling <sylphenix@126.com>
Requested-by: Sébastien Desreux <seb@h-k.fr>

Sponsored-by: Sébastien Desreux <https://doc-solus.fr>
2025-05-14 15:51:24 +02:00
Benno Schulenberg
b8c684193e tweaks: elide the unneeded passing around of three parameters
The function has_old_position() was used just twice, and both calls
were followed by basically the same call of goto_line_and_column().
So... move the latter call into the first function, to avoid the
unneeded passing back and forth of the line and column numbers.
2025-05-09 12:14:06 +02:00
Benno Schulenberg
84b1fdf6c6 syntaxes: add a license line to files that were created by Mike Frysinger
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2025-05-08 10:31:44 +02:00
Benno Schulenberg
2181853574 syntaxes: use character classes instead of range expressions
In some locales certain normal ASCII characters are not included in
the ranges [A-Z] and [a-z].  So, use [[:upper:]] and [[:lower:]]
instead, and [[:alpha:]] for [A-Za-z], and similarly for others.

This fixes https://savannah.gnu.org/bugs/?67094.
2025-05-08 10:24:49 +02:00
Benno Schulenberg
281197895f bindings: lowercase an ASCII character in a locale-proof manner
Calling tolower() on the 'I' (of "M-I") in a Turkish locale will not
return 'i' but 'I' instead.  This is because the lowercase of 'I' is
'ı' (a dotless i), which does not fit in an 8-bit character type, so
tolower() will return the 'I' unchanged.

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

Buglet existed since before version 2.2.0.
2025-05-07 11:02:15 +02:00
Benno Schulenberg
d50e8feed9 tweaks: avoid using toupper() and tolower() where easily possible
Those functions can misbehave for some characters in certain locales.
2025-05-07 11:02:04 +02:00
Benno Schulenberg
8e104117a4 new feature: exit with an error status (2) for ^X^Q and ^O^Q
Nano used to exit always with a success status (0).  But now, if
the user wants to make nano report failure to a calling program,
they can use ^X^Q (when the buffer is modified) or ^O^Q (always).

This fulfills https://savannah.gnu.org/bugs/?65755.
2025-05-06 11:00:02 +02:00
Benno Schulenberg
b8b71399e8 menus: reshuffle an item, to avoid truncating its help-line label
The label "Discard buffer" is rather long (and is in most translations),
so make the item the last-but-one so that it effectively has the space
for two labels available (because the number of items in the WriteOut
menu is currently uneven).
2025-05-05 13:39:34 +02:00
Benno Schulenberg
fb78eea6fc bindings: always bind ^Q in the WriteOut menu, not only for --saveonexit
This gives the user a keystroke combo (for abandonning a buffer) that is
always the same, no matter whether the buffer is modified or not: ^O^Q.
2025-05-05 12:45:49 +02:00
Benno Schulenberg
a942be9f6f feedback: change the level of a certain message, to show it is special 2025-05-04 12:02:05 +02:00
Benno Schulenberg
34db8682b3 moving: make cycling (M-%) independent from centering (^L)
The first strike of M-% should always try to center the cursor,
also when the preceding keystroke was ^L.
2025-05-03 10:12:49 +02:00
Benno Schulenberg
61dee21466 bindings: let ^L just center the cursor, not cycle it -- let M-% cycle it
In my experience the default cycling behavior of ^L was puzzling:
hitting ^L twice left me wondering sometimes: where is the cursor?

Inspired-by: Peter Michaux <petermichaux@gmail.com>
2025-04-28 12:53:49 +02:00
Benno Schulenberg
820f68f147 bindings: do not list ^L twice (in main help text and help lines)
In my eyes this wasn't really a problem, but... better be precise.

Reported-by: Peter Michaux <petermichaux@gmail.com>
2025-04-28 12:20:25 +02:00
Benno Schulenberg
fabc1e1219 syntax: default: show hard spaces with a lightgrey background
Some keyboard layouts allow typing hard spaces (U+00A0),
which means that sometimes they can get typed by accident.
Colorize those spaces to make such accidents noticeable.

Inspired-by: Sébastien Desreux <seb@h-k.fr>
2025-04-26 12:18:42 +02:00
Benno Schulenberg
2fec40e2ec docs: in cheatsheet, equalize the spacing in three consecutive blocks 2025-04-26 11:45:07 +02:00
Benno Schulenberg
95731b800d options: accept --whitespacedisplay and 'set whitespacedisplay'
Allow some people to use 'set whitespacedisplay' in their rcfiles
(or --whitespacedisplay on the command line), but leave the option
undocumented as I think it shouldn't exist.
2025-04-25 17:07:28 +02:00
Benno Schulenberg
3142d471e1 build: swap two linker arguments, to enable compilation on Cygwin
Since nano-8.1 (which moved to gettext-0.20), compiling on Cygwin
failed with: "undefined reference to `libintl_dgettext'".  Avoid
this by moving the '-lintl' argument to after the gnulib one.

Reported-by: Philippe Baril Lecavalier <pbl.ltx@gmail.com>
2025-04-24 09:41:15 +02:00
Benno Schulenberg
045664107e tweaks: in the browser, implement M-\ and M-/ in a slightly denser way
Inspired-by: Peter Michaux <petermichaux@gmail.com>
2025-04-23 11:50:18 +02:00
Peter Michaux
e512466ff0 build: add the 'm4/host-cpu-c-abi.m4' file to .gitignore
For some reason `autopoint` from gettext-0.20 (used since nano-8.1)
started to include the 'm4/host-cpu-c-abi.m4' file.  Ignore it, to
prevent it from accidentally getting tracked.

Signed-off-by: Peter Michaux <petermichaux@gmail.com>
2025-04-22 12:05:25 +02:00
Benno Schulenberg
131849e7e8 gnulib: pull in the fix for a cross-compilation failure
This addresses https://savannah.gnu.org/bugs/?66978.
Reported-by: Chris Renshaw <osm0sis@outlook.com>
2025-04-14 10:52:12 +02:00
Benno Schulenberg
186896f072 po: update translations and regenerate POT file and PO files v8.4 2025-04-02 11:07:28 +02:00
Benno Schulenberg
78eb483bc2 bump version numbers and add a news item for the 8.4 release 2025-04-02 09:29:24 +02:00
Benno Schulenberg
c7033324a9 gnulib: update to its current upstream state 2025-03-24 10:27:28 +01:00
Benno Schulenberg
334604a591 syntax: po: colorize also format specifiers like "%.6f" 2025-03-17 12:48:04 +01:00
Benno Schulenberg
7905ba80ea docs: add a suggestion to the FAQ on how to configure nano for git 2025-03-17 12:47:15 +01:00
Benno Schulenberg
ccff4685df docs: in the FAQ, replace an old item with an item about Byte Order Marks 2025-03-15 12:08:20 +01:00
Benno Schulenberg
0167f78dca feedback: warn when the cursor sits on a Byte Order Mark (BOM)
The ceck is only done at the start of a line, because in other places
the BOM will be glued to the preceding character.

This partially addresses https://bugs.debian.org/964901.
Reported-by: Nils König <oneric@oneric.de>
2025-03-15 09:17:01 +01:00
Benno Schulenberg
282ec08e5e docs: change two interface colors in the sample nanorc
For esthetics, and to showcase possibilities.
2025-03-14 11:48:29 +01:00
Benno Schulenberg
5efb7f31df tweaks: add a translator hint for the three changed file-writing prompts 2025-03-14 08:07:23 +01:00
Benno Schulenberg
bf39ffe903 prompt: accept tabs in an external paste as literal tabs
This fixes https://savannah.gnu.org/bugs/?66892.

Buglet existed since before version 2.0.0.
2025-03-12 16:59:58 +01:00
Benno Schulenberg
f2c30aa437 prompt: beep when an external paste contains a command code
Until the previous commit, nano used to beep for any command code
in an external paste.  It's better to continue doing that.

(When pasting multiple lines, it's debatable whether nano should
beep for each discarded CR.  But for any other command code, it
definitely should beep.  Maybe it should even show a message.)
2025-03-11 16:27:08 +01:00
Benno Schulenberg
bf12c90b07 input: implement bracketed pastes in a different manner
Ask ncurses to recognize the escape sequences that mark the start
and end of a bracketed paste, and thus benefit from the waiting that
ncurses does for an escape sequence to complete.  This helps prevent
nano from failing to recognize an end-of-paste sequence (resulting
in hanging or inserting some sequence characters into the buffer).

This addresses https://savannah.gnu.org/bugs/?66858 in a better way.
Reported-by: Doug Smythies <dsmythies@telus.net>
2025-03-10 17:17:07 +01:00
Benno Schulenberg
615570cf5e tweaks: remove two commented-out lines and two unused variables
And harmonize some whitespace.
2025-03-09 10:25:45 +01:00
Benno Schulenberg
aff9f4742c input: remove single-keycode detection from the bracketed-paste routine
It interferes with an upcoming change.
2025-03-08 12:08:30 +01:00
Benno Schulenberg
31a2cc9d76 tweaks: swap two fragments of code, to allow unwrapping a line 2025-03-08 12:07:49 +01:00
Benno Schulenberg
9c6a62d319 tweaks: remove an unwanted newline from a debugging message 2025-03-06 12:19:29 +01:00
Benno Schulenberg
38c8845b05 input: remove a special-case workaround
Let the more general flaw handling (added in commit 41c1b962, and
amended in the previous commit) handle also this case: it's better
to let the user know that they are using poor pasting software than
to silently work around the issue.

This effectively reverts commit 555a9878 from last week.
2025-03-06 09:42:53 +01:00