Compare commits

..

151 Commits
v5.7 ... v5.9

Author SHA1 Message Date
Benno Schulenberg
bec0cdcb54 po: update translations and regenerate POT file and PO files 2021-10-06 10:53:18 +02:00
Benno Schulenberg
ba9e5ac05d bump version numbers and add a news item for the 5.9 release 2021-10-06 10:04:22 +02:00
Benno Schulenberg
46b5f83601 tweaks: fold two lines into two others, for conciseness 2021-10-04 12:03:47 +02:00
Benno Schulenberg
6d5b16562f help: make the keystrokes ^W^Y and ^W^V work again
The keystrokes are not listed, but should work like
they do in a normal, editable buffer.

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

Bug existed since version 4.0, commit bc98dbca.
2021-10-04 11:54:02 +02:00
Benno Schulenberg
508301a2ef browser: make the keystrokes ^W^Y and ^W^V work again
The functions to_first_file() and to_last_file() can get called from
do_statusbar_input(), which is called indirectly from do_prompt(),
and are expected to make the corresponding adjustment.

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

Bug existed since version 5.0, commit 07c1ac90.
2021-10-04 11:38:30 +02:00
Benno Schulenberg
2f216281e7 syntax: yaml: allow slash and period in key names
Some Yaml files use path names and sometimes version numbers as keys,
even though / and . are not officially in the character set allowed
for key names (just like underscore is not), as far as I understand.

Also, do not colorize any backslash escapes as invalid
because some of them occur sometimes in value strings.

Also, colorize only the valid double-exclamation tags.
2021-10-03 15:38:43 +02:00
Benno Schulenberg
9459030d66 syntax: yaml: allow any character in tags except whitespace
This will colorize also invalid tags, but the rules are too complicated
to catch in a simple regex.

See https://yaml.org/spec/1.2.2/#691-node-tags.
2021-10-03 10:41:03 +02:00
Benno Schulenberg
f545735638 syntax: yaml: colorize the two known directives
See https://yaml.org/spec/1.2.2/#68-directives.

Also, recognize a Yaml file from a %YAML directive on the first line.
2021-10-03 10:14:04 +02:00
Hussam al-Homsi
bb8f40989f tweaks: change 'return ++var;' to 'return var + 1;'
This avoids an unused and misleading assignment that might make
someone think the incremented variable will be used again.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2021-10-02 17:41:03 +02:00
Benno Schulenberg
675ad6386d syntax: yaml: colorize the question mark of complex mappings too
See https://yaml.org/spec/1.2.2/#22-structures, example 2.11.

Also make the dash more visible by bolding it.
2021-10-02 17:15:50 +02:00
Benno Schulenberg
6ce3487b65 syntax: yaml: colorize backslash-escaped characters as valid or invalid
See https://yaml.org/spec/1.2.2/#57-escaped-characters.

Also prevent an escaped double quote from breaking the coloring of
a string, and allow hyphens in an anchor.
2021-10-02 17:15:32 +02:00
Benno Schulenberg
bc7e7d847e docs: list the default color combo for 'spotlightcolor' in sample nanorc
The comment says that only 'errorcolor' and 'spotlightcolor' have
a default value.  Better list the default value for both of them.
2021-10-01 09:47:45 +02:00
Benno Schulenberg
71a73a1a10 syntax: yaml: allow double colon in key & do not colorize unspaced colon
Perl keys can contain a double colon.  And unspaced colons occur
quite regularly in values (URLs, IPv6 addresses, and the like)
and should not be colored as if they were an error.
2021-10-01 09:44:43 +02:00
Benno Schulenberg
c2790a8af3 syntax: yaml: new file -- coloring rules for YAML files
This fulfills https://bugs.debian.org/982091.
Requested-by: Otto Kekäläinen <otto@debian.org>

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2021-09-29 17:14:03 +02:00
Benno Schulenberg
fde86518ae tweaks: rename a function, to be more fitting
The file wasn't marked; a piece of text was marked, resulting in
a region, and it is this region that gets written out to a file.
2021-09-29 15:37:06 +02:00
Benno Schulenberg
61b3aa6626 tweaks: use five symbolic names, to make eight function calls clearer 2021-09-29 15:35:18 +02:00
Benno Schulenberg
6799bc69a6 tweaks: adjust three parameters -- two were mistaken, one superfluous
The calls of write_file() in do_spell() and do_formatter() write out
a temporary file -- such a file does not have an 'openfile' record,
so setting 'annotate' to TRUE was pointless.  Using the correct value
for this parameter allows dropping two conditions in write_file().

And when 'exiting' is TRUE and --save-on-exit is in effect, it is
slightly wasteful to stat() the written file and store the info in
its 'openfile' record as the buffer will be closed directly after.

So, now the only place where 'annotate' is TRUE is when writing out
the full buffer to a normally named file.
2021-09-29 15:04:22 +02:00
Benno Schulenberg
0c01227d86 tweaks: rename a parameter, to fit better what it is used for 2021-09-29 12:34:04 +02:00
Benno Schulenberg
c74fd81302 tweaks: rename a parameter and invert its logic
This makes more sense (an emergency file is not a temp file) and
avoids the constant negating.
2021-09-29 12:20:21 +02:00
Benno Schulenberg
4b30cfb8f8 tweaks: rename a variable, to be more visible and to match others 2021-09-29 11:56:45 +02:00
Benno Schulenberg
36b6416a7b tweaks: reshuffle some lines and adjust some indentation 2021-09-29 11:52:23 +02:00
Benno Schulenberg
e0334e861d shutdown: when dying, do not install/restore a handler for Ctrl+C
First, we don't want the writing of an emergency file to be interrupted
by the user.  But more important: the routine for restoring the handler
also disables SIGINT, which would leave the terminal with a non-working
Ctrl+C.

Saving an emergency file calls write_file() in a unique manner: with
thefile == NULL, fullbuffer == FALSE (even though the entire buffer
will be saved, of course) and tmp == TRUE (even though it is not a
temporary file, as it will persist after nano exits).  But in fact
we want the handler for Ctrl+C installed only for normal files, not
for temporary files and not for emergency files -- the user should
not be able to interrupt the writing of those.

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

Bug existed since version 4.3, commit 8550c6bd.
2021-09-29 11:32:48 +02:00
Benno Schulenberg
b07fb5a811 files: exclude the call of fsync() from the tiny version
To avoid a spurious error message when the user chooses to write
the current buffer to a fifo.

Reported-by: André Kugland <kugland@gmail.com>
  https://lists.gnu.org/archive/html/nano-devel/2021-09/msg00031.html
2021-09-28 11:00:48 +02:00
Benno Schulenberg
9ab49658d7 files: prepending to a fifo makes no sense, so do not try that
Trying to prepend would hang nano until some other process writes
something to the fifo.

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

Bug existed since before version 2.2.4.
2021-09-28 10:10:37 +02:00
Benno Schulenberg
bb3d367716 files: making a backup of a fifo makes no sense, so do not try that
This fixes https://savannah.gnu.org/bugs/?61235.

Bug existed since version 4.3, commit 1b2018e9,
since opening a fifo was made possible again.
2021-09-28 09:45:49 +02:00
Benno Schulenberg
26c0a7962e files: check for a fifo only when it is an existing file
To avoid referencing an uninitialized value.

Reported-by: André Kugland <kugland@gmail.com>
  https://lists.gnu.org/archive/html/nano-devel/2021-09/msg00031.html
2021-09-28 09:44:52 +02:00
Benno Schulenberg
a2b20a1915 files: do not call fsync() on a fifo, to avoid a spurious error message
This fixes https://savannah.gnu.org/bugs/?61234.

The original report was in:
  https://lists.gnu.org/archive/html/nano-devel/2021-09/msg00029.html
Reported-by: André Kugland <kugland@gmail.com>

Bug existed since version 5.0, commit a84cdaaa.
2021-09-27 17:23:49 +02:00
Benno Schulenberg
2087c20a83 tweaks: in comments, say "buffer" instead of "file" where appropriate 2021-09-27 16:37:03 +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
d31cf1da68 gnulib: update to its current upstream state 2021-09-21 16:52:04 +02:00
Benno Schulenberg
ce656cfca8 docs: improve the description of the spotlighting of a search match 2021-09-21 16:49:40 +02:00
Benno Schulenberg
46cdf8b745 startup: if TERM is unset, try falling back to VT220 instead of failing
Curses cannot function if not informed via TERM which type of terminal
is being used.  As many terminals are mostly compatible with a VT220,
falling back to "vt220" when TERM is unset has a good chance of giving
the user a usable nano, instead of simply failing.

(Falling back to "vt100" is not good as it contains padding delays.)

This partially addresses https://bugs.debian.org/991982.
2021-09-20 10:38:25 +02:00
Benno Schulenberg
fdc0b0ac24 tweaks: rename three variables, to follow the general scheme
Also rewrap a line, reshuffle two others, and remove two redundant
comments.
2021-09-20 10:08:56 +02:00
Benno Schulenberg
42b7dea14b docs: add some details to the bug-reporting paragraph in the README
And add a blank line at the end, to make EOF look better.
2021-09-19 12:03:12 +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
189960c467 cutting: copy anchors into the cutbuffer, so that undo can restore them
When a segment of text is extracted, copy any anchors that it has
into the cutbuffer, so that they get saved in the undo item, so that
an undo will put these anchors back on the lines where they were,
instead of leaving an inherited anchor at the top of the segment.

And when text is pasted, clear any anchors in it, so that they will
not travel nor multiply.

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

Bug existed since version 5.0, since anchors were introduced.
2021-09-19 11:29:39 +02:00
Benno Schulenberg
04f8aa83ef tweaks: reshuffle a few lines, for esthetics and to elide an #ifdef 2021-09-17 10:06:21 +02:00
Benno Schulenberg
802a20b222 tweaks: rename a variable, to be more grammatical 2021-09-16 12:32:19 +02:00
Benno Schulenberg
88f7ec38f8 docs: spell "filename" as a single word, like in most other occurrences 2021-09-15 10:27:31 +02:00
Benno Schulenberg
baaff48547 syntax: nanorc: recognize also the template of the sample nanorc file 2021-09-15 10:00:41 +02:00
Benno Schulenberg
0010cd4443 tweaks: slightly reword or rewrap some comments in the sample nanorc 2021-09-15 09:55:14 +02:00
Benno Schulenberg
7d6ffd9e78 docs: don't use "light" after "bold", as the latter often implies "light"
On most terminals "bold" also makes the relevant text lighter (or just
makes it lighter, like on a Linux console).  Only some terminals allow
the user to switch this coupling of bold to light off.

Suggested-by: Hussam al-Homsi <sawuare@gmail.com>
2021-09-14 12:40:32 +02:00
Hussam al-Homsi
b8daf1fb0b docs: correct the default value of the errorcolor option
It should be "bold,white,red" instead of "brightwhite,red"
because "bright" is deprecated and not documented.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2021-09-14 12:03:04 +02:00
Benno Schulenberg
fe5f05f037 files: give the user time to absorb a warning about someone else editing
That is: pause a little to jolt the user, and then leave the message
on the status bar.

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

Bug existed since version 4.8, commit 416386ed.
2021-09-12 10:43:07 +02:00
Benno Schulenberg
5cedb53c62 files: write a lock file also for a freshly saved buffer
This fixes https://savannah.gnu.org/bugs/?61146

Bug existed since version 2.3.2, since --locking was introduced,
and continued to exist since version 4.8 despite commit 497f126b
claiming to have fixed it.
2021-09-12 10:00:17 +02:00
Benno Schulenberg
650dc14e0f tweaks: rename a defined type, to fit within the general pattern
So that it can be colorized as a type by a general syntax rule.

(The name is now uglier than it was, but... alas.)
2021-09-11 18:05:03 +02:00
Benno Schulenberg
43ebabe05d docs: mention how to properly colorize all types in nano's source code 2021-09-11 17:50:11 +02:00
Benno Schulenberg
b6366411dc tweaks: reshuffle a few lines to avoid an #ifdef and unbalanced braces 2021-09-11 15:07:05 +02:00
Benno Schulenberg
914921887e tweaks: rename a variable, to make more sense 2021-09-11 11:09:56 +02:00
Benno Schulenberg
64a8f1930e history: emit a warning when file cannot be made private [coverity] 2021-09-08 09:15:41 +02:00
Benno Schulenberg
0ac2dfd920 docs: refer to the FAQ when <Alt+Up> does nothing on a Linux console 2021-09-04 12:29:31 +02:00
Benno Schulenberg
aa553ee5d6 docs: correct the descriptions of how to invoke the spell checker
The keystrokes to invoke it changed in version 5.0.
2021-08-30 17:09:41 +02:00
Benno Schulenberg
a8961c561f po: permit the Indonesian PO file to come back -- there was a big update 2021-08-27 12:37:26 +02:00
Benno Schulenberg
abce19b0e4 docs: improve the recipe in the FAQ for dealing with Alt+Up on a console 2021-08-25 11:53:27 +02:00
Benno Schulenberg
fc317660cb tweaks: harmonize the indentations in the FAQ somewhat 2021-08-25 11:28:45 +02:00
Benno Schulenberg
949fcde6f7 docs: indent the paragraphs in the FAQ that list commands to be typed
And use a monospaced font for them.
2021-08-25 11:27:26 +02:00
Benno Schulenberg
9f24b6ea65 po: delete the ancient PO files for Indonesian and Nynorsk
These files haven't been updated in more than fifteen years and their
number of translated strings has dropped to below twenty percent.

Also, prevent them from coming back when next syncing with the TP.
2021-08-24 10:23:06 +02:00
Benno Schulenberg
c6ba4ae89a docs: improve the descriptions of several bindable functions
Some functions behave differently when some lines or a region is marked.
2021-08-23 10:12:55 +02:00
Benno Schulenberg
dab3f95c71 tweaks: instead of "one" use "you", like in the rest of the man page 2021-08-23 10:04:01 +02:00
Benno Schulenberg
840ad5890f docs: move the notice in the main man page, to try and catch other eyes 2021-08-23 10:00:44 +02:00
Benno Schulenberg
ae61bab60b files: when there is a slash after the dot, then there is no extension
This fixes https://savannah.gnu.org/bugs/?61071.

Bug existed since commit f429ebe3 from three days ago.
2021-08-23 09:52:32 +02:00
Benno Schulenberg
d3a7f3abed tweaks: restore a quote that was accidentally deleted four months ago
Commit a69a8ce3 unintentionally removed the double quote that should
terminate the version string.
2021-08-23 09:39:12 +02:00
Benno Schulenberg
694cd9ddd4 build: ensure that mkstemps() is available by importing the gnulib module
The mkstemps() function is not part of the POSIX standard,
so there might be some platforms that don't have it.
2021-08-22 11:42:34 +02:00
Benno Schulenberg
47c8e627f4 build: help Haiku find the header files that define mkstemps()
The documentation (https://www.haiku-os.org/docs/api/libroot.html)
says that BSD extensions are enabled by default, but somehow this
does not seem to be the case on my system.  With _DEFAULT_SOURCE
defined, though, src/files.c now compiles fine.
2021-08-22 11:42:34 +02:00
Benno Schulenberg
f429ebe34d files: add the original file's suffix to the name of a temporary file
This allows 'aspell' to recognize a C file and thus
spell check only the comments and strings.

This fulfills https://savannah.gnu.org/bugs/?61056.
2021-08-22 11:41:19 +02:00
Benno Schulenberg
083bbae0e4 tweaks: rename a variable, away form an abbreviation 2021-08-20 10:35:56 +02:00
Benno Schulenberg
eaff5ec9e5 files: check the result of fdopen(), to avoid a possible crash
When safe_tempfile() returns a valid filename, it should also
return a valid open stream.

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

Bug existed since version 1.3.8, commit 5e068c60.
2021-08-20 10:28:42 +02:00
Benno Schulenberg
51eb938fea tweaks: rewrap three lines, for esthetics 2021-08-20 10:14:21 +02:00
Benno Schulenberg
296c5a32c7 docs: replace a non-problem in the FAQ with something possibly useful
Opening a file whose name starts with a plus is not a problem at all.
Instead describe how to get the Alt+Up keystroke to scroll on a Linux
console (on Debian and friends).

This addresses https://savannah.gnu.org/bugs/?57294.
2021-08-18 11:54:54 +02:00
Hussam al-Homsi
ef6ccc47c8 syntax: perl, ruby: remove arbitrary highlighting of here documents
The rules assume that 'STOP' (for Perl) or EOT (for Ruby) is the
terminating string while it could be anything.  Also, the rules
don't take quotes nor backticks nor a tilde into account.

In short: these coloring rules are far too limited.

References:
  https://perldoc.perl.org/perlop#%3C%3CEOF
  https://docs.ruby-lang.org/en/3.0.0/doc/syntax/literals_rdoc.html#label-Here+Documents+-28heredocs-29

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2021-08-09 09:56:50 +02:00
Benno Schulenberg
eea2dfce48 tweaks: fix a typo 2021-07-31 20:48:10 +02:00
Benno Schulenberg
85682abbd5 docs: add a simulated "screenshot" of nano to the README
Suggested-by: Lars Wirzenius -- https://liw.fi/readme-review/
2021-07-21 10:15:07 +02:00
Benno Schulenberg
4005ee3284 docs: mention in the README which licenses cover nano's code and docs
Suggested-by: Lars Wirzenius -- https://liw.fi/readme-review/
2021-07-21 10:01:35 +02:00
Benno Schulenberg
9ead4c87a7 docs: add a paragraph at the start of the README about what nano is
Suggested-by: Lars Wirzenius -- https://liw.fi/readme-review/
2021-07-21 09:29:12 +02:00
Benno Schulenberg
1b5d9171f2 tweaks: try chmodding a dump file only when it was actually written 2021-07-14 10:38:02 +02:00
Benno Schulenberg
50543300d9 tweaks: reshuffle some code to elide a variable, and improve a comment 2021-07-14 10:36:15 +02:00
Benno Schulenberg
d9469b894f tweaks: remove a redundant feedback message
Any error message will already have been written to the terminal by
statusline().  Also, "Buffer not written to" looked too much like
"Buffer written to"; one had to look closely to see the difference.
2021-07-14 10:21:01 +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
c84a769733 memory: free any allocated strings, also in the emergency code path 2021-07-14 10:06:04 +02:00
Benno Schulenberg
e3ef778756 files: when the buffer is nameless, include the PID in name of dump file
Make sure that when multiple nanos with nameless buffers die,
each of them tries saving those buffers to different files.

This addresses https://savannah.gnu.org/bugs/?60902.
Reported-by: Julian Rosen <julianrosen@gmail.com>
2021-07-14 10:02:44 +02:00
Benno Schulenberg
806e8e439f tweaks: reshuffle some lines to elide a variable
Having a local variable that gets assigned to just once looks rather
poor.  To me it makes more sense to have two separate exit points: one
for failure somewhere in the middle, and one for success at the end.
This way it is completely clear which value gets returned when.
2021-07-10 16:18:29 +02:00
Benno Schulenberg
30aaea2d04 tweaks: rename a variable and flip its logic, to avoid two negations
Plus, it makes more sense to start in the state "not saved" than in
the state "failed".
2021-07-10 15:56:38 +02:00
Benno Schulenberg
d0cb64650b usage: improve the description of the --positionlog option
And make the wording for the --historylog option similar.

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

Bug existed since version 2.3.0, commit 8e2a9307, since the
saving and restoring of the cursor position was introduced.
2021-07-01 16:45:49 +02:00
Benno Schulenberg
0694255893 tweaks: adjust a description of 'showcursor', to match the other ones 2021-07-01 16:12:06 +02:00
Benno Schulenberg
5563c710d0 docs: improve the description of the 'tabstospaces' option
It never mentioned to how many spaces a tab would be converted.
2021-07-01 09:52:10 +02:00
Benno Schulenberg
177e4e5805 general: prevent die() from getting recursed into
When something that is called from die() calls die() again,
there is nothing we can do any more but give up.

This would have prevented the spiralling as
seen in https://savannah.gnu.org/bugs/?60853.
2021-06-30 15:54:21 +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
896f174f94 syntax: rust: update the license to GPL3 or newer
With permission from the copyright holder:
    https://lists.gnu.org/archive/html/nano-devel/2021-06/msg00037.html

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2021-06-27 11:17:37 +02:00
David Michael
7b4a835df4 syntax: gentoo: remove some obsolete keywords and add some new ones
Removals:
  - All eblits were dropped from Gentoo years ago.
  - HDEPEND was never fully approved, superseded by BDEPEND.
  - Keywords 'dohard' and 'dosed' have been banned since EAPI 4:
    https://projects.gentoo.org/pms/5/pms.html#x1-130001r8
  - Several arches are dead.  For the currently supported list:
    https://gitweb.gentoo.org/repo/gentoo.git/tree/profiles/arch.list

Additions:
  - Two eapply functions replace the epatch functions, but epatch
    is still supported until EAPI 6 is banned.
  - Modern build systems (ninja and qmake5) have new functions.
  - EAPI 7 added more builtins: dostrip, get_libdir, ver_*
  - Highlight the cross-compiler boolean function.  (There are too
    many toolchain functions to add them all, but this one is very
    common and has a long name, so highlighting it is useful for
    catching typos early.)

The EAPI documentation:
    https://projects.gentoo.org/pms/8/pms.html#x1-590007

An extensive write-up on EAPI 7:
    https://mgorny.pl/articles/the-ultimate-guide-to-eapi-7.html

Signed-off-by: David Michael <fedora.dm0@gmail.com>
2021-06-25 16:37:32 +02:00
David Michael
ac85e16458 syntax: gentoo: highlight additional EAPI 7/8 variables
Add IDEPEND from EAPI 8, and also add more EAPI 7 roots so that all
of ROOT, EROOT, SYSROOT, ESYSROOT, and BROOT are supported.

Signed-off-by: David Michael <fedora.dm0@gmail.com>
2021-06-18 11:00:35 +02:00
Benno Schulenberg
45420968ee tweaks: correct two typos and a spello [codespell] 2021-06-17 10:55:23 +02:00
Benno Schulenberg
3c35538e8b tweaks: add Schiermonnikoog to the list of friendly islands
(The commit message is a joke, of course.  Instead, this commit just
removes some unneeded comments and corrects one bit of whitespace.)
2021-06-16 11:19:23 +02:00
Benno Schulenberg
4f981cd5d9 po: update translations and regenerate POT file and PO files 2021-06-15 10:28:23 +02:00
Benno Schulenberg
44a6c4963b tweaks: avoid a compiler warning when configured with --enable-tiny 2021-06-15 10:20:28 +02:00
Benno Schulenberg
622bfb5b83 build: commit the LINGUAS file too while rolling a release 2021-06-15 10:11:19 +02:00
Benno Schulenberg
a2cb22faab bump version numbers and add a news item for the 5.8 release 2021-06-15 09:52:45 +02:00
Benno Schulenberg
9f8309fba8 help: use smaller triangles for the arrows
In Dejavu Sans Mono the old pointing triangles had a decent size,
but in Noto Mono and in Ubuntu Mono (fonts that handle combining
diacritics better) those triangles were massive, visually taking
up more than a single cell, overlapping the closing parenthesis
when they are displayed in the second column.  Not nice.

The new pointing small triangles look good in the Noto and Ubuntu
fonts, but are real tiny in Dejavu.  :|  Oh well, one can't have
everything.

(Other triangles are not an option, because they don't degrade to
actual arrows when on a Linux console.)
2021-06-14 09:29:27 +02:00
Benno Schulenberg
bf7954bdb7 tweaks: rename a variable, for contrast with the function name 2021-06-13 16:57:54 +02:00
Benno Schulenberg
0371dd1bde tweaks: rename two functions, to get rid of an ugly _void suffix
Also drop an unneeded prototype.
2021-06-13 12:17:33 +02:00
Benno Schulenberg
7c53b133a1 tweaks: use two symbolic names instead of TRUE and FALSE, for clarity 2021-06-13 12:06:24 +02:00
Benno Schulenberg
b1e5f9d9a8 docs: add a relevant item to the news for the 4.3 release
It's a low-level thing, but for the people affected it's a big deal.
2021-06-13 11:18:03 +02:00
Benno Schulenberg
424969258a docs: say thanks to the Icelandic and Slovak translators
(The Slovak file will arrive from the TP upon rolling the next release.)
2021-06-12 16:38:18 +02:00
Benno Schulenberg
6d0fc38285 gnulib: update to its current upstream state 2021-06-12 11:06:06 +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
101dc4e805 docs: make ^E access the Execute menu in the example CUA bindings
Also, add the normal CUA bindings for Undo (^Z) and Redo (^Y),
and drop the M-X thinko.

With these more "usual" alternative bindings, ^X will now do a Cut
(putting the cut text into the cutbuffer) only when in the main menu
-- in the other places it did not put anything into the cutbuffer,
so it's better to have only the default ^K ("kill") for that.

Suspension is now accessible with ^E^Z, and the Speller with ^E^S.

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

Bug existed since version 3.2, commit 33d67d5c,
since the more usual example bindings were introduced.
2021-06-11 11:10:28 +02:00
Benno Schulenberg
d7e3226158 memory: move the correct number of bytes, and not one too many
We want to reduce the size of the answer by one byte,
not keep the full answer (plus terminating NUL).

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

Bug existed since version 2.9.8, commit f304b9ae,
since piping text to an external command was introduced.
2021-06-10 11:34:04 +02:00
Benno Schulenberg
74c6bdac9f docs: add example bindings for uppercasing and lowercasing a word
(The diff looks weird in 'less' -- the "c" before the "^T" hides
two escape sequences.)
2021-06-10 10:40:49 +02:00
Benno Schulenberg
73168bb1b9 docs: improve the contact info and some line spacing in the PDF 2021-06-08 11:31:18 +02:00
Benno Schulenberg
f895f1beba docs: mention the new 'set minicolor' option 2021-06-08 10:51:19 +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
Hussam al-Homsi
092c62ccb8 bindings: allow copying text (with M-6) also when in view mode
This can be useful when wanting to search for the other occurrences
of some (long) string in the buffer: select, M-6, ^W, ^U, <Enter>.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2021-06-02 11:09:24 +02:00
Benno Schulenberg
97dd505647 linter: strip filename and line plus column number from the message
Nano already opens the relevant file (when needed) and puts the cursor
at the relevant spot -- including this information in the message shown
on the bottom bar is just clutter and makes the message harder to read.
2021-05-30 11:30:32 +02:00
Benno Schulenberg
635977fe33 syntax: nanohelp: avoid colorizing M-) in (M-) and M-" in "M-"
Instead of quoting M- as 'M-', some translations use «M-» (Catalan),
(M-) (Croat), "M-" (Italian), „M-” (Romanian), or „М-“ (Serbian).
Those occurrences of M- nor its quotation marks should be colored.

Achieve this by excluding those quotation marks from the M- regex,
and then colorizing M-) and M-" only when at start of line (first
column of shortcuts) or when between parentheses (second column).
2021-05-30 10:44:03 +02:00
Benno Schulenberg
6ab70c2b0a tweaks: improve a comment, remove unneeded braces, reshuffle some lines 2021-05-28 16:42:56 +02:00
Benno Schulenberg
3a86b24a3e tweaks: remove a check that is not needed
The die() has been there for more than a year and no one reported a
problem.  And anyway, indenting does not create more than one group
-- this check was just to be certain.
2021-05-28 16:20:59 +02:00
Benno Schulenberg
77ca8735ab syntax: nanorc: colorize "light" as valid only for the eight basic colors
Only the basic colors (like red, blue and yellow) can take the prefix
"light" or "bright", not the extra colors (like pink, lagoon and lime).

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

Bug existed since version 5.0, since the extra colors were introduced.
2021-05-26 15:53:07 +02:00
Benno Schulenberg
3a0922799d tweaks: reshuffle the coloring of color names, to remove some duplication 2021-05-26 15:39:14 +02:00
Benno Schulenberg
b27efce732 docs: mention that "grey"/"gray" may be used as a synonym of "lightblack"
Also, colorize "grey" and "gray" as valid names in a nanorc file.
2021-05-26 15:31:04 +02:00
Benno Schulenberg
8974430c11 rcfile: allow using "grey" or "gray" as a synonym for "lightblack"
Because "lightblack" sounds strange and will not occur to many people
as a possible color name.
2021-05-26 15:31:04 +02:00
Benno Schulenberg
e044284998 rcfile: do not allow color name "normal" to have a prefix
Because "lightnormal" sounds strange, and can have unexpected effects.

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

Bug existed since version 2.9.5, since the name "normal" was introduced.
2021-05-25 15:43:06 +02:00
Benno Schulenberg
4f9d55bb15 tweaks: normalize the indentation after the previous change 2021-05-25 15:31:54 +02:00
Benno Schulenberg
89adacff3d tweaks: condense some code by putting all color names in a single array 2021-05-25 15:28:02 +02:00
Benno Schulenberg
2314a1932f tweaks: use a symbol instead of a hard-coded number 2021-05-25 15:14:10 +02:00
Benno Schulenberg
fb5eb4856b tweaks: drop an assignment that is already part of the called function 2021-05-25 15:11:33 +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
405c2162b5 startup: allow using a bare "+" to mean put-cursor-on-last-line
Editors like 'vim' and 'ne' and 'uemacs' know this shorthand too.

This fulfills https://savannah.gnu.org/bugs/?60663.
2021-05-25 12:18:48 +02:00
Benno Schulenberg
8797ada815 startup: do not accept stray characters after a "+" on the command line
After a "+" only c, r, C, and R are valid characters,
and only when immediately followed by / or ?.

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

Bug existed since version 4.4, commit 2326bf6,
since searching at startup with +/ or +? was introduced.
2021-05-25 12:15:52 +02:00
Benno Schulenberg
30bafc70cc tweaks: prevent two more size_t subtractions from going negative
This fully fixes https://savannah.gnu.org/bugs/?60658.

Found by compiling with -fsanitize=undefined.
2021-05-24 11:00:29 +02:00
Benno Schulenberg
b38f0cbaf4 feedback: ensure that the reporting of DOS/Mac format is truthful
This fixes https://savannah.gnu.org/bugs/?60660.

Bug existed since version 5.7, commit 77da54c6.
2021-05-23 18:55:41 +02:00
Benno Schulenberg
ceaae49b2d tweaks: avoid the subtraction of two size_t variables becoming negative
This fixes https://savannah.gnu.org/bugs/?60658.

Found by compiling with -fsanitize=undefined.
2021-05-23 11:46:37 +02:00
Benno Schulenberg
d1957819c4 bindings: show either "^/" or "^-" in the help lines, instead of "^_"
The "^_" has always been poorly legible (the underscore melting into
the bottom of the terminal) and difficult to type (Shift+Ctrl+minus).
The "^/" is both more readable and easier to type.

In terminal emulators, "^/" is shown, but on a Linux console "^-",
as ^/ does a backspace in the default console key mapping.

Also, allow using "^-" when rebinding ^_ in a nanorc file.

This addresses https://savannah.gnu.org/bugs/?57393.
2021-05-22 16:52:56 +02:00
Benno Schulenberg
7993fc8b12 syntax: nanorc: colorize literal control codes, to make them stand out
This makes it easier to read string binds that contain control codes.
2021-05-14 15:05:05 +02:00
Benno Schulenberg
51adf02d34 wrapping: when copying the quoting part, adjust the file size accordingly
Simply adding the number of bytes in the quoting part is not entirely
correct, but... currently the indenting and commenting routines also
assume that the whitespace and commenting characters that are added or
removed are single-byte characters...  It will require another patch
to make this all fully correct, but for the default configuration
(and probably most other cases) the current fix will work fine.

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

Bug existed since version 4.4, commit 8fce33af from two years ago,
since this automatic copying of the quoting part was introduced.
2021-05-14 10:24:07 +02:00
Benno Schulenberg
f23e98dd3a memory: prevent a leak when copying the leading quoting to the next line
This fixes https://savannah.gnu.org/bugs/?60596.

Bug existed since version 4.4, commit 8fce33af from two years ago,
since this automatic copying of the quoting part was introduced.
2021-05-14 09:56:45 +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
b741b1c985 startup: skip drawing edit window when having message on one-row terminal
When there is just one row and there is a message, it is not a good idea
to draw the contents of the buffer as it would overwrite the message.

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

Bug existed since version 2.7.0, since nano allows very flat terminals,
and was made worse by commit 2cf28f9d from yesterday.
2021-05-12 15:47:21 +02:00
Benno Schulenberg
5f87ed5644 statusbar: ensure that "No further matches" does not get overwritten
Redraw the content of the edit window (for the undone final completion)
before pushing out the "No further matches" message, so that the latter
will not get overwritten by the buffer content -- in case the terminal
has just one row.

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

Bug existed since commit 2cf28f9d from yesterday.
2021-05-11 15:58:21 +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
07fd4c4598 tweaks: condense and correct a comment, and move another
Since commit 5dcf375f from four years ago, a linter message must
contain a colon followed by a space for it to be recognized as a
linter message.
2021-05-07 12:40:25 +02:00
Benno Schulenberg
44fb3e9991 tweaks: frob some whitespace, and rewrap a line 2021-05-07 12:33:22 +02:00
Benno Schulenberg
088557c516 tweaks: remove a check that has become superfluous
Since version 5.6, commit 76742cc1, nano highlights the search match,
which means that the screen gets refreshed anyhow, so this specific
refresh for a one-row terminal is no longer needed.
2021-05-07 12:20:50 +02:00
Benno Schulenberg
4712d46462 linter: block the resizing signal while reading output from the linter
This prevents read() from returning unexpectedly and causing a crash.

This fixes https://savannah.gnu.org/bugs/?60537.
Reported-by: Filips Romāns <frfilips@gmail.com>

Bug existed since version 2.4.2, since the handling of SIGWINCH changed.
2021-05-06 13:30:41 +02:00
Benno Schulenberg
c01b13a32c syntax: php: colorize the full short tag for echo (<?=) 2021-05-05 12:09:17 +02:00
Benno Schulenberg
b368faf11c replacing: report the number of replacements also on a one-row terminal
That is: call edit_refresh() right away, to prevent the edit_refresh()
in the main loop from overwriting the status-bar message.

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

Bug existed since version 2.7.2, commit f920e0d3.
2021-05-05 10:41:55 +02:00
Benno Schulenberg
7303f0c7b4 search: show "This is the only occurrence" also on a one-row terminal
That is: call edit_refresh() right away, to prevent the edit_refresh()
in the main loop from overwriting the status-bar message.

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

Bug existed since version 5.6, commit 76742cc1.
2021-05-05 10:36:18 +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
80 changed files with 25044 additions and 24531 deletions

165
ChangeLog
View File

@@ -1,3 +1,168 @@
Changes between v5.8 and v5.9:
------------------------------
Benno Schulenberg (88):
browser: make the keystrokes ^W^Y and ^W^V work again
build: ensure that mkstemps() is available by importing the gnulib module
build: help Haiku find the header files that define mkstemps()
bump version numbers and add a news item for the 5.9 release
copyright: update to the current year for significantly changed files
cutting: copy anchors into the cutbuffer, so that undo can restore them
docs: add a paragraph at the start of the README about what nano is
docs: add a simulated "screenshot" of nano to the README
docs: add some details to the bug-reporting paragraph in the README
docs: correct the descriptions of how to invoke the spell checker
docs: don't use "light" after "bold", as the latter often implies "light"
docs: improve the description of the spotlighting of a search match
docs: improve the description of the 'tabstospaces' option
docs: improve the descriptions of several bindable functions
docs: improve the recipe in the FAQ for dealing with Alt+Up on a console
docs: indent the paragraphs in the FAQ that list commands to be typed
docs: list the default color combo for 'spotlightcolor' in sample nanorc
docs: mention how to properly colorize all types in nano's source code
docs: mention in the README which licenses cover nano's code and docs
docs: move the notice in the main man page, to try and catch other eyes
docs: refer to the FAQ when <Alt+Up> does nothing on a Linux console
docs: replace a non-problem in the FAQ with something possibly useful
docs: spell "filename" as a single word, like in most other occurrences
feedback: use a smaller diamond to represent an anchor, to not overflow
feedback: when not in curses mode, just skip displaying any message
feedback: when not in curses mode, write error messages to the terminal
files: add the original file's suffix to the name of a temporary file
files: check for a fifo only when it is an existing file
files: check the result of fdopen(), to avoid a possible crash
files: do not call fsync() on a fifo, to avoid a spurious error message
files: exclude the call of fsync() from the tiny version
files: give the user time to absorb a warning about someone else editing
files: making a backup of a fifo makes no sense, so do not try that
files: prepending to a fifo makes no sense, so do not try that
files: when the buffer is nameless, include the PID in name of dump file
files: when there is a slash after the dot, then there is no extension
files: write a lock file also for a freshly saved buffer
general: prevent die() from getting recursed into
gnulib: update to its current upstream state
help: make the keystrokes ^W^Y and ^W^V work again
history: emit a warning when file cannot be made private [coverity]
input: give up on the input stream only after millions of errors
memory: free any allocated strings, also in the emergency code path
po: delete the ancient PO files for Indonesian and Nynorsk
po: permit the Indonesian PO file to come back -- there was a big update
shutdown: when dying, do not install/restore a handler for Ctrl+C
startup: if TERM is unset, try falling back to VT220 instead of failing
syntax: nanorc: recognize also the template of the sample nanorc file
syntax: rust: update the license to GPL3 or newer
syntax: yaml: allow any character in tags except whitespace
syntax: yaml: allow double colon in key & do not colorize unspaced colon
syntax: yaml: allow slash and period in key names
syntax: yaml: colorize backslash-escaped characters as valid or invalid
syntax: yaml: colorize the question mark of complex mappings too
syntax: yaml: colorize the two known directives
syntax: yaml: new file -- coloring rules for YAML files
tweaks: add Schiermonnikoog to the list of friendly islands
tweaks: adjust a description of 'showcursor', to match the other ones
tweaks: adjust three parameters -- two were mistaken, one superfluous
tweaks: correct two typos and a spello [codespell]
tweaks: fix a typo
tweaks: fold two lines into two others, for conciseness
tweaks: harmonize the indentations in the FAQ somewhat
tweaks: in comments, say "buffer" instead of "file" where appropriate
tweaks: instead of "one" use "you", like in the rest of the man page
tweaks: remove a redundant feedback message
tweaks: rename a defined type, to fit within the general pattern
tweaks: rename a function, to be more fitting
tweaks: rename a parameter and invert its logic
tweaks: rename a parameter, to fit better what it is used for
tweaks: rename a variable and flip its logic, to avoid two negations
tweaks: rename a variable, away form an abbreviation
tweaks: rename a variable, to be more grammatical
tweaks: rename a variable, to be more visible and to match others
tweaks: rename a variable, to make more sense
tweaks: rename three variables, to follow the general scheme
tweaks: reshuffle a few lines, for esthetics and to elide an #ifdef
tweaks: reshuffle a few lines to avoid an #ifdef and unbalanced braces
tweaks: reshuffle a fragment of code, to prepare for the next change
tweaks: reshuffle some code to elide a variable, and improve a comment
tweaks: reshuffle some lines and adjust some indentation
tweaks: reshuffle some lines to elide a variable
tweaks: restore a quote that was accidentally deleted four months ago
tweaks: rewrap three lines, for esthetics
tweaks: slightly reword or rewrap some comments in the sample nanorc
tweaks: try chmodding a dump file only when it was actually written
tweaks: use five symbolic names, to make eight function calls clearer
usage: improve the description of the --positionlog option
David Michael (2):
syntax: gentoo: highlight additional EAPI 7/8 variables
syntax: gentoo: remove some obsolete keywords and add some new ones
Hussam al-Homsi (3):
docs: correct the default value of the errorcolor option
syntax: perl, ruby: remove arbitrary highlighting of here documents
tweaks: change 'return ++var;' to 'return var + 1;'
Changes between v5.7 and v5.8:
------------------------------
Benno Schulenberg (53):
bindings: show either "^/" or "^-" in the help lines, instead of "^_"
bump version numbers and add a news item for the 5.8 release
display: when a message gets overwritten, note that it is cleared
docs: add a relevant item to the news for the 4.3 release
docs: add example bindings for uppercasing and lowercasing a word
docs: improve the contact info and some line spacing in the PDF
docs: make ^E access the Execute menu in the example CUA bindings
docs: mention that "grey"/"gray" may be used as a synonym of "lightblack"
docs: mention the new 'set minicolor' option
docs: say thanks to the Icelandic and Slovak translators
feedback: ensure that the reporting of DOS/Mac format is truthful
gnulib: update to its current upstream state
help: use smaller triangles for the arrows
linter: block the resizing signal while reading output from the linter
linter: strip filename and line plus column number from the message
memory: move the correct number of bytes, and not one too many
memory: prevent a leak when copying the leading quoting to the next line
minibar: stay out of sight when the terminal has just one row
options: accept 'set minicolor' for setting the color of the minibar
rcfile: allow using "grey" or "gray" as a synonym for "lightblack"
rcfile: do not allow color name "normal" to have a prefix
replacing: report the number of replacements also on a one-row terminal
search: automatically drop the spotlighting after a few moments
search: show "This is the only occurrence" also on a one-row terminal
startup: allow using a bare "+" to mean put-cursor-on-last-line
startup: do not accept stray characters after a "+" on the command line
startup: skip drawing edit window when having message on one-row terminal
startup: suppress "Search Wrapped" when using +? to search from EOF
statusbar: ensure that "No further matches" does not get overwritten
statusbar: on a one-row terminal, drop light messages after a few moments
statusbar: suppress --constantshow when the terminal has just one row
statusbar: suppress the cursor when the terminal has just one row
syntax: nanohelp: avoid colorizing M-) in (M-) and M-" in "M-"
syntax: nanorc: colorize "light" as valid only for the eight basic colors
syntax: nanorc: colorize literal control codes, to make them stand out
syntax: php: colorize the full short tag for echo (<?=)
tweaks: avoid the subtraction of two size_t variables becoming negative
tweaks: condense and correct a comment, and move another
tweaks: condense some code by putting all color names in a single array
tweaks: drop an assignment that is already part of the called function
tweaks: frob some whitespace, and rewrap a line
tweaks: improve a comment, remove unneeded braces, reshuffle some lines
tweaks: normalize the indentation after the previous change
tweaks: prevent two more size_t subtractions from going negative
tweaks: redraw only the affected line instead of doing a full refresh
tweaks: remove a check that has become superfluous
tweaks: remove a check that is not needed
tweaks: rename a variable, for contrast with the function name
tweaks: rename two functions, to get rid of an ugly _void suffix
tweaks: reshuffle the coloring of color names, to remove some duplication
tweaks: use a symbol instead of a hard-coded number
tweaks: use two symbolic names instead of TRUE and FALSE, for clarity
wrapping: when copying the quoting part, adjust the file size accordingly
Hussam al-Homsi (1):
bindings: allow copying text (with M-6) also when in view mode
Changes between v5.6.1 and v5.7:
--------------------------------

View File

@@ -2,7 +2,7 @@ Improvements in GNU nano
========================
Since 5.0:
- A search highlights the found text, in black on yellow by default.
- A search briefly spotlights the found text, in black on yellow by default.
- Option --minibar reduces the interface to a bottom bar with basic info.
- The cursor skips over combining characters, <Del> deletes them together
with the character they combine with, but <Bsp> deletes them separately.

31
NEWS
View File

@@ -1,3 +1,23 @@
2021.10.06 - GNU nano 5.9 "El manicomio ha decidido: mañana sol!"
• The extension of a filename is added to the name of a corresponding
temporary file, so that spell checking a C file, for example, will
check only the comments and strings (when using 'aspell').
• The process number is added to the name of an emergency save file,
so that when multiple nanos die they will not fight over a filename.
• Undoing a cutting operation will restore an anchor that was located
in the cut area to its original line.
• When using --locking, saving a new buffer will create a lock file.
• Syntax highlighting for YAML files has been added.
2021.06.15 - GNU nano 5.8 "Why is it necessary to be special?"
• After a search, the spotlighting is dropped after 1.5 seconds (0.8
seconds with --quick) to avoid the idea that the text is selected.
• A + and a space before a filename on the command line will put the
cursor at the end of the corresponding buffer.
• Linter messages no longer include filename and line/column numbers.
• Color name "grey" or "gray" can be used instead of "lightblack".
• The color of the minibar can be chosen with 'set minicolor'.
2021.04.29 - GNU nano 5.7 "Toți ceilalți arau câmpurile"
• The output of --constantshow (without --minibar) is more stable.
• When opening multiple buffers and there is an error message, this
@@ -186,6 +206,7 @@
2019.06.18 - GNU nano 4.3 "Musa Kart"
• The ability to read from and write to a FIFO has been regained.
• Opening a file no longer triggers an inotify CLOSE_WRITE event.
• Startup time is reduced by fully parsing a syntax only when needed.
• Asking for help (^G) when using --operatingdir does not crash.
• The reading of a huge or slow file can be stopped with ^C.
@@ -1202,9 +1223,9 @@
Have fun with it.
2005.06.30 - GNU nano 1.3.8 floats at its own level. This release
contains several new features. Among other things, you
can now move to a specified column number as well as
line number within a file, file backups saved in a
contains several new features. Among other things,
you can now move to a specified column number as well
as line number within a file, file backups saved in a
backup directory will have unique names, the search and
replace history routines should work more consistently,
you can get a word count by pressing Meta-D at the edit
@@ -1215,8 +1236,8 @@
screen updates, UTF-8 display, and flow control; a fix
for a segfault when displaying some lines ending with
tabs; better handling of constant cursor position
display; improved color parsing in the rcfile; and
support for the "Regexp" toggle in tiny mode
display; improved color parsing in the rcfile;
and support for the "Regexp" toggle in tiny mode
(-R/--regexp is gone, and --restricted's short option
has been changed to -R), among other things. Enjoy.

61
README
View File

@@ -1,10 +1,42 @@
GNU nano -- a simple editor, inspired by Pico
Overview
Purpose
The nano project was started because of a few "problems" with the
wonderfully easy-to-use and friendly Pico text editor.
Nano is a small and simple text editor for use on the terminal.
It copied the interface and key bindings of the Pico editor but
added several missing features: undo/redo, syntax highlighting,
line numbers, softwrapping, multiple buffers, selecting text by
holding Shift, search-and-replace with regular expressions, and
several other conveniences.
Appearance
In rough ASCII graphics, this is what nano's screen looks like:
____________________________________________________________________
| GNU nano 5.9 filename Modified |
--------------------------------------------------------------------
| This is the text window, displaying the contents of a 'buffer', |
| the contents of the file you are editing. |
| |
| The top row of the screen is the 'title bar'; it shows nano's |
| version, the name of the file, and whether you modified it. |
| The two bottom rows display the most important shortcuts; in |
| those lines ^ means Ctrl. The third row from the bottom shows |
| some feedback message, or gets replaced with a prompt bar when |
| you tell nano to do something that requires extra input. |
| |
--------------------------------------------------------------------
| [ Some status message ] |
|^G Help ^O Write Out ^W Where Is ^K Cut ^T Execute |
|^X Exit ^R Read File ^\ Replace ^U Paste ^J Justify |
--------------------------------------------------------------------
Origin
The nano project was started in 1999 because of a few "problems"
with the wonderfully easy-to-use and friendly Pico text editor.
First and foremost was its license: the Pine suite does not use
the GPL, and (before using the Apache License) it had unclear
@@ -23,6 +55,19 @@ Overview
The nano editor is an official GNU package. For more information on
GNU and the Free Software Foundation, please see https://www.gnu.org/.
License
Nano's code and documentation are covered by the GPL version 3 or
(at your option) any later version, except for two functions that
were copied from busybox which are under a BSD license. Nano's
documentation is additionally covered by the GNU Free Documentation
License version 1.2 or (at your option) any later version. See the
files COPYING and COPYING.DOC for the full text of these licenses.
When in any file of this package a copyright notice mentions a
year range (such as 1999-2011), it is a shorthand for a list of
all the years in that interval.
How to compile and install nano
Download the latest nano source tarball, and then:
@@ -70,10 +115,8 @@ Mailing Lists
Bug Reports
If you find a bug, please file a detailed description of the problem
on nano's bug tracker: https://savannah.gnu.org/bugs/?group=nano.
on nano's issue tracker: https://savannah.gnu.org/bugs/?group=nano
(you will need an account to be able to do so), or send an email
to the nano-devel list (no need to subscribe, but mention it if
you want to be CC'ed on an answer).
Copyright Years
When in any file of this package a copyright notice mentions a
year range (such as 1999-2011), it is a shorthand for a list of
all the years in that interval.

View File

@@ -84,7 +84,6 @@ Problems?
Please submit any bugs you find in the code in git via the bug tracker
on Savannah (https://savannah.gnu.org/bugs/?group=nano).
Contributing something
----------------------
@@ -114,3 +113,11 @@ to include 'set tabsize 4', or you could use -T4 on the command line.
To make git display things as intended, you can do:
$ git config --local core.pager "less -x1,5"
To see all types that are used in nano's source code colorized as types,
you can add these lines to your ~/.nanorc:
extendsyntax c color green "\<struct (dirent|option|passwd)\>"
extendsyntax c color green "\<struct (sigaction|stat|termios)\>"
extendsyntax c color green "\<struct (timespec|vt_stat|winsize)\>"
extendsyntax c color green "\<([[:lower:]_]+(struct|type)|va_list)\>"

2
THANKS
View File

@@ -18,6 +18,8 @@ Mihai Cristescu <mihai.cristescu@archlinux.info> Romanian
Yavor Doganov <yavor@doganov.org> Bulgarian
Karl Eichwalder <keichwa@gmx.net> German
A. Murat EREN <meren@comu.edu.tr> Turkish
Sveinn í Felli <sv1@fellsnet.is> Icelandic
Marek Felšöci <marek@felsoci.sk> Slovak
Doruk Fisek <dfisek@fisek.com.tr> Turkish
Rafael Fontenelle <rffontenelle@gmail.com> Brazilian Portuguese
Pavel Fric <pavelfric@seznam.cz> Czech

View File

@@ -2,7 +2,7 @@
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="afeeb21058d15e5250fff9fbea2c1fec011c061a"
gnulib_hash="9aca7b67333fd0a90bf56104325ce96199644451"
modules="
futimens
@@ -13,6 +13,7 @@ modules="
isblank
iswblank
lstat
mkstemps
nl_langinfo
regex
sigaction

View File

@@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see https://www.gnu.org/licenses/.
AC_INIT([GNU nano], [5.7], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [5.9], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.14])

View File

@@ -5,6 +5,9 @@
<title>The GNU nano editor FAQ</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="description" content="The genesis story of the nano editor, plus the solution to some common problems.">
<style>
.indented { margin-left: 2em; font-family: courier; font-size: 110%; }
</style>
</head>
<body text="#330000" bgcolor="#ffffff" link="#0000ef" vlink="#51188e" alink="#ff0000">
@@ -40,7 +43,7 @@
</p></blockquote>
<h3><a href="#4">4. Running</a></h3>
<blockquote><p>
<a href="#4.1">4.1. How do I open a file with a name beginning with '+' from the command line?</a><br>
<a href="#4.1">4.1. Alt+Up does nothing on a Linux console. How can I make it scroll?</a><br>
<a href="#4.2">4.2. How can I make Ctrl+Shift+Left/Right select words on urxvt?</a><br>
<a href="#4.3">4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</a><br>
<a href="#4.4">4.4. With what keystroke can I paste text from the clipboard into nano?</a><br>
@@ -89,7 +92,7 @@
<h3><a name="1.3"></a>1.3. Why the name change from TIP?</h3>
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program &quot;establishes a full duplex terminal connection to a remote host&quot;, and was included with many older Unix systems (and newer ones like Solaris). The conflict was not noticed at first because there is no 'tip' utility included with most GNU/Linux distributions (where nano was developed).</p></blockquote>
<h3><a name="1.4"></a>1.4. What is the current version of nano?</h3>
<blockquote><p>The current version of nano <i>should</i> be <b>5.7</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<blockquote><p>The current version of nano <i>should</i> be <b>5.9</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<h3><a name="1.5"></a>1.5. I want to read the man page without having to download the program!</h3>
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="https://nano-editor.org/dist/latest/nano.1.html">here</a>.</p></blockquote>
<hr width="100%">
@@ -127,39 +130,39 @@
<blockquote><p>It's simple really! As root, type <b>rpm -Uvh nano-x.y-1*.rpm</b> if you have a RedHat-ish system or <b>dpkg -i nano_x.y-1*.deb</b> if you have a Debian-ish system, where <b>x.y</b> is the version number of nano. There are other programs to install packages, and if you wish to use those, knock yourself out.</p></blockquote>
<h3><a name="3.2"></a>3.2. Compiling from source: WHAT THE HECK DO I DO NOW?</h3>
<blockquote><p>Okay, take a deep breath, this really isn't hard. Unpack the nano source with a command like:</p>
<p><b>tar -xvf nano-x.y.tar.gz</b></p>
<p class="indented"><b>tar -xvf nano-x.y.tar.gz</b></p>
<p>Then you need to run <b>configure</b> with any options you might want (if any).</p>
<p>The average case is this:</p>
<p><b>cd nano-x.y/</b><br>
<p class="indented"><b>cd nano-x.y/</b><br>
<b>./configure</b><br>
<b>make</b><br>
<b>make install</b> (as root, of course)</p></blockquote>
<b>make install</b>&nbsp;&nbsp; #(as root, of course)</p></blockquote>
<h3><a name="3.3"></a>3.3. Why does everything go into /usr/local?</h3>
<blockquote><p>Well, that's what the <b>configure</b> script defaults to. If you wish to change this, simply do this:</p>
<p><b>./configure --prefix=/usr</b></p>
<p class="indented"><b>./configure --prefix=/usr</b></p>
<p>This will put nano into /usr/bin when you run <b>make install</b>.</p></blockquote>
<h3><a name="3.4"></a>3.4. nano should automatically run strip on the binary when installing it!</h3>
<blockquote><p>It does when you use <b>make install-strip</b>. The default <b>make install</b> does not, and will not, run strip automatically.</p></blockquote>
<h3><a name="3.5"></a>3.5. How can I make the executable smaller? This is too bloated!</h3>
<blockquote><p>Actually, there are several parts of the editor that can be disabled. You can pass arguments to the <b>configure</b> script that disable certain features. Here's a brief list:</p>
<pre>
<b>--disable-browser</b> Disable the built-in file browser
<b>--disable-color</b> Disable color and syntax highlighting
<b>--disable-comment</b> Disable the comment/uncomment function
<b>--disable-extra</b> Disable the easter egg
<b>--disable-help</b> Disable the built-in help texts
<b>--disable-histories</b> Disable the saving of search strings and cursor positions
<b>--disable-justify</b> Disable the justify/unjustify functions
<b>--disable-libmagic</b> Disable the use of libmagic for determining a file's syntax
<b>--disable-linenumbers</b> Disable line numbering
<b>--disable-mouse</b> Disable mouse support
<b>--disable-multibuffer</b> Disable the opening of multiple file buffers
<b>--disable-nanorc</b> Disable the use of .nanorc files
<b>--disable-operatingdir</b> Disable the setting of an operating directory
<b>--disable-speller</b> Disable the spell-checker functions
<b>--disable-tabcomp</b> Disable the tab-completion functions
<b>--disable-wordcomp</b> Disable the word-completion function
<b>--disable-wrapping</b> Disable all hard-wrapping of text</pre>
<b>--disable-browser</b> Disable the built-in file browser
<b>--disable-color</b> Disable color and syntax highlighting
<b>--disable-comment</b> Disable the comment/uncomment function
<b>--disable-extra</b> Disable the easter egg
<b>--disable-help</b> Disable the built-in help texts
<b>--disable-histories</b> Disable the saving of search strings and cursor positions
<b>--disable-justify</b> Disable the justify/unjustify functions
<b>--disable-libmagic</b> Disable the use of libmagic for determining a file's syntax
<b>--disable-linenumbers</b> Disable line numbering
<b>--disable-mouse</b> Disable mouse support
<b>--disable-multibuffer</b> Disable the opening of multiple file buffers
<b>--disable-nanorc</b> Disable the use of .nanorc files
<b>--disable-operatingdir</b> Disable the setting of an operating directory
<b>--disable-speller</b> Disable the spell-checker functions
<b>--disable-tabcomp</b> Disable the tab-completion functions
<b>--disable-wordcomp</b> Disable the word-completion function
<b>--disable-wrapping</b> Disable all hard-wrapping of text</pre>
<p>There's also the <b>--enable-tiny</b> option which disables everything above, as well as some larger chunks of the program (like the undo/redo code and the code for selecting text). Also, if you know you don't need other languages, you can use <b>--disable-nls</b> to disable internationalization and save a few kilobytes. And finally, there's always good old <b>strip</b> to remove all unneeded symbols.</p>
</blockquote>
<h3><a name="3.6"></a>3.6. Tell me more about this multibuffer stuff!</h3>
@@ -175,13 +178,19 @@
<hr width="100%">
<h1><a name="4"></a>4. Running</h1>
<h3><a name="4.1"></a>4.1. How do I open a file with a name beginning with '+' from the command line?</h3>
<blockquote><p>If a command-line argument that begins with '+' is followed by another argument, the former is always treated as a starting line (plus column number), and the latter always as a filename. If a command-line argument that begins with '+' isn't followed by another argument, it's treated as a filename. Examples:</p>
<p>To open '+filename.txt': <b>nano +filename.txt</b><br>
To open '+filename.txt' starting on line 10: <b>nano +10 +filename.txt</b><br>
To open '+filename.txt' starting on line 1, column 20: <b>nano +,20 +filename.txt</b><br>
To open '+filename.txt' starting on line 10, column 20: <b>nano +10,20 +filename.txt</b><br>
To open '+filename.txt' starting on line 1 and 'filename.txt' starting on line 40: <b>nano +1 +filename.txt +40 filename.txt</b></p></blockquote>
<h3><a name="4.1"></a>4.1. Alt+Up does nothing on a Linux console. How can I make it scroll?</h3>
<blockquote><p>On Debian and its derivatives, the <b>Alt+Up</b> keystroke on a Linux console
produces by default a 'KeyboardSignal', which normally does absolutely nothing and is useless
for the average user. To get the keystroke to do what it ought to do (scroll the viewport
one row up), run this in a Linux console:</p>
<p class="indented"><b>dumpkeys --full | sed s/KeyboardSignal/Up/ | sudo loadkeys -</b></p>
<p>You will need to run this command whenever you first switch to a Linux console.</p>
<p>Or you can (as root) execute the following little script just once:</p>
<p class="indented"><b>for file in /etc/console-setup/cached*.kmap.gz; do<br>
&nbsp;&nbsp;&nbsp;&nbsp;gunzip $file;<br>
&nbsp;&nbsp;&nbsp;&nbsp;sed -i 's/KeyboardSignal/Up/' ${file%.gz};<br>
&nbsp;&nbsp;&nbsp;&nbsp;gzip ${file%.gz};<br>
done</b></p></blockquote>
<h3><a name="4.2"></a>4.2. How can I make Ctrl+Shift+Left/Right select words on urxvt?</h3>
<blockquote><p>The urxvt terminal emulator produces non-standard escape sequences for the modified cursor keys. These deviant sequences are not listed in the terminfo database, which means that ncurses does not recognize them. The easiest way around this is to tell urxvt to produce xterm-compatible escape sequences for the relevant keystrokes. To achieve this, add the following lines to your ~/.Xresources file:</p>
<pre>
@@ -219,16 +228,16 @@
<blockquote><p>If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Several example configurations are in the <b>syntax/</b> subdirectory of the nano source, which are normally installed to <b>/usr/local/share/nano/</b>. To enable all of them, uncomment the line <b># include "/usr/local/share/nano/*.nanorc"</b> in your nanorc. See also section <a href="#3.9">3.9</a>.</p></blockquote>
<h3><a name="4.9"></a>4.9. How do I make nano my default editor (in Pine, mutt, etc.)?</h3>
<blockquote><p>You need to make nano your $EDITOR. If you want this to be saved, you should put a line like this in your <b>.bashrc</b> if you use bash (or <b>.zshrc</b> if you believe in zsh):</p>
<p><b>export EDITOR=/usr/local/bin/nano</b></p>
<p class="indented"><b>export EDITOR=/usr/local/bin/nano</b></p>
<p>or, if you use tcsh, put this in your <b>.cshrc</b> file:</p>
<p><b>setenv EDITOR /usr/local/bin/nano</b></p>
<p class="indented"><b>setenv EDITOR /usr/local/bin/nano</b></p>
<p>Change /usr/local/bin/nano to wherever nano is installed on your system. Type &quot;which nano&quot; to find out. This will not take effect until the next time you log in. So log out and back in again.</p>
<p>Then, on top of that, if you use Pine, you must go into setup (type <b>S</b> at the main menu), and then configure (type <b>C</b>). Hit Enter on the lines that say:</p>
<p><b>[ ] enable-alternate-editor-cmd</b><br>
<p class="indented"><b>[ ] enable-alternate-editor-cmd</b><br>
<b>[ ] enable-alternate-editor-implicitly</b></p>
<p>Then exit (<b>E</b>) and select Yes (<b>Y</b>).</p>
<p>If you're a mutt user, you should see an effect immediately the next time you log in. No further configuration is needed. However, if you want to let people know you use nano to compose your email messages, you can put a line like this in your <b>.muttrc</b>:</p>
<p><b>my_hdr X-Composer: nano-x.y</b></p>
<p class="indented"><b>my_hdr X-Composer: nano-x.y</b></p>
<p>Again, replace x.y with the version of nano you use.</p></blockquote>
<hr width="100%">

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 5.7" "April 2021"
.TH NANO 1 "version 5.9" "October 2021"
.SH NAME
nano \- Nano's ANOther editor, inspired by Pico
@@ -27,20 +27,6 @@ nano \- Nano's ANOther editor, inspired by Pico
.sp
.BR nano " [" \fIoptions "] [[" + [ crCR ]( / | ? ) \fIstring "] " \fIfile ]...
.SH NOTICE
Since version 4.0, \fBnano\fR by default:
.sp
.RS 4
\(bu does not automatically hard-wrap lines that become overlong,
.br
\(bu includes the line below the title bar in the editing area,
.br
\(bu does linewise (smooth) scrolling.
.RE
.sp
If you want the old, Pico behavior back, you can use \fB\-\-breaklonglines\fR,
\fB\-\-emptyline\fR, and \fB\-\-jumpyscrolling\fR (or \fB\-bej\fR for short).
.SH DESCRIPTION
\fBnano\fP is a small and friendly editor. It copies the look and feel
of Pico, but is free software, and implements several features that Pico
@@ -58,7 +44,7 @@ regular expression by inserting \fBc\fR and/or \fBr\fR after the \fB+\fR sign.
These search modes can be explicitly disabled by using the uppercase variant
of those letters: \fBC\fR and/or \fBR\fR. When the string contains spaces,
it needs to be enclosed in quotes. To give an example: to open a file at
the first occurrence of the word "Foo", one would do:
the first occurrence of the word "Foo", you would do:
.sp
.RS 4
.BI "nano +c/Foo " file
@@ -77,11 +63,11 @@ Any cursor movement or executing any other command will cause the next
\fB^K\fR to overwrite the cutbuffer. A \fB^U\fR will paste the current
contents of the cutbuffer at the current cursor position.
.sp
When a more precise piece of text needs to be cut or copied, one can mark
When a more precise piece of text needs to be cut or copied, you can mark
its start with \fB^6\fR, move the cursor to its end (the marked text will be
highlighted), and then use \fB^K\fR to cut it, or \fBM\-6\fR to copy it to the
cutbuffer. One can also save the marked text to a file with \fB^O\fR, or
spell check it with \fB^T\fR.
cutbuffer. You can also save the marked text to a file with \fB^O\fR, or
spell check it with \fB^T^T\fR.
.sp
On some terminals, text can be selected also by holding down Shift while
using the arrow keys. Holding down the Ctrl or Alt key too will increase
@@ -93,6 +79,20 @@ the built-in help (\fB^G\fR) lists all the available ones.
The default key bindings can be changed via a \fInanorc\fR file -- see
.BR nanorc (5).
.SH NOTICE
Since version 4.0, \fBnano\fR by default:
.sp
.RS 4
\(bu does not automatically hard-wrap lines that become overlong,
.br
\(bu includes the line below the title bar in the editing area,
.br
\(bu does linewise (smooth) scrolling.
.RE
.sp
If you want the old, Pico behavior back, you can use \fB\-\-breaklonglines\fR,
\fB\-\-emptyline\fR, and \fB\-\-jumpyscrolling\fR (or \fB\-bej\fR for short).
.SH OPTIONS
.TP
.BR \-A ", " \-\-smarthome
@@ -118,7 +118,8 @@ by setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, \fBkeycolor\fP,
nanorc file. See \fBnanorc\fR(5).
.TP
.BR \-E ", " \-\-tabstospaces
Convert typed tabs to spaces.
Convert each typed tab to spaces -- to the number of spaces
that a tab at that position would take up.
.TP
.BR \-F ", " \-\-multibuffer
Read a file into a new buffer by default.
@@ -340,14 +341,14 @@ filename in the center of the title bar.
.BR \-_ ", " \-\-minibar
Suppress the title bar and instead show information about
the current buffer at the bottom of the screen, in the space
for the status bar. In this "minibar" the file name is shown
for the status bar. In this "minibar" the filename is shown
on the left, followed by an asterisk if the buffer has been modified.
On the right are displayed the current line and column number, the
code of the character under the cursor (in Unicode format: U+xxxx),
the same flags as are shown by \fB\-\-stateflags\fR, and a percentage
that expresses how far the cursor is into the file (linewise).
When a file is loaded or saved, and also when switching between buffers,
the number of lines in the buffer is displayed after the file name.
the number of lines in the buffer is displayed after the filename.
This number is cleared upon the next keystroke, or replaced with an
[i/n] counter when multiple buffers are open.
The line plus column numbers and the character code are displayed only when

View File

@@ -7,9 +7,9 @@
@documentencoding UTF-8
@smallbook
@set EDITION 0.5
@set VERSION 5.7
@set UPDATED April 2021
@set EDITION 0.6
@set VERSION 5.9
@set UPDATED October 2021
@dircategory Editors
@direntry
@@ -23,7 +23,7 @@
@titlepage
@title GNU @command{nano}
@subtitle a small and friendly text editor
@subtitle version 5.7
@subtitle version 5.9
@author Chris Allegretta
@page
@@ -53,8 +53,10 @@ under the terms of either of the following licenses:
along with this program. If not, see @url{https://www.gnu.org/licenses/}.
@sp 1
You may contact the author by
You may contact the original author by
e-mail: @email{chrisa@@asty.org}@*
For suggesting improvements: @email{nano-devel@@gnu.org}@*
@end titlepage
@ifnottex
@@ -63,7 +65,7 @@ e-mail: @email{chrisa@@asty.org}@*
@node Top
@top
This manual documents the GNU @command{nano} editor, version 5.7.
This manual documents the GNU @command{nano} editor, version 5.9.
@menu
* Introduction::
@@ -103,9 +105,9 @@ If you want the old, Pico behavior back, you can use the
following options: @option{--breaklonglines},
@option{--jumpyscrolling}, and @option{--emptyline}
(or @option{-bje}).
@sp 1
Please report bugs via @url{https://savannah.gnu.org/bugs/?group=nano}.
@sp 1
For background information see @url{https://nano-editor.org/}.
@node Invoking
@@ -193,7 +195,8 @@ nanorc file. @xref{@code{set functioncolor}} for details.
@item -E
@itemx --tabstospaces
Convert typed tabs to spaces.
Convert each typed tab to spaces --- to the number of spaces
that a tab at that position would take up.
@item -F
@itemx --multibuffer
@@ -481,14 +484,14 @@ filename in the center of the title bar.
@itemx --minibar
Suppress the title bar and instead show information about
the current buffer at the bottom of the screen, in the space
for the status bar. In this "minibar" the file name is shown
for the status bar. In this "minibar" the filename is shown
on the left, followed by an asterisk if the buffer has been modified.
On the right are displayed the current line and column number, the
code of the character under the cursor (in Unicode format: U+xxxx),
the same flags as are shown by @code{--stateflags}, and a percentage
that expresses how far the cursor is into the file (linewise).
When a file is loaded or saved, and also when switching between buffers,
the number of lines in the buffer is displayed after the file name.
the number of lines in the buffer is displayed after the filename.
This number is cleared upon the next keystroke, or replaced with an
[i/n] counter when multiple buffers are open.
The line plus column numbers and the character code are displayed only when
@@ -588,7 +591,7 @@ or @kbd{M-A} and then moving the cursor to the other end of the portion
to be selected. The selected portion of text will be highlighted.
This selection can now be cut or copied in its entirety with a single
@kbd{^K} or @kbd{M-6}. Or the selection can be used to limit the scope of
a search-and-replace (@kbd{^\}) or spell-checking session (@kbd{^T}).
a search-and-replace (@kbd{^\}) or spell-checking session (@kbd{^T^T}).
On some terminals, text can be selected also by holding down @kbd{Shift}
while using the cursor keys. Holding down the @kbd{Ctrl} or @kbd{Alt}
@@ -856,7 +859,7 @@ Do not use the line below the title bar, leaving it entirely blank.
@item set errorcolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
Use this color combination for the status bar when an error message is displayed.
The default value is @t{brightwhite,red}.
The default value is @t{bold,white,red}.
@xref{@code{set functioncolor}} for valid color names.
@item set fill @var{number}
@@ -876,6 +879,8 @@ Valid names for the foreground and background colors are:
@code{white}, and @code{black}.
Each of these eight names may be prefixed with the word
@code{light} to get a brighter version of that color.
The word @code{grey} or @code{gray} may be used as
a synonym for @code{lightblack}.
On terminal emulators that can do at least 256 colors,
other valid (but unprefixable) color names are:
@@ -932,20 +937,25 @@ The default value is "@t{(<[@{)>]@}}".
@item set minibar
Suppress the title bar and instead show information about
the current buffer at the bottom of the screen, in the space
for the status bar. In this "minibar" the file name is shown
for the status bar. In this "minibar" the filename is shown
on the left, followed by an asterisk if the buffer has been modified.
On the right are displayed the current line and column number, the
code of the character under the cursor (in Unicode format: U+xxxx),
the same flags as are shown by @code{set stateflags}, and a percentage
that expresses how far the cursor is into the file (linewise).
When a file is loaded or saved, and also when switching between buffers,
the number of lines in the buffer is displayed after the file name.
the number of lines in the buffer is displayed after the filename.
This number is cleared upon the next keystroke, or replaced with an
[i/n] counter when multiple buffers are open.
The line plus column numbers and the character code are displayed only when
@code{set constantshow} is used, and can be toggled on and off with @key{M-C}.
The state flags are displayed only when @code{set stateflags} is used.
@item set minicolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
Use this color combination for the minibar.
(When this option is not specified, the colors of the title bar are used.)
@xref{@code{set functioncolor}} for valid color names.
@item set mouse
Enable mouse support, so that mouse clicks can be used to place the
cursor, set the mark (with a double click), or execute shortcuts.
@@ -1086,7 +1096,8 @@ Use a tab size of @var{number} columns. The value of @var{number} must be
greater than 0. The default value is @t{8}.
@item set tabstospaces
Convert typed tabs to spaces.
Convert each typed tab to spaces --- to the number of spaces
that a tab at that position would take up.
@item set titlecolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
Use this color combination for the title bar.
@@ -1403,7 +1414,8 @@ the line, column, and character positions.
(The old name of this function, 'curpos', is deprecated.)
@item wordcount
Counts the number of words, lines and characters in the current buffer.
Counts and reports on the status bar the number of lines, words,
and characters in the current buffer (or in the marked region).
@item execute
Prompts for a program to execute. The program's output will be inserted
@@ -1421,27 +1433,28 @@ Invokes a full-buffer-processing program (if the active syntax defines one).
Invokes a syntax-checking program (if the active syntax defines one).
@item justify
Justifies the current paragraph. A paragraph is a group of contiguous lines
Justifies the current paragraph (or the marked region).
A paragraph is a group of contiguous lines
that, apart from possibly the first line, all have the same indentation. The
beginning of a paragraph is detected by either this lone line with a differing
indentation or by a preceding blank line.
@item fulljustify
Justifies the entire current buffer.
Justifies the entire current buffer (or the marked region).
@item indent
Indents (shifts to the right) the currently marked text.
Indents (shifts to the right) the current line or the marked lines.
@item unindent
Unindents (shifts to the left) the currently marked text.
Unindents (shifts to the left) the current line or the marked lines.
@item comment
Comments or uncomments the current line or marked lines, using the comment
style specified in the active syntax.
Comments or uncomments the current line or the marked lines,
using the comment style specified in the active syntax.
@item complete
Completes the fragment before the cursor to a full word found elsewhere
in the current buffer.
Completes (when possible) the fragment before the cursor
to a full word found elsewhere in the current buffer.
@item left
Goes left one position (in the editor or browser).
@@ -1458,10 +1471,14 @@ Goes one line down (in the editor or browser).
@item scrollup
Scrolls the viewport up one row (meaning that the text slides down)
while keeping the cursor in the same text position, if possible.
(This function is bound by default to <Alt+Up>.
If <Alt+Up> does nothing on your Linux console, see the FAQ:
@url{https://nano-editor.org/dist/latest/faq.html#4.1}.)
@item scrolldown
Scrolls the viewport down one row (meaning that the text slides up)
while keeping the cursor in the same text position, if possible.
(This function is bound by default to <Alt+Down>.)
@item center
Scrolls the line with the cursor to the middle of the screen.

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 5.7 "April 2021"
.TH NANORC 5 "version 5.9" "October 2021"
.SH NAME
nanorc \- GNU nano's configuration file
@@ -127,7 +127,7 @@ Do not use the line below the title bar, leaving it entirely blank.
.TP
.B set errorcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the status bar when an error message is displayed.
The default value is \fBbrightwhite,red\fR.
The default value is \fBbold,white,red\fR.
See \fBset titlecolor\fR for valid color names.
.TP
.B set fill \fInumber\fR
@@ -185,20 +185,25 @@ The default value is "\fB(<[{)>]}\fP".
.B set minibar
Suppress the title bar and instead show information about
the current buffer at the bottom of the screen, in the space
for the status bar. In this "minibar" the file name is shown
for the status bar. In this "minibar" the filename is shown
on the left, followed by an asterisk if the buffer has been modified.
On the right are displayed the current line and column number, the
code of the character under the cursor (in Unicode format: U+xxxx),
the same flags as are shown by \fBset stateflags\fR, and a percentage
that expresses how far the cursor is into the file (linewise).
When a file is loaded or saved, and also when switching between buffers,
the number of lines in the buffer is displayed after the file name.
the number of lines in the buffer is displayed after the filename.
This number is cleared upon the next keystroke, or replaced with an
[i/n] counter when multiple buffers are open.
The line plus column numbers and the character code are displayed only when
\fBset constantshow\fR is used, and can be toggled on and off with \fBM-C\fR.
The state flags are displayed only when \fBset stateflags\fR is used.
.TP
.B set minicolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the minibar.
(When this option is not specified, the colors of the title bar are used.)
See \fBset titlecolor\fR for more details.
.TP
.B set mouse
Enable mouse support, if available for your system. When enabled, mouse
clicks can be used to place the cursor, set the mark (with a double
@@ -292,8 +297,9 @@ Use this color combination for selected text.
See \fBset titlecolor\fR for more details.
.TP
.B set showcursor
Put the cursor on the highlighted item in the file browser, to aid
braille users.
Put the cursor on the highlighted item in the file browser, and show
the cursor in the help viewer, to aid braille users and people with
poor vision.
.TP
.B set smarthome
Make the Home key smarter. When Home is pressed anywhere but at the
@@ -340,7 +346,8 @@ Use a tab size of \fInumber\fR columns. The value of \fInumber\fP must be
greater than 0. The default value is \fB8\fR.
.TP
.B set tabstospaces
Convert typed tabs to spaces.
Convert each typed tab to spaces -- to the number of spaces
that a tab at that position would take up.
.TP
.B set titlecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the title bar.
@@ -349,6 +356,8 @@ Valid names for the foreground and background colors are:
.BR white ", and " black .
Each of these eight names may be prefixed with the word \fBlight\fR
to get a brighter version of that color.
The word \fBgrey\fR or \fBgray\fR may be used
as a synonym for \fBlightblack\fR.
On terminal emulators that can do at least 256 colors,
other valid (but unprefixable) color names are:
.BR pink ", " purple ", " mauve ", " lagoon ", " mint ", "
@@ -648,7 +657,8 @@ the line, column, and character positions.
(The old name of this function, 'curpos', is deprecated.)
.TP
.B wordcount
Counts the number of words, lines and characters in the current buffer.
Counts and reports on the status bar the number of lines, words,
and characters in the current buffer (or in the marked region).
.TP
.B execute
Prompts for a program to execute. The program's output will be inserted
@@ -665,27 +675,28 @@ Invokes a full-buffer-processing program (if the active syntax defines one).
Invokes a syntax-checking program (if the active syntax defines one).
.TP
.B justify
Justifies the current paragraph. A paragraph is a group of contiguous lines
Justifies the current paragraph (or the marked region).
A paragraph is a group of contiguous lines
that, apart from possibly the first line, all have the same indentation. The
beginning of a paragraph is detected by either this lone line with a differing
indentation or by a preceding blank line.
.TP
.B fulljustify
Justifies the entire current buffer.
Justifies the entire current buffer (or the marked region).
.TP
.B indent
Indents (shifts to the right) the currently marked text.
Indents (shifts to the right) the current line or the marked lines.
.TP
.B unindent
Unindents (shifts to the left) the currently marked text.
Unindents (shifts to the left) the current line or the marked lines.
.TP
.B comment
Comments or uncomments the current line or marked lines, using the comment
style specified in the active syntax.
Comments or uncomments the current line or the marked lines,
using the comment style specified in the active syntax.
.TP
.B complete
Completes the fragment before the cursor to a full word found elsewhere
in the current buffer.
Completes (when possible) the fragment before the cursor
to a full word found elsewhere in the current buffer.
.TP
.B left
Goes left one position (in the editor or browser).
@@ -702,10 +713,15 @@ Goes one line down (in the editor or browser).
.B scrollup
Scrolls the viewport up one row (meaning that the text slides down)
while keeping the cursor in the same text position, if possible.
(This function is bound by default to <Alt+Up>.
If <Alt+Up> does nothing on your Linux console, see the FAQ:
.UR https://nano\-editor.org/dist/latest/faq.html#4.1
.UE .)
.TP
.B scrolldown
Scrolls the viewport down one row (meaning that the text slides up)
while keeping the cursor in the same text position, if possible.
(This function is bound by default to <Alt+Down>.)
.TP
.B center
Scrolls the line with the cursor to the middle of the screen.

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH RNANO 1 "version 5.7" "April 2021"
.TH RNANO 1 "version 5.9" "October 2021"
.SH NAME
rnano \- a restricted nano

View File

@@ -78,18 +78,19 @@
## Fall back to slow libmagic to try and determine an applicable syntax.
# set magic
## The opening and closing brackets that can be found by bracket
## searches. They cannot contain blank characters. The former set must
## come before the latter set, and both must be in the same order.
## The opening and closing brackets that are found by a matching-bracket
## search. This may not contain blank characters. The opening brackets
## must come before the closing ones, and they must be in the same order.
# set matchbrackets "(<[{)>]}"
## Suppress title bar and show file name and editor state at the bottom.
## Suppress the title bar and show the filename plus a cursor-position
## percentage in the space of the status bar.
# set minibar
## Enable mouse support, if available for your system. When enabled,
## mouse clicks can be used to place the cursor, set the mark (with a
## double click), and execute shortcuts. The mouse will work in the X
## Window System, and on the console when gpm is running.
## double click), and execute shortcuts. The mouse will work in the
## X Window System, and on the console when gpm is running.
# set mouse
## Switch on multiple file buffers (inserting a file will put it into
@@ -117,10 +118,9 @@
## Preserve the XON and XOFF keys (^Q and ^S).
# set preserve
## The characters treated as closing punctuation when justifying
## paragraphs. They cannot contain blank characters. Only closing
## punctuation, optionally followed by closing brackets, can end
## sentences.
## The characters treated as closing punctuation when justifying paragraphs.
## This may not contain blank characters. Only these closing punctuations,
## optionally followed by closing brackets, can end sentences.
# set punct "!.?"
## Make status-bar messages disappear after 1 keystroke instead of after 20.
@@ -144,16 +144,16 @@
# set saveonexit
## (The old form of this option, 'set tempfile', is deprecated.)
## Put the cursor on the highlighted item in the file browser, and show
## the cursor in the help viewer; useful for people who use a braille
## display and people with poor vision.
## Put the cursor on the highlighted item in the file browser, and
## show the cursor in the help viewer; useful for people who use a
## braille display and people with poor vision.
# set showcursor
## Make the Home key smarter. When Home is pressed anywhere but at the
## Make the Home key smarter: when Home is pressed anywhere but at the
## very beginning of non-whitespace characters on a line, the cursor
## will jump to that beginning (either forwards or backwards). If the
## cursor is already at that position, it will jump to the true
## beginning of the line.
## cursor is already at that position, it will jump to the true start
## of the line (the left edge).
# set smarthome
## Spread overlong lines over multiple screen lines.
@@ -174,7 +174,7 @@
## Use this tab size instead of the default; it must be greater than 0.
# set tabsize 8
## Convert typed tabs to spaces.
## Convert each typed tab to the fitting number of spaces.
# set tabstospaces
## Snip whitespace at the end of lines when justifying or hard-wrapping.
@@ -204,11 +204,11 @@
## Paint the interface elements of nano. These are examples; there are
## no colors by default, except for errorcolor and spotlightcolor.
# set titlecolor bold,lightwhite,blue
# set promptcolor lightwhite,lightblack
# set statuscolor bold,lightwhite,green
# set errorcolor bold,lightwhite,red
# set spotlightcolor black,lime
# set titlecolor bold,white,blue
# set promptcolor lightwhite,grey
# set statuscolor bold,white,green
# set errorcolor bold,white,red
# set spotlightcolor black,lightyellow
# set selectedcolor lightwhite,magenta
# set stripecolor ,yellow
# set scrollercolor cyan
@@ -217,10 +217,10 @@
# set functioncolor green
## In root's .nanorc you might want to use:
# set titlecolor bold,lightwhite,magenta
# set titlecolor bold,white,magenta
# set promptcolor black,yellow
# set statuscolor bold,lightwhite,magenta
# set errorcolor bold,lightwhite,red
# set statuscolor bold,white,magenta
# set errorcolor bold,white,red
# set spotlightcolor black,orange
# set selectedcolor lightwhite,cyan
# set stripecolor ,yellow
@@ -265,6 +265,12 @@
## <Ctrl+Backspace> delete the word to the left of the cursor with:
# bind ^H chopwordleft main
## For quickly uppercasing or lowercasing the word under the cursor.
## (These effectively do a Ctrl+Right followed by a Shift+Ctrl+Left,
## and then pipe the selected text through a sed command.)
#bind Sh-M-U "Oc|sed 's/.*/\U&/'
" main
#bind Sh-M-L "Oc|sed 's/.*/\L&/'
" main
## If you would like nano to have keybindings that are more "usual",
@@ -279,11 +285,11 @@
#bind ^F whereis all
#bind ^G findnext all
#bind ^B wherewas all
#bind M-X flipnewbuffer all
#bind ^X cut all
#bind ^D findprevious all
#bind ^R replace main
#bind ^X cut main
#bind ^C copy main
#bind ^V paste all
#bind ^P location main
#bind ^E execute main
#bind ^A mark main
@@ -293,9 +299,10 @@
#unbind ^Y all
#unbind M-J main
#unbind M-T main
#bind ^Y speller main
#bind ^T gotoline main
#bind ^T gotodir browser
#bind ^T cutrestoffile execute
#bind ^L linter execute
#bind ^U undo main
#bind ^E redo main
#bind M-U undo main
#bind M-R redo main
#bind ^Z undo main

View File

@@ -1,2 +1,2 @@
# List of available languages.
bg ca cs da de eo es eu fi fr ga gl hr hu id it ja ko ms nb nl nn pl pt pt_BR ro ru sl sr sv tr uk vi zh_CN zh_TW
bg ca cs da de eo es eu fi fr ga gl hr hu id is it ja ko ms nb nl pl pt pt_BR ro ru sk sl sr sv tr uk vi zh_CN zh_TW

1124
po/bg.po

File diff suppressed because it is too large Load Diff

1142
po/ca.po

File diff suppressed because it is too large Load Diff

1128
po/cs.po

File diff suppressed because it is too large Load Diff

1124
po/da.po

File diff suppressed because it is too large Load Diff

1138
po/de.po

File diff suppressed because it is too large Load Diff

1130
po/eo.po

File diff suppressed because it is too large Load Diff

1131
po/es.po

File diff suppressed because it is too large Load Diff

1130
po/eu.po

File diff suppressed because it is too large Load Diff

1118
po/fi.po

File diff suppressed because it is too large Load Diff

1153
po/fr.po

File diff suppressed because it is too large Load Diff

1137
po/ga.po

File diff suppressed because it is too large Load Diff

1126
po/gl.po

File diff suppressed because it is too large Load Diff

1140
po/hr.po

File diff suppressed because it is too large Load Diff

1128
po/hu.po

File diff suppressed because it is too large Load Diff

2296
po/id.po

File diff suppressed because it is too large Load Diff

1116
po/is.po

File diff suppressed because it is too large Load Diff

1128
po/it.po

File diff suppressed because it is too large Load Diff

1134
po/ja.po

File diff suppressed because it is too large Load Diff

1140
po/ko.po

File diff suppressed because it is too large Load Diff

1165
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1245
po/nb.po

File diff suppressed because it is too large Load Diff

1130
po/nl.po

File diff suppressed because it is too large Load Diff

2885
po/nn.po

File diff suppressed because it is too large Load Diff

1140
po/pl.po

File diff suppressed because it is too large Load Diff

1132
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1288
po/ro.po

File diff suppressed because it is too large Load Diff

1130
po/ru.po

File diff suppressed because it is too large Load Diff

3052
po/sk.po Normal file

File diff suppressed because it is too large Load Diff

1126
po/sl.po

File diff suppressed because it is too large Load Diff

1131
po/sr.po

File diff suppressed because it is too large Load Diff

1138
po/sv.po

File diff suppressed because it is too large Load Diff

1134
po/tr.po

File diff suppressed because it is too large Load Diff

1130
po/uk.po

File diff suppressed because it is too large Load Diff

View File

@@ -9,6 +9,9 @@ rm *.po
wget --recursive --level=1 --accept=po --no-directories --no-verbose \
https://translationproject.org/latest/nano/ || exit 2
# This PO file is less than twenty percent translated:
rm -v nn.po
# Are there now PO files that are not in git yet?
NEWSTUFF=$(git status --porcelain *.po | grep "^??")

1126
po/vi.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
#!/bin/bash
VERSION="5.7"
VERSION="5.9"
./configure -C --enable-tiny && make && ./configure -C &&
@@ -12,7 +12,7 @@ po/update_linguas.sh &&
make distcheck && make dist-xz &&
git add po/*.po po/nano.pot &&
git add po/*.po po/nano.pot po/LINGUAS &&
git commit -m "$(git log -1 --grep 'po: up' | grep o: | sed 's/^ //')" &&
gpg -a -b nano-$VERSION.tar.gz &&

View File

@@ -359,7 +359,8 @@ void search_filename(bool forwards)
#endif
}
findfile(last_search, forwards);
if (response == 0 || response == -2)
findfile(last_search, forwards);
}
/* Search again without prompting for the last given search string,
@@ -380,6 +381,18 @@ void research_filename(bool forwards)
}
}
/* Select the first file in the list -- called by ^W^Y. */
void to_first_file(void)
{
selected = 0;
}
/* Select the last file in the list -- called by ^W^V. */
void to_last_file(void)
{
selected = list_length - 1;
}
/* Strip one element from the end of path, and return the stripped path.
* The returned string is dynamically allocated, and should be freed. */
char *strip_last_component(const char *path)

View File

@@ -2,7 +2,7 @@
* chars.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2016-2020 Benno Schulenberg *
* Copyright (C) 2016-2021 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -498,7 +498,7 @@ char *revstrstr(const char *haystack, const char *needle,
size_t tail_len = strlen(pointer);
if (tail_len < needle_len)
pointer += tail_len - needle_len;
pointer -= (needle_len - tail_len);
while (pointer >= haystack) {
if (strncmp(pointer, needle, needle_len) == 0)
@@ -518,7 +518,7 @@ char *revstrcasestr(const char *haystack, const char *needle,
size_t tail_len = strlen(pointer);
if (tail_len < needle_len)
pointer += tail_len - needle_len;
pointer -= (needle_len - tail_len);
while (pointer >= haystack) {
if (strncasecmp(pointer, needle, needle_len) == 0)
@@ -540,7 +540,7 @@ char *mbrevstrcasestr(const char *haystack, const char *needle,
size_t tail_len = mbstrlen(pointer);
if (tail_len < needle_len)
pointer += tail_len - needle_len;
pointer -= (needle_len - tail_len);
if (pointer < haystack)
return NULL;
@@ -644,7 +644,7 @@ bool has_blank_char(const char *string)
return *string;
}
#endif /* ENABLE_NANORC && (!NANO_TINY || ENABLE_JUSTIFY) */
#endif
/* Return TRUE when the given string is empty or consists of only blanks. */
bool white_string(const char *string)

View File

@@ -2,7 +2,7 @@
* color.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017, 2020 Benno Schulenberg *
* Copyright (C) 2014-2017, 2020, 2021 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -61,7 +61,7 @@ void set_interface_colorpairs(void)
else if (index == SPOTLIGHTED) {
init_pair(index + 1, COLOR_BLACK, COLOR_YELLOW + (COLORS > 15 ? 8 : 0));
interface_color_pair[index] = COLOR_PAIR(index + 1);
} else if (index == PROMPT_BAR)
} else if (index == MINI_INFOBAR || index == PROMPT_BAR)
interface_color_pair[index] = interface_color_pair[TITLE_BAR];
else if (index == ERROR_MESSAGE) {
init_pair(index + 1, COLOR_WHITE, COLOR_RED);

View File

@@ -249,27 +249,29 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
bool same_line = (openfile->mark == top);
bool post_marked = (openfile->mark && (openfile->mark->lineno > top->lineno ||
(same_line && openfile->mark_x > top_x)));
bool was_anchored = top->has_anchor;
static bool inherited_anchor = FALSE;
bool had_anchor = top->has_anchor;
if (top == bot && top_x == bot_x)
return;
if (top != bot)
for (linestruct *line = top->next; line != bot->next; line = line->next)
was_anchored |= line->has_anchor;
had_anchor |= line->has_anchor;
#endif
if (top == bot) {
taken = make_new_node(NULL);
taken->data = measured_copy(top->data + top_x, bot_x - top_x);
memmove(top->data + top_x, top->data + bot_x,
strlen(top->data + bot_x) + 1);
memmove(top->data + top_x, top->data + bot_x, strlen(top->data + bot_x) + 1);
last = taken;
} else if (top_x == 0 && bot_x == 0) {
taken = top;
last = make_new_node(NULL);
last->data = copy_of("");
#ifndef NANO_TINY
last->has_anchor = bot->has_anchor;
#endif
last->prev = bot->prev;
bot->prev->next = last;
last->next = NULL;
@@ -309,11 +311,17 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
if (cutbuffer == NULL) {
cutbuffer = taken;
cutbottom = last;
#ifndef NANO_TINY
inherited_anchor = taken->has_anchor;
#endif
} else {
cutbottom->data = nrealloc(cutbottom->data,
strlen(cutbottom->data) + strlen(taken->data) + 1);
strcat(cutbottom->data, taken->data);
#ifndef NANO_TINY
cutbottom->has_anchor = taken->has_anchor && !inherited_anchor;
inherited_anchor |= taken->has_anchor;
#endif
cutbottom->next = taken->next;
delete_node(taken);
@@ -326,7 +334,7 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
openfile->current_x = top_x;
#ifndef NANO_TINY
openfile->current->has_anchor = was_anchored;
openfile->current->has_anchor = had_anchor;
if (post_marked || same_line)
openfile->mark = openfile->current;
@@ -686,10 +694,13 @@ void copy_text(void)
/* Copy text from the cutbuffer into the current buffer. */
void paste_text(void)
{
#ifndef NANO_TINY
/* Remember where the paste started. */
linestruct *was_current = openfile->current;
bool had_anchor = was_current->has_anchor;
#endif
ssize_t was_lineno = openfile->current->lineno;
/* The line number where we started the paste. */
size_t was_leftedge = 0;
/* The leftedge where we started the paste. */
if (cutbuffer == NULL) {
statusline(AHEM, _("Cutbuffer is empty"));
@@ -708,6 +719,12 @@ void paste_text(void)
copy_from_buffer(cutbuffer);
#ifndef NANO_TINY
/* Wipe any anchors in the pasted text, so that they don't proliferate. */
for (linestruct *line = was_current; line != openfile->current->next; line = line->next)
line->has_anchor = FALSE;
was_current->has_anchor = had_anchor;
update_undo(PASTE);
#endif

View File

@@ -29,6 +29,10 @@
#endif
#endif
#if defined(__HAIKU__) && !defined(_DEFAULT_SOURCE)
#define _DEFAULT_SOURCE 1
#endif
#ifdef __TANDEM
/* Tandem NonStop Kernel support. */
#include <floss.h>
@@ -111,6 +115,13 @@
#define REPLACING 1
#define INREGION 2
#define NORMAL TRUE
#define SPECIAL FALSE
#define TEMPORARY FALSE
#define ANNOTATE TRUE
#define NONOTES FALSE
#ifdef ENABLE_UTF8
/* In UTF-8 a valid character is at most four bytes long. */
#define MAXCHARLEN 4
@@ -216,6 +227,7 @@
#define INCLUDED_LAST_LINE (1<<3)
#define MARK_WAS_SET (1<<4)
#define CURSOR_WAS_AT_HEAD (1<<5)
#define HAD_ANCHOR_AT_START (1<<6)
#endif /* !NANO_TINY */
/* Identifiers for the different menus. */
@@ -283,6 +295,7 @@ enum {
SCROLL_BAR,
SELECTED_TEXT,
SPOTLIGHTED,
MINI_INFOBAR,
PROMPT_BAR,
STATUS_BAR,
ERROR_MESSAGE,
@@ -623,8 +636,8 @@ typedef struct funcstruct {
} funcstruct;
#ifdef ENABLE_WORDCOMPLETION
typedef struct completion_word {
typedef struct completionstruct {
char *word;
struct completion_word *next;
} completion_word;
struct completionstruct *next;
} completionstruct;
#endif

View File

@@ -2,7 +2,7 @@
* files.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2015-2020 Benno Schulenberg *
* Copyright (C) 2015-2021 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -40,19 +40,19 @@ void make_new_buffer(void)
#ifdef ENABLE_MULTIBUFFER
if (openfile == NULL) {
/* Make the first open file the only element in the list. */
/* Make the first buffer the only element in the list. */
newnode->prev = newnode;
newnode->next = newnode;
startfile = newnode;
} else {
/* Add the new open file after the current one in the list. */
/* Add the new buffer after the current one in the list. */
newnode->prev = openfile;
newnode->next = openfile->next;
openfile->next->prev = newnode;
openfile->next = newnode;
/* There is more than one file open: show "Close" in help lines. */
/* There is more than one buffer: show "Close" in help lines. */
exitfunc->desc = close_tag;
more_than_one = !inhelp || more_than_one;
}
@@ -122,7 +122,7 @@ char *crop_to_fit(const char *name, int room)
}
#ifndef NANO_TINY
/* Delete the lockfile. Return TRUE on success, and FALSE otherwise. */
/* Delete the lock file. Return TRUE on success, and FALSE otherwise. */
bool delete_lockfile(const char *lockfilename)
{
if (unlink(lockfilename) < 0 && errno != ENOENT) {
@@ -245,9 +245,11 @@ char *do_lockfile(const char *filename, bool ask_the_user)
free(secondcopy);
free(namecopy);
if (!ask_the_user && stat(lockfilename, &fileinfo) != -1)
warn_and_briefly_pause(_("Someone else is also editing this file"));
else if (stat(lockfilename, &fileinfo) != -1) {
if (!ask_the_user && stat(lockfilename, &fileinfo) != -1) {
blank_bottombars();
statusline(ALERT, _("Someone else is also editing this file"));
napms(1200);
} else if (stat(lockfilename, &fileinfo) != -1) {
char *lockbuf, *question, *pidstring, *postedname, *promptstr;
static char lockprog[11], lockuser[17];
int lockfd, lockpid, choice;
@@ -476,8 +478,8 @@ bool open_buffer(const char *filename, bool new_one)
return TRUE;
}
/* Mark the current file as modified if it isn't already, and
* then update the title bar to display the file's new status. */
/* Mark the current buffer as modified if it isn't already, and
* then update the title bar to display the buffer's new status. */
void set_modified(void)
{
if (openfile->modified)
@@ -521,7 +523,7 @@ void mention_name_and_linecount(void)
return;
}
if (openfile->fmt != NIX_FILE)
if (openfile->fmt > NIX_FILE)
/* TRANSLATORS: First %s is file name, second %s is file format. */
statusline(HUSH, P_("%s -- %zu line (%s)", "%s -- %zu lines (%s)", count),
openfile->filename[0] == '\0' ?
@@ -567,14 +569,14 @@ void redecorate_after_switch(void)
mention_name_and_linecount();
}
/* Switch to the previous entry in the list of open files. */
/* Switch to the previous entry in the circular list of buffers. */
void switch_to_prev_buffer(void)
{
openfile = openfile->prev;
redecorate_after_switch();
}
/* Switch to the next entry in the list of open files. */
/* Switch to the next entry in the circular list of buffers. */
void switch_to_next_buffer(void)
{
openfile = openfile->next;
@@ -971,10 +973,10 @@ bool execute_command(const char *command)
{
int from_fd[2], to_fd[2];
/* The pipes through which text will be written and read. */
const bool should_pipe = (command[0] == '|');
FILE *stream;
struct sigaction oldaction, newaction = {{0}};
/* Original and temporary handlers for SIGINT. */
const bool should_pipe = (command[0] == '|');
FILE *stream;
/* Create a pipe to read the command's output from, and, if needed,
* a pipe to feed the command's input through. */
@@ -1281,7 +1283,7 @@ void do_insertfile(bool execute)
} else
#endif /* ENABLE_MULTIBUFFER */
{
/* If the file actually changed, mark it as modified. */
/* If the buffer actually changed, mark it as modified. */
if (openfile->current->lineno != was_current_lineno ||
openfile->current_x != was_current_x)
set_modified();
@@ -1357,7 +1359,7 @@ char *get_full_path(const char *origpath)
target = real_dir_from_tilde(origpath);
/* Determine whether the target path refers to a directory. If statting
* target fails, however, assume that it refers to a new, unsaved file. */
* target fails, however, assume that it refers to a new, unsaved buffer. */
path_only = (stat(target, &fileinfo) != -1 && S_ISDIR(fileinfo.st_mode));
/* If the target is a directory, make sure its path ends in a slash. */
@@ -1451,7 +1453,8 @@ char *safe_tempfile(FILE **stream)
{
const char *env_dir = getenv("TMPDIR");
char *tempdir = NULL, *tempfile_name = NULL;
int fd;
char *extension;
int descriptor;
/* Get the absolute path for the first directory among $TMPDIR
* and P_tmpdir that is writable, otherwise use /tmp/. */
@@ -1464,18 +1467,26 @@ char *safe_tempfile(FILE **stream)
if (tempdir == NULL)
tempdir = copy_of("/tmp/");
tempfile_name = nrealloc(tempdir, strlen(tempdir) + 12);
extension = strrchr(openfile->filename, '.');
if (!extension || strchr(extension, '/'))
extension = openfile->filename + strlen(openfile->filename);
tempfile_name = nrealloc(tempdir, strlen(tempdir) + 12 + strlen(extension));
strcat(tempfile_name, "nano.XXXXXX");
strcat(tempfile_name, extension);
fd = mkstemp(tempfile_name);
descriptor = mkstemps(tempfile_name, strlen(extension));
if (fd == -1) {
*stream = (descriptor > 0) ? fdopen(descriptor, "r+b") : NULL;
if (*stream == NULL) {
if (descriptor > 0)
close(descriptor);
free(tempfile_name);
return NULL;
}
*stream = fdopen(fd, "r+b");
return tempfile_name;
}
@@ -1735,19 +1746,19 @@ bool make_backup_of(char *realname)
#endif /* !NANO_TINY */
/* Write the current buffer to disk. If thefile isn't NULL, we write to a
* temporary file that is already open. If tmp is TRUE (when spell checking
* or emergency dumping, for example), we don't make a backup and don't give
* temporary file that is already open. If normal is FALSE (for a spellcheck
* or an emergency save, for example), we don't make a backup and don't give
* feedback. If method is APPEND or PREPEND, it means we will be appending
* or prepending instead of overwriting the given file. If fullbuffer is TRUE
* and when writing normally, we set the current filename and stat info.
* or prepending instead of overwriting the given file. If annotate is TRUE
* and when writing a normal file, we set the current filename and stat info.
* Return TRUE on success, and FALSE otherwise. */
bool write_file(const char *name, FILE *thefile, bool tmp,
kind_of_writing_type method, bool fullbuffer)
bool write_file(const char *name, FILE *thefile, bool normal,
kind_of_writing_type method, bool annotate)
{
#ifndef NANO_TINY
bool is_existing_file;
/* Becomes TRUE when the file is non-temporary and exists. */
struct stat st;
struct stat fileinfo;
/* The status fields filled in by statting the file. */
#endif
char *realname = real_dir_from_tilde(name);
@@ -1758,20 +1769,18 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
/* An iterator for moving through the lines of the buffer. */
size_t lineswritten = 0;
/* The number of lines written, for feedback on the status bar. */
bool retval = FALSE;
/* The return value, to become TRUE when writing has succeeded. */
#ifdef ENABLE_OPERATINGDIR
/* If we're writing a temporary file, we're probably going outside
* the operating directory, so skip the operating directory test. */
if (!tmp && outside_of_confinement(realname, FALSE)) {
if (normal && outside_of_confinement(realname, FALSE)) {
statusline(ALERT, _("Can't write outside of %s"), operating_dir);
goto cleanup_and_exit;
}
#endif
#ifndef NANO_TINY
/* Check whether the file (at the end of the symlink) exists. */
is_existing_file = (!tmp) && (stat(realname, &st) != -1);
is_existing_file = normal && (stat(realname, &fileinfo) != -1);
/* If we haven't statted this file before (say, the user just specified
* it interactively), stat and save the value now, or else we will chase
@@ -1782,8 +1791,9 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
/* When the user requested a backup, we do this only if the file exists and
* isn't temporary AND the file has not been modified by someone else since
* we opened it (or we are appending/prepending or writing a selection). */
if (ISSET(MAKE_BACKUP) && is_existing_file && openfile->statinfo &&
(openfile->statinfo->st_mtime == st.st_mtime ||
if (ISSET(MAKE_BACKUP) && is_existing_file && !S_ISFIFO(fileinfo.st_mode) &&
openfile->statinfo &&
(openfile->statinfo->st_mtime == fileinfo.st_mtime ||
method != OVERWRITE || openfile->mark)) {
if (!make_backup_of(realname))
goto cleanup_and_exit;
@@ -1791,10 +1801,17 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
/* When prepending, first copy the existing file to a temporary file. */
if (method == PREPEND) {
FILE *source = fopen(realname, "rb");
FILE *source = NULL;
FILE *target = NULL;
int verdict;
if (is_existing_file && S_ISFIFO(fileinfo.st_mode)) {
statusline(ALERT, _("Error writing %s: %s"), realname, "FIFO");
goto cleanup_and_exit;
}
source = fopen(realname, "rb");
if (source == NULL) {
statusline(ALERT, _("Error reading %s: %s"), realname, strerror(errno));
goto cleanup_and_exit;
@@ -1821,27 +1838,29 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
}
}
if (is_existing_file && S_ISFIFO(st.st_mode))
if (is_existing_file && S_ISFIFO(fileinfo.st_mode))
statusbar(_("Writing to FIFO..."));
#endif /* !NANO_TINY */
/* When it's not a temporary file, this is where we open or create it.
* For an emergency file, access is restricted to just the owner. */
if (thefile == NULL) {
mode_t permissions = (tmp ? S_IRUSR|S_IWUSR : RW_FOR_ALL);
mode_t permissions = (normal ? RW_FOR_ALL : S_IRUSR|S_IWUSR);
int fd;
#ifndef NANO_TINY
block_sigwinch(TRUE);
install_handler_for_Ctrl_C();
if (normal)
install_handler_for_Ctrl_C();
#endif
/* Now open the file. Use O_EXCL for an emergency file. */
fd = open(realname, O_WRONLY | O_CREAT | ((method == APPEND) ?
O_APPEND : (tmp ? O_EXCL : O_TRUNC)), permissions);
O_APPEND : (normal ? O_TRUNC : O_EXCL)), permissions);
#ifndef NANO_TINY
restore_handler_for_Ctrl_C();
if (normal)
restore_handler_for_Ctrl_C();
block_sigwinch(FALSE);
#endif
@@ -1867,7 +1886,7 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
}
}
if (!tmp)
if (normal)
statusbar(_("Writing..."));
while (TRUE) {
@@ -1944,22 +1963,27 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
unlink(tempname);
}
#endif
/* Ensure the data has reached the disk before reporting it as written. */
if (fflush(thefile) != 0 || fsync(fileno(thefile)) != 0) {
statusline(ALERT, _("Error writing %s: %s"), realname, strerror(errno));
fclose(thefile);
goto cleanup_and_exit;
}
if (!is_existing_file || !S_ISFIFO(fileinfo.st_mode))
/* Ensure the data has reached the disk before reporting it as written. */
if (fflush(thefile) != 0 || fsync(fileno(thefile)) != 0) {
statusline(ALERT, _("Error writing %s: %s"), realname, strerror(errno));
fclose(thefile);
goto cleanup_and_exit;
}
#endif
if (fclose(thefile) != 0) {
statusline(ALERT, _("Error writing %s: %s"), realname, strerror(errno));
goto cleanup_and_exit;
cleanup_and_exit:
free(tempname);
free(realname);
return FALSE;
}
/* When having written an entire buffer, update some administrivia. */
if (fullbuffer && method == OVERWRITE && !tmp) {
if (annotate && method == OVERWRITE) {
/* If the filename was changed, write a new lockfile when needed,
* and check whether it means a different syntax gets used. */
if (strcmp(openfile->filename, realname) != 0) {
@@ -1967,8 +1991,10 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
if (openfile->lock_filename != NULL) {
delete_lockfile(openfile->lock_filename);
free(openfile->lock_filename);
openfile->lock_filename = do_lockfile(realname, FALSE);
}
if (ISSET(LOCKING))
openfile->lock_filename = do_lockfile(realname, FALSE);
#endif
openfile->filename = mallocstrcpy(openfile->filename, realname);
#ifdef ENABLE_COLOR
@@ -1995,7 +2021,7 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
/* Get or update the stat info to reflect the current state. */
stat_with_alloc(realname, &openfile->statinfo);
/* Record at which point in the undo stack the file was saved. */
/* Record at which point in the undo stack the buffer was saved. */
openfile->last_saved = openfile->current_undo;
openfile->last_action = OTHER;
#endif
@@ -2004,26 +2030,24 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
}
#ifndef NANO_TINY
if (ISSET(MINIBAR) && fullbuffer && !tmp)
if (ISSET(MINIBAR) && LINES > 1 && annotate)
report_size = TRUE;
else
#endif
if (!tmp)
if (normal)
statusline(REMARK, P_("Wrote %zu line", "Wrote %zu lines",
lineswritten), lineswritten);
retval = TRUE;
cleanup_and_exit:
free(tempname);
free(realname);
return retval;
return TRUE;
}
#ifndef NANO_TINY
/* Write the marked region of the current buffer out to disk.
* Return TRUE on success and FALSE on error. */
bool write_marked_file(const char *name, FILE *stream, bool tmp,
bool write_region_to_file(const char *name, FILE *stream, bool normal,
kind_of_writing_type method)
{
linestruct *birthline, *topline, *botline, *stopper, *afterline;
@@ -2050,7 +2074,7 @@ bool write_marked_file(const char *name, FILE *stream, bool tmp,
birthline = openfile->filetop;
openfile->filetop = topline;
retval = write_file(name, stream, tmp, method, FALSE);
retval = write_file(name, stream, normal, method, NONOTES);
/* Restore the proper state of the buffer. */
openfile->filetop = birthline;
@@ -2065,18 +2089,18 @@ bool write_marked_file(const char *name, FILE *stream, bool tmp,
}
#endif /* !NANO_TINY */
/* Write the current file to disk. If the mark is on, write the current
* marked selection to disk. If exiting is TRUE, write the entire file
/* Write the current buffer to disk. If the mark is on, write the current
* marked selection to disk. If exiting is TRUE, write the entire buffer
* to disk regardless of whether the mark is on. Do not ask for a name
* when withprompt is FALSE nor when the SAVE_ON_EXIT flag is set and the
* file already has a name. Return 0 on error, 1 on success, and 2 when
* buffer already has a name. Return 0 on error, 1 on success, and 2 when
* the buffer is to be discarded. */
int do_writeout(bool exiting, bool withprompt)
{
char *given;
/* The filename we offer, or what the user typed so far. */
bool maychange = (openfile->filename[0] == '\0');
/* Whether it's okay to save the file under a different name. */
/* Whether it's okay to save the buffer under a different name. */
kind_of_writing_type method = OVERWRITE;
#ifdef ENABLE_EXTRA
static bool did_credits = FALSE;
@@ -2201,12 +2225,12 @@ int do_writeout(bool exiting, bool withprompt)
if (method == OVERWRITE) {
bool name_exists, do_warning;
char *full_answer, *full_filename;
struct stat st;
struct stat fileinfo;
full_answer = get_full_path(answer);
full_filename = get_full_path(openfile->filename);
name_exists = (stat((full_answer == NULL) ?
answer : full_answer, &st) != -1);
answer : full_answer, &fileinfo) != -1);
if (openfile->filename[0] == '\0')
do_warning = name_exists;
@@ -2221,11 +2245,10 @@ int do_writeout(bool exiting, bool withprompt)
if (do_warning) {
/* When in restricted mode, we aren't allowed to overwrite
* an existing file with the current buffer, nor to change
* the name of the current file if it already has one. */
* the name of the current buffer if it already has one. */
if (ISSET(RESTRICTED)) {
/* TRANSLATORS: Restricted mode forbids overwriting. */
warn_and_briefly_pause(_("File exists -- "
"cannot overwrite"));
warn_and_briefly_pause(_("File exists -- cannot overwrite"));
continue;
}
@@ -2262,9 +2285,9 @@ int do_writeout(bool exiting, bool withprompt)
* and the stat information we had before does not match
* what we have now. */
else if (name_exists && openfile->statinfo &&
(openfile->statinfo->st_mtime < st.st_mtime ||
openfile->statinfo->st_dev != st.st_dev ||
openfile->statinfo->st_ino != st.st_ino)) {
(openfile->statinfo->st_mtime < fileinfo.st_mtime ||
openfile->statinfo->st_dev != fileinfo.st_dev ||
openfile->statinfo->st_ino != fileinfo.st_ino)) {
warn_and_briefly_pause(_("File on disk has changed"));
@@ -2279,7 +2302,7 @@ int do_writeout(bool exiting, bool withprompt)
free(given);
if (choice == 1)
return write_file(openfile->filename, NULL,
FALSE, OVERWRITE, TRUE);
NORMAL, OVERWRITE, NONOTES);
else if (choice == 0)
return 2;
else
@@ -2301,10 +2324,10 @@ int do_writeout(bool exiting, bool withprompt)
* the marked region; otherwise, write out the whole buffer. */
#ifndef NANO_TINY
if (openfile->mark && withprompt && !exiting && !ISSET(RESTRICTED))
return write_marked_file(answer, NULL, FALSE, method);
return write_region_to_file(answer, NULL, NORMAL, method);
else
#endif
return write_file(answer, NULL, FALSE, method, TRUE);
return write_file(answer, NULL, NORMAL, method, ANNOTATE);
}
/* Write the current buffer to disk, or discard it. */
@@ -2315,7 +2338,7 @@ void do_writeout_void(void)
close_and_go();
}
/* If it has a name, write the current file to disk without prompting. */
/* If it has a name, write the current buffer to disk without prompting. */
void do_savefile(void)
{
if (do_writeout(FALSE, FALSE) == 2)

View File

@@ -301,12 +301,6 @@ void flip_goto(void)
void to_files(void)
{
}
void to_first_file(void)
{
}
void to_last_file(void)
{
}
void goto_dir(void)
{
}
@@ -384,7 +378,7 @@ int keycode_from_string(const char *keystring)
{
if (keystring[0] == '^') {
if (keystring[2] == '\0') {
if (keystring[1] == '/')
if (keystring[1] == '/' || keystring[1] == '-')
return 31;
if (keystring[1] <= '_')
return keystring[1] - 64;
@@ -776,7 +770,7 @@ void shortcut_init(void)
CAN_OPEN_OTHER_BUFFER);
#ifdef ENABLE_JUSTIFY
else
add_to_funcs(do_justify_void, MMAIN,
add_to_funcs(do_justify, MMAIN,
N_("Justify"), WITHORSANS(justify_gist), BLANKAFTER, NOVIEW);
#endif
@@ -815,7 +809,7 @@ void shortcut_init(void)
N_("Execute"), WITHORSANS(execute_gist), TOGETHER, NOVIEW);
#endif
#ifdef ENABLE_JUSTIFY
add_to_funcs(do_justify_void, MMAIN,
add_to_funcs(do_justify, MMAIN,
N_("Justify"), WITHORSANS(justify_gist), BLANKAFTER, NOVIEW);
#endif
}
@@ -841,7 +835,7 @@ void shortcut_init(void)
add_to_funcs(do_mark, MMAIN,
N_("Set Mark"), WITHORSANS(mark_gist), TOGETHER, VIEW);
add_to_funcs(copy_text, MMAIN,
N_("Copy"), WITHORSANS(copy_gist), BLANKAFTER, NOVIEW);
N_("Copy"), WITHORSANS(copy_gist), BLANKAFTER, VIEW);
#endif
add_to_funcs(case_sens_void, MWHEREIS|MREPLACE,
@@ -1192,6 +1186,12 @@ void shortcut_init(void)
N_("Next Linter message"), WITHORSANS(nextlint_gist), TOGETHER, VIEW);
#endif
#ifdef __linux__
#define SLASH_OR_DASH (on_a_vt) ? "^-" : "^/"
#else
#define SLASH_OR_DASH "^/"
#endif
/* Link key combos to functions in certain menus. */
add_to_sclist(MMOST|MBROWSER, "^M", '\r', do_enter, 0);
add_to_sclist(MMOST|MBROWSER, "Enter", KEY_ENTER, do_enter, 0);
@@ -1220,7 +1220,7 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "^T", 0, do_execute, 0);
#endif
#ifdef ENABLE_JUSTIFY
add_to_sclist(MMAIN, "^J", '\n', do_justify_void, 0);
add_to_sclist(MMAIN, "^J", '\n', do_justify, 0);
#endif
#ifdef ENABLE_SPELLER
add_to_sclist(MEXECUTE, "^S", 0, do_spell, 0);
@@ -1233,8 +1233,9 @@ void shortcut_init(void)
add_to_sclist(MEXECUTE, "^O", 0, do_formatter, 0);
#endif
add_to_sclist(MMAIN, "^C", 0, report_cursor_position, 0);
add_to_sclist(MMAIN, "^_", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MMAIN, SLASH_OR_DASH, 0, do_gotolinecolumn_void, 0);
add_to_sclist(MMAIN, "M-G", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MMAIN, "^_", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "^Y", 0, do_page_up, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "PgUp", KEY_PPAGE, do_page_up, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "^V", 0, do_page_down, 0);
@@ -1286,14 +1287,14 @@ void shortcut_init(void)
add_to_sclist(MMOST|MBROWSER, "^F", 0, do_right, 0);
#ifdef ENABLE_UTF8
if (using_utf8()) {
add_to_sclist(MMOST|MBROWSER|MHELP, "\xE2\x97\x80", KEY_LEFT, do_left, 0);
add_to_sclist(MMOST|MBROWSER|MHELP, "\xE2\x96\xb6", KEY_RIGHT, do_right, 0);
add_to_sclist(MSOME, "^\xE2\x97\x80", CONTROL_LEFT, to_prev_word, 0);
add_to_sclist(MSOME, "^\xE2\x96\xb6", CONTROL_RIGHT, to_next_word, 0);
add_to_sclist(MMOST|MBROWSER|MHELP, "\xE2\x97\x82", KEY_LEFT, do_left, 0);
add_to_sclist(MMOST|MBROWSER|MHELP, "\xE2\x96\xb8", KEY_RIGHT, do_right, 0);
add_to_sclist(MSOME, "^\xE2\x97\x82", CONTROL_LEFT, to_prev_word, 0);
add_to_sclist(MSOME, "^\xE2\x96\xb8", CONTROL_RIGHT, to_next_word, 0);
#if !defined(NANO_TINY) && defined(ENABLE_MULTIBUFFER)
if (!on_a_vt) {
add_to_sclist(MMAIN, "M-\xE2\x97\x80", ALT_LEFT, switch_to_prev_buffer, 0);
add_to_sclist(MMAIN, "M-\xE2\x96\xb6", ALT_RIGHT, switch_to_next_buffer, 0);
add_to_sclist(MMAIN, "M-\xE2\x97\x82", ALT_LEFT, switch_to_prev_buffer, 0);
add_to_sclist(MMAIN, "M-\xE2\x96\xb8", ALT_RIGHT, switch_to_next_buffer, 0);
}
#endif
} else
@@ -1320,10 +1321,10 @@ void shortcut_init(void)
add_to_sclist(MMAIN|MBROWSER|MHELP, "^N", 0, do_down, 0);
#ifdef ENABLE_UTF8
if (using_utf8()) {
add_to_sclist(MMAIN|MBROWSER|MHELP, "\xE2\x96\xb2", KEY_UP, do_up, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP, "\xE2\x96\xbc", KEY_DOWN, do_down, 0);
add_to_sclist(MMAIN|MBROWSER|MLINTER, "^\xE2\x96\xb2", CONTROL_UP, to_prev_block, 0);
add_to_sclist(MMAIN|MBROWSER|MLINTER, "^\xE2\x96\xbc", CONTROL_DOWN, to_next_block, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP, "\xE2\x96\xb4", KEY_UP, do_up, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP, "\xE2\x96\xbe", KEY_DOWN, do_down, 0);
add_to_sclist(MMAIN|MBROWSER|MLINTER, "^\xE2\x96\xb4", CONTROL_UP, to_prev_block, 0);
add_to_sclist(MMAIN|MBROWSER|MLINTER, "^\xE2\x96\xbe", CONTROL_DOWN, to_next_block, 0);
} else
#endif
{
@@ -1343,8 +1344,8 @@ void shortcut_init(void)
#ifndef NANO_TINY
#ifdef ENABLE_UTF8
if (using_utf8()) {
add_to_sclist(MMAIN|MHELP, "M-\xE2\x96\xb2", ALT_UP, do_scroll_up, 0);
add_to_sclist(MMAIN|MHELP, "M-\xE2\x96\xbc", ALT_DOWN, do_scroll_down, 0);
add_to_sclist(MMAIN|MHELP, "M-\xE2\x96\xb4", ALT_UP, do_scroll_up, 0);
add_to_sclist(MMAIN|MHELP, "M-\xE2\x96\xbe", ALT_DOWN, do_scroll_down, 0);
} else
#endif
{
@@ -1428,8 +1429,8 @@ void shortcut_init(void)
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "^N", 0, get_history_newer_void, 0);
#ifdef ENABLE_UTF8
if (using_utf8()) {
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\xb2", KEY_UP, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\xbc", KEY_DOWN, get_history_newer_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\xb4", KEY_UP, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\xbe", KEY_DOWN, get_history_newer_void, 0);
} else
#endif
{
@@ -1441,11 +1442,9 @@ void shortcut_init(void)
add_to_sclist(MGOTOLINE, "^W", 0, to_para_begin, 0);
add_to_sclist(MGOTOLINE, "^O", 0, to_para_end, 0);
#endif
add_to_sclist(MGOTOLINE, "^Y", 0, to_first_line, 0);
add_to_sclist(MGOTOLINE, "^V", 0, to_last_line, 0);
/* Some people are used to having these keystrokes in the Search menu. */
add_to_sclist(MWHEREIS, "^Y", 0, to_first_line, 0);
add_to_sclist(MWHEREIS, "^V", 0, to_last_line, 0);
add_to_sclist(MGOTOLINE|MWHEREIS|MFINDINHELP, "^Y", 0, to_first_line, 0);
add_to_sclist(MGOTOLINE|MWHEREIS|MFINDINHELP, "^V", 0, to_last_line, 0);
#ifdef ENABLE_BROWSER
add_to_sclist(MWHEREISFILE, "^Y", 0, to_first_file, 0);
add_to_sclist(MWHEREISFILE, "^V", 0, to_last_file, 0);
@@ -1455,8 +1454,9 @@ void shortcut_init(void)
add_to_sclist(MBROWSER, "End", KEY_END, to_last_file, 0);
add_to_sclist(MBROWSER, "^Home", CONTROL_HOME, to_first_file, 0);
add_to_sclist(MBROWSER, "^End", CONTROL_END, to_last_file, 0);
add_to_sclist(MBROWSER, "^_", 0, goto_dir, 0);
add_to_sclist(MBROWSER, SLASH_OR_DASH, 0, goto_dir, 0);
add_to_sclist(MBROWSER, "M-G", 0, goto_dir, 0);
add_to_sclist(MBROWSER, "^_", 0, goto_dir, 0);
#endif
if (ISSET(SAVE_ON_EXIT) && !ISSET(PRESERVE))
add_to_sclist(MWRITEFILE, "^Q", 0, discard_buffer, 0);
@@ -1506,7 +1506,7 @@ void shortcut_init(void)
add_to_sclist(MMAIN|MBROWSER|MHELP, "F2", KEY_F(2), do_exit, 0);
add_to_sclist(MMAIN, "F3", KEY_F(3), do_writeout_void, 0);
#ifdef ENABLE_JUSTIFY
add_to_sclist(MMAIN, "F4", KEY_F(4), do_justify_void, 0);
add_to_sclist(MMAIN, "F4", KEY_F(4), do_justify, 0);
#endif
add_to_sclist(MMAIN, "F5", KEY_F(5), do_insertfile_void, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP, "F6", KEY_F(6), do_search_forward, 0);

View File

@@ -310,7 +310,7 @@ void help_init(void)
}
}
}
#endif /* !NANO_TINY */
#endif
}
/* Hard-wrap the concatenated help text, and write it into a new buffer. */

View File

@@ -367,7 +367,8 @@ void save_history(void)
}
/* Don't allow others to read or write the history file. */
chmod(histname, S_IRUSR | S_IWUSR);
if (chmod(histname, S_IRUSR | S_IWUSR) < 0)
jot_error(N_("Cannot limit permissions on %s: %s"), histname, strerror(errno));
if (!write_list(searchtop, histfile) || !write_list(replacetop, histfile) ||
!write_list(executetop, histfile))
@@ -465,7 +466,8 @@ void save_poshistory(void)
}
/* Don't allow others to read or write the history file. */
chmod(poshistname, S_IRUSR | S_IWUSR);
if (chmod(poshistname, S_IRUSR | S_IWUSR) < 0)
jot_error(N_("Cannot limit permissions on %s: %s"), poshistname, strerror(errno));
for (posptr = position_history; posptr != NULL; posptr = posptr->next) {
char *path_and_place;

View File

@@ -2,7 +2,7 @@
* nano.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014-2020 Benno Schulenberg *
* Copyright (C) 2014-2021 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -154,7 +154,7 @@ linestruct *copy_node(const linestruct *src)
#endif
dst->lineno = src->lineno;
#ifndef NANO_TINY
dst->has_anchor = FALSE;
dst->has_anchor = src->has_anchor;
#endif
return dst;
@@ -309,40 +309,37 @@ void do_exit(void)
statusbar(_("Cancelled"));
}
/* Save the current buffer under the given name (or under the name "nano"
* for a nameless buffer). If needed, the name is modified to be unique. */
void emergency_save(const char *plainname)
/* Save the current buffer under the given name (or "nano.<pid>" when nameless)
* with suffix ".save". If needed, the name is further suffixed to be unique. */
void emergency_save(const char *filename)
{
bool failed = TRUE;
char *targetname;
char *plainname, *targetname;
if (*plainname == '\0')
plainname = "nano";
if (*filename == '\0') {
plainname = nmalloc(28);
sprintf(plainname, "nano.%u", getpid());
} else
plainname = copy_of(filename);
targetname = get_next_filename(plainname, ".save");
if (*targetname != '\0')
failed = !write_file(targetname, NULL, TRUE, OVERWRITE, FALSE);
if (!failed)
if (*targetname == '\0')
fprintf(stderr, _("\nToo many .save files\n"));
else if (write_file(targetname, NULL, SPECIAL, OVERWRITE, NONOTES)) {
fprintf(stderr, _("\nBuffer written to %s\n"), targetname);
else if (*targetname != '\0')
fprintf(stderr, _("\nBuffer not written to %s: %s\n"),
targetname, strerror(errno));
else
fprintf(stderr, _("\nToo many .save files"));
#ifndef NANO_TINY
/* Try to chmod/chown the saved file to the values of the original file,
* but ignore any failure as we are in a hurry to get out. */
if (openfile->statinfo) {
IGNORE_CALL_RESULT(chmod(targetname, openfile->statinfo->st_mode));
IGNORE_CALL_RESULT(chown(targetname, openfile->statinfo->st_uid,
openfile->statinfo->st_gid));
}
/* Try to chmod/chown the saved file to the values of the original file,
* but ignore any failure as we are in a hurry to get out. */
if (openfile->statinfo) {
IGNORE_CALL_RESULT(chmod(targetname, openfile->statinfo->st_mode));
IGNORE_CALL_RESULT(chown(targetname, openfile->statinfo->st_uid,
openfile->statinfo->st_gid));
}
#endif
}
free(targetname);
free(plainname);
}
/* Die gracefully -- by restoring the terminal state and saving any buffers
@@ -351,6 +348,11 @@ void die(const char *msg, ...)
{
va_list ap;
openfilestruct *firstone = openfile;
static int stabs = 0;
/* When dying for a second time, just give up. */
if (++stabs > 1)
exit(11);
restore_terminal();
@@ -365,7 +367,7 @@ void die(const char *msg, ...)
while (openfile) {
#ifndef NANO_TINY
/* If the current buffer has a lockfile, remove it. */
/* If the current buffer has a lock file, remove it. */
if (openfile->lock_filename)
delete_lockfile(openfile->lock_filename);
#endif
@@ -518,7 +520,7 @@ void usage(void)
#ifdef ENABLE_HISTORIES
if (!ISSET(RESTRICTED))
print_opt("-H", "--historylog",
N_("Log & read search/replace string history"));
N_("Save & reload old search/replace strings"));
#endif
#ifdef ENABLE_NANORC
print_opt("-I", "--ignorercfiles", N_("Don't look at nanorc files"));
@@ -546,7 +548,7 @@ void usage(void)
#ifdef ENABLE_HISTORIES
if (!ISSET(RESTRICTED))
print_opt("-P", "--positionlog",
N_("Log & read location of cursor position"));
N_("Save & restore position of the cursor"));
#endif
#ifdef ENABLE_JUSTIFY
print_opt(_("-Q <regex>"), _("--quotestr=<regex>"),
@@ -1094,7 +1096,7 @@ void do_toggle(int flag)
if (flag == AUTOINDENT || flag == BREAK_LONG_LINES || flag == SOFTWRAP)
titlebar(NULL);
if (ISSET(MINIBAR) && (flag == NO_HELP || flag == LINE_NUMBERS ))
if (ISSET(MINIBAR) && (flag == NO_HELP || flag == LINE_NUMBERS))
return;
if (flag == CONSTANT_SHOW)
@@ -2053,6 +2055,10 @@ int main(int argc, char **argv)
}
}
/* Curses needs TERM; if it is unset, try falling back to a VT220. */
if (getenv("TERM") == NULL)
setenv("TERM", "vt220", 0);
/* Enter into curses mode. Abort if this fails. */
if (initscr() == NULL)
exit(1);
@@ -2203,7 +2209,7 @@ int main(int argc, char **argv)
load_history();
if (ISSET(POSITIONLOG))
load_poshistory();
#endif /* ENABLE_HISTORIES */
#endif
#ifndef NANO_TINY
/* If a backup directory was specified and we're not in restricted mode,
@@ -2237,7 +2243,7 @@ int main(int argc, char **argv)
die(_("Bad quoting regex \"%s\": %s\n"), quotestr, message);
} else
free(quotestr);
#endif /* ENABLE_JUSTIFY */
#endif
#ifdef ENABLE_SPELLER
/* If we don't have an alternative spell checker after reading the
@@ -2298,6 +2304,7 @@ int main(int argc, char **argv)
interface_color_pair[SCROLL_BAR] = A_NORMAL;
interface_color_pair[SELECTED_TEXT] = hilite_attribute;
interface_color_pair[SPOTLIGHTED] = A_REVERSE;
interface_color_pair[MINI_INFOBAR] = hilite_attribute;
interface_color_pair[PROMPT_BAR] = hilite_attribute;
interface_color_pair[STATUS_BAR] = hilite_attribute;
interface_color_pair[ERROR_MESSAGE] = hilite_attribute;
@@ -2378,9 +2385,9 @@ int main(int argc, char **argv)
#endif
/* If there's a +LINE[,COLUMN] argument here, eat it up. */
if (optind < argc - 1 && argv[optind][0] == '+') {
#ifndef NANO_TINY
int n = 1;
#ifndef NANO_TINY
while (isalpha(argv[optind][n])) {
switch (argv[optind][n++]) {
case 'c': SET(CASE_SENSITIVE); break;
@@ -2403,7 +2410,11 @@ int main(int argc, char **argv)
optind++;
} else
#endif
if (!parse_line_column(&argv[optind++][n], &givenline, &givencol))
/* When there is nothing after the "+", understand it as go-to-EOF,
* otherwise parse and store the given number(s).*/
if (argv[optind++][1] == '\0')
givenline = -1;
else if (!parse_line_column(&argv[optind - 1][1], &givenline, &givencol))
statusline(ALERT, _("Invalid line or column number"));
}
@@ -2429,7 +2440,7 @@ int main(int argc, char **argv)
if (!findnextstr(searchstring, FALSE, JUSTFIND, NULL,
ISSET(BACKWARDS_SEARCH), openfile->filetop, 0))
not_found_msg(searchstring);
else if (lastmessage == HUSH)
else if (lastmessage <= REMARK)
wipe_statusbar();
openfile->placewewant = xplustabs();
if (ISSET(USE_REGEXP))
@@ -2501,13 +2512,14 @@ int main(int argc, char **argv)
bottombars(MMAIN);
#ifndef NANO_TINY
if (ISSET(MINIBAR) && lastmessage < REMARK)
if (ISSET(MINIBAR) && LINES > 1 && lastmessage < REMARK)
minibar();
else
#endif
/* Update the displayed current cursor position only when there
* is no message and no keys are waiting in the input buffer. */
if (ISSET(CONSTANT_SHOW) && lastmessage == VACUUM && get_key_buffer_len() == 0)
if (ISSET(CONSTANT_SHOW) && lastmessage == VACUUM && LINES > 1 &&
get_key_buffer_len() == 0)
report_cursor_position();
as_an_at = TRUE;
@@ -2516,14 +2528,9 @@ int main(int argc, char **argv)
if (!refresh_needed) {
place_the_cursor();
wnoutrefresh(edit);
} else
} else if (LINES > 1 || lastmessage == VACUUM)
edit_refresh();
#ifndef NANO_TINY
/* Let the next keystroke cancel the highlighting of a search match. */
refresh_needed = spotlighted;
spotlighted = FALSE;
#endif
errno = 0;
focusing = TRUE;

View File

@@ -426,7 +426,7 @@ void draw_the_promptbar(void)
void add_or_remove_pipe_symbol_from_answer(void)
{
if (answer[0] == '|') {
memmove(answer, answer + 1, strlen(answer) + 1);
memmove(answer, answer + 1, strlen(answer));
if (typing_x > 0)
typing_x--;
} else {
@@ -766,7 +766,7 @@ int do_yesno_prompt(bool all, const char *msg)
choice = -2;
}
}
#endif /* ENABLE_MOUSE */
#endif
else if (func_from_key(&kbinput) == full_refresh)
full_refresh();
#ifndef NANO_TINY

View File

@@ -191,6 +191,8 @@ typedef void (*functionptrtype)(void);
#ifdef ENABLE_BROWSER
void browser_refresh(void);
char *browse_in(const char *inpath);
void to_first_file(void);
void to_last_file(void);
#endif
/* Most functions in chars.c. */
@@ -294,11 +296,11 @@ bool outside_of_confinement(const char *currpath, bool allow_tabcomp);
void init_backup_dir(void);
#endif
int copy_file(FILE *inn, FILE *out, bool close_out);
bool write_file(const char *name, FILE *thefile, bool tmp,
kind_of_writing_type method, bool fullbuffer);
bool write_file(const char *name, FILE *thefile, bool normal,
kind_of_writing_type method, bool annotate);
#ifndef NANO_TINY
bool write_marked_file(const char *name, FILE *stream, bool tmp,
kind_of_writing_type method);
bool write_region_to_file(const char *name, FILE *stream, bool normal,
kind_of_writing_type method);
#endif
int do_writeout(bool exiting, bool withprompt);
void do_writeout_void(void);
@@ -507,8 +509,7 @@ size_t indent_length(const char *line);
size_t quote_length(const char *line);
bool begpar(const linestruct *const line, int depth);
bool inpar(const linestruct *const line);
void do_justify(bool full_justify);
void do_justify_void(void);
void do_justify(void);
void do_full_justify(void);
#endif
#ifdef ENABLE_SPELLER
@@ -637,8 +638,6 @@ void flip_replace(void);
void flip_goto(void);
#ifdef ENABLE_BROWSER
void to_files(void);
void to_first_file(void);
void to_last_file(void);
void goto_dir(void);
#endif
#ifndef NANO_TINY

View File

@@ -130,6 +130,7 @@ static const rcoption rcopts[] = {
{"scrollercolor", 0},
{"selectedcolor", 0},
{"spotlightcolor", 0},
{"minicolor", 0},
{"promptcolor", 0},
{"statuscolor", 0},
{"errorcolor", 0},
@@ -290,7 +291,7 @@ keystruct *strtosc(const char *input)
s->func = do_gotolinecolumn_void;
#ifdef ENABLE_JUSTIFY
else if (!strcmp(input, "justify"))
s->func = do_justify_void;
s->func = do_justify;
else if (!strcmp(input, "fulljustify"))
s->func = do_full_justify;
else if (!strcmp(input, "beginpara"))
@@ -991,9 +992,21 @@ void parse_includes(char *ptr)
free(expanded);
}
const char hues[9][7] = { "pink", "purple", "mauve", "lagoon", "mint",
"lime", "peach", "orange", "latte" };
short indices[9] = { 204, 163, 134, 38, 48, 148, 215, 208, 137 };
#define COLORCOUNT 20
const char hues[COLORCOUNT][8] = { "red", "green", "blue",
"yellow", "cyan", "magenta",
"white", "black", "normal",
"pink", "purple", "mauve",
"lagoon", "mint", "lime",
"peach", "orange", "latte",
"grey", "gray" };
short indices[COLORCOUNT] = { COLOR_RED, COLOR_GREEN, COLOR_BLUE,
COLOR_YELLOW, COLOR_CYAN, COLOR_MAGENTA,
COLOR_WHITE, COLOR_BLACK, THE_DEFAULT,
204, 163, 134, 38, 48, 148, 215, 208, 137,
COLOR_BLACK + 8, COLOR_BLACK + 8 };
/* Return the short value corresponding to the given color name, and set
* vivid to TRUE for a lighter color, and thick for a heavier typeface. */
@@ -1013,35 +1026,16 @@ short color_to_short(const char *colorname, bool *vivid, bool *thick)
*thick = FALSE;
}
if (strcmp(colorname, "green") == 0)
return COLOR_GREEN;
else if (strcmp(colorname, "red") == 0)
return COLOR_RED;
else if (strcmp(colorname, "blue") == 0)
return COLOR_BLUE;
else if (strcmp(colorname, "white") == 0)
return COLOR_WHITE;
else if (strcmp(colorname, "yellow") == 0)
return COLOR_YELLOW;
else if (strcmp(colorname, "cyan") == 0)
return COLOR_CYAN;
else if (strcmp(colorname, "magenta") == 0)
return COLOR_MAGENTA;
else if (strcmp(colorname, "black") == 0)
return COLOR_BLACK;
else if (strcmp(colorname, "normal") == 0)
return THE_DEFAULT;
else
for (int index = 0; index < 9; index++)
if (strcmp(colorname, hues[index]) == 0) {
if (*vivid) {
jot_error(N_("Color '%s' takes no prefix"), colorname);
return BAD_COLOR;
} else if (COLORS < 255)
return THE_DEFAULT;
else
return indices[index];
}
for (int index = 0; index < COLORCOUNT; index++)
if (strcmp(colorname, hues[index]) == 0) {
if (index > 7 && *vivid) {
jot_error(N_("Color '%s' takes no prefix"), colorname);
return BAD_COLOR;
} else if (index > 8 && COLORS < 255)
return THE_DEFAULT;
else
return indices[index];
}
jot_error(N_("Color \"%s\" not understood"), colorname);
return BAD_COLOR;
@@ -1557,6 +1551,8 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
color_combo[SELECTED_TEXT] = parse_interface_color(argument);
else if (strcmp(option, "spotlightcolor") == 0)
color_combo[SPOTLIGHTED] = parse_interface_color(argument);
else if (strcmp(option, "minicolor") == 0)
color_combo[MINI_INFOBAR] = parse_interface_color(argument);
else if (strcmp(option, "promptcolor") == 0)
color_combo[PROMPT_BAR] = parse_interface_color(argument);
else if (strcmp(option, "statuscolor") == 0)

View File

@@ -82,7 +82,7 @@ void search_init(bool replacing, bool retain_answer)
thedefault = nmalloc(strlen(disp) + 7);
/* We use (COLS / 3) here because we need to see more on the line. */
sprintf(thedefault, " [%s%s]", disp,
(breadth(last_search) > COLS / 3) ? "..." : "");
(breadth(last_search) > COLS / 3) ? "..." : "");
free(disp);
} else
thedefault = copy_of("");
@@ -329,15 +329,12 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
light_to_col = wideness(line->data, found_x + found_len);
if (!ISSET(SHOW_CURSOR))
hide_cursor = TRUE;
refresh_needed = TRUE;
edit_refresh();
}
#endif
/* Wipe the "Searching..." message and unsuppress cursor-position display. */
if (feedback > 0) {
if (feedback > 0)
wipe_statusbar();
lastmessage = VACUUM;
}
return 1;
}
@@ -431,10 +428,8 @@ void go_looking(void)
/* If we found something, and we're back at the exact same spot
* where we started searching, then this is the only occurrence. */
if (didfind == 1 && openfile->current == was_current &&
openfile->current_x == was_current_x)
openfile->current_x == was_current_x)
statusline(REMARK, _("This is the only occurrence"));
else if (didfind == 1 && LINES == 1)
refresh_needed = TRUE;
else if (didfind == 0)
not_found_msg(last_search);
@@ -475,8 +470,7 @@ int replace_regexp(char *string, bool create)
/* And if create is TRUE, append the result of the
* subexpression match to the new line. */
if (create) {
strncpy(string, openfile->current->data +
regmatches[num].rm_so, i);
strncpy(string, openfile->current->data + regmatches[num].rm_so, i);
string += i;
}
}
@@ -556,7 +550,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
openfile->current_x = bot_x;
}
}
#endif /* !NANO_TINY */
#endif
came_full_circle = FALSE;
@@ -612,17 +606,16 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
}
if (choice == 1 || replaceall) { /* Yes, replace it. */
char *copy;
size_t length_change;
char *altered;
altered = replace_line(needle);
length_change = strlen(altered) - strlen(openfile->current->data);
#ifndef NANO_TINY
add_undo(REPLACE, NULL);
#endif
copy = replace_line(needle);
length_change = strlen(copy) - strlen(openfile->current->data);
#ifndef NANO_TINY
/* If the mark was on and it was located after the cursor,
* then adjust its x position for any text length changes. */
if (was_mark && !right_side_up) {
@@ -638,8 +631,9 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
/* If the mark was not on or it was before the cursor, then
* adjust the cursor's x position for any text length changes. */
if (!was_mark || right_side_up) {
if (!was_mark || right_side_up)
#endif
{
if (openfile->current == real_current &&
openfile->current_x < *real_current_x) {
if (*real_current_x < openfile->current_x + match_len)
@@ -647,8 +641,8 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
*real_current_x += length_change;
#ifndef NANO_TINY
bot_x = *real_current_x;
}
#endif
}
}
/* Don't find the same zero-length or BOL match again. */
@@ -661,9 +655,9 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
openfile->current_x += match_len + length_change;
/* Update the file size, and put the changed line into place. */
openfile->totsize += mbstrlen(copy) - mbstrlen(openfile->current->data);
openfile->totsize += mbstrlen(altered) - mbstrlen(openfile->current->data);
free(openfile->current->data);
openfile->current->data = copy;
openfile->current->data = altered;
set_modified();
as_an_at = TRUE;
@@ -706,8 +700,8 @@ void ask_for_and_do_replacements(void)
size_t begin_x = openfile->current_x;
ssize_t numreplaced;
int response = do_prompt(MREPLACEWITH, "", &replace_history,
/* TRANSLATORS: This is a prompt. */
edit_refresh, _("Replace with"));
/* TRANSLATORS: This is a prompt. */
edit_refresh, _("Replace with"));
#ifdef ENABLE_HISTORIES
/* When not "", add the replace string to the replace history list. */
@@ -729,11 +723,12 @@ void ask_for_and_do_replacements(void)
openfile->firstcolumn = was_firstcolumn;
openfile->current = beginline;
openfile->current_x = begin_x;
refresh_needed = TRUE;
edit_refresh();
if (numreplaced >= 0)
statusline(REMARK, P_("Replaced %zd occurrence",
"Replaced %zd occurrences", numreplaced), numreplaced);
"Replaced %zd occurrences", numreplaced), numreplaced);
}
/* Go to the specified line and x position. */

View File

@@ -6,7 +6,7 @@
* Copyright (C) 2016 Mike Scalora *
* Copyright (C) 2016 Sumedh Pendurkar *
* Copyright (C) 2018 Marco Diego Aurélio Mesquita *
* Copyright (C) 2015-2020 Benno Schulenberg *
* Copyright (C) 2015-2021 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -39,7 +39,7 @@
#ifdef ENABLE_WORDCOMPLETION
static int pletion_x = 0;
/* The x position in pletion_line of the last found completion. */
static completion_word *list_of_completions;
static completionstruct *list_of_completions;
/* A linked list of the completions that have been attempted. */
#endif
@@ -58,10 +58,10 @@ void do_mark(void)
refresh_needed = TRUE;
}
}
#endif /* !NANO_TINY */
#endif
/* Insert a tab. If the TABS_TO_SPACES flag is set, insert the number
* of spaces that a tab would normally take up. */
/* Insert a tab. Or, if --tabstospaces is in effect, insert the number
* of spaces that a tab would normally take up at this position. */
void do_tab(void)
{
#ifdef ENABLE_COLOR
@@ -133,12 +133,12 @@ void do_indent(void)
indentation = nmalloc(tabsize + 1);
/* Set the indentation to either a bunch of spaces or a single tab. */
#ifdef ENABLE_COLOR
if (openfile->syntax && openfile->syntax->tab)
indentation = mallocstrcpy(indentation, openfile->syntax->tab);
else
#endif
/* Set the indentation to either a bunch of spaces or a single tab. */
if (ISSET(TABS_TO_SPACES)) {
memset(indentation, ' ', tabsize);
indentation[tabsize] = '\0';
@@ -186,7 +186,7 @@ size_t length_of_white(const char *text)
while (TRUE) {
if (*text == '\t')
return ++white_count;
return white_count + 1;
if (*text != ' ')
return white_count;
@@ -278,9 +278,6 @@ void handle_indent_action(undostruct *u, bool undoing, bool add_indent)
groupstruct *group = u->grouping;
linestruct *line = line_from_number(group->top_line);
if (group->next != NULL)
die("Multiple groups -- please report a bug\n");
/* When redoing, reposition the cursor and let the indenter adjust it. */
if (!undoing)
goto_line_posx(u->head_lineno, u->head_x);
@@ -418,11 +415,9 @@ void do_comment(void)
/* Comment/uncomment each of the selected lines when possible, and
* store undo data when a line changed. */
for (line = top; line != bot->next; line = line->next) {
if (comment_line(action, line, comment_seq)) {
for (line = top; line != bot->next; line = line->next)
if (comment_line(action, line, comment_seq))
update_multiline_undo(line->lineno, "");
}
}
set_modified();
ensure_firstcolumn_is_aligned();
@@ -468,6 +463,10 @@ void undo_cut(undostruct *u)
{
goto_line_posx(u->head_lineno, (u->xflags & WAS_WHOLE_LINE) ? 0 : u->head_x);
/* Clear an inherited anchor but not a user-placed one. */
if (!(u->xflags & HAD_ANCHOR_AT_START))
openfile->current->has_anchor = FALSE;
if (u->cutbuffer)
copy_from_buffer(u->cutbuffer);
@@ -666,7 +665,7 @@ void do_undo(void)
openfile->totsize = u->wassize;
/* When at the point where the file was last saved, unset "Modified". */
/* When at the point where the buffer was last saved, unset "Modified". */
if (openfile->current_undo == openfile->last_saved) {
openfile->modified = FALSE;
titlebar(NULL);
@@ -826,7 +825,7 @@ void do_redo(void)
openfile->totsize = u->newsize;
/* When at the point where the file was last saved, unset "Modified". */
/* When at the point where the buffer was last saved, unset "Modified". */
if (openfile->current_undo == openfile->last_saved) {
openfile->modified = FALSE;
titlebar(NULL);
@@ -1028,6 +1027,8 @@ void add_undo(undo_type action, const char *message)
#endif
case CUT_TO_EOF:
u->xflags |= (INCLUDED_LAST_LINE | CURSOR_WAS_AT_HEAD);
if (openfile->current->has_anchor)
u->xflags |= HAD_ANCHOR_AT_START;
break;
case ZAP:
case CUT:
@@ -1049,6 +1050,9 @@ void add_undo(undo_type action, const char *message)
u->tail_x = 0;
} else
u->xflags |= CURSOR_WAS_AT_HEAD;
if ((openfile->mark && mark_is_before_cursor() && openfile->mark->has_anchor) ||
((!openfile->mark || !mark_is_before_cursor()) && openfile->current->has_anchor))
u->xflags |= HAD_ANCHOR_AT_START;
break;
case PASTE:
u->cutbuffer = copy_buffer(cutbuffer);
@@ -1087,24 +1091,24 @@ void update_multiline_undo(ssize_t lineno, char *indentation)
/* If there already is a group and the current line is contiguous with it,
* extend the group; otherwise, create a new group. */
if (u->grouping && u->grouping->bottom_line + 1 == lineno) {
size_t number_of_lines;
size_t number_of_lines = lineno - u->grouping->top_line + 1;
u->grouping->bottom_line++;
u->grouping->bottom_line = lineno;
number_of_lines = u->grouping->bottom_line - u->grouping->top_line + 1;
u->grouping->indentations = nrealloc(u->grouping->indentations,
number_of_lines * sizeof(char *));
u->grouping->indentations[number_of_lines - 1] = copy_of(indentation);
} else {
groupstruct *born = nmalloc(sizeof(groupstruct));
born->next = u->grouping;
u->grouping = born;
born->top_line = lineno;
born->bottom_line = lineno;
u->grouping->indentations = nmalloc(sizeof(char *));
u->grouping->indentations[0] = copy_of(indentation);
born->indentations = nmalloc(sizeof(char *));
born->indentations[0] = copy_of(indentation);
born->next = u->grouping;
u->grouping = born;
}
/* Store the file size after the change, to be used when redoing. */
@@ -1332,7 +1336,9 @@ bool do_wrap(void)
strncpy(line->data, line->prev->data, lead_len);
openfile->current_x += lead_len;
openfile->totsize += lead_len;
#ifndef NANO_TINY
free(openfile->undotop->strdata);
update_undo(ENTER);
#endif
if (autowhite)
@@ -1707,9 +1713,12 @@ void justify_paragraph(linestruct **line, size_t count)
free(lead_string);
}
/* Justify the current paragraph, or the entire buffer when full_justify is
#define ONE_PARAGRAPH FALSE
#define WHOLE_BUFFER TRUE
/* Justify the current paragraph, or the entire buffer when whole_buffer is
* TRUE. But if the mark is on, justify only the marked text instead. */
void do_justify(bool full_justify)
void justify_text(bool whole_buffer)
{
size_t linecount;
/* The number of lines in the original paragraph. */
@@ -1825,7 +1834,7 @@ void do_justify(bool full_justify)
{
/* When justifying the entire buffer, start at the top. Otherwise, when
* in a paragraph but not at its beginning, move back to its first line. */
if (full_justify)
if (whole_buffer)
openfile->current = openfile->filetop;
else if (inpar(openfile->current) && !begpar(openfile->current, 0))
do_para_begin(&openfile->current);
@@ -1847,7 +1856,7 @@ void do_justify(bool full_justify)
start_x = 0;
/* Set the end point of the paragraph. */
if (full_justify)
if (whole_buffer)
endline = openfile->filebot;
else {
endline = startline;
@@ -1922,7 +1931,7 @@ void do_justify(bool full_justify)
justify_paragraph(&jusline, linecount);
/* When justifying the entire buffer, find and justify all paragraphs. */
if (full_justify) {
if (whole_buffer) {
while (find_paragraph(&jusline, &linecount)) {
justify_paragraph(&jusline, linecount);
@@ -1933,9 +1942,11 @@ void do_justify(bool full_justify)
}
#ifndef NANO_TINY
add_undo(PASTE, NULL);
if (full_justify && !openfile->mark && !cutbuffer->has_anchor)
/* Wipe an anchor on the first paragraph if it was only inherited. */
if (whole_buffer && !openfile->mark && !cutbuffer->has_anchor)
openfile->current->has_anchor = FALSE;
add_undo(PASTE, NULL);
#endif
/* Do the equivalent of a paste of the justified text. */
ingraft_buffer(cutbuffer);
@@ -1954,22 +1965,20 @@ void do_justify(bool full_justify)
}
add_undo(COUPLE_END, N_("justification"));
#endif
/* We're done justifying. Restore the old cutbuffer. */
cutbuffer = was_cutbuffer;
/* Show what we justified on the status bar. */
#ifndef NANO_TINY
/* Report on the status bar what we justified. */
if (openfile->mark)
statusline(REMARK, _("Justified selection"));
else
#endif
if (full_justify)
if (whole_buffer)
statusline(REMARK, _("Justified file"));
else
statusbar(_("Justified paragraph"));
/* We're done justifying. Restore the cutbuffer. */
cutbuffer = was_cutbuffer;
/* Set the desired screen column (always zero, except at EOF). */
openfile->placewewant = xplustabs();
@@ -1979,15 +1988,15 @@ void do_justify(bool full_justify)
}
/* Justify the current paragraph. */
void do_justify_void(void)
void do_justify(void)
{
do_justify(FALSE);
justify_text(ONE_PARAGRAPH);
}
/* Justify the entire file. */
void do_full_justify(void)
{
do_justify(TRUE);
justify_text(WHOLE_BUFFER);
ran_a_tool = TRUE;
}
#endif /* ENABLE_JUSTIFY */
@@ -2052,9 +2061,9 @@ bool replace_buffer(const char *filename, undo_type action, const char *operatio
/* Execute the given program, with the given temp file as last argument. */
void treat(char *tempfile_name, char *theprogram, bool spelling)
{
ssize_t lineno_save = openfile->current->lineno;
size_t current_x_save = openfile->current_x;
size_t pww_save = openfile->placewewant;
ssize_t was_lineno = openfile->current->lineno;
size_t was_pww = openfile->placewewant;
size_t was_x = openfile->current_x;
bool was_at_eol = (openfile->current->data[openfile->current_x] == '\0');
struct stat fileinfo;
long timestamp_sec = 0;
@@ -2138,7 +2147,7 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
/* Adjust the end point of the marked region for any change in
* length of the region's last line. */
if (upright)
current_x_save = openfile->current_x;
was_x = openfile->current_x;
else
openfile->mark_x = openfile->current_x;
@@ -2156,7 +2165,7 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
}
/* Go back to the old position. */
goto_line_posx(lineno_save, current_x_save);
goto_line_posx(was_lineno, was_x);
if (was_at_eol || openfile->current_x > strlen(openfile->current->data))
openfile->current_x = strlen(openfile->current->data);
@@ -2167,7 +2176,7 @@ void treat(char *tempfile_name, char *theprogram, bool spelling)
#endif
}
openfile->placewewant = pww_save;
openfile->placewewant = was_pww;
adjust_viewport(STATIONARY);
if (spelling)
@@ -2490,10 +2499,10 @@ void do_spell(void)
#ifndef NANO_TINY
if (openfile->mark)
okay = write_marked_file(temp_name, stream, TRUE, OVERWRITE);
okay = write_region_to_file(temp_name, stream, TEMPORARY, OVERWRITE);
else
#endif
okay = write_file(temp_name, stream, TRUE, OVERWRITE, TRUE);
okay = write_file(temp_name, stream, TEMPORARY, OVERWRITE, NONOTES);
if (!okay) {
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
@@ -2610,6 +2619,9 @@ void do_linter(void)
return;
}
/* Block resizing signals while reading from the pipe. */
block_sigwinch(TRUE);
/* Read in the returned syntax errors. */
totalread = 0;
buffersize = pipesize + 1;
@@ -2626,10 +2638,12 @@ void do_linter(void)
*pointer = '\0';
close(lint_fd[0]);
/* Process the linter output. */
block_sigwinch(FALSE);
pointer = lintings;
onelint = lintings;
/* Now parse the output of the linter. */
while (*pointer != '\0') {
if ((*pointer == '\r') || (*pointer == '\n')) {
*pointer = '\0';
@@ -2637,11 +2651,8 @@ void do_linter(void)
char *filename = NULL, *linestr = NULL, *maybecol = NULL;
char *message = copy_of(onelint);
/* At the moment we handle the following formats:
*
* filenameorcategory:line:column:message (e.g. splint)
* filenameorcategory:line,column:message (e.g. pylint)
* filenameorcategory:line:message (e.g. pyflakes) */
/* The recognized format is "filename:line:column: message",
* where ":column" may be absent or be ",column" instead. */
if (strstr(message, ": ") != NULL) {
filename = strtok(onelint, ":");
if ((linestr = strtok(NULL, ":")) != NULL) {
@@ -2674,7 +2685,7 @@ void do_linter(void)
curlint->prev = tmplint;
if (curlint->prev != NULL)
curlint->prev->next = curlint;
curlint->msg = copy_of(message);
curlint->msg = copy_of(strstr(message, ": ") + 2);
curlint->lineno = tmplineno;
curlint->colno = tmpcolno;
curlint->filename = copy_of(filename);
@@ -2892,7 +2903,7 @@ void do_formatter(void)
temp_name = safe_tempfile(&stream);
if (temp_name != NULL)
okay = write_file(temp_name, stream, TRUE, OVERWRITE, TRUE);
okay = write_file(temp_name, stream, TEMPORARY, OVERWRITE, NONOTES);
if (!okay) {
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
@@ -3025,7 +3036,7 @@ void complete_a_word(void)
char *shard, *completion = NULL;
size_t start_of_shard, shard_length = 0;
size_t i = 0, j = 0;
completion_word *some_word;
completionstruct *some_word;
#ifdef ENABLE_WRAPPING
bool was_set_wrapping = ISSET(BREAK_LONG_LINES);
#endif
@@ -3034,7 +3045,7 @@ void complete_a_word(void)
if (pletion_line == NULL) {
/* Clear the list of words of a previous completion run. */
while (list_of_completions != NULL) {
completion_word *dropit = list_of_completions;
completionstruct *dropit = list_of_completions;
list_of_completions = list_of_completions->next;
free(dropit->word);
free(dropit);
@@ -3127,7 +3138,7 @@ void complete_a_word(void)
}
/* Add the found word to the list of completions. */
some_word = nmalloc(sizeof(completion_word));
some_word = nmalloc(sizeof(completionstruct));
some_word->word = completion;
some_word->next = list_of_completions;
list_of_completions = some_word;
@@ -3159,8 +3170,8 @@ void complete_a_word(void)
/* The search has reached the end of the file. */
if (list_of_completions != NULL) {
edit_refresh();
statusline(AHEM, _("No further matches"));
refresh_needed = TRUE;
} else
/* TRANSLATORS: Shown when there are zero possible completions. */
statusline(AHEM, _("No matches"));

View File

@@ -61,7 +61,7 @@ const char *tail(const char *path)
if (slash == NULL)
return path;
else
return ++slash;
return slash + 1;
}
/* Return a copy of the two given strings, welded together. */

View File

@@ -2,7 +2,7 @@
* winio.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014-2020 Benno Schulenberg *
* Copyright (C) 2014-2021 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -182,15 +182,20 @@ void read_keys_from(WINDOW *win)
bool timed = FALSE;
#endif
/* On a one-row terminal, overwrite an unimportant message. */
if (LINES == 1 && currmenu == MMAIN && lastmessage == HUSH)
edit_refresh();
/* Before reading the first keycode, display any pending screen updates. */
doupdate();
if (reveal_cursor && !hide_cursor)
if (reveal_cursor && !hide_cursor && (LINES > 1 || lastmessage <= HUSH))
curs_set(1);
#ifndef NANO_TINY
if (currmenu == MMAIN && ISSET(MINIBAR) && lastmessage > HUSH &&
lastmessage != INFO && lastmessage < ALERT) {
if (currmenu == MMAIN && (spotlighted || ((ISSET(MINIBAR) || LINES == 1) &&
lastmessage > HUSH &&
lastmessage != INFO && lastmessage < ALERT))) {
timed = TRUE;
halfdelay(ISSET(QUICK_BLANK) ? 8 : 15);
disable_kb_interrupt();
@@ -212,7 +217,15 @@ void read_keys_from(WINDOW *win)
raw();
if (input == ERR) {
minibar();
if (spotlighted || LINES == 1) {
lastmessage = VACUUM;
spotlighted = FALSE;
update_line(openfile->current, openfile->current_x);
wnoutrefresh(edit);
curs_set(1);
}
if (ISSET(MINIBAR) && LINES > 1)
minibar();
as_an_at = TRUE;
place_the_cursor();
doupdate();
@@ -220,11 +233,11 @@ void read_keys_from(WINDOW *win)
}
}
#endif
/* When we've failed to get a keycode over a hundred times in a row,
/* When we've failed to get a keycode millions of times in a row,
* assume our input source is gone and die gracefully. We could
* check if errno is set to EIO ("Input/output error") and die in
* that case, but it's not always set properly. Argh. */
if (input == ERR && ++errcount == 123)
if (input == ERR && ++errcount == 12345678)
die(_("Too many errors from stdin\n"));
}
@@ -236,6 +249,10 @@ void read_keys_from(WINDOW *win)
key_buffer_len = 1;
#ifndef NANO_TINY
/* Cancel the highlighting of a search match, if there still is one. */
refresh_needed |= spotlighted;
spotlighted = FALSE;
/* If we got a SIGWINCH, get out as the win argument is no longer valid. */
if (input == KEY_WINCH)
return;
@@ -1661,6 +1678,7 @@ void wipe_statusbar(void)
{
blank_row(bottomwin, 0);
wnoutrefresh(bottomwin);
lastmessage = VACUUM;
}
/* Blank out the two help lines (when they are present). */
@@ -1683,7 +1701,7 @@ void check_statusblank(void)
statusblank--;
/* When editing and 'constantshow' is active, skip the blanking. */
if (currmenu == MMAIN && ISSET(CONSTANT_SHOW))
if (currmenu == MMAIN && ISSET(CONSTANT_SHOW) && LINES > 1)
return;
if (statusblank == 0)
@@ -2100,7 +2118,7 @@ void minibar(void)
#endif
/* Draw a colored bar over the full width of the screen. */
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
wattron(bottomwin, interface_color_pair[MINI_INFOBAR]);
mvwprintw(bottomwin, 0, 0, "%*s", COLS, " ");
if (openfile->filename[0] != '\0') {
@@ -2131,7 +2149,7 @@ void minibar(void)
}
/* Right after reading or writing a file, display its number of lines;
* otherwise, when there a mutiple buffers, display an [x/n] counter. */
* otherwise, when there are multiple buffers, display an [x/n] counter. */
if (report_size && COLS > 35) {
size_t count = openfile->filebot->lineno - (openfile->filebot->data[0] == '\0');
@@ -2158,7 +2176,7 @@ void minibar(void)
mvwaddstr(bottomwin, 0, COLS - 27 - placewidth, location);
/* Display the hexadecimal code of the character under the cursor,
* plus the codes of upto two succeeding zero-width characters. */
* plus the codes of up to two succeeding zero-width characters. */
if (ISSET(CONSTANT_SHOW) && namewidth + tallywidth + 28 < COLS) {
char *this_position = openfile->current->data + openfile->current_x;
@@ -2212,7 +2230,7 @@ void minibar(void)
mvwaddstr(bottomwin, 0, COLS - 4 - padding, location);
}
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
wattroff(bottomwin, interface_color_pair[MINI_INFOBAR]);
wrefresh(bottomwin);
free(number_of_lines);
@@ -2236,9 +2254,6 @@ void statusline(message_type importance, const char *msg, ...)
bool old_whitespace = ISSET(WHITESPACE_DISPLAY);
UNSET(WHITESPACE_DISPLAY);
if (isendwin())
die("Out of curses -- please report a bug\n");
#endif
/* Ignore a message with an importance that is lower than the last one. */
@@ -2251,12 +2266,24 @@ void statusline(message_type importance, const char *msg, ...)
vsnprintf(compound, MAXCHARLEN * COLS + 1, msg, ap);
va_end(ap);
/* When not in curses mode, write the message to standard error. */
if (isendwin()) {
fprintf(stderr, "\n%s\n", compound);
free(compound);
return;
}
#if !defined(NANO_TINY) && defined(ENABLE_MULTIBUFFER)
if (!we_are_running && importance == ALERT && openfile && !openfile->fmt &&
!openfile->errormessage && openfile->next != openfile)
openfile->errormessage = copy_of(compound);
#endif
/* On a one-row terminal, ensure that any changes in the edit window are
* written out first, to prevent them from overwriting the message. */
if (LINES == 1 && importance < INFO)
wnoutrefresh(edit);
/* If there are multiple alert messages, add trailing dots to the first. */
if (lastmessage == ALERT) {
if (start_col > 4) {
@@ -2475,7 +2502,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
if (line->has_anchor && (from_col == 0 || !ISSET(SOFTWRAP)))
#ifdef ENABLE_UTF8
if (using_utf8())
wprintw(edit, "\xE2\x97\x86"); /* black diamond */
wprintw(edit, "\xE2\xAC\xA5"); /* black medium diamond */
else
#endif
wprintw(edit, "+");

View File

@@ -1,7 +1,7 @@
## Syntax highlighting for Gentoo ebuilds/eclasses,
## and (further down) for Portage control files.
syntax ebuild "\.e(build|class|blit)$"
syntax ebuild "\.e(build|class)$"
comment "#"
## All the standard portage functions:
@@ -17,25 +17,25 @@ color green "-(eq|ne|gt|lt|ge|le)\>"
## Variables... official portage ones in red, all others in bright red:
color brightred "\$[-0-9@*#?$!]" "\$[[:alpha:]_][[:alnum:]_]*"
color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:digit:]]|@)+\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
color red "\<(EAPI|ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|[BHPR]?DEPEND|PROVIDE|PROPERTIES|REQUIRED_USE|RESTRICT|USERLAND)\>"
color red "\<(S|E?D|T|PV|PF|P|PN|PR|PVR|A|CATEGORY|DISTDIR|FILESDIR|EPREFIX|E?ROOT|WORKDIR)\>"
color red "\<(EAPI|ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|[BIPR]?DEPEND|PROVIDE|PROPERTIES|REQUIRED_USE|RESTRICT|USERLAND)\>"
color red "\<(S|E?D|T|PV|PF|P|PN|PR|PVR|A|CATEGORY|DISTDIR|FILESDIR|EPREFIX|(B|E|E?SYS)?ROOT|WORKDIR)\>"
color red "\<(AS|C(PP|XX)?|LD)FLAGS\>" "\<C(HOST|TARGET|BUILD)\>" "\<(MERGE_TYPE|REPLACING_VERSIONS|REPLACED_BY_VERSION)\>"
color red "\<EBUILD_PHASE(_FUNC)?\>"
color red "\<QA_((TEXTRELS|EXECSTACK|WX_LOAD)(_[a-zA-Z_0-9]+)?|DT_HASH|PRESTRIPPED)\>"
color red "\<(PATCHES|(HTML_)?DOCS)\>" "\<WANT_(AUTO(CONF|MAKE)|LIBTOOL)\>" "\<AT_M4DIR\>"
## Portage commands:
color magenta "\<(use(_(with|enable|if_iuse)|x)?|in_iuse) [!a-zA-Z0-9_+ -]*" "inherit.*"
color brightblue "\<e(begin|end|conf|install|make|qmake4|ant|(qa)?warn|infon?|error|log|patch(_user)?|new(group|user))\>"
color brightblue "\<e(apply(_user)?|begin|end|conf|install|make|ninja|qmake5|ant|(qa)?warn|infon?|error|log|patch(_user)?|new(group|user))\>"
color brightblue "\<e(pause|beep|mktemp|(cvs|svn)_clean|punt_cxx)\>" "\<e(aclocal|auto(reconf|header|conf|make)|libtoolize)\>"
color brightblue "\<e(stack|shopts|umask)_(push|pop)\>" "\<version_is_at_least\>"
color brightblue "\<e(stack|shopts|umask)_(push|pop)\>" "\<get_libdir\>" "\<ver_(cut|rs|test)\>" "\<version_is_at_least\>"
color brightblue "\<make_desktop_entry\>" "\<unpack(_(makeself|pdv))?\>"
color brightblue "\<(die|hasv?|inherit|nonfatal)\>" "\<(use(_(with|enable|if_iuse)|x)?|in_iuse)\>" "\<(has|best)_version\>"
color brightblue "\<(do|new)(ins|(games)?s?bin|doc|lib(\.so|\.a)?|man|info|exe|initd|confd|envd|pam|menu|icon)\>"
color brightblue "\<do(compress|header|python|sed|dir|hard|sym|html|jar|mo)\>" "\<keepdir\>"
color brightblue "\<prepall(docs|info|man|strip)?\>" "\<prep(info|lib|lib\.(so|a)|man|strip|gamesdirs)\>"
color brightblue "\<(doc|ins|exe)?into\>" "\<(f|games)(owners|perms)\>" "\<(exe|ins|dir)opts\>"
color brightblue "\<(do|new)(ins|s?bin|doc|header|lib(\.so|\.a)?|man|info|exe|initd|confd|envd|pam|menu|icon)\>"
color brightblue "\<do(compress|dir|html|mo|strip|sym)\>" "\<keepdir\>"
color brightblue "\<prepall(docs|info|man|strip)?\>" "\<prep(info|lib|lib\.(so|a)|man|strip)\>"
color brightblue "\<(doc|ins|exe)?into\>" "\<f(owners|perms)\>" "\<(exe|ins|dir)opts\>"
color brightblue "\<tc-get(BUILD_)?(AR|AS|CC|CPP|CXX|LD|NM|OBJCOPY|PKG_CONFIG|RANLIB)\>"
color brightblue "\<tc-(arch(-kernel)?|export|has-(tls|openmp))\>"
color brightblue "\<tc-(arch(-kernel)?|export|has-(tls|openmp)|is-cross-compiler)\>"
## Common commands used in ebuilds:
color blue "\<(awk|cat|cd|chmod|chown|cp|echo|env|find|e?grep|ln|make|mkdir|mv|popd|printf|pushd|rm|rmdir|sed|set|tar|touch|unset|xargs)\>"
## Comments (doesn't work that well):
@@ -60,7 +60,7 @@ color magenta ":[^[:space:]]+([[:space:]]|$)"
color brightred "[[:space:]]+\+?[A-Za-z0-9+_@-]+"
color brightblue "[[:space:]]+-[A-Za-z0-9+_@-]+"
## Accepted arches:
color white "[~-]?\<(alpha|amd64|arm(64)?|hppa|ia64|m68k|mips|nios2|ppc(64)?|riscv|s390|sh|sparc|x86)(-(aix|(f|free|net|open)bsd|cygwin|hpux|interix|linux|macos|mint|solaris|winnt))?\>"
color white "[~-]?\<(alpha|amd64|arm(64)?|hppa|ia64|m68k|mips|ppc(64)?|riscv|s390|sparc|x86)(-(cygwin|linux|macos|solaris|winnt))?\>"
color white "[[:space:]][*~-]?\*"
## Categories:
color cyan "^[[:space:]]*[^/]*/"

View File

@@ -4,8 +4,14 @@
syntax nanohelp
# Key combos:
color cyan "\^[]/4-8@A-Z\^_`◀▶▲▼]" "[◀▶▲▼]" "\<(M|S[Hh]-[Mm])-." "\<F([1-9]|1[0-9]|2[0-4])"
color cyan "\^[]/4-8@A-Z\^_`◂▸▴▾-]" "[◂▸▴▾]" "\<(M|S[Hh]-[Mm])-[^")”»“」]" "\<F([1-9]|1[0-9]|2[0-4])"
color cyan "\<((Sh-)?Tab|Enter|Ins|(Sh-\^?)?Del|Space|Bsp|Up|Down|Left|Right|Home|End|PgUp|PgDn)\>"
# Colorize M-) and M-" only when between parentheses...
color cyan "\(M-(\)|")\)"
color normal " \(|\) "
# ...or when at start of line.
color cyan "^M-(\)|")"
# Quoted indicators:
color brightred "'(\^|M-)'"

View File

@@ -1,18 +1,20 @@
## Syntax highlighting for nanorc files.
syntax nanorc "\.?nanorc$"
syntax nanorc "\.?nanorc(\.in)?$"
comment "#"
# Everything that does not get recolored is invalid
color brightred ".*"
# Color names
color yellow "^[[:blank:]]*(i?color|set[[:blank:]]+((error|function|key|mini|number|prompt|scroller|selected|spotlight|status|stripe|title)color))[[:blank:]]+(bold,)?(italic,)?(((bright|light)?(white|black|red|blue|green|yellow|magenta|cyan))|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte|grey|gray)?(,(((light)?(white|black|red|blue|green|yellow|magenta|cyan))|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte|grey|gray))?\>"
# Keywords
color brightgreen "^[[:blank:]]*(set|unset)[[:blank:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|boldtext|bookstyle|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|historylog|indicator|jumpyscrolling|linenumbers|locking|magic|minibar|mouse|multibuffer|noconvert|nohelp|nonewlines|positionlog|preserve|quickblank|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|softwrap|stateflags|suspendable|tabstospaces|trimblanks|unix|wordbounds|zap)\>"
color yellow "^[[:blank:]]*set[[:blank:]]+((error|function|key|number|prompt|scroller|selected|spotlight|status|stripe|title)color)[[:blank:]]+(bold,)?(italic,)?(bright|light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte)?(,(light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte))?\>"
color brightgreen "^[[:blank:]]*set[[:blank:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|promptcolor|punct|quotestr|scrollercolor|selectedcolor|speller|spotlightcolor|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:blank:]]+"
color brightgreen "^[[:blank:]]*set[[:blank:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|minicolor|numbercolor|operatingdir|promptcolor|punct|quotestr|scrollercolor|selectedcolor|speller|spotlightcolor|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:blank:]]+"
color brightgreen "^[[:blank:]]*set[[:blank:]]+(fill[[:blank:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:blank:]]+[1-9][0-9]*)\>"
color brightgreen "^[[:blank:]]*bind[[:blank:]]+((\^([A-Za-z]|[]/@\^_`]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:blank:]]+([a-z]+|".*")[[:blank:]]+(main|help|search|replace(with)?|yesno|gotoline|writeout|insert|browser|whereisfile|gotodir|execute|spell|linter|all)([[:blank:]]+#|[[:blank:]]*$)"
color brightgreen "^[[:blank:]]*unbind[[:blank:]]+((\^([A-Za-z]|[]/@\^_`]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:blank:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:blank:]]+#|[[:blank:]]*$)"
color brightgreen "^[[:blank:]]*bind[[:blank:]]+((\^([A-Za-z]|[]/@\^_`-]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:blank:]]+([a-z]+|".*")[[:blank:]]+(main|help|search|replace(with)?|yesno|gotoline|writeout|insert|browser|whereisfile|gotodir|execute|spell|linter|all)([[:blank:]]+#|[[:blank:]]*$)"
color brightgreen "^[[:blank:]]*unbind[[:blank:]]+((\^([A-Za-z]|[]/@\^_`-]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:blank:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:blank:]]+#|[[:blank:]]*$)"
color brightgreen "^[[:blank:]]*extendsyntax[[:blank:]]+[[:alpha:]]+[[:blank:]]+(i?color|header|magic|comment|formatter|linter|tabgives)[[:blank:]]+.*"
color brightgreen "^[[:blank:]]*(syntax[[:blank:]]+[^[:space:]]+|(formatter|linter)[[:blank:]]+.+)"
color green "^[[:blank:]]*((un)?(bind|set)|include|syntax|header|magic|comment|formatter|linter|tabgives|extendsyntax)\>"
@@ -20,8 +22,10 @@ color green "^[[:blank:]]*((un)?(bind|set)|include|syntax|header|magic|comment|f
# Strings
color brightmagenta "([[:blank:]]|(start|end)=)".+"([[:blank:]]|$)"
# Colors
color yellow "^[[:blank:]]*i?color[[:blank:]]*(bold,)?(italic,)?(bright|light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte)?(,(light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte))?\>"
# Control codes
color bold,pink "[[:cntrl:]]"
# Color commands
color magenta "^[[:blank:]]*i?color\>" "\<(start|end)="
# Comments

View File

@@ -20,5 +20,3 @@ color white start="(^use| = new)" end=";"
# Comments.
color green "(^|[[:blank:]])#.*"
color yellow start="<< 'STOP'" end="STOP"

View File

@@ -5,7 +5,7 @@ magic "PHP script"
comment "//"
# PHP markings.
color brightgreen "(<\?(php)?|\?>)"
color brightgreen "(<\?(php|=)?|\?>)"
# Function names.
color white "\<[A-Za-z_][A-Za-z_0-9]*\("

View File

@@ -31,7 +31,5 @@ color green "'([^']|(\\'))*'" "%[qw]\{[^}]*\}" "%[qw]\([^)]*\)" "%[qw]<[^>]*>" "
# Comments.
color cyan "#[^{].*" "#$"
color brightcyan "##[^{].*" "##$"
# "Here" docs.
color green start="<<-?'?EOT'?" end="^EOT"
# Some common markers.
color brightcyan "XXX|TODO|FIXME|\?\?\?"

View File

@@ -1,7 +1,7 @@
## Syntax highlighting for Rust.
## Copyright 2015 Luke Francl.
## Licensed under GPL version 3.
## Licensed under GPL version 3 or newer.
syntax rust "\.(rlib|rs)$"
comment "//"

47
syntax/yaml.nanorc Normal file
View File

@@ -0,0 +1,47 @@
## Syntax highlighting for YAML files.
## Original author: Benno Schulenberg
## License: GPL version 3 or newer
syntax yaml "\.ya?ml$"
header "^%YAML |^---( |$)"
tabgives " "
comment "#"
# Keys:
color lightgreen "(\w|::|[/.-])+:( |$)"
color lightgreen "\[(\w|::|[/., -])+\]:( |$)"
# Values (booleans, numbers, octal/hex):
color lightmagenta "[:,] +(Y(es)?|No?|y(es)?|no?|[Tt]rue|[Ff]alse|[Oo](n|ff))( *[]}]|, | +#|$)"
color lightmagenta "[:,] +[+-]?[0-9]+(\.([0-9]+)?)?( *[]}]|, | +#|$)"
color lightmagenta " 0(o[0-7]+|x[[:xdigit:]]+)( *[]}]|, | +#|$)"
color normal "[:,]( |$)"
# Values (dates, strings):
color lightmagenta " [12][0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])"
color lightmagenta "("([^"]|\\")+"|'[^']+')"
# Anchors and aliases:
color pink " [&*](\w|-)+( |$)"
# Symbols:
color bold,lagoon "^(%YAML +[1-9]\.[0-9]$|%TAG |(---|\.\.\.)( |$))"
color bold,lagoon " [|>]([1-9]?[+-]|[+-][1-9]?)?$"
color bold,yellow "^ *(\?|([?:] +)?-) "
color yellow "[]{}[]"
color normal "^ *: "
# Tags:
color mint " !!(binary|bool|float|int|map|null|omap|seq|set|str)( |,|$)"
color mint " ![^! ][^ ]*( |$)"
# Escaped characters:
color orange "\\([0abefnrtv"/ \_NLP]|$)"
color orange "\\(x[[:xdigit:]]{2}|u[[:xdigit:]]{4}|U[[:xdigit:]]{8})"
# Mistakes (control codes, trailing space):
color ,red "[[:cntrl:]]| +$"
# Comments:
color italic,cyan "(^| )#.*"