Compare commits

..

494 Commits
v5.2 ... 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
Benno Schulenberg
02df950240 po: update translations and regenerate POT file and PO files 2021-04-29 12:57:17 +02:00
Benno Schulenberg
a69a8ce3ca bump version numbers and add a news item for the 5.7 release 2021-04-29 11:28:21 +02:00
Benno Schulenberg
8a03d55c53 gnulib: pull in the fix for a build problem on older Debian
The issue was reported here:
  https://lists.gnu.org/archive/html/bug-gnulib/2021-04/msg00198.html
2021-04-28 09:49:14 +02:00
Benno Schulenberg
544351f3be syntaxes: replace [[:space:]] with [[:blank:]] to exclude carriage return
In many places a carriage return is not valid whitespace and should
thus not be colored as such.  In some of these places a vertical tab
or form feed is maybe valid whitespace, but it would be ugly or even
wrong to color them because they are not part of the subsequent
comment or keyword.

This fixes https://savannah.gnu.org/bugs/?60456.
2021-04-27 11:18:41 +02:00
Hussam al-Homsi
96ebaf8ab4 syntax: c: make the highlighting of '#include <...>' more compliant
Changes:
  1. There may be zero spaces between 'include' and '<...>'.
  2. Blanks and '=' may occur inside '<...>' but '>' may not.
  3. There must be at least one character inside '<...>'.

References:
  Change 1:
    C:   www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf#subsection.6.10.2
    C++: www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf#section.19.2

  Changes 2 and 3:
    C:   www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf#subsection.6.4.7
    C++: www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf#section.5.8

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2021-04-26 12:14:44 +02:00
Benno Schulenberg
6b7c661fb7 syntax: po: improve the coloring of format specifiers
This now handles most of the things listed in 'man 3 printf'.
2021-04-26 11:29:05 +02:00
Benno Schulenberg
6823831c06 build: drop the check for two functions that we don't use any more
Since commits b0209374 and 1c010d8e from a month ago, nano does not use
mblen() and mbtowc() any more, so there is no need to check for their
presence.

Instead, add a check for iswalpha(), which we do use.
2021-04-25 11:55:04 +02:00
Benno Schulenberg
ec82530125 gnulib: update to its current upstream state 2021-04-25 10:48:56 +02:00
Benno Schulenberg
a45e1f89c0 oops: that doesn't work -- you can't break out of two for loops at once
This effectively reverts the previous commit.
2021-04-24 13:56:36 +02:00
Benno Schulenberg
c1cd813dcb tweaks: elide a function that is now basically just two lines 2021-04-24 11:48:04 +02:00
Benno Schulenberg
c96e62e33a startup: save the compiled file-matching regexes, to avoid recompiling
This reduces startup time by seven percent (when using the standard set
of syntaxes) when opening just one file that doesn't match any syntax,
and more than ten percent when opening multiple files.  It takes some
extra memory, but... not wasting CPU cycles is more important.

This addresses https://savannah.gnu.org/bugs/?56433.
2021-04-24 10:54:04 +02:00
Benno Schulenberg
6283557d2f memory: prevent a use-after-free when the user respects a lock file
This fixes https://savannah.gnu.org/bugs/?60447.

Bug existed since commit 2f718e11 from a month ago.
2021-04-23 12:20:45 +02:00
Benno Schulenberg
af90f03ac5 tweaks: condense three comments, drop another, and rewrap a line 2021-04-23 12:04:19 +02:00
Benno Schulenberg
588022ab8c editing: prevent the pointer for the top row from becoming dangling
When undoing several actions, it is possible for the line at the top
of the screen to be removed, leaving 'edittop' pointing to a structure
that has been freed.  Soon after, 'edittop' is referenced to determine
whether the cursor is offscreen...  Prevent this invalid reference by
stepping 'edittop' one line back in that special case.  This changes
the normal centering behavior of Undo when the cursor goes offscreen,
but... so be it.

When a single node is deleted, it is always possible to step one line
back, because a buffer contains always at least one line (even though
maybe empty), so if the current line could be deleted, there must be
one before it (when at the top of the screen).

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

Bug existed since version 2.3.3, commit 60815461,
since undoing does not always center the cursor.
2021-04-23 09:35:12 +02:00
Benno Schulenberg
cf0820549b tweaks: avoid calling extra_chunks_in() when not softwrapping
The function is somewhat costly; better avoid it whenever possible.
2021-04-22 12:19:09 +02:00
Benno Schulenberg
f54bc6c7d6 indicator: adjust the size to the number of visible lines, not chunks
Since two commits ago, the position of the indicator shows the position
of the viewport relative to the full buffer in terms of actual lines,
not of visual chunks (to avoid excessive computation).  But the size of
the indicator stayed constant, as if it always covered as many lines as
the edit window has rows.  But the latter will not be the case when
softwrapping occurs.  Therefore, when softwrapping, compute how many
actual lines are visible in the viewport, and adjust the size of the
indicator accordingly.
2021-04-22 11:52:57 +02:00
Benno Schulenberg
2cdff6c32c tweaks: adjust two comments, and reshuffle two fragments
Also rename two variables, to be more fitting.
2021-04-21 16:52:35 +02:00
Benno Schulenberg
49d8b99e4f softwrap: avoid time-consuming computations, to burden large files less
Whenever softwrap was toggled on or line numbers were toggled on/off or
the window was resized, the extra rows per line needed to be recomputed
for ALL the lines.  For large files with many long lines this was too
costly.

(This change causes the indicator to have an incorrect size when there
are many softwrapped chunks onscreen, but that will be addressed later.)

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

Problem existed since version 5.0, since the indicator was introduced.
2021-04-21 16:40:20 +02:00
Benno Schulenberg
bb81932422 chars: work around the wrong private-use-character widths on OpenBSD
This fixes https://savannah.gnu.org/bugs/?60393.
2021-04-20 11:13:08 +02:00
Benno Schulenberg
5efb6836a8 options: retire the obsolete 'smooth', 'morespace', and 'nopauses' 2021-04-15 11:43:39 +02:00
Benno Schulenberg
48fa14acc0 tweaks: simplify two fragments of code
This makes the handling of plain ASCII a tiny bit slower, but it
affects only the users of --constantshow without --minibar, so...

All other uses of mbstrlen() and collect_char() are not in speed-
critical code paths.
2021-04-13 11:19:32 +02:00
Benno Schulenberg
eb7181b35e tweaks: adjust and improve one comment, and frob another 2021-04-12 15:14:05 +02:00
Benno Schulenberg
8db42023bb files: when Mac format has been detected, stay with it
This fixes https://savannah.gnu.org/bugs/?60382.

Bug existed since commit 09b919a6 from three weeks ago.
2021-04-12 14:50:04 +02:00
Benno Schulenberg
018a8e12ca build: fix compilation for --enable-tiny plus --enable-multibuffer
This will not show the error messages for other buffers when using
a tiny build, but... one cannot have everything.
2021-04-10 12:01:34 +02:00
Benno Schulenberg
b4a5aedc6c tweaks: remove a misplaced (and nested) #ifdef
It was accidentally introduced two weeks ago by commit 1c010d8e.
2021-04-09 16:55:07 +02:00
Benno Schulenberg
d6ed174d09 tweaks: morph a function into what it is actually used for
Since the previous commit, mbwidth() is used only to determine whether
a character is either double width or zero width.  There is no need to
return the actual width of the character; a simple yes or no is enough.

Transforming mbwidth() into is_doublewidth() also allows streamlining
it and is_zerowidth() a bit, so that they become slightly faster.
2021-04-09 16:38:23 +02:00
Benno Schulenberg
78f92e044a tweaks: avoid parsing a multibyte character twice
The number of bytes in the character were determined twice: first in
mbwidth() and then in char_length().  Do it just once, in mbtowide().

Also, avoid calling is_cntrl_char(), because it does unneeded checks
when we already know that the high bit is set.

This duplicates some code, but advance_over() is called a lot, so it
is important that it is as fast as possible.

This shouldn't slow down plain ASCII, as the extra checks (use_utf8
and *string < 0xA0) are done only for non-ASCII (apart from DEL).
2021-04-09 11:32:15 +02:00
Benno Schulenberg
f11931a0dd tweaks: rename a variable, for contrast with another
The 'start_index' was in index in the given text, while 'index' is an
index in the displayable string.  Having both of them using 'index' in
their name was somewhat confusing.
2021-04-08 12:19:34 +02:00
Benno Schulenberg
31a6931be9 tweaks: elide a call of strlen() for every row
For a normal file (without overlong lines) the strlen() wasn't much
of a problem.  But when there are very long lines, it wasted time
counting stuff that wouldn't be displayed on the current row anyway,
and reserved *far* too much memory for the displayable string.

Problem existed since commit cf0eed6c from five years ago that traded
a continuous comparison (of the used space with the reserved space)
against a one-time big reservation up front involving a strlen().
In retrospect that was not a good trade-off when softwrapping.

The extra check (charwidth == 0) is incurred only by characters that
have their high bit set, so the average file (with only ASCII) is not
affected by this -- it just loses an unneeded call of strlen().
2021-04-08 12:15:12 +02:00
Benno Schulenberg
debb288115 tweaks: reduce the maximum character length from six bytes to four
In UTF-8 valid multibyte characters are at most four bytes long,
and now that we no longer make use of mblen() and mbtowc() from
the underlying system, we won't get five- or six-byte sequences
mistakenly reported as valid (by glibc).  So it is always enough
to reserve space for just four bytes per character.
2021-04-07 17:21:25 +02:00
Benno Schulenberg
c75a3839da tweaks: elide a small function that is used just once 2021-04-07 17:08:05 +02:00
Benno Schulenberg
b6a32fbd5f tweaks: elide an unneeded resetting NULL call to wctomb()
Calling wctomb() with NULL as the first parameter returns zero in a
UTF-8 locale, meaning that there is no state, so there is no point
in resetting it either.
2021-04-07 16:11:40 +02:00
Benno Schulenberg
09e4c86606 tweaks: improve a couple of comments 2021-04-07 12:28:48 +02:00
Benno Schulenberg
20eb422829 tweaks: avoid converting a file name for more than will fit on screen 2021-04-07 12:12:06 +02:00
Benno Schulenberg
90c6b572d0 display: avoid determining twice from and until where to draw each row
The two calls of draw_row() are each immediately preceded by a call to
display_string(), which has already determined from which x position
and until which x position in the relevant line the current row will
be drawn -- doing this again in draw_row() is a waste of time.  Even
though it is ugly, pass the two data points from one function to the
other via global variables.

For normal files (without overlong lines), this saves on average some
fifty calls of advance_over() per row.  When softwrapping a file with
overlong lines, the savings for each softwrapped chunk are much higher.
2021-04-07 11:27:10 +02:00
Benno Schulenberg
712b574fb7 tweaks: rename a variable, away from an abbreviation 2021-04-06 16:27:46 +02:00
Benno Schulenberg
fd023d6dcf tweaks: put the most likely condition first, for a quicker return
Also condense a comment.
2021-04-06 11:32:25 +02:00
Benno Schulenberg
9c16be32d7 tweaks: reshuffle two conditions, to have the most unlikely one first
This also better fits the preceding comment.
2021-04-05 16:10:44 +02:00
Benno Schulenberg
c3cdb099da tweaks: reshuffle a comment, and put the main extension first
And add some air to the compact file.
2021-04-05 16:06:54 +02:00
Mike Frysinger
682a088fb8 syntax: tcl: support Expect scripts too 2021-04-05 16:02:44 +02:00
Benno Schulenberg
8c25bd0e94 tweaks: elide two more instances of useless character copying
Just point at the relevant characters directly
instead of first copying them out.
2021-04-02 16:39:10 +02:00
Benno Schulenberg
20e122ef41 startup: show the helpful message only when ^G has not been rebound
(Well, it now checks that ^G is still the first shortcut that is bound
to 'do_help', but that is good enough: if the user did any rebinding,
they probably do not need any reminder about how to invoke 'Help'.)

This fixes https://savannah.gnu.org/bugs/?60315.
Reported-by: Robert Goulding <goulding.2@nd.edu>
2021-04-01 10:09:28 +02:00
Benno Schulenberg
0dcac9188f tweaks: simplify two fragments of code, eliding useless character copying 2021-03-29 20:06:05 +02:00
Benno Schulenberg
1c010d8ec9 chars: implement mbtowc() ourselves, for more efficiency
This saves a function call, and the passing and checking of the
MAXCHARLEN parameter, and the checking whether wc is maybe NULL
(which for nano is never the case), and who knows what other
overheads mbtowc() has, and our workaround for glibc.

Code was written after looking at gnulib/lib/mbrtowc-impl-utf8.h.
2021-03-29 12:36:10 +02:00
Benno Schulenberg
b020937475 chars: implement mblen() ourselves, for efficiency
Most implementations of mblen() do a call to mbtowc(), which is
a waste of time when all we want to know is the number of bytes
(and when we already know that we're using UTF-8 and that the
first byte is at least 0xC2).

(This also avoids burdening correct implementations with the
workaround that was needed only for glibc.)

Code was written after looking at gnulib/lib/mbrtowc-impl-utf8.h.
2021-03-27 14:38:28 +01:00
Benno Schulenberg
e3f46b066a build: fix compilation when configured with --disable-multibuffer 2021-03-26 12:21:44 +01:00
Benno Schulenberg
df7fe1280d tweaks: drop unneeded braces and adjust indentation after previous change 2021-03-26 12:17:44 +01:00
Benno Schulenberg
929770191e chars: work around a UTF-8 bug in glibc, to display invalid codes right
The mblen() and mbtowc() functions will happily return 4 or 5 or 6
for byte sequences that start with 0xF4 0x90 or higher.  But those
sequences encode for U+110000 or higher, which are not valid Unicode
code points.  The libc of FreeBSD and OpenBSD and Alpine correctly
return -1 for such sequences.  Make nano behave correctly also when
linked against glibc, so that invalid sequences are always presented
as a series of invalid bytes and never as a single invalid code.

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

Bug existed since before version 2.0.0.
2021-03-26 11:07:05 +01:00
Benno Schulenberg
66d9d6c6d2 tweaks: elide the pointless is_valid_unicode() function
The call of this function in make_mbchar() does not add anything,
because wctomb() already returns -1 for codes U+D800 to U+DFFF,
and parse_verbatim_kbinput() already rejects anything that starts
with U+11.... or higher, so make_mbchar() is never called for codes
beyond U+10FFFF.

And the call in display_string() just needs to check for wc <= 0x10FFFF
because mbtowc() already returns -1 for codes U+D800 to U+DFFF.
2021-03-25 11:24:41 +01:00
Benno Schulenberg
de816840cb input: accept Unicode codes for non-characters as valid, since they are
That is, accept U+FDD0 to U+FDEF, and accept U+xxFFFE and U+xxFFFF
for xx from 00 to 10 hex, being the 66 reserved "non-characters".

It may not be wise of the user to input these "things" (by typing
their code after M-V), but the codes are valid Unicode code points
and should not be rejected.

See https://www.unicode.org/faq/private_use.html#nonchar8 et al.

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

Bug existed since before version 2.0.0.
2021-03-24 17:11:05 +01:00
Benno Schulenberg
74fcc3be79 tweaks: normalize the indentation after an earlier change
(Should have been done yesterday, right after commit 2f718e11.)
2021-03-24 12:29:50 +01:00
Benno Schulenberg
b6909d3737 build: fix compilation when configured with --enable-tiny
Commit 0c1bf429 from last week added two calls to digits()
for --constantshow.
2021-03-24 12:21:50 +01:00
Benno Schulenberg
823d79b36c tweaks: shorten a comment and trim an #ifdef 2021-03-24 12:16:10 +01:00
Benno Schulenberg
735757b0c1 tweaks: set the file format only when unset, so it doesn't need saving
When inserting a file into the current buffer, the 'fmt' element will
already be set.  When we avoid overwriting the current value of 'fmt'
(when it's other than UNSPECIFIED), we don't need to save and restore
the value when inserting a file.
2021-03-24 12:00:34 +01:00
Benno Schulenberg
09b919a68f files: always register the format, also when the file is unwritable
When saving the buffer under a different name, it should by default
have the same format as the original file.

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

Bug existed since version 2.6.0, commit 0293eac1.
2021-03-24 11:53:56 +01:00
Benno Schulenberg
2f718e11a7 files: create a new buffer earlier, so that error messages can be stored
This improves the fix for https://savannah.gnu.org/bugs/?60269,
by not dropping error messages that happen before a buffer is opened.

This basically reverts commit b63c90bf from a year ago, except that
it now always deletes the created buffer when the user does not want
to override the lock file, also when it is the only buffer.
2021-03-23 16:46:37 +01:00
Benno Schulenberg
77da54c6c6 startup: do not store an error message in the record of another buffer
Set the 'format' of a file only when it has been fully read in,
so that this field can be used to indicate that any later error
message cannot be meant for this buffer.

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

Bug existed since commit 6bf52dcc from yesterday.
2021-03-23 16:19:07 +01:00
Benno Schulenberg
6bf52dcc8d startup: do not crash when trying to open a device or directory
Make sure there is an 'openfile' record before trying to save an
error message in this record.

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

Bug existed since commit ede64d7e from yesterday.
2021-03-22 15:50:31 +01:00
Benno Schulenberg
3d9e803aed syntax: c: colorize also labels that contain digits, and uncolorize colon
Labels may contain digits (after the first character).
And the colon after "default" should not be colored.

Inspired-by: Hussam al-Homsi <sawuare@gmail.com>
2021-03-22 11:41:08 +01:00
Benno Schulenberg
ede64d7ea0 feedback: upon first switch to a buffer, show its error message (if any)
When opening multiple files and some of them had an error, only the
first message was shown and the others were lost -- indicated only
by three dots.  Improve upon this by storing the first error message
for each buffer and showing this message when the buffer is first
switched to.

Requested-by: Mike Frysinger <vapier@gentoo.org>
2021-03-21 16:52:29 +01:00
Benno Schulenberg
e8db390d6f tweaks: reshuffle a fragment of code, to prepare for the next change
Also, don't reserve MAXCHARLEN bytes for the terminating NUL byte.
2021-03-21 16:52:29 +01:00
Benno Schulenberg
0c1bf429e8 display: make the output of --constantshow less jittery
That is: reserve for the current line and current character the number
of positions needed for the total number of lines and characters, and
reserve two positions for both the current column and the total number
of columns.  This will keep all nine numbers in the output in the same
place -- as long as there are no lines with more than 99 columns.  In
this latter case there will still be some jitter, but all-in-all the
output is much stabler than it was.

Suggested-by: Mike Frysinger <vapier@gentoo.org>
2021-03-18 16:20:04 +01:00
Benno Schulenberg
f6357a73f0 memory: fix an off-by-one error to free also the last line in a group
The number of lines in a group is the difference in line numbers
between the last line and the first line *plus one*.

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

Bug existed since version 2.9.0, since indenting and unindenting
became undoable, and commit f722c532 formed a part of that.
2021-03-05 18:50:34 +01:00
Benno Schulenberg
49ca7e5aa8 memory: do not allocate space for multidata when it's already allocated
Allocating it again would leak the existing space.

This fixes https://savannah.gnu.org/bugs/?60172.
Reported-by: Mike Frysinger <vapier@gentoo.org>

Bug existed since version 5.6, commit 1fdd23d3.
2021-03-05 11:25:14 +01:00
Benno Schulenberg
be9b1a1887 tweaks: avoid a warning on newer compilers, by writing an extra byte
When the version number is a trio, the version string will occupy
ten bytes and the terminating NUL byte would not be written (which
was not a problem as byte 12 of the lock data is zero anyway).
But it's better to not have the compiler complain, so allow writing
the terminating NUL byte outside of the ten bytes reserved for the
version string.
2021-03-03 10:47:41 +01:00
Benno Schulenberg
bb74aacf2d po: update translations and regenerate POT file and PO files 2021-03-03 10:11:58 +01:00
Benno Schulenberg
b72d9af52c bump version numbers and add a news item for the 5.6.1 release 2021-03-03 09:47:41 +01:00
Benno Schulenberg
a9ccd99b90 tweaks: rename a symbol, to better match the corresponding option 2021-03-03 09:39:49 +01:00
Benno Schulenberg
ac5e5179fb options: rename 'highlightcolor' to the more distinct 'spotlightcolor'
This way there cannot be any confusion with syntax highlighting,
and it indicates better that a single place will be highlighted.
2021-03-03 09:31:46 +01:00
Benno Schulenberg
a543f8cd8f search: correctly colorize a match also when softwrapping is active
This fixes https://savannah.gnu.org/bugs/?60149.
Reported-by: Peter Passchier <peter@passchier.net>
Reported-by: Liu Hao <lh_mouse@126.com>

Bug existed since version 5.6, since a special color for highlighting
search matches was introduced in commit 87fe73dd.
2021-03-01 10:43:28 +01:00
Benno Schulenberg
d7853df8b6 po: update translations and regenerate POT file and PO files 2021-02-24 11:09:56 +01:00
Benno Schulenberg
1e9d12abc5 bump version numbers and add a news item for the 5.6 release 2021-02-24 09:23:50 +01:00
Benno Schulenberg
3bce9fb755 gnulib: update to its current upstream state 2021-02-23 09:53:17 +01:00
Benno Schulenberg
0a57da42e0 docs: correct the description of --quickblank for the changed base value
And mention that --minibar overrides the option too.
2021-02-22 12:24:06 +01:00
Benno Schulenberg
73067e0e16 build: include a workaround only for versions of ncurses that need it
The cursor-misplacement bug has been fixed in ncurses-6.2-20210220:

  https://lists.gnu.org/archive/html/bug-ncurses/2021-02/msg00010.html

See also https://savannah.gnu.org/bugs/?59808.
2021-02-21 12:00:28 +01:00
Benno Schulenberg
b9328d0eac feedback: make Full Justify show a message also when using --minibar
Full justification (like justification of a selection) is probably
a rather rare action -- and possibly even an unintended action --
so it's good to give feedback about what happened also when using
the minibar.
2021-02-20 12:11:43 +01:00
Benno Schulenberg
0596b875f0 painting: trigger a refresh when a second start match appears on a line
When a line is marked as JUSTONTHIS, there should be no second start
match on that line, because otherwise the line would have been marked
as STARTSHERE (unless there is also a second end match -- but it's
fine to do unnecessary refreshes in this unlikely case, as long as
the necessary refreshes are made).

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

Bug existed since version 2.5.0, but has been masked (for the C syntax)
by unnecessary refreshes since version 4.1, commit c9605e73.
2021-02-18 17:15:24 +01:00
Benno Schulenberg
b94dcfd34b painting: trigger fewer unneeded full-screen refreshes
When a line is marked as NOTHING, then the existence or the appearance
of an end match is irrelevant: there is no unpaired start match, so no
recoloring would occur, so there is no need to refresh.

When a line is marked as WOULDBE, then the existence or the appearance
of a start match is irrelevant (for the lines after the first WOULDBE
line): there already is an unpaired start match, so another one will
not change anything, so no refresh is needed.  Only the appearance of
an end match would recolor things and thus require a refresh.  However,
start and end regexes could match the same thing, so an end might get
misinterpreted as a start.  So the rule has to check for the absence
of both a start and an end match, like for WHOLELINE.

This addresses https://savannah.gnu.org/bugs/?60072.
2021-02-18 12:21:37 +01:00
Benno Schulenberg
4238564673 tweaks: rewrap two lines, for esthetics 2021-02-16 16:52:41 +01:00
Benno Schulenberg
764ab96bda tweaks: make a skipping condition more precise
A step forward needs to be forced not when both start match and
end match have zero length, but when the "full match" (all text
from the start of the start match to the end of the end match)
covers zero bytes.  In other words: the start and end match are
both of zero length AND are at the same spot.
2021-02-16 16:12:41 +01:00
Benno Schulenberg
f0cc59bead color: use inverse video for highlighting when there are no colors
When a terminal has no colors but has the ability to hide the cursor
(like a VT320), then using --bold would make a search match too hard
to see.
2021-02-16 11:28:22 +01:00
Benno Schulenberg
282f438967 color: use bright yellow to highlight a search match
Plain yellow is too dark (more like brown) on some machines.
Lightyellow is a bit loud, but... very visible.
2021-02-15 12:29:15 +01:00
Benno Schulenberg
1b01adfa9f docs: mention the new 'set highlightcolor' option 2021-02-14 12:51:09 +01:00
Benno Schulenberg
87fe73ddaa color: give highlighted text its own color, to not look like marked text
Now that a search match gets highlighted, the unsuspecting user might
think that the text is selected, because it is colorized the same way
as selected text.  Avoid this by colorizing a highlighted search match
with its own specific color, black on yellow by default.
2021-02-14 12:51:09 +01:00
Benno Schulenberg
c2746c0bb2 tweaks: reshuffle some code, and reduce the scope of a variable 2021-02-08 12:33:10 +01:00
Benno Schulenberg
399a024857 minibar: suppress the toggling feedback for M-C, but show it for M-Y/M-P
In addition, suppress the feedback for M-C also when --minibar
isn't used, as the feedback obscures the effect of the toggle:
showing information about the cursor position on the status bar.

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

Bug existed since commit 7545eb5b from one week ago.
2021-02-08 10:27:29 +01:00
Benno Schulenberg
d131c2d438 minibar: show a message a little longer when --quickblank isn't used
The --minibar option made --quickblank a no-op.  Now the use of the
latter together with --minibar still has some effect.
2021-02-07 12:09:38 +01:00
Benno Schulenberg
eb0962fb06 docs: remove all mentions of --markmatch and 'set markmatch' 2021-02-07 09:18:15 +01:00
Benno Schulenberg
7bf253702e options: remove --markmatch and 'set markmatch', as the behavior is gone 2021-02-07 09:18:15 +01:00
Benno Schulenberg
76742cc193 search: make highlighting the standard, non-changeable behavior
Highlighting an occurrence is so much clearer than just putting the
cursor on it.  People seem to like it.  So let's make this how nano
behaves by default.
2021-02-07 09:18:15 +01:00
Benno Schulenberg
37717baeed search: just highlight the found occurrence, instead of marking it
Requested-by: Peter Passchier <peter@passchier.net>
2021-02-07 09:18:15 +01:00
Benno Schulenberg
ade2fafbd3 tweaks: remove a strangely placed warning
(After some trying, I haven't seen the warning displayed, but...
I'm not yet sure that it could never occur, so I keep the 'if'.)
2021-02-06 19:12:43 +01:00
Benno Schulenberg
53fe7ba26a tweaks: be slightly more efficient in marking lines as WOULDBE
Take two conditions that are relevant only for a rather unlikely case
(a start match without a corresponding end match) out of an inner loop.
Give the case its own, dedicated loop.
2021-02-06 17:01:02 +01:00
Benno Schulenberg
7e04fea92b painting: when finding an end match, set its multidata right away
When leaving the multidata unset (as was done until now) and the
end match is offscreen, then this could lead to miscolorings later
when jumping over this end match instead of scrolling past it.

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

Bug existed since before version 2.1.10.
2021-02-05 17:25:03 +01:00
Benno Schulenberg
1fdd23d347 display: for a large paste or insertion, recalculate the multiline cache
When a large piece of text or code is pasted or inserted, it could
contain matches for start= and end= regexes, and backtracking from
the current screen could mistake an end for a start and could thus
miscolor things.  Avoid this by recalculating the multiline cache
for pastes and insertions that cover more than a screenful.

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

Bug existed since version 2.6.0, but existed also before 2.4.3.
2021-02-03 17:00:28 +01:00
Benno Schulenberg
5ea930e25f build: detect a build from git also when building out of tree
Reported-by: Hans-Bernhard Bröker <HBBroeker@t-online.de>

Bug existed since version 2.6.0, commit ec295f5e.
2021-02-02 12:00:24 +01:00
Benno Schulenberg
45defd25f3 build: avoid a warning about duplicate symbol when building from tarball
Reported-by: Hans-Bernhard Bröker <HBBroeker@t-online.de>

Bug existed since commit 3ea2694d from last week.
2021-02-02 11:39:26 +01:00
Benno Schulenberg
0d11964503 docs: say that --minibar is modified by --constantshow and --stateflags
The previous two commits reduced what is shown by default on the minibar.
Mention which extra options are needed to show the extra information.
2021-02-02 11:10:09 +01:00
Benno Schulenberg
7545eb5bbf minibar: show the state flags only when --stateflags is used
For users who always have auto-indent or hardwrap or softwrap on
and do not need to see this continuously advertised at the bottom.
2021-02-02 11:10:09 +01:00
Benno Schulenberg
878bd53d11 minibar: show cursor position + character code only with --constantshow
This allows having an even leaner interface, and gives the M-C toggle
an appropriate function (instead of leaving it a "dead" keystroke).

Suggested-by: Sébastien Desreux <seb@h-k.fr>
2021-02-02 11:10:09 +01:00
Benno Schulenberg
e0a4ee0148 scrolling: keep centering after large paste, also when line numbers widen
If a paste (or insertion) is more than a screenful, it will not set
'focusing' to FALSE.  In that case, and when line numbers are already
active, then 'focusing' should be kept set to TRUE, despite it getting
set to FALSE by ensure_firstcolumn_is_aligned().  That latter action
is meant to cushion size changes of the edit window, but in this case
the large paste (or insertion) should trump the size change.

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

Bug existed since version 2.8.3, commit 2b385478.
2021-02-01 12:42:55 +01:00
Benno Schulenberg
d3fbc4d498 tweaks: remove an old fix that was made superfluous by a recent fix
Commit 43d94692 fixed a miscoloring bug [1] by doing proper backtracking
for multiline regexes.  But this change also solves an older miscoloring
issue [2] without needing to recalculate all the multiline data.  So...
just drop the old fix.  (This isn't perfect: it's probably possible to
cook up a replacement scheme where things get miscolored, but... until
then, this is good enough.)

  [1] https://savannah.gnu.org/bugs/?59948
  [2] https://savannah.gnu.org/bugs/?58481

Also, there is no need to set 'refresh_needed' in do_replace_loop(),
because each replacement prompt will call edit_refresh() anyway, and
the functions that call do_replace_loop() will set it afterward.
2021-01-29 16:57:11 +01:00
Benno Schulenberg
a8e2a24f60 tweaks: frob a condition, to be more concise, and reshuffle another 2021-01-29 10:58:09 +01:00
Benno Schulenberg
36855544d1 tweaks: rewrap and reindent a few lines 2021-01-29 10:52:40 +01:00
Benno Schulenberg
dc745c0b77 tweaks: elide a function that is now just one line 2021-01-29 10:30:05 +01:00
Benno Schulenberg
a8ed1d7a9a tweaks: don't bother wiping the multidata before recomputing it
The precalc_multicolorinfo() routine will assign a value to every
element for every line without looking at any current value, so
wiping the data first is a waste of time.
2021-01-29 10:25:27 +01:00
Benno Schulenberg
94c371a38f tweaks: don't bother initializing freshly allocated multidata
After having been allocated, the multidata will get computed
immediately, in precalc_multicolorinfo() and draw_row(), so
first setting each element to -1 is a small waste of time.
2021-01-29 10:18:39 +01:00
Benno Schulenberg
36618f1dca tweaks: don't bother comparing virgin multidata with current situation
The initialization of -1 cannot possibly match with NOTHING or
WHOLELINE or the other available values.

(Also, put in a warning, as I don't think an onscreen line without
a multidata cache can occur at all.)
2021-01-29 10:06:03 +01:00
Benno Schulenberg
3ea2694d9c tweaks: rename six symbols, to be more straightforward 2021-01-28 16:11:57 +01:00
Benno Schulenberg
85cc99a2a3 tweaks: frob some comments, and reshuffle two fragments of code 2021-01-28 15:44:54 +01:00
Benno Schulenberg
befe4ea5de tweaks: frob some comments, and adjust indentation after previous change 2021-01-28 11:57:33 +01:00
Benno Schulenberg
43d94692ce painting: always do backtracking for the first row of the screen
Backtracking from the first row is needed in case a start match was
added recently somewhere offscreen and the user jumped to the current
location (instead of scrolling) so that the CWOULDBE markings did not
reach the current lines.

Also, search for an end match only for the first screen row.  For the
other rows, rely on the CENDAFTER, CWHOLELINE, and CWOULDBE values to
indicate whether there *is* an end match (the first two values) or not.
This saves considerable time when there is no end match in the large
remainder of a buffer: it will search in vain for the end match just
once, instead of for every row of the screen.

This fixes https://savannah.gnu.org/bugs/?59948,
and addresses https://savannah.gnu.org/bugs/?59945.

Bug existed since version 2.7.5, commit b3bcc8ee.
2021-01-27 17:01:17 +01:00
Benno Schulenberg
1364b41dc9 debug: add timing instruments to cache precalculation and screen refresh 2021-01-26 16:06:31 +01:00
Benno Schulenberg
7d3a555464 tweaks: avoid the vague possibility of advancing beyond end-of-line
Like the other two fragments that advance over a zero-length match,
also this fragment should avoid the possibility of stepping beyond
the end of the line.
2021-01-24 17:19:44 +01:00
Benno Schulenberg
0508520b47 tweaks: reshuffle three conditions into a better order
When a zero-length match is beyond the width of the screen, there
is no point in continuing evaluating the rule, so the check for
"offscreen to the right" needs to come first.  The check for a
zero-width match needs to come second because otherwise we would
get stuck on such a match when it is offscreen to the left.
2021-01-24 17:19:37 +01:00
Benno Schulenberg
6cbb7bc443 tweaks: frob two fragments of code, to be more readable 2021-01-24 16:44:38 +01:00
Benno Schulenberg
055e262b56 tweaks: stop evaluating a rule when the match is offscreen to the right
When the match of a coloring regex is beyond the width of the screen,
there is no point in continuing to evaluate the regex for the rest of
the line, because any other matches will be offscreen too.

This will save some time when there are several overlong lines.
2021-01-24 12:40:34 +01:00
Benno Schulenberg
9d8388e836 tweaks: call wattron()/wattroff() only when actually painting something
A syntax has on average a dozen coloring rules, but on average maybe
three or four pieces of text (rough estimate) in a line get painted.
So, on average, it is cheaper to call wattron() and wattroff() only
when actually coloring a piece of text, instead of calling wattron()
before starting to evaluate each rule and wattroff() after finishing
its evaluation.
2021-01-23 19:28:08 +01:00
Benno Schulenberg
895de17a58 color: do not look for another 'end' match after already finding one
When reaching end-of-line after having found a zero-width end match,
nano should not continue at 'seek-an-end' but instead at 'step_two':
going on to seek a start match in the current line.

(There is no bug report, because I cannot figure out how to trigger
this issue and cause nano to misbehave.  The problem was found while
reviewing the comments.)

Bug existed since commit 9a4a5454 from four years ago,
but the behavior was poorer before that commit.
2021-01-22 16:40:53 +01:00
Benno Schulenberg
b202966d30 tweaks: correct a comment, improve another, and trim some verbosity 2021-01-22 11:58:53 +01:00
Benno Schulenberg
a19a7820f9 color: recompile the file-probing regexes a little faster with REG_NOSUB
When the filename, header-line, and magic regexes are first compiled
while reading in the rc files (to check their validity), REG_NOSUB is
used, but for some reason this wasn't done when each of these regexes
gets recompiled in order to be used.  Fix this oversight.  It shaves
some twenty percent off of each of these regexes' compiling time.
2021-01-21 12:35:16 +01:00
Benno Schulenberg
0122119a44 docs: correct the word order for Alt+D in the cheat sheet -- it changed 2021-01-20 19:25:29 +01:00
Benno Schulenberg
64bf03b0d9 docs: correct the formatting of a comment in the sample nanorc 2021-01-15 10:05:04 +01:00
Benno Schulenberg
4bc6d67052 po: update translations and regenerate POT file and PO files 2021-01-14 11:21:21 +01:00
Benno Schulenberg
7519a458b2 bump version numbers and add a news item for the 5.5 release 2021-01-14 11:08:05 +01:00
Benno Schulenberg
bc36813349 memory: avoid leaking the speller or linter command string, when invoked
This fixes https://savannah.gnu.org/bugs/?59854.
Reported-by: Mike Frysinger <vapier@gentoo.org>

Bug existed probably since version 2.9.6, commit 94347f08.
2021-01-11 19:36:34 +01:00
Benno Schulenberg
9bd7d62c10 tweaks: do not change the pointer, but move the content of the string 2021-01-11 19:22:40 +01:00
Benno Schulenberg
735a608e80 speller: strip leading whitespace from command, to avoid a sneaky crash
This completes the fix for https://savannah.gnu.org/bugs/?59855.
2021-01-11 19:15:35 +01:00
Benno Schulenberg
71402bb7e9 feedback: wipe the status bar by default after 20 keystrokes
The 26 keystrokes inherited from Pico is a weird number, and too long.
2021-01-11 16:18:35 +01:00
Benno Schulenberg
9266fa6657 speller: do an internal spell check when --speller is an empty string
This fixes https://savannah.gnu.org/bugs/?59855.
Indirectly-reported-by: Mike Frysinger <vapier@gentoo.org>

Bug existed since version 2.9.6, commit 94347f08.
2021-01-11 16:05:54 +01:00
Benno Schulenberg
6360e4170a copyright: update the years for the FSF 2021-01-11 14:22:51 +01:00
Benno Schulenberg
dcb072d04b build: fix compilation for --enable-{tiny,help,multibuffer}
The mark is not available in the tiny version,
nor can the cursor get hidden by --markmatch.
2021-01-11 13:24:10 +01:00
Benno Schulenberg
4c6ce3c39d minibar: when the overnext character has zero width too, show its code
Requested-by: Peter Passchier <peter@passchier.net>
2021-01-09 12:44:10 +01:00
Benno Schulenberg
41fd09706d minibar: when the next character has zero width, show its code too
This allows seeing that an accented character is not a single code point
but composed from a base character plus a combining character.
2021-01-09 12:44:10 +01:00
Benno Schulenberg
24e5f956d0 build: fix compilation when configured with --disable-utf8
This fixes https://savannah.gnu.org/bugs/?59842.
Reported-by: Ruben van Wyk <admin@knwip.com>

Bug existed since commit 5129e718 from two days ago.
2021-01-08 12:05:55 +01:00
Benno Schulenberg
f602613a9a tweaks: avoid compilation warnings on 32-bit machine plus newer compiler 2021-01-07 16:17:17 +01:00
Benno Schulenberg
ba124ffa5d gnulib: update to its current upstream state 2021-01-07 15:20:45 +01:00
Benno Schulenberg
d30ddf0add tweaks: correct a translator hint 2021-01-07 15:18:57 +01:00
Benno Schulenberg
e66c7d0f8d tweaks: put the new options in a consistent order in the code 2021-01-07 14:27:49 +01:00
Benno Schulenberg
7b9567719c tweaks: reshuffle an option, to have two related ones grouped together
Options --stateflags and --minibar are slightly related; it looks
better to not have them separated by an unrelated option.
2021-01-07 14:27:49 +01:00
Benno Schulenberg
04d33e7981 tweaks: reword the description of an option
Avoid using the word "state" in the description of --minibar,
as it could cause confusion with the --stateflags option.
2021-01-07 14:27:49 +01:00
Benno Schulenberg
c62d12ca93 tweaks: drop a small optimization for invalid UTF-8 starter bytes 2021-01-07 10:37:35 +01:00
Benno Schulenberg
297633d086 minibar: show Unicode codes when in a UTF-8 locale
The only exception is 0x00.  But that code should really not occur
in a normal text.  And if it does, it is fine that it stands out.
2021-01-07 10:36:14 +01:00
Benno Schulenberg
10b99d8ac0 chars: short-circuit determining the width of characters under U+0300
The combining characters (that are zero-width) start at U+0300.
After that it's pretty much chaos, width-wise.

The mbwidth() function is not called for control characters (whose
representation takes up two columns), as they are handled separately.

The calls of mbwidth() that *can* happen with a control character as
argument are only to determine whether the character is zero-width,
and then it doesn't matter whether the exact width is 1 or 2.
2021-01-06 20:15:14 +01:00
Benno Schulenberg
0693d6974a minibar: represent bytes as 0xNN and valid Unicode code points as U+NNNN
An invalid UTF-8 starter byte should not be represented in the same way
as a valid Unicode character.

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

Bug existed since two weeks ago, since the mini-bar code was merged.
2021-01-06 15:10:11 +01:00
Benno Schulenberg
5129e718d7 chars: speed up the handling of invalid UTF-8 starter bytes
The first byte of a multi-byte UTF-8 sequence must be in the range
0xC2...0xFF.  Any other byte cannot be a starter byte and can thus
immediately be treated as a single byte.
2021-01-06 12:41:49 +01:00
Benno Schulenberg
8c406bc875 tweaks: change an intermediate variable to a better one 2021-01-06 10:05:35 +01:00
Benno Schulenberg
c53da9aa5b tweaks: fold some conditions into bitwise masks, for efficiency 2021-01-05 11:49:03 +01:00
Benno Schulenberg
e7a420eca7 prompt: suppress the ">" character always when exactly at the right edge
When the tail of the answer still fits exactly on the screen, the ">"
continuation character should not be shown -- also when the start of
the answer is "scrolled off" to the left.

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

Bug existed in this form since version 4.0, commit 56181896.
2021-01-04 15:39:29 +01:00
Benno Schulenberg
1236341746 tweaks: reshuffle a condition, to probably avoid an unneeded calculation
Also frob three comments.
2021-01-04 11:37:47 +01:00
Benno Schulenberg
c96c343fac tweaks: avoid computing the cursor column twice, and the "page" too 2021-01-04 11:31:07 +01:00
Benno Schulenberg
02f1fec497 prompt: restore a workaround for a cursor misplacement bug in ncurses
When making small movements in the lower right corner, ncurses can
get confused about where the cursor actually is -- a double-width
character seems to throw its calculations off.

This addresses https://savannah.gnu.org/bugs/?59808.

Bug existed since version 5.4, commit 39705c60.
2021-01-03 13:52:31 +01:00
Benno Schulenberg
a102e45e90 tweaks: elide a variable, by using a reallocation instead
Also unwrap a line.
2021-01-03 11:35:11 +01:00
Benno Schulenberg
86c9b9b54e files: when truncating a file name, give an indication of this
Show leading dots for the truncated part, or (if there is no room
at all) show just an underscore instead of the file name.

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

Bug existed since version 2.9.3, commit 97cbbb0c.
2021-01-03 11:32:14 +01:00
Benno Schulenberg
e14127b843 rcfile: rename 'nowrap' toggle to 'breaklonglines', to match the option
Now all toggle functions have the same name as their corresponding
long command-line option.  Also, all names now indicate the effect
of the toggle when it is invoked from a default setting.
2021-01-02 17:14:07 +01:00
Benno Schulenberg
67cdd71352 tweaks: push back the deprecation of the 'set nowrap' option
It is probably the most used option in a .nanorc file.
Keep accepting it for three more years.
2021-01-02 16:55:17 +01:00
Benno Schulenberg
6a88fe8807 tweaks: fold two similar and three identical cases together 2021-01-01 20:27:30 +01:00
Benno Schulenberg
90f6f25e31 oops: use the correct condition for checking the last line will change
Only when the replacement string (in 'answer') is non-empty will the
last line be changed and thus possibly a magic lined added.
2021-01-01 20:09:42 +01:00
Benno Schulenberg
0f4bb64eaf undo: remove the added magic line when a replacement caused one
This fixes https://savannah.gnu.org/bugs/?59796.

Bug existed since before version 2.2.4.
2021-01-01 19:48:03 +01:00
Benno Schulenberg
45efe28f05 minibar: drop the side spaces before suppressing the state flags
Also, consistently keep the right-side elements at least two spaces
away from the modification asterisk.
2020-12-30 19:03:27 +01:00
Benno Schulenberg
c8c7986f65 minibar: allow the number-of-lines to overrule also the state flags 2020-12-30 16:14:38 +01:00
Benno Schulenberg
f437117bf2 tweaks: avoid hitting negative values when using size_t 2020-12-30 16:07:29 +01:00
Benno Schulenberg
33e882e6f8 minibar: allow the number-of-lines to overrule location + character code
When space is too tight to show all three elements, show the report on
the number of lines in preference to the current location and character
code.  The latter two will be shown again upon the next keystroke, so
there is little harm in hiding them for a moment.
2020-12-29 20:10:18 +01:00
Benno Schulenberg
bad591d43d tweaks: adjust the indentation after the previous change
Also, reduce the scope of a variable, and rehuffle two lines.
2020-12-29 15:55:14 +01:00
Benno Schulenberg
7b48458380 minibar: suppress some elements when there is no room to show them
This fixes https://savannah.gnu.org/bugs/?59767.

Bug existed since last week, since the mini-bar code was merged.
2020-12-29 15:54:28 +01:00
Benno Schulenberg
1e16a3f411 syntax: nanorc: colorize 'bookstyle' as a valid option
This fixes https://savannah.gnu.org/bugs/?59769.
Reported-by: Tiago Almeida <tjamadeira@gmail.com>

Bug existed since version 5.0, since --bookstyle was introduced.
2020-12-29 09:36:42 +01:00
Benno Schulenberg
6a3ba2ab50 syntax: sh: recognize shebangs with any shell after 'env', not just 'sh'
(Inspired by a complaint seen somewhere on Stackoverflow.)
2020-12-25 17:05:02 +01:00
Benno Schulenberg
1878168ae3 tweaks: condense the description of how to report a bug
The list of bugs is quite short these days, and most of them are
feature requests, so asking the user to check whether a particular
problem has already been reported doesn't make much sense.
2020-12-25 16:45:31 +01:00
Benno Schulenberg
545709a165 weeding: remove some obsolete information from the README
The distinction between a stable series (even minor number) and
a development series (uneven) was abandonned five years ago.
This information is no longer helpful.
2020-12-25 16:34:08 +01:00
Benno Schulenberg
ca398fdfdf docs: explain the purpose of --markmatch / -^ / 'set markmatch'
Also, colorize 'set markmatch' as a valid option in a nanorc file.
2020-12-24 11:49:49 +01:00
Benno Schulenberg
d0bceb1449 options: add --markmatch and -^ for activating the select-match behavior
And add, of course, the 'set markmatch' nanorc option.
2020-12-24 11:49:22 +01:00
Benno Schulenberg
caef3128eb search: suppress the cursor when highlighting a match
Having a block cursor present when highlighting a match...
does not look nice.  So... hide the cursor until the next
keystroke, unless --showcursor or 'set showcursor' is used.
2020-12-24 11:49:22 +01:00
Benno Schulenberg
856a6ecde3 search: set the mark at the end of a found match so it gets highlighted
Not only does the match get highlighted (for better visibility), but
this also allows deleting the match with a single keystroke (^K, or
<Del> or <Bsp> when --zap is used) and then type something else.

This https://savannah.gnu.org/bugs/?59655.
Requested-by: Noam Sondak <noamso@gmail.com>
2020-12-24 11:49:22 +01:00
Benno Schulenberg
e353203010 docs: explain the effect of --minibar / -_ / 'set minibar'
Also, colorize 'set minibar' as valid option in a nanorc file.
2020-12-23 17:15:06 +01:00
Benno Schulenberg
f1fc66060f minibar: add a percentage that shows how far the cursor is into the file
Requested-by: Peter Passchier <peter@passchier.net>
2020-12-23 12:17:06 +01:00
Benno Schulenberg
ba4f4bdc64 minibar: show the line count in the bar (at startup and when saving)
Show the line count too when switching between buffers.
2020-12-23 12:17:06 +01:00
Benno Schulenberg
2b6c08b955 minibar: add an [x/y] "counter" when multiple files are open 2020-12-23 12:17:06 +01:00
Benno Schulenberg
b86f7868d1 feedback: differentiate between remarks, mistakes, and information
Remarks are about unsurprising things but it's good to give feedback
on them; "mistakes" are unexpected things, and get colored like an
error; and information is something that the user requested and thus
needs to stay on the status bar until the next keystroke.
2020-12-23 12:17:06 +01:00
Benno Schulenberg
54995defd2 input: intercept ^Z also when --minibar is active
For some reason, calling halfdelay() undoes the ISIG mask.
So, mask keyboard interrupts again immediately after the call.

Reported-by: Peter Passchier <peter@passchier.net>
2020-12-23 12:17:06 +01:00
Benno Schulenberg
b89bc2cce6 minibar: show the info bar again some 0.8 seconds after a message
Instead of redisplaying the minibar only upon the next keystroke
(when some feedback message is shown on the status bar), time the
waiting for the keystroke out after four fifths of a second, then
redisplay the minibar and continue the wait.
2020-12-23 12:17:06 +01:00
Benno Schulenberg
8f24ffaaef options: add --minibar and -_ for activating basic state-information bar 2020-12-23 12:17:05 +01:00
Benno Schulenberg
d31cc373de display: add code for showing minimal state-information bar at the bottom
When activated, it suppresses the title bar, and suppresses feedback
on the status bar for toggles whose effect is obvious or whose state
is already shown in the minibar.

This addresses https://savannah.gnu.org/bugs/?58152,
and addresses https://savannah.gnu.org/bugs/?58789.
2020-12-23 12:17:05 +01:00
Benno Schulenberg
f52f503c38 tweaks: move the displaying of the state letters into a separate function 2020-12-23 12:17:05 +01:00
Benno Schulenberg
8939163659 tweaks: reshuffle two lines, and rename a variable to a plain word 2020-12-22 19:23:40 +01:00
Benno Schulenberg
265bdd94f1 mouse: do not offset the shortcuts by 'margin' when using --linenumbers
The bottom window (the prompt bar and the shortcuts) does not shift
its position when line numbers are active, so mouse clicks in this
window should be not be compensated for the line-numbers margin.

This fixes https://savannah.gnu.org/bugs/?59749.
Indirectly-reported-by: ObeliX <ObeliX-@gmx.de>

Bug existed since version 2.7.0, since line numbers were introduced.
2020-12-22 19:15:32 +01:00
OIX
d1c412d200 mouse: update title bar (the M flag) when the click is on the cursor
Clicking on the cursor toggles the mark, meaning that the flags in
the title bar should be updated when --stateflags is active.

This fixes https://savannah.gnu.org/bugs/?59747.
Indirectly-reported-by: ObeliX <ObeliX-@gmx.de>

Signed-off-by: OIX <ObeliX-@gmx.de>
2020-12-22 14:21:28 +01:00
Benno Schulenberg
5c4c30e26b display: do not show the state flags in the help viewer or file browser
The state flags are relevant only when editing.

This fixes https://savannah.gnu.org/bugs/?59744.
Indirectly-reported-by: ObeliX <ObeliX-@gmx.de>

Bug existed since version 5.3, since --stateflags was introduced.
2020-12-21 14:59:18 +01:00
Benno Schulenberg
1b65d39722 docs: insert links to the mailing-list archives into the README
To make those archives easier to find.
2020-12-21 12:29:41 +01:00
Benno Schulenberg
96e4fec31c tweaks: use a boolean instead of an enumeration of two values 2020-12-19 16:40:21 +01:00
Benno Schulenberg
208146f2f2 syntax: go: add author and license line
In the original submission (https://savannah.gnu.org/patch/?8189)
the submitter said: "I hereby put it into the public domain."

Public-domain license: https://directory.fsf.org/wiki/License:CC0

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2020-12-10 15:48:28 +01:00
Benno Schulenberg
89e84e76c3 build: fix compilation when configured with --enable-tiny
The BACK and DEL symbols are used as parameters for do_deletion().
2020-12-09 16:27:34 +01:00
Benno Schulenberg
c44a5e960e syntax: nanorc: colorize 'set promptcolor' as valid 2020-12-07 11:19:48 +01:00
Benno Schulenberg
c1bd54dd47 tweaks: move 'set indicator' to its alphabetical place in the manual
Also, reword some option descriptions, to mention the effect of the
option instead of what the user should give as argument.
2020-12-06 16:34:42 +01:00
Benno Schulenberg
3efb9c3a2e docs: mention the new 'set promptcolor' option 2020-12-06 16:34:42 +01:00
Benno Schulenberg
b87d7f69fc options: accept 'set promptcolor' for setting the color of the prompt bar
When it is not specified, it defaults to the value for 'titlecolor'.
2020-12-06 16:34:42 +01:00
Benno Schulenberg
8ba653f395 docs: mention in NEWS that some workarounds were removed
It would have been good to mention this for the 5.4 release,
but when all is well, no one should be affected by it.
2020-12-06 16:34:18 +01:00
Benno Schulenberg
c6501beba7 tweaks: reshuffle some more lines, to have most #defines together 2020-12-06 12:30:52 +01:00
Benno Schulenberg
dbf522b750 tweaks: reshuffle some lines, to have most #includes near the beginning 2020-12-06 11:49:37 +01:00
Benno Schulenberg
651e97ceef tweaks: reshuffle some lines, to group things better 2020-12-06 11:40:25 +01:00
Benno Schulenberg
d8500f0467 tweaks: remove some #ifdefs that were there only for Slang 2020-12-05 12:34:17 +01:00
Benno Schulenberg
a9bc118178 docs: remove all mentions of Slang 2020-12-05 12:23:06 +01:00
Benno Schulenberg
903942b4f0 build: remove the '--with-slang' configure option 2020-12-05 12:17:48 +01:00
Benno Schulenberg
7ebf5f52b8 tweaks: clean up after the previous change 2020-12-05 12:12:11 +01:00
Benno Schulenberg
4f7593b704 general: remove support for Slang
Slang has too many bugs to be useful.

This addresses https://savannah.gnu.org/bugs/?59210.
2020-12-05 11:57:08 +01:00
Benno Schulenberg
2157738a18 tweaks: correct two comments after the previous changes 2020-12-04 17:03:10 +01:00
Benno Schulenberg
681d11c0cf tweaks: rename a variable, to be similar to its sister 2020-12-04 16:57:17 +01:00
Benno Schulenberg
d96f296b8e input: interpret a keystroke as Meta only when an earlier escape was solo
This allows using <Esc> <Esc> <letter> in a macro as an alternative
for <Ctrl+letter>, but it does require that one does not type <Esc>
by accident when recording a macro as it might modify the subsequent
keystroke when the macro is replayed.

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

Bug existed since version 3.0, commit ecc9211a.
2020-12-04 16:35:28 +01:00
Benno Schulenberg
048ab0ee0b tweaks: reduce the scope of a static variable 2020-12-04 16:30:28 +01:00
Benno Schulenberg
16dff06a4c tweaks: simplify a bit of logic 2020-12-04 16:27:34 +01:00
Benno Schulenberg
c3900e90f0 po: update translations and regenerate POT file and PO files 2020-12-02 11:49:28 +01:00
Benno Schulenberg
0f334f8ee4 bump the version number in configure.ac too 2020-12-02 11:39:51 +01:00
Benno Schulenberg
587e6e2c88 bump version numbers and add a news item for the 5.4 release 2020-12-02 11:15:31 +01:00
Benno Schulenberg
a3a1391a51 tweaks: rename two variables, one for contrast, another for visibility
Also normalize two bits of whitespace.
2020-11-30 13:32:22 +01:00
Benno Schulenberg
a4675acdba copyright: update to the current year for significantly changed files 2020-11-30 12:01:47 +01:00
Benno Schulenberg
00ac41f632 weeding: remove another unneeded workaround for VTE
The issue is only reproducible when lying about the width
of the terminal.

It was a workaround for https://savannah.gnu.org/bugs/?49106.
2020-11-28 16:12:20 +01:00
Benno Schulenberg
fe22da6b2a build: exclude a workaround for VTE/Konsole when using a recent ncurses
The workaround was for https://savannah.gnu.org/bugs/?51335
(a cursor-misplacement bug), but both an recent Xfce Terminal
and a recent Konsole appear unaffected by the issue.  So, drop
the workaround for modern systems.
2020-11-27 14:15:42 +01:00
Benno Schulenberg
0c87a4ba41 build: include a workaround for VTE only when using an older libvte
Checking for the actual version of libvte is too complicated, so
assume that libvte is 0.58 or newer (where the problem is fixed)
when ncurses is 6.2 or newer.
2020-11-27 12:31:41 +01:00
Benno Schulenberg
39705c60df weeding: remove a workaround for VTE that is not needed
It was only ever needed when the user lied about the size
of the terminal, which should be considered a user error.

It was a workaround for https://savannah.gnu.org/bugs/?48852.
2020-11-26 20:09:23 +01:00
Benno Schulenberg
9da23799ff tweaks: reshuffle a fragment of code, for clarity 2020-11-26 17:32:30 +01:00
Benno Schulenberg
29276d1d3a help: allow the penultimate item extra space when the number is uneven
This avoids unnecessarily truncating the last help item on the
very bottom row when there is still plenty of room.

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

Bug has been visible since at least version 2.5.1.
2020-11-26 17:12:09 +01:00
Benno Schulenberg
13b839734f hellp: show all valid help items also in the Write-Out menu
Subtract one from the count only if all possible items in the menu
have been counted (item == NULL), meaning that the last item in the
Write-Out menu (the 'discard_buffer' function) has been counted too.

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

Bug existed since version 4.5, commit b3ace4d8.
2020-11-26 15:37:21 +01:00
Benno Schulenberg
63bb1b62b7 gnulib: update to its current upstream state 2020-11-25 11:22:46 +01:00
Benno Schulenberg
743100feab options: do not spew out the help text when an option is not recognized
When getopt() does not recognize an option, it returns '?', which means
that '-?' cannot be used as a valid option because any invalid option
would be treated the same way as '-?'.

Spewing out the full help text drowns the "invalid option" message at
the beginning.

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

Bug existed since version 5.3, commit 5bd92d4c.
2020-11-24 10:09:41 +01:00
Benno Schulenberg
d3d2d324d2 statusbar: properly pluralize the line+word+character count report
This avoids poor wordings such as "Words: 1  Lines: 1  Chars: 1".

Also, display the numbers in a more logical, ascending order: lines
first, words second, characters third.  This is what 'wc' uses, too.
2020-11-21 15:25:23 +01:00
Benno Schulenberg
925a1a11f9 feedback: abort when user tries to open multiple files in tiny version
This fixes https://savannah.gnu.org/bugs/?56227.
2020-11-17 19:08:12 +01:00
Benno Schulenberg
5918ca6cab tweaks: normalize the formatting after the previous two changes 2020-11-17 10:28:28 +01:00
Benno Schulenberg
dc907bfe43 prompt: skip over combining characters also when editing a search string 2020-11-17 10:27:47 +01:00
Benno Schulenberg
687efd210c moving: skip combining characters and other zero-width characters
This makes the cursor move smoothly left and right -- instead of
"stuttering" when passing over a zero-width character.

Pressing <Delete> on a normal (spacing) character also deletes
any zero-width characters after it.  But pressing <Backspace>
while the cursor is placed after a zero-width character, just
deletes that zero-width character.  The latter behavior allows
deleting and retyping just the combining diacritic of a character
instead of the whole character.

This addresses https://savannah.gnu.org/bugs/?50773.
Requested-by: Mike Frysinger <vapier@gentoo.org>
2020-11-17 10:21:50 +01:00
Benno Schulenberg
b7539ea985 weeding: remove a workaround for versions of ncurses before 5.9
(Yes, the test is for 6.0, but the bug was actually fixed in 5.9,
as far as I remember -- I just wasn't sure and didn't want to bother
building different versions of ncurses myself.)
2020-11-15 10:27:22 +01:00
Benno Schulenberg
7d35f71c87 weeding: remove a workaround for early versions of ncurses-6.0
Those versions are more than five years old.  If there are still
machines with those versions, people should upgrade ncurses too
if they want the newest version of nano.
2020-11-15 10:27:22 +01:00
Benno Schulenberg
7f184ee2ba linting: avoid putting the cursor beyond the end of the line
Some linters report a column position (assuming a TAB to be 8 spaces)
instead of a byte index, so make sure that the cursor is not placed
out of bounds when interpreting such a column number as an index.

This fixes https://savannah.gnu.org/bugs/?59419.
Reported-by: Ava McWhorter <qwerty0s.e.m@gmail.com>

Bug existed since version 2.8.1, commit 2439e1e4.
2020-11-06 10:36:08 +01:00
Benno Schulenberg
ec9fc5d320 utils: die when trying to allocate zero bytes
This shouldn't occur, so go down when it does.
2020-10-29 16:18:03 +01:00
Benno Schulenberg
3c2eb96243 tweaks: rename two variables and improve two comments 2020-10-21 12:24:52 +02:00
Benno Schulenberg
de313586ab tweaks: reshuffle three lines and elide braces after the previous change 2020-10-21 11:39:56 +02:00
Benno Schulenberg
e96bda4b9f tweaks: avoid copying an option's argument when there is no need
This takes eight extra calls of copy_of(), but saves ten calls of
free().  But more importantly: it avoids an unneeded copying and
then freeing again of the argument after 'titlecolor' and friends.
2020-10-21 11:37:21 +02:00
Benno Schulenberg
d9944c03c4 docs: adjust for the changed name of the header-file package on Debian
Also, be more complete, reword a few things, and stop mentioning Slang.
2020-10-11 16:44:40 +02:00
Benno Schulenberg
b9d6d547b8 bindings: accept b for scrolling back up in help viewer and file browser
Like in Dillo, and because it could be mnemonic for "Back" and
is directly above the space bar (in a QWERTY layout, at least).
2020-10-11 16:11:21 +02:00
Benno Schulenberg
622b031e27 docs: use standard-compliant HTML entities for the four arrows
HTML 4 knows only the four-letter abbreviations for the arrows.
Use those, so that also browsers with very limited knowledge
(like Dillo) will show the arrows correctly.
2020-10-11 15:58:40 +02:00
Benno Schulenberg
26f5c8b9d5 rcfile: stop accepting 'set view' in a nanorc file, and undocument it
Like --restricted, --view really only makes sense on the command line.
2020-10-10 12:42:20 +02:00
Benno Schulenberg
e1601d2eb5 tweaks: use the standard symbols for the three standard file descriptors
Also, take into account (as elsewhere) that dup2() could fail,
and harmonize their error checks.
2020-10-10 12:32:02 +02:00
Benno Schulenberg
bc14fc35d7 tweaks: reshuffle a line, elide two braces, and adjust the indentation
And improve a comment.
2020-10-08 15:07:03 +02:00
Benno Schulenberg
f660f22623 tweaks: slightly shorten a loop, to place the actual action outside of it
And in the bargain elide a variable, and make it clearer
what the return value is at two early exit points.

[This change makes use of the fact that TRUE (successful write) == 1
and FALSE (failed write) == 0.  But this is already used twenty lines
earlier, for the other call of write_file().]
2020-10-08 15:07:03 +02:00
Benno Schulenberg
300f67d78f po: update translations and regenerate POT file and PO files 2020-10-07 11:07:06 +02:00
Benno Schulenberg
8a3ecfe5c1 tweaks: correct some typos and spellos in the changelog 2020-10-07 10:44:03 +02:00
Benno Schulenberg
ced0019b6c bump version numbers and add a news item for the 5.3 release 2020-10-07 10:40:12 +02:00
Benno Schulenberg
5d88528fe4 tweaks: rewrap nine more old NEWS items, for balanced line lengths 2020-10-05 17:25:05 +02:00
Benno Schulenberg
1572248866 build: exclude the three --help column headers from the tiny version 2020-10-03 12:15:38 +02:00
Benno Schulenberg
d26916199b tweaks: reshuffle some lines after the previous change 2020-10-03 11:58:43 +02:00
Benno Schulenberg
2e9fb7d840 build: exclude option --tabsize (-T) from the tiny version
An unneeded option when wanting nano to be small.  Excluding it saves
roughly 120 bytes.  It also makes the output of --help nice and clean.
2020-10-03 11:25:43 +02:00
Benno Schulenberg
7a086bef08 gnulib: update to its current upstream state 2020-10-02 10:34:54 +02:00
Benno Schulenberg
777082a7b8 docs: add a link to the website also to the info manual
And add a reference to the "cheat sheet" to the nanorc man page.
2020-10-02 10:32:44 +02:00
Benno Schulenberg
a4e3d88c67 version: remove URL and email address from the --version output
Web links and email addresses do not belong in the version information.
This has bothered me for a long time.  The URL is in the man page, and
bug reports should go to Savannah.
2020-10-02 10:23:40 +02:00
Benno Schulenberg
06b903f807 tweaks: rewrap three NEWS items, for more balanced line lengths 2020-10-01 14:56:14 +02:00
Benno Schulenberg
d2869ab348 build: include some raw sequences for the graphical Debian installer
The terminal window in the graphical Debian installer (the default)
produces the same escape sequences as xterm for F1 to F4.  Though
TERM is set to xterm, the xterm terminfo data is not available, so
ncurses is unable to translate the sequences for us.  :|  Therefore,
recognize the relevant raw escape sequences.

Also, eat all bytes of the non-recognized modified function and arrow
keys, so that they do not enter junk into the buffer.
2020-10-01 14:43:34 +02:00
Benno Schulenberg
072c8aa39b options: move --stateflags (-%) and --magic (-!) to the end of the list
It's nicer to start the list with -A, -B, -C.  And, when the user
does 'nano --help', these new flags are more likely to be noticed.
2020-10-01 11:24:39 +02:00
Benno Schulenberg
5bd92d4c60 options: add -? as a synonym of -h (--help), but leave it undocumented
This option was lost six years ago in commit 43019189, without giving a
reason for it.  It's not really needed, but it doesn't hurt to have it.
2020-10-01 10:45:22 +02:00
Benno Schulenberg
d6c194265f build: exclude excessive version information from the tiny version
The tiny version is about being tiny.  Copyright information and
website links are not essential.
2020-10-01 10:44:37 +02:00
Benno Schulenberg
3f938e29b6 build: exclude bunches of raw escape sequences from the tiny version
The tiny version is probably only ever used in the Debian installer,
on the bterm terminal, which produces escape sequences like those of
a Linux console.  So, exclude all other raw sequences.

(After support for Slang has been removed, we can maybe even exclude
ALL raw sequences from the tiny version, and the corresponding option
(-K/--rawsequences) too.)
2020-10-01 09:06:12 +02:00
Benno Schulenberg
037b77555e tweaks: condense a bit of code after the previous change 2020-09-30 19:51:29 +02:00
Benno Schulenberg
51b9e86d13 tweaks: remove mistaken escape sequences for function keys on xterm
At least since version 229 of xterm (from August 2007), the escape
sequences for F1 to F4 have been "Esc O P" to "Esc O S".  There is
no bracket in those sequences, and there probably never was -- most
likely the extra "[" in nano's code was a slip of the fingers.
2020-09-30 19:46:48 +02:00
Benno Schulenberg
cbf6fd021a tweaks: remove an usused element from 'funcstruct', saving 8 more bytes 2020-09-28 11:57:03 +02:00
Hussam al-Homsi
b093d19262 tweaks: reorder a member of 'funcstruct', to save 8 bytes of padding
Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2020-09-28 11:57:03 +02:00
Benno Schulenberg
7c698a9c3a syntax: sh: recognize some shell scripts by their Emacs modeline
This helps with recognizing most files in /usr/share/bash*/completions/,
where --magic is powerless.
2020-09-28 11:56:17 +02:00
Benno Schulenberg
17f531890a display: skip a special-case refresh when a message was written
This fixes https://savannah.gnu.org/bugs/?59188.

Bug existed since the previous commit, dac58bb6.
2020-09-27 11:23:23 +02:00
Benno Schulenberg
dac58bb651 display: do not wipe the status bar when the terminal has just one row
If there is just one row, the edit window would be wiped too.

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

Bug existed in this form since version 4.4, commit f7d5a82a.
2020-09-25 19:59:06 +02:00
Benno Schulenberg
4a403ae00f display: do not unnecessarily wipe the status bar
It would wipe the edit window if there is just one row.

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

Bug existed since version 2.9.3.
2020-09-25 16:52:31 +02:00
Benno Schulenberg
2c41600957 docs: explain the purpose of -! / --magic / 'set magic'
Also, colorize 'set magic' as valid option in a nanorc file.
2020-09-25 16:35:50 +02:00
Benno Schulenberg
58a3293efc options: require --magic or 'set magic' to enable the use of libmagic
Trying to determine which syntax to apply with the help of libmagic
can be a somewhat time-consuming and yet often still fruitless affair.
Therefore using libmagic should not be the default; it should require
an option to tell nano to try using libmagic when it can't determine
the applicable syntax from the file's name or first line.

This is better than having a --nomagic option (and using libmagic by
default), because when the user has 'set nomagic' in their nanorc or
--nomagic in their alias, then switching the use of libmagic back on
is troublesome.  But with --magic (and not using libmagic by default),
when nano fails to recognize a file, it is a simple ^X, add -! to the
command line, and restart.

The short form of the option is -! because we have run out of letters.

This addresses https://savannah.gnu.org/bugs/?59028.
2020-09-25 16:34:01 +02:00
Benno Schulenberg
0906181d75 tweaks: reshuffle a condition, to elide a blank string 2020-09-24 16:24:34 +02:00
Benno Schulenberg
d5fcc9271a tweaks: harmonize the spelling of a compound word, and rewrap a section 2020-09-24 16:11:04 +02:00
Benno Schulenberg
844c671bf1 docs: explain what the options --stateflags (-%) and 'set stateflags' do
Also, colorize 'set stateflags' as valid option in a nanorc file.
2020-09-23 19:48:03 +02:00
Benno Schulenberg
7ff6b97e5c tweaks: reshuffle some lines and adjust indentation after previous change
Also, exclude the state-flag stuff from the tiny version.
2020-09-23 19:48:03 +02:00
Benno Schulenberg
d679bbc802 new feature: option --stateflags to show some states in top-right corner
With --stateflags (short form: -%) or 'set stateflags', nano reserves
the righthand end of the title bar not for showing "Modified" but for
showing the state of auto-indentation (I), the mark (M), the breaking
of long lines (L), macro recording (R), and softwrapping (S).

When the buffer is modified, this is indicated with a star (*) after
the file name (shown in the center of the title bar).

This fulfills https://savannah.gnu.org/bugs/?57953.
Requested-by: Sébastien Desreux <seb@h-k.fr>
2020-09-23 19:48:03 +02:00
Benno Schulenberg
6d88281357 tweaks: rename another variable, away from being misnamed
It refers to a column number, not an x position.
2020-09-22 11:18:44 +02:00
Benno Schulenberg
32787a9f22 tweaks: rename two variables, to be more distinct
And for the second: to indicate that it isn't used.
2020-09-22 10:53:57 +02:00
Benno Schulenberg
9709dfd563 tweaks: rename two elements of history struct, away from abbreviations 2020-09-22 10:12:43 +02:00
Benno Schulenberg
6dd5a75d13 tweaks: add a hint for translators 2020-09-21 19:34:21 +02:00
Benno Schulenberg
9c04d0c956 tweaks: remove an inconsistent newline from the end of an error message
There are eight other occurrences without the newline.
And an error message should not end in a newline anyway.
2020-09-21 19:27:57 +02:00
Benno Schulenberg
c3e74f02c2 build: exclude --emptyline, --jumpyscrolling, and --noread from tiny nano
When looking at the output of 'nano --help', why confuse the user with
a cosmetic option, an awkward behavioral one, and an obscure one?
2020-09-21 19:02:07 +02:00
Benno Schulenberg
cb56cd70f5 syntax: nanorc: stop coloring 'quiet' and 'backwards' and 'finalnewline'
Those options have been obsolete for a long time already.
2020-09-21 10:37:48 +02:00
Benno Schulenberg
de0395bee9 syntax: nanorc: stop coloring 'nopauses' and 'nowrap' as valid
Those options are obsolete or deprecated.
2020-09-21 10:15:30 +02:00
Benno Schulenberg
abb5b14281 syntax: nanorc: stop coloring 'morespace' and 'smooth' as valid
Those options are deprecated, so should not be colored green but red.
2020-09-21 10:12:31 +02:00
Benno Schulenberg
2289bb7c19 tweaks: reshuffle two lines and a function name, for a consistent order
Also rewrap a a line.
2020-09-20 20:03:18 +02:00
Benno Schulenberg
746ef89745 docs: condense the desciptions of cutting and pasting
Mention the relevant keystroke directly (instead of the command name
followed by the default binding).
2020-09-20 19:38:52 +02:00
Benno Schulenberg
ffc0b4863b feedback: in the tiny version, let M-H show the helpful hint too 2020-09-19 12:23:16 +02:00
Benno Schulenberg
89f8d71001 feedback: don't give a hint for <Bsp>, and not after an Alt+key was used 2020-09-19 12:15:07 +02:00
Benno Schulenberg
a2878bff67 help: nicely pair menu items also when built with just --disable-help 2020-09-18 19:14:43 +02:00
Benno Schulenberg
34cfa55f58 feedback: show helpful message for the first ^H at the top of the file
Typing ^H (by default equivalent to Backspace) at the start of the file
is not useful.  When it happens, assume that the user is new and tried
to ask for Help.  So... explain what the caret and the "M-" in the help
lines mean.
2020-09-18 16:29:34 +02:00
Benno Schulenberg
7dd5484cb5 feedback: show a helpful message for ^G even when there is no help
Saying that "Help is not available" is useless.
Better say something that might help a newbie.
2020-09-18 16:24:15 +02:00
Benno Schulenberg
37f1d43ce3 tweaks: elide a one-line function, after reducing it to a single call 2020-09-18 15:22:12 +02:00
Benno Schulenberg
07b5d97a3a help: do not show "^G Help" in the tiny version when there is no help
Also, to keep menu items nicely grouped in the Main, Search, Replace,
and Goto menus, reorder a few items when no help is available.

This addresses https://savannah.gnu.org/bugs/?59110.
2020-09-18 15:21:24 +02:00
Benno Schulenberg
cb841de3fc feedback: make an "Unbound key" message disappear on the next keystroke
When nano reports "Unbound key" or "Unknown sequence", this message
should stay onscreen only for the relevant keystroke, not for any
succeeding keystroke.

This addresses https://savannah.gnu.org/bugs/?59119.

Bug existed since before version 2.0.6.
2020-09-17 19:36:04 +02:00
Benno Schulenberg
e12f397140 build: do not let Slang translate escape sequences to key codes
Slang fails to translate the longer sequences, and then truncates
these sequences to just four bytes, effectively destroying them.

Therefore, when built with --with-slang, always activate --raw-sequences.

This avoids https://savannah.gnu.org/bugs/?49771.

Bug was visible since version 2.5.0, since bindings
for Ctrl+Left/Ctrl+Right were added.
2020-09-17 16:54:41 +02:00
Benno Schulenberg
3a22028042 tweaks: make two of the changes that 'autoupdate' suggests
Also, normalize a bit of indentation.
2020-09-17 16:28:05 +02:00
Benno Schulenberg
f12264723d tweaks: replace two more occurrences of 'AC_TRY_RUN' with 'AC_RUN_IFELSE'
Leave the occurrences in the Slang stuff alone, as all that stuff
will be removed after the next release.
2020-09-17 13:26:24 +02:00
Benno Schulenberg
65f14624c8 tweaks: stop 'autoupdate' from failing with "end of file in string" 2020-09-17 13:17:52 +02:00
Benno Schulenberg
30016a7e19 tweaks: harmonize the style of error messages and warnings in ./configure 2020-09-17 09:49:35 +02:00
Benno Schulenberg
e8abbc7045 build: stop using an obsolete macro, and use 'void' for signal handlers
The Autoconf manual says that 'AC_TYPE_SIGNAL' is obsolete and
that it is fine to simply use 'void' instead of 'RETSIGTYPE'.
2020-09-16 16:27:32 +02:00
Benno Schulenberg
235f92ce09 build: do not accept --enable-libmagic when not having color support
When nano does not support any syntaxes, libmagic is irrelevant.

This fixes https://savannah.gnu.org/bugs/?59070.
2020-09-16 16:27:15 +02:00
Benno Schulenberg
22fc10911a tweaks: remove two stray comments and two lines that were commented out
And adjust the indentation after the latter change.
2020-09-16 16:21:37 +02:00
Ryan Westlund
11ae201d71 syntax: markdown: add author and license line
Signed-off-by: Ryan Westlund <rlwestlund@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2020-09-15 19:11:35 +02:00
Arturo Borrero González
8586efda0b syntax: nftables: include author and license lines
Signed-off-by: Arturo Borrero González <arturo@debian.org>
2020-09-14 19:52:25 +02:00
Benno Schulenberg
9e382ba691 syntaxes: add author and license lines to four of the files
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2020-09-14 19:38:29 +02:00
Benno Schulenberg
accb645d3f browser: wipe the status bar before searching again with M-W or M-Q
In this way, any message that is on the status bar after the search
will be a response to this search and not some leftover.

This fixes https://savannah.gnu.org/bugs/?59109.
2020-09-14 11:15:00 +02:00
Benno Schulenberg
620496f5cd build: avoid two compiler warnings when gnulib has been ripped out 2020-09-14 11:02:31 +02:00
Benno Schulenberg
73cd96838e help: do not leave the cursor on the status bar after a search
(This effectively reverts commit ba47abb4 from two days ago, but it
groups things better.  It makes an unnecessary call to bottombars()
for M-Q and M-W, but this hardly matters: searching in a help text
does not need to be efficient.)

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

Bug existed since commit ba47abb4 from two days ago.
2020-09-13 10:24:22 +02:00
Benno Schulenberg
82080b044b docs: mention that syntax definitions are available in /usr/share/nano/
Inspired-by: Hussam al-Homsi <sawuare@gmail.com>
2020-09-12 12:48:37 +02:00
Benno Schulenberg
93b25ce014 tweaks: adjust some whitespace in the docs, and improve a comment 2020-09-12 12:21:24 +02:00
Benno Schulenberg
f883465263 build: exclude reading a file from standard input from the tiny version
The tiny version is about being small, not about convenience features
that hardly anyone uses anyway.

Also exclude the description of the "+line[,column]" feature -- it is
unneeded verbosity.

This addresses https://savannah.gnu.org/bugs/?59101.
2020-09-12 11:44:22 +02:00
Benno Schulenberg
ba049fcaf8 tweaks: avoid a compiler warning when compiling with more than -O1 2020-09-11 18:59:04 +02:00
Benno Schulenberg
ba47abb473 help: ensure the help lines are always drawn, also when using Slang
This is needed when --enable-tiny and --with-slang are used together
with --enable-help.
2020-09-11 18:55:21 +02:00
Benno Schulenberg
b9a1a586c0 display: force the cursor to reappear in a better way (when using Slang)
The cursor would disappear after any message on the status bar --
for example, also when M-W is typed and nothing is found -- so the
mitigation trick needs to be performed in statusline() itself.

This addresses https://savannah.gnu.org/bugs/?59091.
2020-09-11 18:54:49 +02:00
Benno Schulenberg
7b19b4114c docs: improve two wordings in the sample nanorc 2020-09-11 10:45:19 +02:00
Benno Schulenberg
3e9c2ecc85 help: in the tiny version, show Prev/Next Word before Backward/Forward
In the tiny version (built with Slang and running on Debian's bterm)
the Ctrl+Left/Ctrl+Right keystrokes do not work.  When the terminal
is wide enough, instead of showing ^B + ^F for Backward and Forward
(which are unneeded because the unmodified arrow keys work fine),
show M-B + M-N for Prev Word and Next Word.

(Listing ^Space and M-Space instead would cause "Prev Word" and
"Next Word" to be truncated.  They are weird keystrokes anyway.)

Also, list M-Q + M-W for "Previous" and "Next" next to "Where Is"
and "Replace", so that it is slightly clearer what they refer to.
2020-09-11 10:00:21 +02:00
Benno Schulenberg
3940032cd3 syntax: po: do not leave the occasional tab with a red background color 2020-09-10 19:48:31 +02:00
Benno Schulenberg
d2d0c665b1 display: force the cursor to reappear after a message (when using Slang)
For some reason, when running a tiny nano built with Slang on the bterm
of a Debian installer image, the cursor disappears when certain things
are written to the status bar.  Make the cursor reappear by rewriting
the two help lines with dummy items (and then rewriting it again with
the normal menu in the central loop).  Of course, this does not help
when the user uses -x or --nohelp to suppress the help lines, but at
least in the default setup the cursor doesn't get hidden now and then.

This mitigates https://savannah.gnu.org/bugs/?59091.

Bug existed since before version 2.2.4.
2020-09-10 18:46:48 +02:00
Benno Schulenberg
50aa3587d4 build: abort the update script if a PO file contains a control character
This is to prevent the ^Q from creeping back into the Romanian PO file.
2020-09-09 16:38:39 +02:00
Benno Schulenberg
0bc834e6f3 syntax: po: highlight embedded control codes that shouldn't be there
For some reason the Romanian PO file contains a literal ^Q in one
of its translated messages -- currently at line 1984.  This stray
^Q causes 'file' to classify po/ro.po as data.

Make such mistaken control codes easier to spot when using nano.
2020-09-08 19:38:55 +02:00
Benno Schulenberg
dd24f6a18d suspension: resume properly from an external SIGSTOP (when using Slang)
Slang apparently needs a call to SLsmg_refresh() to restore the screen
content and put the cursor in the right place.  But call this function
only when the suspension was actually caused by an external SIGSTOP,
because otherwise the original screen (from which nano was invoked)
gets plastered with nano's interface and content -- upon exit, this
is annoying and confusing.

Do not stuff a dummy keystroke into the input stream, as it seems to
get placed *after* the first byte of the next keystroke from the user.
That would cause an "Unknown sequence" for some keystrokes.

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

Bug existed since version 2.8.5, commit 84ff9ebb.
2020-09-08 16:54:06 +02:00
Benno Schulenberg
462e9d4822 suspension: switch off flow control at the right moment (for Slang)
This fixes https://savannah.gnu.org/bugs/?59078.

Bug existed since version 4.8, commit c09e96f2.
2020-09-08 09:15:12 +02:00
Benno Schulenberg
48ac0a64c6 tweaks: dummy commit, to add some info about the previous one
The previous commit fixed https://savannah.gnu.org/bugs/?59071.

That bug existed since version 5.1, commit cc6d1d59.

But before that, a capital Ñ could not be typed (when built with Slang)
and would enter an invalid byte upon the next keystroke.

That bug existed since version 2.8.6, commit 43a5c876.
2020-09-08 09:05:01 +02:00
Benno Schulenberg
cf4901da2d suspension: do not enter an invalid byte upon resume (when using Slang)
Instead of stuffing 0x91 into the input stream, use 0xFF when built
with Slang -- the same code that Slang itself produces when resuming
from an externally induced suspension.  This byte is ignored.

In a UTF-8 locale, it should be safe to ignore the byte 0xFF coming
from the keyboard, as no valid UTF-8 sequence can contain 0xFF.

In an ISO8859 locale, this change prevents ÿ from being typed on the
keyboard -- it can still be entered with <Esc> <Esc> 255, though.
My apologies to the people of Pierre Louÿs and L'Haÿ-les-Roses.
2020-09-07 17:09:57 +02:00
Benno Schulenberg
9f20fadee1 tweaks: normalize the indentation after the previous change 2020-09-07 11:44:29 +02:00
Benno Schulenberg
0f7a309adc suspension: properly resume from an external SIGSTOP
Trying to ignore an external SIGSTOP/SIGTSTP with SIG_IGN does not work,
so always install the SIGCONT handler so that it is possible to continue
from a SIGSTOP.

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

Bug existed since before version 2.0.6.
2020-09-07 11:26:04 +02:00
Benno Schulenberg
c771167b6a tweaks: add some comments to the C syntax, and sort some keywords
Also, fold three regexes into one, eliding some redundant parentheses.
2020-09-06 11:14:16 +02:00
Hussam al-Homsi
e1cf93640c syntax: c: colorize also the keywords that start with an underscore
Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2020-09-06 10:48:07 +02:00
Hussam al-Homsi
1716f140b7 syntax: c: colorize also the 'restrict' keyword, and the #line directive
Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2020-09-06 10:44:43 +02:00
Benno Schulenberg
586a7d22e7 docs: add the customary (1) after the name of command-line programs
Also, don't format the wrapping quotes of strings,
and normalize the formatting of default values.

This addresses https://savannah.gnu.org/bugs/?59064.
Reported-by: Helge Kreutzmann <debian@helgefjell.de>
2020-09-05 19:43:51 +02:00
Hussam al-Homsi
cab9294f62 syntax: c: colorize also one-character constants, and the null directive
Constants that consist of a single character are valid too.
And a lone hash character on a line by itself also.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2020-09-05 13:25:54 +02:00
Benno Schulenberg
98a24fc8f9 build: to verify wide curses, probe for a function that cannot be a macro
This probing has been changed four times in the past:

    git log --grep get_wch

In March 2005, commit 2161fa62 changed the probe from get_wch() to
wget_wch(), reasoning that "get_wch() might be a macro instead of
a function".  (Four months earlier, commit 3ba9c351 changed it
from addwstr() to wget_wch(), probably for the same reason.)  But
three months later, in commit 25799f68, the probe gets changed to
get_wch() again, because "it's a more generic function"...

It seems clear that the non-macro argument is the stronger one.
See the NOTES section in 'man get_wch' for its possible macroness.

This addresses https://savannah.gnu.org/bugs/?58997.
Reported-by: Randall S. Becker <rsbecker@nexbridge.com>
2020-09-03 19:47:09 +02:00
Benno Schulenberg
bbc7c59563 browser: sort names that differ only in case with uppercase first
This is the opposite of what 'ls' does in a UTF-8 locale, but nano
has never followed the collating rules of Unicode (uppercase after
lowercase, ignoring punctuation, and so on) -- it would be strange
to change that now.

Until now, nano left such equivalent names unsorted, in a seemingly
random order.

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

Bug existed since before version 2.0.6.
2020-09-03 16:28:47 +02:00
Benno Schulenberg
b122d3b8e5 docs: explain the 'set scrollercolor' option, for coloring the indicator
And mention that a background color does not work on libvte before 0.55.

To find out the version of libvte on your system:

  ls -R1 /usr/lib | grep libvte | grep 00 | grep -o "0\..."
2020-09-02 19:55:24 +02:00
Benno Schulenberg
46e769a113 rcfile: add 'set scrollercolor', for changing the color of the indicator
This fulfills https://savannah.gnu.org/bugs/?59041.
2020-09-02 19:55:24 +02:00
Benno Schulenberg
79545187b8 tweaks: move two more functions, to before the ones that call them 2020-09-02 10:19:04 +02:00
Benno Schulenberg
413a83c2e2 tweaks: move two more functions, to before the one that calls them 2020-09-02 10:09:20 +02:00
Benno Schulenberg
ab08eebfc1 tweaks: move three functions, to before the ones that call them 2020-09-02 10:02:55 +02:00
Benno Schulenberg
ac4c56f636 tweaks: fold one function into another, to elide an unneeded return value 2020-09-02 09:55:08 +02:00
Benno Schulenberg
1db7d57a24 browser: make M-W/M-Q functional right after startup, if there is history
Do the same what the normal "research" code does: if nothing was
searched for yet during this session, and there is a history of
search items, then search for the last item in that history.
2020-09-02 09:22:50 +02:00
Benno Schulenberg
e32ca98ccf tweaks: condense a bit of code
Make it equal to what the normal search code does.
2020-09-02 09:15:23 +02:00
Benno Schulenberg
5a635db262 chars: reduce searching time with roughly 85 percent for plain ASCII
Make case-insensitive searching in a UTF-8 locale eight times faster
when the actual characters involved are plain ASCII.

This makes us faster than 'less', and as fast as Vim and Emacs.

The disadvantage of this change is that searching for a string that
begins with a multibyte character is nearly ten times slower than
searching for one that begins with an ASCII character.  This may be
unsettling when searching a huge file first for a simple ASCII string
and later for a UTF-8 one.  Doing this second search, the user might
get impatient: "Why is it taking so long?"

(This patch fell through the cracks four years ago, when I worked on
the searching code.  It sat in a branch on top of other changes that
I never applied because I made different improvements.  The speedup
at the time, on that machine, was only around sixty percent, though.
But measuring it now again on the same machine, it clocks in at an
82 percent reduction with -O0 and an 87 percent reduction with -O2.)
2020-09-01 19:35:34 +02:00
Hussam al-Homsi
c87bc1d55f tweaks: stop casting the return of malloc() and friends
Those casts are redundant, and sometimes ugly.  And as the types of
variables are extremely unlikely to change any more at this point,
the protection they offer against miscompilations is moot.

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2020-08-31 12:17:27 +02:00
Benno Schulenberg
5c63975097 tweaks: rename four variables, reshuffle them, and correct one type
Also, drop three unneeded comments.
2020-08-25 12:13:55 +02:00
Benno Schulenberg
fee905a34a tweaks: drop the unneeded saving and restoring of a global variable
The two functions findnextstr() and do_replace_loop() do not change
or even touch 'last_search', so there is no need to save and then
restore its value when doing corrections of misspelled words.
2020-08-25 11:58:04 +02:00
104 changed files with 34993 additions and 29439 deletions

560
ChangeLog
View File

@@ -1,3 +1,551 @@
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:
--------------------------------
Benno Schulenberg (62):
build: drop the check for two functions that we don't use any more
build: fix compilation for --enable-tiny plus --enable-multibuffer
build: fix compilation when configured with --disable-multibuffer
build: fix compilation when configured with --enable-tiny
bump version numbers and add a news item for the 5.7 release
chars: implement mblen() ourselves, for efficiency
chars: implement mbtowc() ourselves, for more efficiency
chars: work around a UTF-8 bug in glibc, to display invalid codes right
chars: work around the wrong private-use-character widths on OpenBSD
display: avoid determining twice from and until where to draw each row
display: make the output of --constantshow less jittery
editing: prevent the pointer for the top row from becoming dangling
feedback: upon first switch to a buffer, show its error message (if any)
files: always register the format, also when the file is unwritable
files: create a new buffer earlier, so that error messages can be stored
files: when Mac format has been detected, stay with it
gnulib: pull in the fix for a build problem on older Debian
gnulib: update to its current upstream state
indicator: adjust the size to the number of visible lines, not chunks
input: accept Unicode codes for non-characters as valid, since they are
memory: do not allocate space for multidata when it's already allocated
memory: fix an off-by-one error to free also the last line in a group
memory: prevent a use-after-free when the user respects a lock file
oops: that doesn't work -- you can't break out of two for loops at once
options: retire the obsolete 'smooth', 'morespace', and 'nopauses'
softwrap: avoid time-consuming computations, to burden large files less
startup: do not crash when trying to open a device or directory
startup: do not store an error message in the record of another buffer
startup: save the compiled file-matching regexes, to avoid recompiling
startup: show the helpful message only when ^G has not been rebound
syntax: c: colorize also labels that contain digits, and uncolorize colon
syntax: po: improve the coloring of format specifiers
syntaxes: replace [[:space:]] with [[:blank:]] to exclude carriage return
tweaks: adjust and improve one comment, and frob another
tweaks: adjust two comments, and reshuffle two fragments
tweaks: avoid a warning on newer compilers, by writing an extra byte
tweaks: avoid calling extra_chunks_in() when not softwrapping
tweaks: avoid converting a file name for more than will fit on screen
tweaks: avoid parsing a multibyte character twice
tweaks: condense three comments, drop another, and rewrap a line
tweaks: drop unneeded braces and adjust indentation after previous change
tweaks: elide a call of strlen() for every row
tweaks: elide a function that is now basically just two lines
tweaks: elide an unneeded resetting NULL call to wctomb()
tweaks: elide a small function that is used just once
tweaks: elide the pointless is_valid_unicode() function
tweaks: elide two more instances of useless character copying
tweaks: improve a couple of comments
tweaks: morph a function into what it is actually used for
tweaks: normalize the indentation after an earlier change
tweaks: put the most likely condition first, for a quicker return
tweaks: reduce the maximum character length from six bytes to four
tweaks: remove a misplaced (and nested) #ifdef
tweaks: rename a variable, away from an abbreviation
tweaks: rename a variable, for contrast with another
tweaks: reshuffle a comment, and put the main extension first
tweaks: reshuffle a fragment of code, to prepare for the next change
tweaks: reshuffle two conditions, to have the most unlikely one first
tweaks: set the file format only when unset, so it doesn't need saving
tweaks: shorten a comment and trim an #ifdef
tweaks: simplify two fragments of code
tweaks: simplify two fragments of code, eliding useless character copying
Hussam al-Homsi (1):
syntax: c: make the highlighting of '#include <...>' more compliant
Mike Frysinger (1):
syntax: tcl: support Expect scripts too
Changes between v5.6 and v5.6.1:
--------------------------------
Benno Schulenberg (4):
bump version numbers and add a news item for the 5.6.1 release
options: rename 'highlightcolor' to the more distinct 'spotlightcolor'
search: correctly colorize a match also when softwrapping is active
tweaks: rename a symbol, to better match the corresponding option
Changes between v5.5 and v5.6:
------------------------------
Benno Schulenberg (52):
build: avoid a warning about duplicate symbol when building from tarball
build: detect a build from git also when building out of tree
build: include a workaround only for versions of ncurses that need it
bump version numbers and add a news item for the 5.6 release
color: do not look for another 'end' match after already finding one
color: give highlighted text its own color, to not look like marked text
color: recompile the file-probing regexes a little faster with REG_NOSUB
color: use bright yellow to highlight a search match
color: use inverse video for highlighting when there are no colors
debug: add timing instruments to cache precalculation and screen refresh
display: for a large paste or insertion, recalculate the multiline cache
docs: correct the description of --quickblank for the changed base value
docs: correct the formatting of a comment in the sample nanorc
docs: correct the word order for Alt+D in the cheat sheet -- it changed
docs: mention the new 'set highlightcolor' option
docs: remove all mentions of --markmatch and 'set markmatch'
docs: say that --minibar is modified by --constantshow and --stateflags
feedback: make Full Justify show a message also when using --minibar
gnulib: update to its current upstream state
minibar: show a message a little longer when --quickblank isn't used
minibar: show cursor position + character code only with --constantshow
minibar: show the state flags only when --stateflags is used
minibar: suppress the toggling feedback for M-C, but show it for M-Y/M-P
options: remove --markmatch and 'set markmatch', as the behavior is gone
painting: always do backtracking for the first row of the screen
painting: trigger a refresh when a second start match appears on a line
painting: trigger fewer unneeded full-screen refreshes
painting: when finding an end match, set its multidata right away
scrolling: keep centering after large paste, also when line numbers widen
search: just highlight the found occurrence, instead of marking it
search: make highlighting the standard, non-changeable behavior
tweaks: avoid the vague possibility of advancing beyond end-of-line
tweaks: be slightly more efficient in marking lines as WOULDBE
tweaks: call wattron()/wattroff() only when actually painting something
tweaks: correct a comment, improve another, and trim some verbosity
tweaks: don't bother comparing virgin multidata with current situation
tweaks: don't bother initializing freshly allocated multidata
tweaks: don't bother wiping the multidata before recomputing it
tweaks: elide a function that is now just one line
tweaks: frob a condition, to be more concise, and reshuffle another
tweaks: frob some comments, and adjust indentation after previous change
tweaks: frob some comments, and reshuffle two fragments of code
tweaks: frob two fragments of code, to be more readable
tweaks: make a skipping condition more precise
tweaks: remove an old fix that was made superfluous by a recent fix
tweaks: remove a strangely placed warning
tweaks: rename six symbols, to be more straightforward
tweaks: reshuffle some code, and reduce the scope of a variable
tweaks: reshuffle three conditions into a better order
tweaks: rewrap and reindent a few lines
tweaks: rewrap two lines, for esthetics
tweaks: stop evaluating a rule when the match is offscreen to the right
Changes between v5.4 and v5.5:
------------------------------
Benno Schulenberg (84):
build: fix compilation for --enable-{tiny,help,multibuffer}
build: fix compilation when configured with --disable-utf8
build: fix compilation when configured with --enable-tiny
build: remove the '--with-slang' configure option
bump version numbers and add a news item for the 5.5 release
chars: short-circuit determining the width of characters under U+0300
chars: speed up the handling of invalid UTF-8 starter bytes
copyright: update the years for the FSF
display: add code for showing minimal state-information bar at the bottom
display: do not show the state flags in the help viewer or file browser
docs: explain the effect of --minibar / -_ / 'set minibar'
docs: explain the purpose of --markmatch / -^ / 'set markmatch'
docs: insert links to the mailing-list archives into the README
docs: mention in NEWS that some workarounds were removed
docs: mention the new 'set promptcolor' option
docs: remove all mentions of Slang
feedback: differentiate between remarks, mistakes, and information
feedback: wipe the status bar by default after 20 keystrokes
files: when truncating a file name, give an indication of this
general: remove support for Slang
gnulib: update to its current upstream state
input: intercept ^Z also when --minibar is active
input: interpret a keystroke as Meta only when an earlier escape was solo
memory: avoid leaking the speller or linter command string, when invoked
minibar: add an [x/y] "counter" when multiple files are open
minibar: add a percentage that shows how far the cursor is into the file
minibar: allow the number-of-lines to overrule also the state flags
minibar: allow the number-of-lines to overrule location + character code
minibar: drop the side spaces before suppressing the state flags
minibar: represent bytes as 0xNN and valid Unicode code points as U+NNNN
minibar: show the info bar again some 0.8 seconds after a message
minibar: show the line count in the bar (at startup and when saving)
minibar: show Unicode codes when in a UTF-8 locale
minibar: suppress some elements when there is no room to show them
minibar: when the next character has zero width, show its code too
minibar: when the overnext character has zero width too, show its code
mouse: do not offset the shortcuts by 'margin' when using --linenumbers
oops: use the correct condition for checking the last line will change
options: accept 'set promptcolor' for setting the color of the prompt bar
options: add --markmatch and -^ for activating the select-match behavior
options: add --minibar and -_ for activating basic state-information bar
prompt: restore a workaround for a cursor misplacement bug in ncurses
prompt: suppress the ">" character always when exactly at the right edge
rcfile: rename 'nowrap' toggle to 'breaklonglines', to match the option
search: set the mark at the end of a found match so it gets highlighted
search: suppress the cursor when highlighting a match
speller: do an internal spell check when --speller is an empty string
speller: strip leading whitespace from command, to avoid a sneaky crash
syntax: go: add author and license line
syntax: nanorc: colorize 'bookstyle' as a valid option
syntax: nanorc: colorize 'set promptcolor' as valid
syntax: sh: recognize shebangs with any shell after 'env', not just 'sh'
tweaks: adjust the indentation after the previous change
tweaks: avoid compilation warnings on 32-bit machine plus newer compiler
tweaks: avoid computing the cursor column twice, and the "page" too
tweaks: avoid hitting negative values when using size_t
tweaks: change an intermediate variable to a better one
tweaks: clean up after the previous change
tweaks: condense the description of how to report a bug
tweaks: correct a translator hint
tweaks: correct two comments after the previous changes
tweaks: do not change the pointer, but move the content of the string
tweaks: drop a small optimization for invalid UTF-8 starter bytes
tweaks: elide a variable, by using a reallocation instead
tweaks: fold some conditions into bitwise masks, for efficiency
tweaks: fold two similar and three identical cases together
tweaks: move 'set indicator' to its alphabetical place in the manual
tweaks: move the displaying of the state letters into a separate function
tweaks: push back the deprecation of the 'set nowrap' option
tweaks: put the new options in a consistent order in the code
tweaks: reduce the scope of a static variable
tweaks: remove some #ifdefs that were there only for Slang
tweaks: rename a variable, to be similar to its sister
tweaks: reshuffle a condition, to probably avoid an unneeded calculation
tweaks: reshuffle an option, to have two related ones grouped together
tweaks: reshuffle some lines, to group things better
tweaks: reshuffle some lines, to have most #includes near the beginning
tweaks: reshuffle some more lines, to have most #defines together
tweaks: reshuffle two lines, and rename a variable to a plain word
tweaks: reword the description of an option
tweaks: simplify a bit of logic
tweaks: use a boolean instead of an enumeration of two values
undo: remove the added magic line when a replacement caused one
weeding: remove some obsolete information from the README
OIX (1):
mouse: update title bar (the M flag) when the click is on the cursor
Changes between v5.3 and v5.4:
------------------------------
Benno Schulenberg (31):
bindings: accept b for scrolling back up in help viewer and file browser
build: exclude a workaround for VTE/Konsole when using a recent ncurses
build: include a workaround for VTE only when using an older libvte
bump version numbers and add a news item for the 5.4 release
copyright: update to the current year for significantly changed files
docs: adjust for the changed name of the header-file package on Debian
docs: use standard-compliant HTML entities for the four arrows
feedback: abort when user tries to open multiple files in tiny version
gnulib: update to its current upstream state
help: allow the penultimate item extra space when the number is uneven
help: show all valid help items also in the Write-Out menu
linting: avoid putting the cursor beyond the end of the line
moving: skip combining characters and other zero-width characters
options: do not spew out the help text when an option is not recognized
prompt: skip over combining characters also when editing a search string
rcfile: stop accepting 'set view' in a nanorc file, and undocument it
statusbar: properly pluralize the line+word+character count report
tweaks: avoid copying an option's argument when there is no need
tweaks: normalize the formatting after the previous two changes
tweaks: rename two variables and improve two comments
tweaks: rename two variables, one for contrast, another for visibility
tweaks: reshuffle a fragment of code, for clarity
tweaks: reshuffle a line, elide two braces, and adjust the indentation
tweaks: reshuffle three lines and elide braces after the previous change
tweaks: slightly shorten a loop, to place the actual action outside of it
tweaks: use the standard symbols for the three standard file descriptors
utils: die when trying to allocate zero bytes
weeding: remove another unneeded workaround for VTE
weeding: remove a workaround for early versions of ncurses-6.0
weeding: remove a workaround for versions of ncurses before 5.9
weeding: remove a workaround for VTE that is not needed
Changes between v5.2 and v5.3:
------------------------------
Arturo Borrero González (1):
syntax: nftables: include author and license lines
Benno Schulenberg (92):
browser: make M-W/M-Q functional right after startup, if there is history
browser: sort names that differ only in case with uppercase first
browser: wipe the status bar before searching again with M-W or M-Q
build: abort the update script if a PO file contains a control character
build: avoid two compiler warnings when gnulib has been ripped out
build: do not accept --enable-libmagic when not having color support
build: do not let Slang translate escape sequences to key codes
build: exclude bunches of raw escape sequences from the tiny version
build: exclude --emptyline, --jumpyscrolling, and --noread from tiny nano
build: exclude excessive version information from the tiny version
build: exclude option --tabsize (-T) from the tiny version
build: exclude reading a file from standard input from the tiny version
build: exclude the three --help column headers from the tiny version
build: include some raw sequences for the graphical Debian installer
build: stop using an obsolete macro, and use 'void' for signal handlers
build: to verify wide curses, probe for a function that cannot be a macro
bump version numbers and add a news item for the 5.3 release
chars: reduce searching time with roughly 85 percent for plain ASCII
display: do not unnecessarily wipe the status bar
display: do not wipe the status bar when the terminal has just one row
display: force the cursor to reappear after a message (when using Slang)
display: force the cursor to reappear in a better way (when using Slang)
display: skip a special-case refresh when a message was written
docs: add a link to the website also to the info manual
docs: add the customary (1) after the name of command-line programs
docs: condense the descriptions of cutting and pasting
docs: explain the purpose of -! / --magic / 'set magic'
docs: explain the 'set scrollercolor' option, for coloring the indicator
docs: explain what the options --stateflags (-%) and 'set stateflags' do
docs: improve two wordings in the sample nanorc
docs: mention that syntax definitions are available in /usr/share/nano/
feedback: don't give a hint for <Bsp>, and not after an Alt+key was used
feedback: in the tiny version, let M-H show the helpful hint too
feedback: make an "Unbound key" message disappear on the next keystroke
feedback: show a helpful message for ^G even when there is no help
feedback: show helpful message for the first ^H at the top of the file
gnulib: update to its current upstream state
help: do not leave the cursor on the status bar after a search
help: do not show "^G Help" in the tiny version when there is no help
help: ensure the help lines are always drawn, also when using Slang
help: in the tiny version, show Prev/Next Word before Backward/Forward
help: nicely pair menu items also when built with just --disable-help
new feature: option --stateflags to show some states in top-right corner
options: add -? as a synonym of -h (--help), but leave it undocumented
options: move --stateflags (-%) and --magic (-!) to the end of the list
options: require --magic or 'set magic' to enable the use of libmagic
rcfile: add 'set scrollercolor', for changing the color of the indicator
suspension: do not enter an invalid byte upon resume (when using Slang)
suspension: properly resume from an external SIGSTOP
suspension: resume properly from an external SIGSTOP (when using Slang)
suspension: switch off flow control at the right moment (for Slang)
syntaxes: add author and license lines to four of the files
syntax: nanorc: stop coloring 'morespace' and 'smooth' as valid
syntax: nanorc: stop coloring 'nopauses' and 'nowrap' as valid
syntax: nanorc: stop coloring 'quiet' and 'backwards' and 'finalnewline'
syntax: po: do not leave the occasional tab with a red background color
syntax: po: highlight embedded control codes that shouldn't be there
syntax: sh: recognize some shell scripts by their Emacs modeline
tweaks: add a hint for translators
tweaks: add some comments to the C syntax, and sort some keywords
tweaks: adjust some whitespace in the docs, and improve a comment
tweaks: avoid a compiler warning when compiling with more than -O1
tweaks: condense a bit of code
tweaks: condense a bit of code after the previous change
tweaks: drop the unneeded saving and restoring of a global variable
tweaks: dummy commit, to add some info about the previous one
tweaks: elide a one-line function, after reducing it to a single call
tweaks: fold one function into another, to elide an unneeded return value
tweaks: harmonize the spelling of a compound word, and rewrap a section
tweaks: harmonize the style of error messages and warnings in ./configure
tweaks: make two of the changes that 'autoupdate' suggests
tweaks: move three functions, to before the ones that call them
tweaks: move two more functions, to before the ones that call them
tweaks: move two more functions, to before the one that calls them
tweaks: normalize the indentation after the previous change
tweaks: remove an inconsistent newline from the end of an error message
tweaks: remove an unused element from 'funcstruct', saving 8 more bytes
tweaks: remove mistaken escape sequences for function keys on xterm
tweaks: remove two stray comments and two lines that were commented out
tweaks: rename another variable, away from being misnamed
tweaks: rename four variables, reshuffle them, and correct one type
tweaks: rename two elements of history struct, away from abbreviations
tweaks: rename two variables, to be more distinct
tweaks: replace two more occurrences of 'AC_TRY_RUN' with 'AC_RUN_IFELSE'
tweaks: reshuffle a condition, to elide a blank string
tweaks: reshuffle some lines after the previous change
tweaks: reshuffle some lines and adjust indentation after previous change
tweaks: reshuffle two lines and a function name, for a consistent order
tweaks: rewrap nine more old NEWS items, for balanced line lengths
tweaks: rewrap three NEWS items, for more balanced line lengths
tweaks: stop 'autoupdate' from failing with "end of file in string"
version: remove URL and email address from the --version output
Hussam al-Homsi (5):
syntax: c: colorize also one-character constants, and the null directive
syntax: c: colorize also the keywords that start with an underscore
syntax: c: colorize also the 'restrict' keyword, and the #line directive
tweaks: reorder a member of 'funcstruct', to save 8 bytes of padding
tweaks: stop casting the return of malloc() and friends
Ryan Westlund (1):
syntax: markdown: add author and license line
Changes between v5.1 and v5.2:
------------------------------
@@ -216,7 +764,7 @@ Benno Schulenberg (374):
locking: prevent a symlink attack by not opening an existing lock file
memory: plug a leak, by freeing the cutbuffer after a bracketed paste
menus: remove unneeded words and shortenings from key labels
new feature: a position-plus-portion indicator on the righthand side
new feature: a position-plus-portion indicator on the right-hand side
oops -- restore an accidentally changed file
options: add --indicator and -q for switching on the scroll-bar thing
options: add -O/--bookstyle to make leading whitespace mean new paragraph
@@ -276,7 +824,7 @@ Benno Schulenberg (374):
tweaks: adjust the conditional help-item pairing for absence of speller
tweaks: adjust the file format indicator in a quicker way
tweaks: adjust the indentation after the previous change
tweask: adjust the indentation after the previous change
tweaks: adjust the indentation after the previous change
tweaks: avoid a compiler warning
tweaks: avoid a function call when a simple boolean will do
tweaks: avoid an unnecessary refresh for zero or just one completion
@@ -876,7 +1424,7 @@ Benno Schulenberg (166):
tweaks: reshuffle some declarations, and expand a few variable names
tweaks: reshuffle some lines, to avoid tallying the menus when not needed
tweaks: reshuffle some lines, to group all ignored keystrokes together
tweaks: reshuffle three lines, to make the grouping tighther
tweaks: reshuffle three lines, to make the grouping tighter
tweaks: reshuffle two lines, to do the linking first, then the content
tweaks: reword two comments, and rewrap another
tweaks: rewrap a comment and a line, and reshuffle a fragment of code
@@ -1340,7 +1888,7 @@ Benno Schulenberg (235):
tweaks: elide a pre-processor #else clause, by using braces instead
tweaks: elide a variable, drop a comment, and remove unneeded braces
tweaks: elide two unneeded variables
tweaks: enforce the miminum amount of scrolling in a simpler way
tweaks: enforce the minimum amount of scrolling in a simpler way
tweaks: exclude a bug check from the tiny version
tweaks: exclude another bug check from the tiny version
tweaks: factor out a fragment of code that is repeated three times
@@ -1360,7 +1908,7 @@ Benno Schulenberg (235):
tweaks: move a function to the file where it is used
tweaks: move an assignment that is useful only when searching forward
tweaks: move a syntax check to a better place, to reduce duplication
tweaks: move the tyding-up-after-a-search to a single exit point
tweaks: move the tidying-up-after-a-search to a single exit point
tweaks: normalize the indentation after the previous two changes
tweaks: place a function better, and reduce some comments to a single one
tweaks: put some timing code back into the search function
@@ -1566,7 +2114,7 @@ Benno Schulenberg (85):
tweaks: rename a variable, to be more distinct and more descriptive
tweaks: rename a variable, to get out of the way for another rename
tweaks: rename some variables, for more contrast and to match others
tweaks: rename some variables, to be less repititious
tweaks: rename some variables, to be less repetitious
tweaks: rename two variables, for more contrast
tweaks: rename two variables, to be more distinct and more fitting
tweaks: rename two variables, to make more sense

View File

@@ -2,6 +2,12 @@ Improvements in GNU nano
========================
Since 5.0:
- 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.
- For using libmagic the option --magic or -! or 'set magic' is required.
- With --stateflags the state of some things is shown in the title bar.
- M-Bsp deletes a word leftward.
- With --indicator a "scrollbar" is shown, indicating position+portion.
- M-Ins places an anchor, M-PgUp/M-PgDn jump to the nearest anchor.

287
NEWS
View File

@@ -1,3 +1,84 @@
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
message is shown again upon first switch to the relevant buffer.
• The position and size of the indicator now follow actual lines,
instead of visual lines when in softwrap mode, meaning that the
size of the indicator can change when scrolling in softwrap mode.
2021.03.03 - GNU nano 5.6.1 "Geelgors"
• Search matches are properly colorized in softwrap mode too.
• Option 'highlightcolor' has been renamed to 'spotlightcolor'.
2021.02.24 - GNU nano 5.6 "Wielewaal"
• A search match gets highlighted (in black on yellow by default),
in addition to placing the cursor at the start of the match.
The color combination can be changed with 'set highlightcolor'.
By default the cursor is hidden until the next keystroke, but
it can be forced on with --showcursor / 'set showcursor'.
• Option --markmatch / 'set markmatch' has been removed.
• Cursor position and character code are displayed in the minibar
only when option --constantshow / 'set constantshow' is used,
and their display can be toggled with M-C.
• The state flags are displayed in the minibar only when option
--stateflags / 'set stateflags' is used.
2021.01.14 - GNU nano 5.5 "Rebecca"
• Option 'set minibar' makes nano suppress the title bar and instead
show a bar with basic editing information at the bottom: file name
(plus an asterisk when the buffer is modified), the cursor position
(line,column), the character under the cursor (U+xxxx), the flags
that --stateflags normally shows, plus the percentage of the buffer
that is above the cursor.
• With 'set promptcolor' the color combination of the prompt bar can
be changed, to allow contrasting it with the mini bar (which always
has the same color as the title bar).
• Option 'set markmatch' highlights the result of a successful search
by putting the mark at the end of the match, making the match more
visible. It also suppresses the cursor until the next keystroke.
(If you dislike the hiding of the cursor, use 'set showcursor'.)
• The bindable toggle 'nowrap' has been renamed to 'breaklonglines',
to match the corresponding option, like for all other toggles.
• Support for Slang has been removed.
2020.12.02 - GNU nano 5.4 "Terre des hommes"
• Moving the cursor now skips over combining characters (and other
zero-width characters). Deleting a character deletes also any
succeeding zero-width characters, but backspacing deletes just
one character at a time.
• Workarounds for older ncurses and older libvtes were removed.
2020.10.07 - GNU nano 5.3 "Revolution!"
• Option 'set stateflags' makes nano show the state of auto-indenting,
the mark, hard-wrapping, macro recording, and soft-wrapping in the
title bar. The flags take the place of "Modified", and a modified
buffer is instead indicated by an asterisk (*) after its name.
• Nano no longer by default tries using libmagic to determine the type
of a file (when neither filename nor first line gave a clue), because
in most cases it is a waste of time. It requires using the option
--magic or -! or 'set magic' to make nano try libmagic.
• The color of the indicator can be changed with 'set scrollercolor'.
2020.08.24 - GNU nano 5.2 "Ranrapalca"
• Making certain replacements after a large paste does not crash.
• Hitting a toggle at the Search prompt does not clear the answer.
@@ -125,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.
@@ -529,7 +611,7 @@
2016.02.12 - GNU nano 2.5.2 is carrying too many dogs. This release
includes several fixes for various memory leaks, position-
history size growth, and a long standing issue with using
history size growth, and a long-standing issue with using
nano under sudo creating root-owned files. There are also
the usual bevy of documentation and other miscellaneous
fixes and touchups. Upgrade today while supplies last,
@@ -771,28 +853,27 @@
2009.11.30 - GNU nano 2.2.0 "Doc Brown" is released! The culmination
of almost two years of development and hot on the heels
of nano's 10th birthday is available for all your
editing needs! Bugs fixed since the last release
include several fixes for tiny mode (involving both
the help keys and replace menu text), more 'final'
fixes for soft wrapping, and several typo and documentation
updates including nanorc tweaks and a new syntax
highlighting file for makefiles. Also included is a long
standing fix for random crashing when using nanorc on
FreeBSD, and nano will no longer clear the screen on
suspend to maintain compatibility with other *nix editors.
For those who haven't been playing along at home, please
see the official web page for the summary of new
features since 2.0. Special thanks to all who have
submitted bug reports recently in support of our new
stable release, and apologies for all those bugs we
didn't yet find :-) Peace to all.
of nano's 10th birthday is available for all your editing
needs! Bugs fixed since the last release include several
fixes for tiny mode (involving both the help keys and
replace menu text), more 'final' fixes for soft wrapping,
and several typo and documentation updates including nanorc
tweaks and a new syntax highlighting file for makefiles.
Also included is a long-standing fix for random crashing
when using nanorc on FreeBSD, and nano will no longer clear
the screen on suspend to maintain compatibility with other
*nix editors. For those who haven't been playing along at
home, please see the official web page for the summary of
new features since 2.0. Special thanks to all who have
submitted bug reports recently in support of our new stable
release, and apologies for all those bugs we didn't yet
find :-) Peace to all.
2009.11.21 - GNU nano 2.1.99pre2 is available for a special pre-Black
Friday discount. Included are some (hopefully final)
fixes for issues with last page display caused by the
soft wrapping code, and a fix for a long standing issue
soft wrapping code, and a fix for a long-standing issue
with hitting the Home key when going through the search
history. On the features front, nano will now attempt to
retain the proper ownership and permissions when trying
@@ -924,7 +1005,7 @@
contains fixes for binding bad keys, some
configure-specific compilation failures, and more issues
with the new input back end and in particular the status
bar. Also fixed are some long standing issues with
bar. Also fixed are some long-standing issues with
compiling on AIX, and a segfault when making the terminal
window too small. Rest in Peace Tim and George!
@@ -1105,7 +1186,7 @@
2005.12.23 - GNU nano 1.3.10 rises to the surface. This release
contains several new features as well as fixes for
several longstanding bugs. The former include the
several long-standing bugs. The former include the
ability to scroll up or down single lines without
scrolling the cursor, reworked bracket searching code
that doesn't require regular expression support,
@@ -1142,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
@@ -1155,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.
@@ -1327,38 +1408,37 @@
and enjoy GNU nano 1.2.0.
2003.02.13 - GNU nano 1.1.99pre3 "The last testing version, no
really!" is released. This release includes fixes for
wrapping (again), resizing, color syntax highlighting,
rcfile parsing, the mouse code, more memory leaks, and
some reversion of the code to get the user's home
directory (nano will now again rely on $HOME). There
are also translation updates, a new manual page for the
nanorc file, and an UPGRADE file detailing the changes
since version 1.0. Please submit reports for any bugs
you might find to the development team
(nano-devel@gnu.org), and enjoy nano almost-1.2.0 ;-)
2003.02.13 - GNU nano 1.1.99pre3 "The last testing version, no really!"
is released. This release includes fixes for wrapping
(again), resizing, color syntax highlighting, rcfile
parsing, the mouse code, more memory leaks, and some
reversion of the code to get the user's home directory
(nano will now again rely on $HOME). There are also
translation updates, a new manual page for the nanorc
file, and an UPGRADE file detailing the changes since
version 1.0. Please submit reports for any bugs you
might find to the development team (nano-devel@gnu.org),
and enjoy nano almost-1.2.0 ;-)
2003.02.03 - GNU nano 1.1.99pre2 "bugs in my pockets, bugs in my
shoes" is released. There are, not surprisingly, only
bugfixes in this release as we move toward the stable
1.2.0 release. Fixes are included for translatable
string format, subexpression replacement, constant
cursor position, invalid search regexes, justify, screen
state on SIGHUP and SIGTERM, cutting to end cuts with
long lines, many file browser and operating directory
bugs, memory and file descriptor leaks, marker code,
spell checker, the mouse code with long lines, multiple
buffers and non-file open errors, replacement string
length, and a silly but serious history message crash.
There is also a drastic improvement in CPU utilization
for the color regex code.
Depending on the number of bugs found in this
release, there may be a 1.1.99pre3 or RC1, or just a
1.2.0 release. Most of the major bugs seem to have been
worked out, so if you are waiting for a good time to
test nano before the official 1.2.0 release, this would
be the one to use. Happy bug hunting!
2003.02.03 - GNU nano 1.1.99pre2 "bugs in my pockets, bugs in my shoes"
is released. There are, not surprisingly, only bugfixes
in this release as we move toward the stable 1.2.0
release. Fixes are included for translatable string
format, subexpression replacement, constant cursor
position, invalid search regexes, justify, screen state on
SIGHUP and SIGTERM, cutting to end cuts with long lines,
many file browser and operating directory bugs, memory and
file descriptor leaks, marker code, spell checker, the
mouse code with long lines, multiple buffers and non-file
open errors, replacement string length, and a silly but
serious history message crash. There is also a drastic
improvement in CPU utilization for the color regex code.
Depending on the number of bugs found in this release,
there may be a 1.1.99pre3 or RC1, or just a 1.2.0 release.
Most of the major bugs seem to have been worked out, so if
you are waiting for a good time to test nano before the
official 1.2.0 release, this would be the one to use.
Happy bug hunting!
2003.01.17 - GNU nano 1.1.99pre1 "enough already" has been released.
This release is, barring bug fixes and documentation
@@ -1419,19 +1499,19 @@
word and next word, nanorc parser and line wrapping
code. Have fun!
2002.07.25 - At long last! GNU nano 1.1.10 "What didn't we break?" is
released. This version of GNU nano features version
2002.07.25 - At long last! GNU nano 1.1.10 "What didn't we break?"
is released. This version of GNU nano features version
0.11.2 of gettext, building with automake 1.6, some new
code for displaying control characters, browser
improvements, a new backup file option (-B, --backup), a
new option to ignore rc files (-I, --ignorercfiles),
improvements, a new backup file option (-B, --backup),
a new option to ignore rc files (-I, --ignorercfiles),
compatibility with -pedantic, handling null characters
before EOF, a slightly sportier nanorc.sample and more.
Fixes are included for justification,
the reading and writing file routines, resizing and fill
length, millions of memory leaks, the usage screen was
updated, and the --quotestr and --regexp really work
now ;-) Enjoy :)
Fixes are included for justification, the reading
and writing file routines, resizing and fill length,
millions of memory leaks, the usage screen was updated,
and the --quotestr and --regexp really work now ;-)
Enjoy :)
2002.05.12 - GNU nano 1.1.9 is released, happy Mother's Day! This
release includes many new features, including a prepend
@@ -1701,7 +1781,7 @@
2000.11.23 - Happy Thanksgiving! Nano 0.9.21 is our "last version was
a big turkey" release. It fixes several bugs introduced
by the previous version, as well as a few long- standing
by the previous version, as well as a few long-standing
display bugs. All 0.9.20 users are strongly encouraged
to upgrade to this release.
@@ -1922,19 +2002,19 @@
it is yours to take care of and keep up to date.
2000.03.01 - Well, to continue my trend of going back on my previous
release's comments, nano 0.8.7 is released. The
crashing behavior was still occurring, and this most
recent fix also fixes some other wrapping problems, so
here you go. There may be another release soon, there
may not be, is that vague enough? =)
release's comments, nano 0.8.7 is released. The crashing
behavior was still occurring, and this most recent fix
also fixes some other wrapping problems, so here you go.
There may be another release soon, there may not be, is
that vague enough? =)
2000.02.25 - More minor bugfixes in 0.8.6, the bizarre behavior at the
end of a page has ceased, thankfully. I'm also moving
next weekend, so don't be shocked if you don't see a new
version of nano next week =-)
2000.02.11 - Okay, here we go again. Aside from a few minor fixes and
some under-the-hood changes, you won't notice much
2000.02.11 - Okay, here we go again. Aside from a few minor fixes
and some under-the-hood changes, you won't notice much
different in this version of nano. I haven't gotten
much feedback on the help feature, is it simply amazing
or does no one care? Write and let me know! =)
@@ -1949,23 +2029,22 @@
address nano@asty.org for bugs, etc.
2000.02.02 - Okay, I hate to go back on what I said in the last release,
but I may be changing jobs very soon. I will release
version 0.8.2 as is (no i18n, no help menu (yet)). I
expect things to settle down by the end of next week,
and then I can try to start on the i18n support and help
menu; look for these new features in version 0.8.5 to
0.9.0.
but I may be changing jobs very soon. I will release version
0.8.2 as is (no i18n, no help menu (yet)). I expect things
to settle down by the end of next week, and then I can try to
start on the i18n support and help menu; look for these new
features in version 0.8.5 to 0.9.0.
2000.01.28 - Nano 0.8.1 marks our first official step toward
internationalization (i18n) and the help system (^G). I
will be merging in Jordi's patches for initial i18n in
the next version, and will implement the help system
internationalization (i18n) and the help system (^G).
I will be merging in Jordi's patches for initial i18n
in the next version, and will implement the help system
with i18n built into it shortly after that. Please
don't hesitate to send bug reports, as long as you're
sure the fault lies with nano =-).
2000.01.25 - Nano 0.8.0 is officially the 'let's try and be at least a
little portable, mmmmkay?' release. There are many
2000.01.25 - Nano 0.8.0 is officially the "let's try and be at least
a little portable, mmmmkay?" release. There are many
portability checks and fixes; many thanks to Andy Kahn
for his patches. I removed the broken do_spell behavior
with the 'spell' program; for now, we only try to call
@@ -1975,31 +2054,29 @@
2000.01.24 - Nano 0.7.9 features many new features. Among them are a
new autoindent feature (-i, --autoindent), tempfile flag
like Pico's -t flag (-t, --tempfile), and preliminary
spelling program support. The spelling function tries
to run 'spell' and then 'ispell' in that order, but you
can specify another spelling program with -s or
--speller.
spelling program support. The spelling function tries to
run 'spell' and then 'ispell' in that order, but you can
specify another spelling program with -s or --speller.
2000.01.17 - Nano 0.7.7 is officially the 'way too much stuff changed this
release' release. It's the busy time at work for me, so
please don't get offended if your patch doesn't get
included in the next immediate version of nano. I'm
sure all the changes in this release will cause a few
bugs, so 0.7.8 will primarily be about fixing those
bugs.
2000.01.17 - Nano 0.7.7 is officially the "way too much stuff changed
this release" release. It's the busy time at work for me,
so please don't get offended if your patch doesn't get
included in the next immediate version of nano. I'm sure
all the changes in this release will cause a few bugs, so
0.7.8 will primarily be about fixing those bugs.
Things added this release include resizability (kinda),
new -x and -c flags (see nano -h for help), long command
line flag support, and the usual array of bugfixes.
2000.01.15 - Nano 0.7.6 is officially the 'lightning' release. It now
loads large files much faster than previous versions,
and is even much faster than Pico or vi in some rather
rudimentary tests. Many thanks to Adam Rogoyski for the
read_byte patch!
2000.01.15 - Nano 0.7.6 is officially the "lightning" release.
It now loads large files much faster than previous
versions, and is even much faster than Pico or vi
in some rather rudimentary tests. Many thanks to
Adam Rogoyski for the read_byte patch!
2000.01.09 - As of this version (0.7.4), TIP has officially been renamed
to nano. The new homepage is at
http://faculty.plattsburgh.edu/astyanax/nano. Please
update your bookmarks, tell your friends, and all that
jazz.
2000.01.09 - As of this version (0.7.4), TIP has officially
been renamed to nano. The new homepage is at
http://faculty.plattsburgh.edu/astyanax/nano.
Please update your bookmarks, tell your friends,
and all that jazz.

91
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,9 +55,22 @@ 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, then:
Download the latest nano source tarball, and then:
tar -xvf nano-x.y.tar.gz
cd nano-x.y
@@ -33,12 +78,13 @@ How to compile and install nano
make
make install
It's that simple. Use --prefix with configure to override the
default installation directory of /usr/local.
You will need the header files of ncurses installed for ./configure
to succeed -- get them from libncurses-dev (Debian) or ncurses-devel
(Fedora) or a similarly named package. Use --prefix with ./configure
to override the default installation directory of /usr/local.
If you haven't configured with the --disable-nanorc option, after
installation you may want to copy the doc/sample.nanorc file to
your home directory, rename it to ".nanorc", and then edit it
After installation you may want to copy the doc/sample.nanorc file
to your home directory, rename it to ".nanorc", and then edit it
according to your taste.
Web Page
@@ -51,29 +97,26 @@ Mailing Lists
+ info-nano@gnu.org is a very low traffic list used to announce
new nano versions or other important info about the project.
+ help-nano@gnu.org is for those seeking to get help without
wanting to hear about the technical details of its development.
+ nano-devel@gnu.org is the list used by the people that make nano
and a general development discussion list, with moderate traffic.
To subscribe, send email to <name>-request@gnu.org with a subject
of "subscribe", where <name> is the list you want to subscribe to.
The archives of the development and help mailing lists are here:
https://lists.gnu.org/archive/html/nano-devel/
https://lists.gnu.org/archive/html/help-nano/
Bug Reports
To report a bug, please file a description of the problem on nano's
bug tracker (https://savannah.gnu.org/bugs/?group=nano -- hover on
"Bugs", then click "Submit new"). The issue may have already been
reported, so please look first.
If you find a bug, please file a detailed description of the problem
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).
Current Status
Since version 2.5.0, GNU nano has abandoned the distinction between
a stable and a development branch: it is now on a "rolling" release
-- fixing bugs and adding new features go hand in hand.
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

@@ -22,11 +22,11 @@ packages:
- pkg-config (version >= 0.22)
- texinfo (version >= 4.0)
If you want UTF-8 support, you will also need libncursesw5-dev installed
(version >= 5.7), or libslang2-dev (version >= 2.0) if you use --with-slang.
You will also need to have the header files for ncurses installed,
from libncurses-dev on Debian, ncurses-devel on Fedora, or similar.
These should all be available in your distro's package manager or software
center, or otherwise on any GNU mirror.
These should all be available in your distro's package manager or
software center, or otherwise on any GNU mirror.
Download the source
@@ -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="6a78706ae230ad24bc06d33d9eddca25806ffb2a"
gnulib_hash="9aca7b67333fd0a90bf56104325ce96199644451"
modules="
futimens
@@ -13,6 +13,7 @@ modules="
isblank
iswblank
lstat
mkstemps
nl_langinfo
regex
sigaction

View File

@@ -1,6 +1,6 @@
# Configuration for GNU nano - a small and user-friendly text editor
#
# Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc.
# Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc.
# Copyright (C) 2014, 2017 Mike Frysinger
#
# GNU nano is free software: you can redistribute it and/or modify
@@ -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.2], [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])
@@ -36,12 +36,12 @@ gl_cv_glob_lists_symlinks=yes
dnl Checks for programs.
AC_GNU_SOURCE
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
gl_EARLY
gl_INIT
AC_PROG_LN_S
AC_ISC_POSIX
AC_SEARCH_LIBS([strerror], [cposix])
AC_SYS_LARGEFILE
PKG_PROG_PKG_CONFIG
@@ -59,7 +59,7 @@ AC_DEFINE_DIR([PKGDATADIR], [pkgdatadir], [Where data are placed to.])
dnl Whether this is a git repository.
AC_MSG_CHECKING([whether building from git])
if test -f roll-a-release.sh ; then
if test -f "$srcdir/roll-a-release.sh" ; then
AC_MSG_RESULT([yes])
from_git=yes
else
@@ -73,14 +73,14 @@ dnl Checks for pkg-config and gettext when building from git.
if test x$from_git = xyes; then
if test ! -f $(aclocal --print-ac-dir)/pkg.m4; then
AC_MSG_ERROR([
*** The pkg.m4 macros are missing. ***
*** The pkg-config package needs to be installed when building from git. ***
*** After fixing this problem, rerun ./autogen.sh. ***])
*** The pkg.m4 macros are missing.
*** The pkg-config package needs to be installed when building from git.
*** After fixing this problem, rerun ./autogen.sh.])
fi
if test "$ac_cv_path_MSGFMT" = ":"; then
AC_MSG_ERROR([
*** The msgfmt program is missing. ***
*** The gettext package needs to be installed when building from git. ***])
*** The msgfmt program is missing.
*** The gettext package needs to be installed when building from git.])
fi
fi
@@ -90,12 +90,6 @@ AC_CHECK_HEADERS(libintl.h limits.h pwd.h termios.h sys/param.h)
dnl Checks for options.
if test "x$with_slang" = xyes; then
if test "x$enable_tiny" != xyes; then
AC_MSG_ERROR([--with-slang is supported only together with --enable-tiny])
fi
fi
AC_ARG_ENABLE(browser,
AS_HELP_STRING([--disable-browser], [Disable the built-in file browser]))
if test "x$enable_tiny" = xyes; then
@@ -112,7 +106,8 @@ AS_HELP_STRING([--disable-color], [Disable color and syntax highlighting]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_color" = xyes; then
if test "x$enable_nanorc" != xyes; then
AC_MSG_ERROR([--enable-color needs --enable-nanorc to work])
AC_MSG_ERROR([
*** --enable-color needs --enable-nanorc to work])
fi
else
enable_color=no
@@ -120,7 +115,8 @@ if test "x$enable_tiny" = xyes; then
fi
if test "x$enable_nanorc" = xno; then
if test "x$enable_color" = xyes; then
AC_MSG_ERROR([--enable-color cannot work with --disable-nanorc])
AC_MSG_ERROR([
*** --enable-color cannot work with --disable-nanorc])
else
# Disabling nanorc silently disables color support.
enable_color=no
@@ -135,7 +131,8 @@ AC_ARG_ENABLE(comment,
AS_HELP_STRING([--disable-comment], [Disable the comment/uncomment function]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_comment" = xyes; then
AC_MSG_ERROR([--enable-comment cannot work with --enable-tiny])
AC_MSG_ERROR([
*** --enable-comment cannot work with --enable-tiny])
else
enable_comment=no
fi
@@ -160,7 +157,8 @@ AS_HELP_STRING([--disable-help], [Disable the built-in help texts]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_help" = xyes; then
if test "x$enable_multibuffer" != xyes; then
AC_MSG_ERROR([--enable-help needs --enable-multibuffer to work])
AC_MSG_ERROR([
*** --enable-help needs --enable-multibuffer to work])
fi
else
enable_help=no
@@ -168,7 +166,8 @@ if test "x$enable_tiny" = xyes; then
fi
if test "x$enable_multibuffer" = xno; then
if test "x$enable_help" = xyes; then
AC_MSG_ERROR([--enable-help cannot work with --disable-multibuffer])
AC_MSG_ERROR([
*** --enable-help cannot work with --disable-multibuffer])
else
# Disabling multibuffer silently disables the help texts.
enable_help=no
@@ -202,6 +201,18 @@ fi
AC_ARG_ENABLE(libmagic,
AS_HELP_STRING([--disable-libmagic], [Disable detection of file types via libmagic]))
if test "x$enable_libmagic" = xyes; then
if test "x$enable_tiny" = xyes; then
if test "x$enable_color" != xyes; then
AC_MSG_ERROR([
*** --enable-libmagic needs --enable-color and --enable-nanorc to work])
fi
fi
if test "x$enable_color" = xno; then
AC_MSG_ERROR([
*** --enable-libmagic cannot work with --disable-color nor --disable-nanorc])
fi
fi
AC_ARG_ENABLE(linenumbers,
AS_HELP_STRING([--disable-linenumbers], [Disable line numbering]))
@@ -285,7 +296,8 @@ AC_ARG_ENABLE(wordcomp,
AS_HELP_STRING([--disable-wordcomp], [Disable the word-completion function]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_wordcomp" = xyes; then
AC_MSG_ERROR([--enable-wordcomp cannot work with --enable-tiny])
AC_MSG_ERROR([
*** --enable-wordcomp cannot work with --enable-tiny])
else
enable_wordcomp=no
fi
@@ -335,209 +347,16 @@ AS_HELP_STRING([--enable-altrcname], [Specify an alternate rcfile name (default:
AC_DEFINE_UNQUOTED(RCFILE_NAME, "$enableval", [Specify an alternate rcfile name (default: .nanorc).]) rcfilename=$enableval
fi])
AC_MSG_CHECKING([whether to use slang])
CURSES_LIB_NAME=""
AC_ARG_WITH(slang,
AS_HELP_STRING([--with-slang[=DIR]], [Use the slang library instead of curses]),
[ case "$with_slang" in
no)
AC_MSG_RESULT(no)
;;
*)
AC_MSG_RESULT(yes)
if test x$with_slang != xyes; then
# Add additional search path.
LDFLAGS="-L$with_slang/lib $LDFLAGS"
CPPFLAGS="-I$with_slang/include $CPPFLAGS"
fi
if test "x$enable_utf8" != xno; then
AC_CHECK_HEADER(slcurses.h,
AC_MSG_CHECKING([for SLutf8_enable in -lslang])
_libs=$LIBS
LIBS="$LIBS -lslang"
AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
SLutf8_enable(1);
return 0;
}],
[AC_MSG_RESULT(yes)
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
CURSES_LIB_WIDE=yes
if test x$with_slang != xyes; then
CURSES_LIB="-L${with_slang}/lib -lslang"
else
CURSES_LIB="-lslang"
fi
CURSES_LIB_NAME=slang],
[AC_MSG_RESULT(no)
# We might need the term library.
for termlib in ncurses curses termcap terminfo termlib; do
AC_CHECK_LIB([${termlib}], tputs, [tcap="-l$termlib"])
test -n "$tcap" && break
done
AC_MSG_CHECKING([for SLutf8_enable in -lslang $tcap])
LIBS="$LIBS $tcap"
AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
SLutf8_enable(1);
return 0;
}],
[AC_MSG_RESULT(yes)
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
CURSES_LIB_WIDE=yes
if test x$with_slang != xyes; then
CURSES_LIB="-L${with_slang}/lib -lslang $tcap"
else
CURSES_LIB="-lslang $tcap"
fi
CURSES_LIB_NAME=slang],
[AC_MSG_RESULT(no)
# We might need the math library.
AC_MSG_CHECKING([for SLutf8_enable in -lslang $tcap -lm])
LIBS="$LIBS -lm"
AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
SLutf8_enable(1);
return 0;
}],
[AC_MSG_RESULT(yes)
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
CURSES_LIB_WIDE=yes
if test x$with_slang != xyes; then
CURSES_LIB="-L${with_slang}/lib -lslang $tcap -lm"
else
CURSES_LIB="-lslang $tcap -lm"
fi
CURSES_LIB_NAME=slang],
[AC_MSG_RESULT(no)],
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
AC_MSG_WARN([*** Can not use slang when cross-compiling])),
AC_MSG_ERROR([
*** The header file slcurses.h was not found. This header file
*** is required if you wish to use Slang support. Please either
*** install a version of Slang that includes the slcurses.h file
*** or do not call the configure script with --with-slang.]))
fi
if eval "test x$CURSES_LIB_NAME = x"; then
# Reset libs if the above slang tests failed.
if test "x$enable_utf8" != xno; then
LIBS=$_libs
fi
AC_CHECK_HEADER(slcurses.h,
AC_MSG_CHECKING([for SLtt_initialize in -lslang])
_libs=$LIBS
LIBS="$LIBS -lslang"
AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
SLtt_initialize(NULL);
return 0;
}],
[AC_MSG_RESULT(yes)
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
if test x$with_slang != xyes; then
CURSES_LIB="-L${with_slang}/lib -lslang"
else
CURSES_LIB="-lslang"
fi
CURSES_LIB_NAME=slang],
[AC_MSG_RESULT(no)
# We might need the term library.
for termlib in ncurses curses termcap terminfo termlib; do
AC_CHECK_LIB([${termlib}], tputs, [tcap="-l$termlib"])
test -n "$tcap" && break
done
AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap])
LIBS="$LIBS $tcap"
AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
SLtt_initialize(NULL);
return 0;
}],
[AC_MSG_RESULT(yes)
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
if test x$with_slang != xyes; then
CURSES_LIB="-L${with_slang}/lib -lslang $tcap"
else
CURSES_LIB="-lslang $tcap"
fi
CURSES_LIB_NAME=slang],
[AC_MSG_RESULT(no)
# We might need the math library.
AC_MSG_CHECKING([for SLtt_initialize in -lslang $tcap -lm])
LIBS="$LIBS -lm"
AC_TRY_RUN([
#include <slcurses.h>
int main(void)
{
SLtt_initialize(NULL);
return 0;
}],
[AC_MSG_RESULT(yes)
AC_DEFINE(USE_SLANG, 1, [Define this to use the slang wrappers for curses instead of native curses.])
if test x$with_slang != xyes; then
CURSES_LIB="-L${with_slang}/lib -lslang $tcap -lm"
else
CURSES_LIB="-lslang $tcap -lm"
fi
CURSES_LIB_NAME=slang],
[AC_MSG_RESULT(no)],
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
AC_MSG_WARN([*** Can not use slang when cross-compiling]))],
AC_MSG_WARN([*** Can not use slang when cross-compiling])),
AC_MSG_ERROR([
*** The header file slcurses.h was not found. This header file
*** is required if you wish to use Slang support. Please either
*** install a version of Slang that includes the slcurses.h file
*** or do not call the configure script with --with-slang.]))
fi
if test "${_libs+set}" = "set"; then
LIBS=$_libs
fi
if test x$with_slang != xyes; then
LDFLAGS=${_ldflags}
fi
;;
esac], [AC_MSG_RESULT(no)])
dnl Checks for functions.
if test "x$enable_utf8" != xno; then
AC_CHECK_FUNCS(iswalnum iswpunct mblen mbstowcs mbtowc wctomb)
AC_CHECK_FUNCS(iswalpha iswalnum iswpunct mbstowcs wctomb)
fi
dnl Checks for typedefs, structures, and compiler characteristics.
dnl Checks for available flags.
AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"], [], [])
dnl Checks for library functions.
AC_TYPE_SIGNAL
dnl Checks for libraries.
if eval "test x$CURSES_LIB_NAME = x"; then
@@ -567,9 +386,9 @@ if eval "test x$CURSES_LIB_NAME = x"; then
CURSES_LIB=`$NCURSESW_CONFIG --libs`
LIBS="$CURSES_LIB $LIBS"
CPPFLAGS="`$NCURSESW_CONFIG --cflags` $CPPFLAGS"
AC_CHECK_LIB(ncursesw, get_wch, [CURSES_LIB_NAME=ncursesw CURSES_LIB_WIDE=yes])
AC_CHECK_LIB(ncursesw, wget_wch, [CURSES_LIB_NAME=ncursesw CURSES_LIB_WIDE=yes])
else
AC_CHECK_LIB(ncursesw, get_wch, [CURSES_LIB="-lncursesw" CURSES_LIB_NAME=ncursesw CURSES_LIB_WIDE=yes])
AC_CHECK_LIB(ncursesw, wget_wch, [CURSES_LIB="-lncursesw" CURSES_LIB_NAME=ncursesw CURSES_LIB_WIDE=yes])
fi
LIBS="$OLDLIBS"
fi
@@ -583,7 +402,7 @@ if eval "test x$CURSES_LIB_NAME = x"; then
AC_CHECK_HEADERS(curses.h)
if test "x$enable_utf8" != xno; then
AC_CHECK_LIB(curses, get_wch, [CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses CURSES_LIB_WIDE=yes])
AC_CHECK_LIB(curses, wget_wch, [CURSES_LIB="-lcurses" CURSES_LIB_NAME=curses CURSES_LIB_WIDE=yes])
fi
if eval "test x$CURSES_LIB_NAME = x"; then
@@ -594,7 +413,7 @@ fi
if eval "test x$CURSES_LIB_NAME = x"; then
AC_MSG_ERROR([
*** No curses lib was found. Please install the curses header files
*** from libncursesw5-dev (Debian), ncurses-devel (Fedora), or similar.
*** from libncurses-dev (Debian), ncurses-devel (Fedora), or similar.
*** (Or install ncurses from https://ftp.gnu.org/gnu/ncurses/.)])
else
AC_MSG_RESULT([ The curses library to be used is: $CURSES_LIB_NAME])
@@ -610,19 +429,16 @@ AC_CHECK_LIB([$CURSES_LIB_NAME], [key_defined],
[AC_DEFINE(HAVE_KEY_DEFINED, 1, [Define this if your curses library has the key_defined() function.])],
[], [$CURSES_LIB])
dnl Parse any configure options.
LIBS="$LIBS $CURSES_LIB"
AC_SUBST(CURSES_LIB)
if test "x$enable_utf8" != xno && \
test x$CURSES_LIB_WIDE = xyes && \
test x$ac_cv_func_iswalpha = xyes && \
test x$ac_cv_func_iswalnum = xyes && \
test x$ac_cv_func_iswpunct = xyes && \
test x$ac_cv_func_mblen = xyes && \
test x$ac_cv_func_mbstowcs = xyes && \
test x$ac_cv_func_mbtowc = xyes && \
test x$ac_cv_func_wctomb = xyes; then
AC_DEFINE(ENABLE_UTF8, 1, [Define this if your system has sufficient UTF-8 support.])
else
@@ -664,16 +480,16 @@ AC_DEFINE_UNQUOTED(NANO_REG_EXTENDED, $nano_reg_extended,
[Flag(s) to use to get the full range of extended regular expressions])
if test x$color_support = xyes; then
# if test x$CURSES_LIB_NAME = xcurses; then
AC_MSG_CHECKING([whether _XOPEN_SOURCE_EXTENDED is needed])
AC_TRY_RUN([
AC_MSG_CHECKING([whether _XOPEN_SOURCE_EXTENDED is needed])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <curses.h>
int main(void)
{
int testcolor = COLOR_WHITE;
return 0;
}], AC_MSG_RESULT(no),
AC_TRY_RUN([
}]])],
AC_MSG_RESULT(no),
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#ifndef _XOPEN_SOURCE_EXTENDED
#define _XOPEN_SOURCE_EXTENDED 1
#endif
@@ -682,35 +498,38 @@ int main(void)
{
int testcolor = COLOR_WHITE;
return 0;
}],
AC_DEFINE(NEED_XOPEN_SOURCE_EXTENDED, 1, [Define this if you need the _XOPEN_SOURCE_EXTENDED macro for color support.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(not sure)
AC_MSG_WARN([*** Couldn't successfully compile basic color test with or without _XOPEN_SOURCE_EXTENDED])
AC_MSG_WARN([*** This build may not compile. Consider configuring with --disable-color or installing ncurses])),
AC_MSG_WARN([*** Can't check need for _XOPEN_SOURCE_EXTENDED when cross-compiling]))
# fi
}]])],
AC_DEFINE(NEED_XOPEN_SOURCE_EXTENDED, 1, [Define this if you need the _XOPEN_SOURCE_EXTENDED macro for color support.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(not sure)
AC_MSG_WARN([
*** Couldn't successfully compile basic color test with or without
*** _XOPEN_SOURCE_EXTENDED. This build may not compile. Consider
*** configuring with --disable-color or installing ncurses.])),
AC_MSG_WARN([
*** Can't check need for _XOPEN_SOURCE_EXTENDED when cross-compiling.]))
fi
AC_MSG_CHECKING([whether LINES and COLS can be redefined])
AC_TRY_RUN([
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <curses.h>
int main(void)
{
LINES = 80;
COLS = 25;
return 0;
}],
}]])],
AC_DEFINE(REDEFINING_MACROS_OK, 1, [Define this if you know your curses library allows LINES and COLS to be redefined to deal with a resizing bug.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no),
AC_MSG_WARN([*** Can't check for macro redefinability when cross-compiling]))
AC_MSG_WARN([
*** Can't check for macro redefinability when cross-compiling.]))
AS_IF([test "x$enable_libmagic" != "xno"], [
AC_CHECK_HEADERS([magic.h])
AC_CHECK_LIB(magic, magic_open)
AC_CHECK_HEADERS([zlib.h])
AC_CHECK_LIB(z, inflate)
AC_CHECK_HEADERS([magic.h])
AC_CHECK_LIB(magic, magic_open)
AC_CHECK_HEADERS([zlib.h])
AC_CHECK_LIB(z, inflate)
])
# Check for groff html support.
@@ -719,8 +538,8 @@ groff -t -mandoc -Thtml </dev/null >/dev/null
if test $? -ne 0 ; then
AC_MSG_RESULT([no])
AC_MSG_WARN([
*** Will not generate HTML version of man pages. ***
*** Consider installing a newer version of groff with HTML support. ***])
*** Will not generate HTML version of man pages. Consider
*** installing a newer version of groff with HTML support.])
groff_html_support=no
else
AC_MSG_RESULT([yes])

View File

@@ -79,14 +79,14 @@
<table><tbody>
<tr><td>Ctrl+B &nbsp;&nbsp;</td><td>One character backward</td></tr>
<tr><td>Ctrl+F</td><td>One character forward</td></tr>
<tr><td>Ctrl+<b>&leftarrow;</b></td><td>One word backward</td></tr>
<tr><td>Ctrl+<b>&rightarrow;</b></td><td>One word forward</td></tr>
<tr><td>Ctrl+<b>&larr;</b></td><td>One word backward</td></tr>
<tr><td>Ctrl+<b>&rarr;</b></td><td>One word forward</td></tr>
<tr><td>Ctrl+A</td><td>To start of line</td></tr>
<tr><td>Ctrl+E</td><td>To end of line</td></tr>
<tr><td>Ctrl+P</td><td>One line up</td></tr>
<tr><td>Ctrl+N</td><td>One line down</td></tr>
<tr><td>Ctrl+<b>&uparrow;</b></td><td>To previous block</td></tr>
<tr><td>Ctrl+<b>&downarrow;</b></td><td>To next block</td></tr>
<tr><td>Ctrl+<b>&uarr;</b></td><td>To previous block</td></tr>
<tr><td>Ctrl+<b>&darr;</b></td><td>To next block</td></tr>
<tr><td>Ctrl+Y</td><td>One page up</td></tr>
<tr><td>Ctrl+V</td><td>One page down</td></tr>
<tr><td>Alt+\</td><td>To top of buffer</td></tr>
@@ -98,8 +98,8 @@
<table><tbody>
<tr><td>Alt+G &nbsp;&nbsp;&nbsp;</td><td>Go to specified line</td></tr>
<tr><td>Alt+]</td><td>Go to complementary bracket</td></tr>
<tr><td>Alt+<b>&uparrow;</b></td><td>Scroll viewport up</td></tr>
<tr><td>Alt+<b>&downarrow;</b></td><td>Scroll viewport down</td></tr>
<tr><td>Alt+<b>&uarr;</b></td><td>Scroll viewport up</td></tr>
<tr><td>Alt+<b>&darr;</b></td><td>Scroll viewport down</td></tr>
<tr><td>Alt+&lt;</td><td>Switch to preceding buffer</td></tr>
<tr><td>Alt+&gt;</td><td>Switch to succeeding buffer</td></tr>
</tbody></table>
@@ -108,7 +108,7 @@
<b>Information</b>
<table><tbody>
<tr><td>Ctrl+C &nbsp;&nbsp;</td><td>Report cursor position</td></tr>
<tr><td>Alt+D</td><td>Report word/line/char count</td></tr>
<tr><td>Alt+D</td><td>Report line/word/character count</td></tr>
<tr><td>Ctrl+G</td><td>Display help text</td></tr>
</tbody></table>
<br>

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.2</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

@@ -1,4 +1,4 @@
.\" Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc.
.\" Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc.
.\"
.\" This document is dual-licensed. You may distribute and/or modify it
.\" under the terms of either of the following licenses:
@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 5.2" "August 2020"
.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.
@@ -165,7 +166,7 @@ and place it at that position again upon reopening such a file.
.TP
.BR "\-Q ""\fIregex\fB""" ", " "\-\-quotestr=""" \fIregex """
Set the regular expression for matching the quoting part of a line.
The default value is \fB"^([\ \\t]*([!#%:;>|}]|//))+"\fP.
The default value is "\fB^([\ \\t]*([!#%:;>|}]|//))+\fR".
(Note that \fB\\t\fP stands for an actual Tab.)
This makes it possible to rejustify blocks of quoted text when composing
email, and to rewrap blocks of line comments when writing source code.
@@ -187,12 +188,12 @@ the screen's edge, by using also \fB\-\-atblanks\fR.)
.TP
.BR \-T\ \fInumber ", " \-\-tabsize= \fInumber
Set the size (width) of a tab to \fInumber\fP columns. The value of
\fInumber\fP must be greater than 0. The default value is 8.
\fInumber\fR must be greater than 0. The default value is \fB8\fR.
.TP
.BR \-U ", " \-\-quickblank
Do quick status-bar blanking: status-bar messages will disappear after 1
keystroke instead of 25. Note that option \fB\-c\fR (\fB\-\-constantshow\fR)
overrides this.
Make status-bar messages disappear after 1 keystroke instead of after 20.
Note that options \fB\-c\fR (\fB\-\-constantshow\fR)
and \fB\-_\fR (\fB\-\-minibar\fR) override this.
.TP
.BR \-V ", " \-\-version
Show the current version number and exit.
@@ -295,11 +296,11 @@ Set the target width for justifying and automatic hard-wrapping at this
\fInumber\fR of columns. If the value is 0 or less, wrapping will occur
at the width of the screen minus \fInumber\fR columns, allowing the wrap
point to vary along with the width of the screen if the screen is resized.
The default value is \-8.
The default value is \fB\-8\fR.
.TP
.B "\-s ""\fIprogram\fR [\fIargument \fR...]\fB""\fR, \fB\-\-speller=""\fIprogram\fR [\fIargument \fR...]\fB"""
Use this command to perform spell checking and correcting, instead of
using the built-in corrector that calls \fBhunspell\fR or GNU \fBspell\fR.
using the built-in corrector that calls \fBhunspell\fR(1) or \fBspell\fR(1).
.TP
.BR \-t ", " \-\-saveonexit
Save a changed buffer without prompting (when exiting with \fB^X\fR).
@@ -319,7 +320,6 @@ unless \fB\-\-restricted\fR is given too.
Do not automatically hard-wrap the current line when it becomes overlong.
This is the default. (This option is the opposite of \fB\-b\fR
(\fB\-\-breaklonglines\fR) -- the last one given takes effect.)
.TP
.BR \-x ", " \-\-nohelp
Don't show the two help lines at the bottom of the screen.
@@ -329,6 +329,35 @@ Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
.TP
.BR \-z ", " \-\-suspendable
Allow the user to suspend the editor (with \fB^Z\fR by default).
.TP
.BR \-% ", " \-\-stateflags
Use the top-right corner of the screen for showing some state flags:
\fBI\fR when auto-indenting, \fBM\fR when the mark is on, \fBL\fR when
hard-wrapping (breaking long lines), \fBR\fR when recording a macro,
and \fBS\fR when soft-wrapping.
When the buffer is modified, a star (\fB*\fR) is shown after the
filename in the center of the title bar.
.TP
.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 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 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
\fB\-\-constantshow\fR is used, and can be toggled on and off with \fBM-C\fR.
The state flags are displayed only when \fB\-\-stateflags\fR is used.
.TP
.BR \-! ", " \-\-magic
When neither the file's name nor its first line give a clue,
try using libmagic to determine the applicable syntax.
.SH TOGGLES
Several of the above options can be switched on and off also while
@@ -351,6 +380,9 @@ exists), either \fI~/.nanorc\fR or \fI$XDG_CONFIG_HOME/nano/nanorc\fR
or \fI~/.config/nano/nanorc\fR, whichever is encountered first. See
.BR nanorc (5)
for more information on the possible contents of those files.
.sp
See \fI/usr/share/nano/\fR and \fI/usr/share/nano/extra/\fR
for available syntax-coloring definitions.
.SH NOTES
If no alternative spell checker command is specified on the command

View File

@@ -7,9 +7,9 @@
@documentencoding UTF-8
@smallbook
@set EDITION 0.5
@set VERSION 5.2
@set UPDATED August 2020
@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.2
@subtitle version 5.9
@author Chris Allegretta
@page
@@ -33,7 +33,7 @@ This manual documents the GNU @command{nano} editor.
This manual is part of the GNU @command{nano} distribution.@*
@sp 4
Copyright @copyright{} 1999-2009, 2014-2020 Free Software Foundation, Inc.
Copyright @copyright{} 1999-2009, 2014-2021 Free Software Foundation, Inc.
@sp 1
This document is dual-licensed. You may distribute and/or modify it
@@ -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.2.
This manual documents the GNU @command{nano} editor, version 5.9.
@menu
* Introduction::
@@ -99,14 +101,14 @@ Pico differ.
Starting with version 4.0, @command{nano} no longer hard-wraps an overlong
line by default. It further uses linewise scrolling by default, and by
default includes the line below the title bar into the editing area.
If you want the old, Pico behavior back, you can use the
following options: @option{--breaklonglines},
@option{--jumpyscrolling}, and @option{--emptyline}
(or @option{-bje} for short).
(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
@chapter 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
@@ -252,7 +255,7 @@ and place it at that position again upon reopening such a file.
@item -Q "@var{regex}"
@itemx --quotestr="@var{regex}"
Set the regular expression for matching the quoting part of a line.
The default value is @t{"^([@w{ }\t]*([!#%:;>|@}]|//))+"}.
The default value is "@t{^([@w{ }\t]*([!#%:;>|@}]|//))+}".
(Note that @code{\t} stands for a literal Tab character.)
This makes it possible to rejustify blocks of quoted text when composing
email, and to rewrap blocks of line comments when writing source code.
@@ -281,9 +284,9 @@ Set the displayed tab length to @var{number} columns. The value of
@item -U
@itemx --quickblank
Do quick status-bar blanking: status-bar messages will disappear after 1
keystroke instead of 25. Note that option @option{-c}
(@option{--constantshow}) overrides this.
Make status-bar messages disappear after 1 keystroke instead of after 20.
Note that options @option{-c} (@option{--constantshow})
and @option{-_} (@option{--minibar}) override this.
@item -V
@itemx --version
@@ -468,6 +471,38 @@ Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
Enable the ability to suspend @command{nano} using the system's suspend
keystroke (usually @kbd{^Z}).
@item -%
@itemx --stateflags
Use the top-right corner of the screen for showing some state flags:
@code{I} when auto-indenting, @code{M} when the mark is on, @code{L} when
hard-wrapping (breaking long lines), @code{R} when recording a macro,
and @code{S} when soft-wrapping.
When the buffer is modified, a star (@code{*}) is shown after the
filename in the center of the title bar.
@item -_
@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 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 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{--constantshow} is used, and can be toggled on and off with @key{M-C}.
The state flags are displayed only when @code{--stateflags} is used.
@item -!
@itemx --magic
When neither the file's name nor its first line give a clue,
try using libmagic to determine the applicable syntax.
@end table
@@ -537,35 +572,34 @@ and then pressing the desired key.
@node The Cutbuffer
@section The Cutbuffer
Text can be cut from a file, a whole line at a time, by using the 'Cut Text'
command (default key binding: @kbd{^K}). The cut line is stored in
the cutbuffer. Consecutive strokes of @kbd{^K} will add each cut line
to this buffer, but a @kbd{^K}
Text can be cut from a file a whole line at a time with @kbd{^K}.
The cut line is stored in the cutbuffer. Consecutive strokes of @kbd{^K}
will add each cut line to this buffer, but a @kbd{^K}
after any other keystroke will overwrite the entire cutbuffer.
The contents of the cutbuffer can be pasted back into the file with the
'Uncut Text' command (default key binding: @kbd{^U}).
The contents of the cutbuffer can be pasted at the current cursor position
with @kbd{^U}.
A line of text can be copied into the cutbuffer (without cutting it) with
the 'Copy Text' command (default key binding: @kbd{M-6}).
A line of text can be copied into the cutbuffer (without cutting it)
with @kbd{M-6}.
@node The Mark
@section The Mark
Text can be selected by first 'setting the Mark' (default key bindings:
@kbd{^6} and @kbd{M-A}) and then moving the cursor to the other end of the portion
Text can be selected by first 'setting the Mark' with @kbd{^6}
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}
key too will increase the stride. Such a selection is cancelled
upon any cursor movement where @kbd{Shift} isn't held.
Cutting or copying selected text will toggle the mark off automatically.
If necessary, it can be toggled off manually with another @kbd{^6} or @kbd{M-A}.
Cutting or copying selected text toggles off the mark automatically.
If needed, it can be toggled off manually with another @kbd{^6} or @kbd{M-A}.
@node Screen Layout
@section Screen Layout
@@ -805,7 +839,7 @@ Set the characters treated as closing brackets when justifying
paragraphs. This may not include blank characters. Only closing
punctuation (see @code{set punct}), optionally followed by the specified
closing brackets, can end sentences. The default value is
@t{""')>]@}"}.
"@t{"')>]@}}".
@item set breaklonglines
Automatically hard-wrap the current line when it becomes overlong.
@@ -825,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}
@@ -845,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:
@@ -865,6 +901,11 @@ text. (The color of the stripe can be changed with @code{set stripecolor}.)
Save the last hundred search strings and replacement strings and
executed commands, so they can be easily reused in later sessions.
@item set indicator
Display a "scrollbar" on the righthand side of the edit window.
It shows the position of the viewport in the buffer
and how much of the buffer is covered by the viewport.
@item set jumpyscrolling
Scroll the buffer contents per half-screen instead of per line.
@@ -880,16 +921,40 @@ Display line numbers to the left of the text area.
@item set locking
Enable vim-style lock-files for when editing files.
@item set magic
When neither the file's name nor its first line give a clue,
try using libmagic to determine the applicable syntax.
(Calling libmagic can be relatively time consuming.
It is therefore not done by default.)
@anchor{@code{set matchbrackets}}
@item set matchbrackets "@var{characters}"
Specify the opening and closing brackets that can be found by bracket
searches. This may not include blank characters. The opening set must
come before the closing set, and the two sets must be in the same order.
The default value is @t{"(<[@{)>]@}"}.
The default value is "@t{(<[@{)>]@}}".
@item set morespace
Deprecated option since it has become the default setting.
When needed, use @code{unset emptyline} instead.
@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 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 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
@@ -908,9 +973,6 @@ Don't display the help lists at the bottom of the screen.
Don't automatically add a newline when a text does not end with one.
(This can cause you to save non-POSIX text files.)
@item set nopauses
Obsolete option. Ignored.
@item set nowrap
Deprecated option since it has become the default setting.
When needed, use @code{unset breaklonglines} instead.
@@ -932,25 +994,25 @@ The cursor position is remembered for the 200 most-recently edited files.
@item set preserve
Preserve the XON and XOFF keys (@kbd{^Q} and @kbd{^S}).
@item set indicator
Display a "scrollbar" on the righthand side of the edit window.
It shows the position of the viewport in the buffer
and how much of the buffer is covered by the viewport.
@item set promptcolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
Use this color combination for the prompt bar.
(When this option is not specified, the colors of the title bar are used.)
@xref{@code{set functioncolor}} for valid color names.
@item set punct "@var{characters}"
Set the characters treated as closing punctuation when justifying
paragraphs. This may not include blank characters. Only the
specified closing punctuation, optionally followed by closing brackets
(see @code{set brackets}), can end sentences.
The default value is @t{"!.?"}.
The default value is "@t{!.?}".
@item set quickblank
Do quick status-bar blanking: status-bar messages will disappear after 1
keystroke instead of 25. Note that @option{constantshow} overrides this.
Make status-bar messages disappear after 1 keystroke instead of after 20.
Note that options @option{constantshow} and @option{minibar} override this.
@item set quotestr "@var{regex}"
Set the regular expression for matching the quoting part of a line.
The default value is @t{"^([@w{ }\t]*([!#%:;>|@}]|//))+"}.
The default value is "@t{^([@w{ }\t]*([!#%:;>|@}]|//))+}".
(Note that @code{\t} stands for a literal Tab character.)
This makes it possible to rejustify blocks of quoted text when composing
email, and to rewrap blocks of line comments when writing source code.
@@ -974,6 +1036,12 @@ Regular expressions in @command{nano} are of the extended type (ERE).
Save a changed buffer automatically on exit (@kbd{^X}); don't prompt.
(The old form of this option, @code{set tempfile}, is deprecated.)
@item set scrollercolor @var{fgcolor},@var{bgcolor}
Use this color combination for the indicator alias "scrollbar".
(On terminal emulators that link to a libvte older than version 0.55,
using a background color here does not work correctly.)
@xref{@code{set functioncolor}} for valid color names.
@item set selectedcolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
Use this color combination for selected text.
@xref{@code{set functioncolor}} for valid color names.
@@ -990,10 +1058,6 @@ 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.
@item set smooth
Deprecated option since it has become the default setting.
When needed, use @code{unset jumpyscrolling} instead.
@item set softwrap
Display lines that exceed the screen's width over multiple screen lines.
(You can make this soft-wrapping occur at whitespace instead of rudely at
@@ -1003,6 +1067,19 @@ the screen's edge, by using also @code{set atblanks}.)
Use the given program to do spell checking and correcting.
@xref{@option{--speller}} for details.
@item set spotlightcolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
Use this color combination for highlighting a search match.
The default value is @t{black,lightyellow}.
@xref{@code{set functioncolor}} for valid color names.
@item set stateflags
Use the top-right corner of the screen for showing some state flags:
@code{I} when auto-indenting, @code{M} when the mark is on, @code{L} when
hard-wrapping (breaking long lines), @code{R} when recording a macro,
and @code{S} when soft-wrapping.
When the buffer is modified, a star (@code{*}) is shown after the
filename in the center of the title bar.
@item set statuscolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
Use this color combination for the status bar.
@xref{@code{set functioncolor}} for valid color names.
@@ -1019,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.
@@ -1034,11 +1112,6 @@ Save a file by default in Unix format. This overrides nano's
default behavior of saving a file in the format that it had.
(This option has no effect when you also use @code{set noconvert}.)
@item set view
Disallow file modification: read-only mode.
This mode allows the user to open also other files for viewing,
unless @option{--restricted} is given on the command line.
@anchor{Whitespace}
@item set whitespace "@var{characters}"
Set the two characters used to indicate the presence of tabs and
@@ -1070,6 +1143,9 @@ powerful enough to fully parse a file. Nevertheless, regular
expressions can do a lot and are easy to make, so they are a
good fit for a small editor like @command{nano}.
See @file{/usr/share/nano/} and @file{/usr/share/nano/extra/}
for the syntax-coloring definitions that are available out of the box.
All regular expressions in @command{nano} are POSIX extended regular expressions
(ERE). This means that @code{.}, @code{?}, @code{*}, @code{+}, @code{^},
@code{$}, and several other characters are special.
@@ -1137,7 +1213,7 @@ characters after the pipe are appended at the end of the line. If no pipe
character is present, the full string is prepended; for example, @t{"#"} for
Python files. If empty double quotes are specified, the comment/uncomment
functions are disabled; for example, @t{""} for JSON.
The default value is @t{"#"}.
The default value is "@t{#}".
@item tabgives "@var{string}"
Make the <Tab> key produce the given @var{string}. Useful for languages like
@@ -1338,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
@@ -1356,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).
@@ -1393,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.
@@ -1600,8 +1682,9 @@ is the beginning of a paragraph.
Toggles whether cutting text will cut the whole line or just from the current cursor
position to the end of the line.
@item nowrap
@item breaklonglines
Toggles whether long lines will be hard-wrapped to the next line.
(The old name of this function, 'nowrap', is deprecated.)
@item tabstospaces
Toggles whether typed tabs will be converted to spaces.
@@ -1884,8 +1967,8 @@ Exclude Native Language support. This will disable the use of any
available GNU @command{nano} translations.
@item --enable-utf8
Include support for reading and writing Unicode files. This will require
either a wide version of curses, or a UTF-8-enabled version of Slang.
Include support for reading and writing Unicode files.
This requires a wide version of the curses library.
@item --disable-utf8
Exclude support for reading and writing Unicode files. Normally the
@@ -1896,10 +1979,6 @@ You can use this or the previous option to override that detection.
Use the file with the given @var{name} (in the user's home directory)
as nano's settings file, instead of the default @code{.nanorc}.
@item --with-slang
Compile @command{nano} against Slang instead of against ncurses or other
curses libraries.
@end table
@html

View File

@@ -1,4 +1,4 @@
.\" Copyright (C) 2003-2011, 2013-2020 Free Software Foundation, Inc.
.\" Copyright (C) 2003-2011, 2013-2021 Free Software Foundation, Inc.
.\"
.\" This document is dual-licensed. You may distribute and/or modify it
.\" under the terms of either of the following licenses:
@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 5.2" "August 2020"
.TH NANORC 5 "version 5.9" "October 2021"
.SH NAME
nanorc \- GNU nano's configuration file
@@ -65,7 +65,6 @@ Quotes inside the \fIcharacters\fR parameters below should not be escaped.
The last double quote on the line will be seen as the closing quote.
.sp
The supported commands and arguments are:
.TP 3
.B set afterends
Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
@@ -108,7 +107,7 @@ beginning of a paragraph (unless auto-indenting is on).
Set the characters treated as closing brackets when justifying
paragraphs. This may not include blank characters. Only closing
punctuation (see \fBset punct\fP), optionally followed by the specified
closing brackets, can end sentences. The default value is "\fB"')>]}\fP".
closing brackets, can end sentences. The default value is "\fB\(dq')>]}\fR".
.TP
.B set breaklonglines
Automatically hard-wrap the current line when it becomes overlong.
@@ -128,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
@@ -139,7 +138,7 @@ point to vary along with the width of the screen if the screen is resized.
The default value is \fB\-8\fR.
.TP
.B set functioncolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for the function descriptions
Use this color combination for the concise function descriptions
in the two help lines at the bottom of the screen.
See \fBset titlecolor\fR for more details.
.TP
@@ -160,7 +159,7 @@ and how much of the buffer is covered by the viewport.
Scroll the buffer contents per half-screen instead of per line.
.TP
.B set keycolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for the shortcut key combos
Use this color combination for the shortcut key combos
in the two help lines at the bottom of the screen.
See \fBset titlecolor\fR for more details.
.TP
@@ -171,15 +170,39 @@ Display line numbers to the left of the text area.
.B set locking
Enable vim-style lock-files for when editing files.
.TP
.B set magic
When neither the file's name nor its first line give a clue,
try using libmagic to determine the applicable syntax.
(Calling libmagic can be relatively time consuming.
It is therefore not done by default.)
.TP
.BI "set matchbrackets """ characters """
Specify the opening and closing brackets that can be found by bracket
searches. This may not include blank characters. The opening set must
come before the closing set, and the two sets must be in the same order.
The default value is "\fB(<[{)>]}\fP".
.TP
.B set morespace
Deprecated option since it has become the default setting.
When needed, use \fBunset emptyline\fR instead.
.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 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 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
@@ -201,15 +224,12 @@ Don't display the two help lines at the bottom of the screen.
Don't automatically add a newline when a text does not end with one.
(This can cause you to save non-POSIX text files.)
.TP
.B set nopauses
Obsolete option. Ignored.
.TP
.B set nowrap
Deprecated option since it has become the default setting.
When needed, use \fBunset breaklonglines\fR instead.
.TP
.B set numbercolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for line numbers.
Use this color combination for line numbers.
See \fBset titlecolor\fR for more details.
.TP
.B set operatingdir "\fIdirectory\fP"
@@ -225,6 +245,11 @@ The cursor position is remembered for the 200 most-recently edited files.
.B set preserve
Preserve the XON and XOFF keys (\fB^Q\fR and \fB^S\fR).
.TP
.B set promptcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the prompt bar.
(When this option is not specified, the colors of the title bar are used.)
See \fBset titlecolor\fR for more details.
.TP
.BI "set punct """ characters """
Set the characters treated as closing punctuation when justifying
paragraphs. This may not include blank characters. Only the
@@ -232,8 +257,8 @@ specfified closing punctuation, optionally followed by closing brackets
(see \fBbrackets\fP), can end sentences. The default value is "\fB!.?\fP".
.TP
.B set quickblank
Do quick status-bar blanking: status-bar messages will disappear after 1
keystroke instead of 25. The option \fBconstantshow\fR overrides this.
Make status-bar messages disappear after 1 keystroke instead of after 20.
Note that options \fBconstantshow\fR and \fBminibar\fR override this.
.TP
.BI "set quotestr """ regex """
Set the regular expression for matching the quoting part of a line.
@@ -261,13 +286,20 @@ Regular expressions in \fBnano\fR are of the extended type (ERE).
Save a changed buffer automatically on exit (\fB^X\fR); don't prompt.
(The old form of this option, \fBset tempfile\fR, is deprecated.)
.TP
.B set scrollercolor \fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the indicator alias "scrollbar".
(On terminal emulators that link to a libvte older than version 0.55,
using a background color here does not work correctly.)
See \fBset titlecolor\fR for more details.
.TP
.B set selectedcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for selected text.
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
@@ -276,10 +308,6 @@ 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.
.TP
.B set smooth
Deprecated option since it has become the default setting.
When needed, use \fBunset jumpyscrolling\fR instead.
.TP
.B set softwrap
Display lines that exceed the screen's width over multiple screen lines.
(You can make this soft-wrapping occur at whitespace instead of rudely at
@@ -287,14 +315,27 @@ the screen's edge, by using also \fBset atblanks\fR.)
.TP
.B set speller """\fIprogram\fR [\fIargument \fR...]\fB"""
Use the given \fIprogram\fR to do spell checking and correcting, instead of
using the built-in corrector that calls \fBhunspell\fR or GNU \fBspell\fR.
using the built-in corrector that calls \fBhunspell\fR(1) or \fBspell\fR(1).
.TP
.B set spotlightcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for highlighting a search match.
The default value is \fBblack,lightyellow\fR.
See \fBset titlecolor\fR for valid color names.
.TP
.B set stateflags
Use the top-right corner of the screen for showing some state flags:
\fBI\fR when auto-indenting, \fBM\fR when the mark is on, \fBL\fR when
hard-wrapping (breaking long lines), \fBR\fR when recording a macro,
and \fBS\fR when soft-wrapping.
When the buffer is modified, a star (\fB*\fR) is shown after the
filename in the center of the title bar.
.TP
.B set statuscolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for the status bar.
Use this color combination for the status bar.
See \fBset titlecolor\fR for more details.
.TP
.B set stripecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for the vertical guiding stripe.
Use this color combination for the vertical guiding stripe.
See \fBset titlecolor\fR for more details.
.TP
.B set suspendable
@@ -305,15 +346,18 @@ 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
Specify the color combination to use for the title bar.
Use this color combination for the title bar.
Valid names for the foreground and background colors are:
.BR red ", " green ", " blue ", " magenta ", " yellow ", " cyan ", "
.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 ", "
@@ -333,11 +377,6 @@ Save a file by default in Unix format. This overrides nano's
default behavior of saving a file in the format that it had.
(This option has no effect when you also use \fBset noconvert\fR.)
.TP
.B set view
Disallow file modification: read-only mode.
This mode allows the user to open also other files for viewing,
unless \fB\-\-restricted\fR is given on the command line.
.TP
.BI "set whitespace """ characters """
Set the two characters used to indicate the presence of tabs and
spaces. They must be single-column characters. The default pair
@@ -386,13 +425,13 @@ Start the definition of a syntax with this \fIname\fR.
All subsequent \fBcolor\fR and other such commands
will be added to this syntax, until a new \fBsyntax\fR
command is encountered.
.sp
When \fBnano\fR is run, this syntax will be automatically
activated if the current filename matches the extended regular
expression \fIfileregex\fR. Or the syntax can be explicitly
activated by using the \fB\-Y\fR or \fB\-\-syntax\fR
command-line option followed by the \fIname\fR.
.sp
The syntax \fBdefault\fP is special: it takes no \fIfileregex\fR,
and applies to files that don't match any syntax's regexes.
The syntax \fBnone\fP is reserved; specifying it on the command line
@@ -529,11 +568,10 @@ no longer be the case, for all letters.
where \fIN\fR is a numeric value from 1 to 24.
Example: F10.
(Often, \fBF13\fR to \fBF24\fR can be typed as \fBF1\fR to \fBF12\fR with Shift.)
.TP
.BR Ins " or " Del .
.RE
.sp
Rebinding \fB^M\fR (Enter) or \fB^I\fR (Tab) is probably not a good idea.
Rebinding \fB^[\fR (Esc) is not possible, because its keycode
is the starter byte of Meta keystrokes and escape sequences.
@@ -619,15 +657,16 @@ 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
into the current buffer (or into a new buffer when \fBM-F\fR is toggled).
.TP
.B speller
Invokes a spell-checking program, either the default \fBhunspell\fR or GNU
\fBspell\fR, or the one defined by \fB\-\-speller\fR or \fBset speller\fR.
Invokes a spell-checking program, either the default \fBhunspell\fR(1) or GNU
\fBspell\fR(1), or the one defined by \fB\-\-speller\fR or \fBset speller\fR.
.TP
.B formatter
Invokes a full-buffer-processing program (if the active syntax defines one).
@@ -636,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).
@@ -673,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.
@@ -880,8 +925,9 @@ is the beginning of a paragraph.
Toggles whether cutting text will cut the whole line or just from the current cursor
position to the end of the line.
.TP
.B nowrap
.B breaklonglines
Toggles whether long lines will be hard-wrapped to the next line.
(The old name of this function, 'nowrap', is deprecated.)
.TP
.B tabstospaces
Toggles whether typed tabs will be converted to spaces.
@@ -961,6 +1007,13 @@ System-wide configuration file.
.TP
.IR ~/.nanorc " or " $XDG_CONFIG_HOME/nano/nanorc " or " ~/.config/nano/nanorc
Per-user configuration file.
.TP
.I /usr/share/nano/*
Syntax definitions for the syntax coloring of common file types
(and for less common file types in the \fIextra/\fR subdirectory).
.SH SEE ALSO
.BR nano (1)
.TP
.I https://nano-editor.org/cheatsheet.html
An overview of the default key bindings.

View File

@@ -1,4 +1,4 @@
.\" Copyright (C) 2002-2007, 2014-2020 Free Software Foundation, Inc.
.\" Copyright (C) 2002-2007, 2014-2021 Free Software Foundation, Inc.
.\"
.\" This document is dual-licensed. You may distribute and/or modify it
.\" under the terms of either of the following licenses:
@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH RNANO 1 "version 5.2" "August 2020"
.TH RNANO 1 "version 5.9" "October 2021"
.SH NAME
rnano \- a restricted nano

View File

@@ -44,8 +44,7 @@
## Do case-sensitive searches by default.
# set casesensitive
## Constantly display the cursor position in the status bar. Note that
## this overrides "quickblank".
## Constantly display the cursor position in the status bar or minibar.
# set constantshow
## Use cut-from-cursor-to-end-of-line by default.
@@ -76,15 +75,22 @@
## no plans to implement vim-style undo state in these files.
# set locking
## 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.
## Fall back to slow libmagic to try and determine an applicable syntax.
# set magic
## 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 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
@@ -112,14 +118,12 @@
## 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 "!.?"
## Do quick status-bar blanking. Status-bar messages will disappear after
## 1 keystroke instead of 26. Note that "constantshow" overrides this.
## Make status-bar messages disappear after 1 keystroke instead of after 20.
# set quickblank
## The regular expression that matches quoting characters in email
@@ -140,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.
@@ -159,6 +163,10 @@
## does not have a default value.
# set speller "aspell -x -c"
## Use the end of the title bar for some state flags: I = auto-indenting,
## M = mark, L = hard-wrapping long lines, R = recording, S = soft-wrapping.
# set stateflags
## Allow nano to be suspended (with ^Z by default).
# set suspendable
## (The old form of this option, 'set suspend', is deprecated.)
@@ -166,15 +174,12 @@
## 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.
# set trimblanks
## Disallow file modification. Why would you want this in an rcfile? ;)
# set view
## The two single-column characters used to display the first characters
## of tabs and spaces. 187 in ISO 8859-1 (0000BB in Unicode) and 183 in
## ISO-8859-1 (0000B7 in Unicode) seem to be good values for these.
@@ -196,22 +201,30 @@
## of a single character, and without affecting the cutbuffer).
# set zap
## Paint the interface elements of nano. These are examples;
## by default there are no colors, except for errorcolor.
# set titlecolor bold,lightwhite,blue
# set statuscolor bold,lightwhite,green
# set errorcolor bold,lightwhite,red
## Paint the interface elements of nano. These are examples; there are
## no colors by default, except for errorcolor and spotlightcolor.
# 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
# set numbercolor cyan
# set keycolor cyan
# set functioncolor green
## In root's .nanorc you might want to use:
# set titlecolor bold,lightwhite,magenta
# set statuscolor bold,lightwhite,magenta
# set errorcolor bold,lightwhite,red
# set titlecolor bold,white,magenta
# set promptcolor black,yellow
# set statuscolor bold,white,magenta
# set errorcolor bold,white,red
# set spotlightcolor black,orange
# set selectedcolor lightwhite,cyan
# set stripecolor ,yellow
# set scrollercolor magenta
# set numbercolor magenta
# set keycolor lightmagenta
# set functioncolor magenta
@@ -220,7 +233,7 @@
## === Syntax coloring ===
## For all details, see 'man nanorc', section SYNTAX HIGHLIGHTING.
## To include all existing syntax definitions, you can do:
## To include most of the existing syntax definitions, you can do:
# include "@PKGDATADIR@/*.nanorc"
## Or you can select just the ones you need. For example:
@@ -229,7 +242,8 @@
# include "@PKGDATADIR@/sh.nanorc"
## In @PKGDATADIR@/extra/ you can find some syntaxes that are
## specific for certain distros or for less common languages.
## specific for certain distros or for some less common languages.
## If <Tab> should always produce four spaces when editing a Python file,
## independent of the settings of 'tabsize' and 'tabstospaces':
@@ -251,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",
@@ -265,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
@@ -279,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

1352
po/bg.po

File diff suppressed because it is too large Load Diff

1396
po/ca.po

File diff suppressed because it is too large Load Diff

1368
po/cs.po

File diff suppressed because it is too large Load Diff

1464
po/da.po

File diff suppressed because it is too large Load Diff

1377
po/de.po

File diff suppressed because it is too large Load Diff

1373
po/eo.po

File diff suppressed because it is too large Load Diff

1369
po/es.po

File diff suppressed because it is too large Load Diff

1358
po/eu.po

File diff suppressed because it is too large Load Diff

1352
po/fi.po

File diff suppressed because it is too large Load Diff

1400
po/fr.po

File diff suppressed because it is too large Load Diff

1383
po/ga.po

File diff suppressed because it is too large Load Diff

1989
po/gl.po

File diff suppressed because it is too large Load Diff

1615
po/hr.po

File diff suppressed because it is too large Load Diff

1362
po/hu.po

File diff suppressed because it is too large Load Diff

2462
po/id.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1362
po/it.po

File diff suppressed because it is too large Load Diff

1370
po/ja.po

File diff suppressed because it is too large Load Diff

1377
po/ko.po

File diff suppressed because it is too large Load Diff

1461
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1490
po/nb.po

File diff suppressed because it is too large Load Diff

1373
po/nl.po

File diff suppressed because it is too large Load Diff

1609
po/pl.po

File diff suppressed because it is too large Load Diff

1407
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1735
po/ro.po

File diff suppressed because it is too large Load Diff

2320
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

1362
po/sl.po

File diff suppressed because it is too large Load Diff

1541
po/sr.po

File diff suppressed because it is too large Load Diff

1509
po/sv.po

File diff suppressed because it is too large Load Diff

1373
po/tr.po

File diff suppressed because it is too large Load Diff

1378
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 "^??")
@@ -26,6 +29,11 @@ for pofile in *.po; do
msgattrib --no-obsolete --no-fuzzy $pofile >trimmed.po || exit 4
mv trimmed.po $pofile || exit 4
done
echo
if grep "[[:cntrl:]]" ./*.po; then
echo "*** PO file contains control character"; exit 5;
fi
# If needed, fix a problem in the Makefile template.
grep -q '^datarootdir' Makefile.in.in || \

1358
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.2"
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

@@ -6,7 +6,7 @@ CLEANFILES = revision.h
if BUILDING_FROM_GIT
SOMETHING = "REVISION \"`git describe --tags 2>/dev/null`\""
else
SOMETHING = "NOTHING \"from tarball\""
SOMETHING = "PLAINBUILD \"from tarball\""
endif
nano.o: revision.h

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* browser.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2015-2016 Benno Schulenberg *
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2015-2016, 2020 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 *
@@ -30,7 +30,7 @@
static char **filelist = NULL;
/* The list of files to display in the file browser. */
static size_t filelist_len = 0;
static size_t list_length = 0;
/* The number of files in the list. */
static size_t width = 0;
/* The number of files that we can display per screen row. */
@@ -39,6 +39,373 @@ static size_t longest = 0;
static size_t selected = 0;
/* The currently selected filename in the list; zero-based. */
/* Set filelist to the list of files contained in the directory path,
* set list_length to the number of files in that list, set longest to
* the width in columns of the longest filename in that list (between 15
* and COLS), and set width to the number of files that we can display
* per screen row. And sort the list too. */
void read_the_list(const char *path, DIR *dir)
{
size_t path_len = strlen(path), index = 0;
const struct dirent *nextdir;
longest = 0;
/* Find the length of the longest filename in the current folder. */
while ((nextdir = readdir(dir)) != NULL) {
size_t name_len = breadth(nextdir->d_name);
if (name_len > longest)
longest = name_len;
index++;
}
/* Put 10 characters' worth of blank space between columns of filenames
* in the list whenever possible, as Pico does. */
longest += 10;
/* If needed, make room for ".. (parent dir)". */
if (longest < 15)
longest = 15;
/* Make sure we're not wider than the window. */
if (longest > COLS)
longest = COLS;
rewinddir(dir);
free_chararray(filelist, list_length);
list_length = index;
index = 0;
filelist = nmalloc(list_length * sizeof(char *));
while ((nextdir = readdir(dir)) != NULL && index < list_length) {
/* Don't show the "." entry. */
if (strcmp(nextdir->d_name, ".") == 0)
continue;
filelist[index] = nmalloc(path_len + strlen(nextdir->d_name) + 1);
sprintf(filelist[index], "%s%s", path, nextdir->d_name);
index++;
}
/* Maybe the number of files in the directory decreased between the
* first time we scanned and the second time. index is the actual
* length of the file list, so record it. */
list_length = index;
/* Sort the list of names. */
qsort(filelist, list_length, sizeof(char *), diralphasort);
/* Calculate how many files fit on a line -- feigning room for two
* spaces beyond the right edge, and adding two spaces of padding
* between columns. */
width = (COLS + 2) / (longest + 2);
}
/* Look for needle. If we find it, set selected to its location.
* Note that needle must be an exact match for a file in the list. */
void browser_select_dirname(const char *needle)
{
size_t looking_at = 0;
for (; looking_at < list_length; looking_at++) {
if (strcmp(filelist[looking_at], needle) == 0) {
selected = looking_at;
break;
}
}
/* If the sought name isn't found, move the highlight so that the
* changed selection will be noticed. */
if (looking_at == list_length) {
--selected;
/* Make sure we stay within the available range. */
if (selected >= list_length)
selected = list_length - 1;
}
}
/* Display at most a screenful of filenames from the gleaned filelist. */
void browser_refresh(void)
{
int row = 0, col = 0;
/* The current row and column while the list is getting displayed. */
int the_row = 0, the_column = 0;
/* The row and column of the selected item. */
char *info;
/* The additional information that we'll display about a file. */
titlebar(present_path);
blank_edit();
for (size_t index = selected - selected % (editwinrows * width);
index < list_length && row < editwinrows; index++) {
const char *thename = tail(filelist[index]);
/* The filename we display, minus the path. */
size_t namelen = breadth(thename);
/* The length of the filename in columns. */
size_t infolen;
/* The length of the file information in columns. */
size_t infomaxlen = 7;
/* The maximum length of the file information in columns:
* normally seven, but will be twelve for "(parent dir)". */
bool dots = (COLS >= 15 && namelen >= longest - infomaxlen);
/* Whether to put an ellipsis before the filename? We don't
* waste space on dots when there are fewer than 15 columns. */
char *disp = display_string(thename, dots ?
namelen + infomaxlen + 4 - longest : 0, longest, FALSE, FALSE);
/* The filename (or a fragment of it) in displayable format.
* When a fragment, account for dots plus one space padding. */
struct stat state;
/* If this is the selected item, draw its highlighted bar upfront, and
* remember its location to be able to place the cursor on it. */
if (index == selected) {
wattron(edit, interface_color_pair[SELECTED_TEXT]);
mvwprintw(edit, row, col, "%*s", longest, " ");
the_row = row;
the_column = col;
}
/* If the name is too long, we display something like "...ename". */
if (dots)
mvwaddstr(edit, row, col, "...");
mvwaddstr(edit, row, dots ? col + 3 : col, disp);
col += longest;
/* Show information about the file: "--" for symlinks (except when
* they point to a directory) and for files that have disappeared,
* "(dir)" for directories, and the file size for normal files. */
if (lstat(filelist[index], &state) == -1 || S_ISLNK(state.st_mode)) {
if (stat(filelist[index], &state) == -1 || !S_ISDIR(state.st_mode))
info = copy_of("--");
else
/* TRANSLATORS: Try to keep this at most 7 characters. */
info = copy_of(_("(dir)"));
} else if (S_ISDIR(state.st_mode)) {
if (strcmp(thename, "..") == 0) {
/* TRANSLATORS: Try to keep this at most 12 characters. */
info = copy_of(_("(parent dir)"));
infomaxlen = 12;
} else
info = copy_of(_("(dir)"));
} else {
off_t result = state.st_size;
char modifier;
info = nmalloc(infomaxlen + 1);
/* Massage the file size into a human-readable form. */
if (state.st_size < (1 << 10))
modifier = ' '; /* bytes */
else if (state.st_size < (1 << 20)) {
result >>= 10;
modifier = 'K'; /* kilobytes */
} else if (state.st_size < (1 << 30)) {
result >>= 20;
modifier = 'M'; /* megabytes */
} else {
result >>= 30;
modifier = 'G'; /* gigabytes */
}
/* Show the size if less than a terabyte, else show "(huge)". */
if (result < (1 << 10))
sprintf(info, "%4ju %cB", (intmax_t)result, modifier);
else
/* TRANSLATORS: Try to keep this at most 7 characters.
* If necessary, you can leave out the parentheses. */
info = mallocstrcpy(info, _("(huge)"));
}
/* Make sure info takes up no more than infomaxlen columns. */
infolen = breadth(info);
if (infolen > infomaxlen) {
info[actual_x(info, infomaxlen)] = '\0';
infolen = infomaxlen;
}
mvwaddstr(edit, row, col - infolen, info);
/* If this is the selected item, finish its highlighting. */
if (index == selected)
wattroff(edit, interface_color_pair[SELECTED_TEXT]);
free(disp);
free(info);
/* Add some space between the columns. */
col += 2;
/* If the next entry will not fit on this row, move to next row. */
if (col > COLS - longest) {
row++;
col = 0;
}
}
/* If requested, put the cursor on the selected item and switch it on. */
if (ISSET(SHOW_CURSOR)) {
wmove(edit, the_row, the_column);
curs_set(1);
}
wnoutrefresh(edit);
}
/* Look for the given needle in the list of files. If forwards is TRUE,
* search forward in the list; otherwise, search backward. */
void findfile(const char *needle, bool forwards)
{
size_t looking_at = selected;
/* The location in the file list of the filename we're looking at. */
const char *thename;
/* The plain filename, without the path. */
unsigned stash[sizeof(flags) / sizeof(flags[0])];
/* A storage place for the current flag settings. */
/* Save the settings of all flags. */
memcpy(stash, flags, sizeof(flags));
/* Search forward, case insensitive, and without regexes. */
UNSET(BACKWARDS_SEARCH);
UNSET(CASE_SENSITIVE);
UNSET(USE_REGEXP);
/* Step through each filename in the list until a match is found or
* we've come back to the point where we started. */
while (TRUE) {
if (forwards) {
if (looking_at++ == list_length - 1) {
looking_at = 0;
statusbar(_("Search Wrapped"));
}
} else {
if (looking_at-- == 0) {
looking_at = list_length - 1;
statusbar(_("Search Wrapped"));
}
}
/* Get the bare filename, without the path. */
thename = tail(filelist[looking_at]);
/* If the needle matches, we're done. And if we're back at the file
* where we started, it is the only occurrence. */
if (strstrwrapper(thename, needle, thename)) {
if (looking_at == selected)
statusbar(_("This is the only occurrence"));
break;
}
/* If we're back at the beginning and didn't find any match... */
if (looking_at == selected) {
not_found_msg(needle);
break;
}
}
/* Restore the settings of all flags. */
memcpy(flags, stash, sizeof(flags));
/* Select the one we've found. */
selected = looking_at;
}
/* Prepare the prompt and ask the user what to search for; then search for it.
* If forwards is TRUE, search forward in the list; otherwise, search backward. */
void search_filename(bool forwards)
{
char *thedefault;
int response;
/* If something was searched for before, show it between square brackets. */
if (*last_search != '\0') {
char *disp = display_string(last_search, 0, COLS / 3, FALSE, FALSE);
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) ? "..." : "");
free(disp);
} else
thedefault = copy_of("");
/* Now ask what to search for. */
response = do_prompt(MWHEREISFILE, "", &search_history,
browser_refresh, "%s%s%s", _("Search"),
/* TRANSLATORS: A modifier of the Search prompt. */
!forwards ? _(" [Backwards]") : "", thedefault);
free(thedefault);
/* If the user cancelled, or typed <Enter> on a blank answer and
* nothing was searched for yet during this session, get out. */
if (response == -1 || (response == -2 && *last_search == '\0')) {
statusbar(_("Cancelled"));
return;
}
/* If the user typed an answer, remember it. */
if (*answer != '\0') {
last_search = mallocstrcpy(last_search, answer);
#ifdef ENABLE_HISTORIES
update_history(&search_history, answer);
#endif
}
if (response == 0 || response == -2)
findfile(last_search, forwards);
}
/* Search again without prompting for the last given search string,
* either forwards or backwards. */
void research_filename(bool forwards)
{
#ifdef ENABLE_HISTORIES
/* If nothing was searched for yet, take the last item from history. */
if (*last_search == '\0' && searchbot->prev != NULL)
last_search = mallocstrcpy(last_search, searchbot->prev->data);
#endif
if (*last_search == '\0')
statusbar(_("No current search pattern"));
else {
wipe_statusbar();
findfile(last_search, 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)
{
char *copy = copy_of(path);
char *last_slash = strrchr(copy, '/');
if (last_slash != NULL)
*last_slash = '\0';
return copy;
}
/* Allow the user to browse through the directories in the filesystem,
* starting at the given path. */
char *browse(char *path)
@@ -133,8 +500,8 @@ char *browse(char *path)
selected--;
/* If we're beyond the list, select the last filename. */
if (selected > filelist_len - 1)
selected = filelist_len - 1;
if (selected > list_length - 1)
selected = list_length - 1;
/* If we selected the same filename as last time, fake a
* press of the Enter key so that the file is read in. */
@@ -161,46 +528,42 @@ char *browse(char *path)
kbinput = KEY_WINCH;
#endif
} else if (func == do_help) {
#ifdef ENABLE_HELP
do_help();
#ifndef NANO_TINY
/* The window dimensions might have changed, so act as if. */
kbinput = KEY_WINCH;
#endif
#else
say_there_is_no_help();
#endif
#ifndef NANO_TINY
} else if (func == do_toggle_void) {
TOGGLE(NO_HELP);
window_init();
kbinput = KEY_WINCH;
#endif
} else if (func == do_search_forward) {
do_filesearch(FORWARD);
} else if (func == do_search_backward) {
do_filesearch(BACKWARD);
search_filename(BACKWARD);
} else if (func == do_search_forward) {
search_filename(FORWARD);
} else if (func == do_findprevious) {
do_fileresearch(BACKWARD);
research_filename(BACKWARD);
} else if (func == do_findnext) {
do_fileresearch(FORWARD);
research_filename(FORWARD);
} else if (func == do_left) {
if (selected > 0)
selected--;
} else if (func == do_right) {
if (selected < filelist_len - 1)
if (selected < list_length - 1)
selected++;
} else if (func == to_prev_word) {
selected -= (selected % width);
} else if (func == to_next_word) {
selected += width - 1 - (selected % width);
if (selected >= filelist_len)
selected = filelist_len - 1;
if (selected >= list_length)
selected = list_length - 1;
} else if (func == do_up) {
if (selected >= width)
selected -= width;
} else if (func == do_down) {
if (selected + width <= filelist_len - 1)
if (selected + width <= list_length - 1)
selected += width;
} else if (func == to_prev_block) {
selected = ((selected / (editwinrows * width)) *
@@ -209,9 +572,9 @@ char *browse(char *path)
selected = ((selected / (editwinrows * width)) *
editwinrows * width) + selected % width +
editwinrows * width - width;
if (selected >= filelist_len)
selected = (filelist_len / width) * width + selected % width;
if (selected >= filelist_len)
if (selected >= list_length)
selected = (list_length / width) * width + selected % width;
if (selected >= list_length)
selected -= width;
} else if (func == do_page_up) {
if (selected < width)
@@ -221,17 +584,17 @@ char *browse(char *path)
else
selected -= editwinrows * width;
} else if (func == do_page_down) {
if (selected + width >= filelist_len - 1)
selected = filelist_len - 1;
else if (selected + editwinrows * width >= filelist_len)
selected = (selected + editwinrows * width - filelist_len) %
width + filelist_len - width;
if (selected + width >= list_length - 1)
selected = list_length - 1;
else if (selected + editwinrows * width >= list_length)
selected = (selected + editwinrows * width - list_length) %
width + list_length - width;
else
selected += editwinrows * width;
} else if (func == to_first_file) {
selected = 0;
} else if (func == to_last_file) {
selected = filelist_len - 1;
selected = list_length - 1;
} else if (func == goto_dir) {
/* Ask for the directory to go to. */
if (do_prompt(MGOTODIR, "", NULL,
@@ -245,7 +608,7 @@ char *browse(char *path)
/* If the given path is relative, join it with the current path. */
if (*path != '/') {
path = charealloc(path, strlen(present_path) +
path = nrealloc(path, strlen(present_path) +
strlen(answer) + 1);
sprintf(path, "%s%s", present_path, answer);
}
@@ -265,7 +628,7 @@ char *browse(char *path)
/* In case the specified directory cannot be entered, select it
* (if it is in the current list) so it will be highlighted. */
for (size_t j = 0; j < filelist_len; j++)
for (size_t j = 0; j < list_length; j++)
if (strcmp(filelist[j], path) == 0)
selected = j;
@@ -339,9 +702,9 @@ char *browse(char *path)
free(path);
free_chararray(filelist, filelist_len);
free_chararray(filelist, list_length);
filelist = NULL;
filelist_len = 0;
list_length = 0;
return chosen;
}
@@ -359,7 +722,7 @@ char *browse_in(const char *inpath)
path = free_and_assign(path, strip_last_component(path));
if (stat(path, &fileinfo) == -1 || !S_ISDIR(fileinfo.st_mode)) {
char *currentdir = charalloc(PATH_MAX + 1);
char *currentdir = nmalloc(PATH_MAX + 1);
path = free_and_assign(path, getcwd(currentdir, PATH_MAX + 1));
@@ -383,369 +746,4 @@ char *browse_in(const char *inpath)
return browse(path);
}
/* Set filelist to the list of files contained in the directory path,
* set filelist_len to the number of files in that list, set longest to
* the width in columns of the longest filename in that list (between 15
* and COLS), and set width to the number of files that we can display
* per screen row. And sort the list too. */
void read_the_list(const char *path, DIR *dir)
{
const struct dirent *nextdir;
size_t i = 0, path_len = strlen(path);
longest = 0;
/* Find the length of the longest filename in the current folder. */
while ((nextdir = readdir(dir)) != NULL) {
size_t name_len = breadth(nextdir->d_name);
if (name_len > longest)
longest = name_len;
i++;
}
/* Put 10 characters' worth of blank space between columns of filenames
* in the list whenever possible, as Pico does. */
longest += 10;
/* If needed, make room for ".. (parent dir)". */
if (longest < 15)
longest = 15;
/* Make sure we're not wider than the window. */
if (longest > COLS)
longest = COLS;
rewinddir(dir);
free_chararray(filelist, filelist_len);
filelist_len = i;
filelist = (char **)nmalloc(filelist_len * sizeof(char *));
i = 0;
while ((nextdir = readdir(dir)) != NULL && i < filelist_len) {
/* Don't show the "." entry. */
if (strcmp(nextdir->d_name, ".") == 0)
continue;
filelist[i] = charalloc(path_len + strlen(nextdir->d_name) + 1);
sprintf(filelist[i], "%s%s", path, nextdir->d_name);
i++;
}
/* Maybe the number of files in the directory changed between the
* first time we scanned and the second. i is the actual length of
* filelist, so record it. */
filelist_len = i;
/* Sort the list of names. */
qsort(filelist, filelist_len, sizeof(char *), diralphasort);
/* Calculate how many files fit on a line -- feigning room for two
* spaces beyond the right edge, and adding two spaces of padding
* between columns. */
width = (COLS + 2) / (longest + 2);
}
/* Display at most a screenful of filenames from the gleaned filelist. */
void browser_refresh(void)
{
int row = 0, col = 0;
/* The current row and column while the list is getting displayed. */
int the_row = 0, the_column = 0;
/* The row and column of the selected item. */
char *info;
/* The additional information that we'll display about a file. */
titlebar(present_path);
blank_edit();
for (size_t index = selected - selected % (editwinrows * width);
index < filelist_len && row < editwinrows; index++) {
const char *thename = tail(filelist[index]);
/* The filename we display, minus the path. */
size_t namelen = breadth(thename);
/* The length of the filename in columns. */
size_t infolen;
/* The length of the file information in columns. */
size_t infomaxlen = 7;
/* The maximum length of the file information in columns:
* normally seven, but will be twelve for "(parent dir)". */
bool dots = (COLS >= 15 && namelen >= longest - infomaxlen);
/* Whether to put an ellipsis before the filename? We don't
* waste space on dots when there are fewer than 15 columns. */
char *disp = display_string(thename, dots ?
namelen + infomaxlen + 4 - longest : 0, longest, FALSE, FALSE);
/* The filename (or a fragment of it) in displayable format.
* When a fragment, account for dots plus one space padding. */
struct stat state;
/* If this is the selected item, draw its highlighted bar upfront, and
* remember its location to be able to place the cursor on it. */
if (index == selected) {
wattron(edit, interface_color_pair[SELECTED_TEXT]);
mvwprintw(edit, row, col, "%*s", longest, " ");
the_row = row;
the_column = col;
}
/* If the name is too long, we display something like "...ename". */
if (dots)
mvwaddstr(edit, row, col, "...");
mvwaddstr(edit, row, dots ? col + 3 : col, disp);
col += longest;
/* Show information about the file: "--" for symlinks (except when
* they point to a directory) and for files that have disappeared,
* "(dir)" for directories, and the file size for normal files. */
if (lstat(filelist[index], &state) == -1 || S_ISLNK(state.st_mode)) {
if (stat(filelist[index], &state) == -1 || !S_ISDIR(state.st_mode))
info = copy_of("--");
else
/* TRANSLATORS: Try to keep this at most 7 characters. */
info = copy_of(_("(dir)"));
} else if (S_ISDIR(state.st_mode)) {
if (strcmp(thename, "..") == 0) {
/* TRANSLATORS: Try to keep this at most 12 characters. */
info = copy_of(_("(parent dir)"));
infomaxlen = 12;
} else
info = copy_of(_("(dir)"));
} else {
off_t result = state.st_size;
char modifier;
info = charalloc(infomaxlen + 1);
/* Massage the file size into a human-readable form. */
if (state.st_size < (1 << 10))
modifier = ' '; /* bytes */
else if (state.st_size < (1 << 20)) {
result >>= 10;
modifier = 'K'; /* kilobytes */
} else if (state.st_size < (1 << 30)) {
result >>= 20;
modifier = 'M'; /* megabytes */
} else {
result >>= 30;
modifier = 'G'; /* gigabytes */
}
/* Show the size if less than a terabyte, else show "(huge)". */
if (result < (1 << 10))
sprintf(info, "%4ju %cB", (intmax_t)result, modifier);
else
/* TRANSLATORS: Try to keep this at most 7 characters.
* If necessary, you can leave out the parentheses. */
info = mallocstrcpy(info, _("(huge)"));
}
/* Make sure info takes up no more than infomaxlen columns. */
infolen = breadth(info);
if (infolen > infomaxlen) {
info[actual_x(info, infomaxlen)] = '\0';
infolen = infomaxlen;
}
mvwaddstr(edit, row, col - infolen, info);
/* If this is the selected item, finish its highlighting. */
if (index == selected)
wattroff(edit, interface_color_pair[SELECTED_TEXT]);
free(disp);
free(info);
/* Add some space between the columns. */
col += 2;
/* If the next entry will not fit on this row, move to next row. */
if (col > COLS - longest) {
row++;
col = 0;
}
}
/* If requested, put the cursor on the selected item and switch it on. */
if (ISSET(SHOW_CURSOR)) {
wmove(edit, the_row, the_column);
curs_set(1);
}
wnoutrefresh(edit);
}
/* Look for needle. If we find it, set selected to its location.
* Note that needle must be an exact match for a file in the list. */
void browser_select_dirname(const char *needle)
{
size_t looking_at = 0;
for (; looking_at < filelist_len; looking_at++) {
if (strcmp(filelist[looking_at], needle) == 0) {
selected = looking_at;
break;
}
}
/* If the sought name isn't found, move the highlight so that the
* changed selection will be noticed. */
if (looking_at == filelist_len) {
--selected;
/* Make sure we stay within the available range. */
if (selected >= filelist_len)
selected = filelist_len - 1;
}
}
/* Prepare the prompt and ask the user what to search for. If forwards is
* TRUE, search forward in the list; otherwise, search backward. Return -2
* for a blank answer, -1 for Cancel, 0 when we have a string, and a
* positive value when some function was run. */
int filesearch_init(bool forwards)
{
char *thedefault;
int response;
/* If something was searched for before, show it between square brackets. */
if (*last_search != '\0') {
char *disp = display_string(last_search, 0, COLS / 3, FALSE, FALSE);
thedefault = charalloc(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) ? "..." : "");
free(disp);
} else
thedefault = copy_of("");
/* Now ask what to search for. */
response = do_prompt(MWHEREISFILE, "", &search_history,
browser_refresh, "%s%s%s", _("Search"),
/* TRANSLATORS: A modifier of the Search prompt. */
!forwards ? _(" [Backwards]") : "", thedefault);
free(thedefault);
/* If only Enter was pressed but we have a previous string, it's okay. */
if (response == -2 && *last_search != '\0')
return 0;
/* Otherwise negative responses are a bailout. */
if (response < 0)
statusbar(_("Cancelled"));
return response;
}
/* Look for the given needle in the list of files. If forwards is TRUE,
* search forward in the list; otherwise, search backward. */
void findfile(const char *needle, bool forwards)
{
size_t looking_at = selected;
/* The location in the file list of the filename we're looking at. */
const char *thename;
/* The plain filename, without the path. */
unsigned stash[sizeof(flags) / sizeof(flags[0])];
/* A storage place for the current flag settings. */
/* Save the settings of all flags. */
memcpy(stash, flags, sizeof(flags));
/* Search forward, case insensitive, and without regexes. */
UNSET(BACKWARDS_SEARCH);
UNSET(CASE_SENSITIVE);
UNSET(USE_REGEXP);
/* Step through each filename in the list until a match is found or
* we've come back to the point where we started. */
while (TRUE) {
if (forwards) {
if (looking_at++ == filelist_len - 1) {
looking_at = 0;
statusbar(_("Search Wrapped"));
}
} else {
if (looking_at-- == 0) {
looking_at = filelist_len - 1;
statusbar(_("Search Wrapped"));
}
}
/* Get the bare filename, without the path. */
thename = tail(filelist[looking_at]);
/* If the needle matches, we're done. And if we're back at the file
* where we started, it is the only occurrence. */
if (strstrwrapper(thename, needle, thename)) {
if (looking_at == selected)
statusbar(_("This is the only occurrence"));
break;
}
/* If we're back at the beginning and didn't find any match... */
if (looking_at == selected) {
not_found_msg(needle);
break;
}
}
/* Restore the settings of all flags. */
memcpy(flags, stash, sizeof(flags));
/* Select the one we've found. */
selected = looking_at;
}
/* Search for a filename. If forwards is TRUE, search forward in the list;
* otherwise, search backward.*/
void do_filesearch(bool forwards)
{
/* If the user cancelled or jumped to first or last file, don't search. */
if (filesearch_init(forwards) != 0)
return;
/* If answer is now "", copy last_search into answer. */
if (*answer == '\0')
answer = mallocstrcpy(answer, last_search);
else
last_search = mallocstrcpy(last_search, answer);
#ifdef ENABLE_HISTORIES
/* If answer is not empty, add the string to the search history list. */
if (*answer != '\0')
update_history(&search_history, answer);
#endif
findfile(answer, forwards);
}
/* Search again without prompting for the last given search string,
* either forwards or backwards. */
void do_fileresearch(bool forwards)
{
if (*last_search == '\0')
statusbar(_("No current search pattern"));
else
findfile(last_search, forwards);
}
/* 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)
{
char *copy = copy_of(path);
char *last_slash = strrchr(copy, '/');
if (last_slash != NULL)
*last_slash = '\0';
return copy;
}
#endif /* ENABLE_BROWSER */

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* chars.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2016-2019 Benno Schulenberg *
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
* 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 *
@@ -51,7 +51,7 @@ bool is_alpha_char(const char *c)
#ifdef ENABLE_UTF8
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
if (mbtowide(&wc, c) < 0)
return FALSE;
return iswalpha(wc);
@@ -67,7 +67,7 @@ bool is_alnum_char(const char *c)
#ifdef ENABLE_UTF8
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
if (mbtowide(&wc, c) < 0)
return FALSE;
return iswalnum(wc);
@@ -85,7 +85,7 @@ bool is_blank_char(const char *c)
if ((signed char)*c >= 0)
return (*c == ' ' || *c == '\t');
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
if (mbtowide(&wc, c) < 0)
return FALSE;
return iswblank(wc);
@@ -112,7 +112,7 @@ bool is_punct_char(const char *c)
#ifdef ENABLE_UTF8
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
if (mbtowide(&wc, c) < 0)
return FALSE;
return iswpunct(wc);
@@ -176,56 +176,123 @@ char control_mbrep(const char *c, bool isdata)
}
#ifdef ENABLE_UTF8
/* Return the width in columns of the given (multibyte) character. */
int mbwidth(const char *c)
/* Convert the given multibyte sequence c to wide character wc, and return
* the number of bytes in the sequence, or -1 for an invalid sequence. */
int mbtowide(wchar_t *wc, const char *c)
{
/* Ask for the width only when the character isn't plain ASCII. */
if ((signed char)*c <= 0) {
wchar_t wc;
int width;
if ((signed char)*c < 0 && use_utf8) {
unsigned char v1 = (unsigned char)c[0];
unsigned char v2 = (unsigned char)c[1] ^ 0x80;
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return 1;
if (v2 > 0x3F || v1 < 0xC2)
return -1;
width = wcwidth(wc);
if (v1 < 0xE0) {
*wc = (((unsigned int)(v1 & 0x1F) << 6) | (unsigned int)v2);
return 2;
}
if (width < 0)
return 1;
unsigned char v3 = (unsigned char)c[2] ^ 0x80;
return width;
} else
return 1;
}
if (v3 > 0x3F)
return -1;
/* Convert the given Unicode value to a multibyte character, if possible.
* If the conversion succeeds, return the (dynamically allocated) multibyte
* character and its length. Otherwise, return a length of zero. */
char *make_mbchar(long code, int *length)
{
char *mb_char = charalloc(MAXCHARLEN);
if (v1 < 0xF0) {
if ((v1 > 0xE0 || v2 >= 0x20) && (v1 != 0xED || v2 < 0x20)) {
*wc = (((unsigned int)(v1 & 0x0F) << 12) |
((unsigned int)v2 << 6) | (unsigned int)v3);
return 3;
} else
return -1;
}
*length = wctomb(mb_char, (wchar_t)code);
unsigned char v4 = (unsigned char)c[3] ^ 0x80;
/* Reject invalid Unicode characters. */
if (*length < 0 || !is_valid_unicode((wchar_t)code)) {
IGNORE_CALL_RESULT(wctomb(NULL, 0));
*length = 0;
if (v4 > 0x3F || v1 > 0xF4)
return -1;
if ((v1 > 0xF0 || v2 >= 0x10) && (v1 != 0xF4 || v2 < 0x10)) {
*wc = (((unsigned int)(v1 & 0x07) << 18) | ((unsigned int)v2 << 12) |
((unsigned int)v3 << 6) | (unsigned int)v4);
return 4;
} else
return -1;
}
return mb_char;
*wc = (unsigned int)*c;
return 1;
}
/* Return TRUE when the given character occupies two cells. */
bool is_doublewidth(const char *ch)
{
wchar_t wc;
/* Only from U+1100 can code points have double width. */
if ((unsigned char)*ch < 0xE1 || !use_utf8)
return FALSE;
if (mbtowide(&wc, ch) < 0)
return FALSE;
return (wcwidth(wc) == 2);
}
/* Return TRUE when the given character occupies zero cells. */
bool is_zerowidth(const char *ch)
{
wchar_t wc;
/* Only from U+0300 can code points have zero width. */
if ((unsigned char)*ch < 0xCC || !use_utf8)
return FALSE;
if (mbtowide(&wc, ch) < 0)
return FALSE;
#if defined(__OpenBSD__)
/* Work around an OpenBSD bug -- see https://sv.gnu.org/bugs/?60393. */
if (wc >= 0xF0000)
return FALSE;
#endif
return (wcwidth(wc) == 0);
}
#endif /* ENABLE_UTF8 */
/* Return the length (in bytes) of the character located at *pointer. */
/* Return the number of bytes in the character that starts at *pointer. */
int char_length(const char *pointer)
{
#ifdef ENABLE_UTF8
/* If possibly a multibyte character, get its length; otherwise, it's 1. */
if ((signed char)*pointer < 0) {
int length = mblen(pointer, MAXCHARLEN);
if ((unsigned char)*pointer > 0xC1 && use_utf8) {
unsigned char c1 = (unsigned char)pointer[0];
unsigned char c2 = (unsigned char)pointer[1];
return (length < 0 ? 1 : length);
} else
if ((c2 ^ 0x80) > 0x3F)
return 1;
if (c1 < 0xE0)
return 2;
if (((unsigned char)pointer[2] ^ 0x80) > 0x3F)
return 1;
if (c1 < 0xF0) {
if ((c1 > 0xE0 || c2 >= 0xA0) && (c1 != 0xED || c2 < 0xA0))
return 3;
else
return 1;
}
if (((unsigned char)pointer[3] ^ 0x80) > 0x3F)
return 1;
if (c1 > 0xF4)
return 1;
if ((c1 > 0xF0 || c2 >= 0x90) && (c1 != 0xF4 || c2 < 0x90))
return 4;
}
#endif
return 1;
}
@@ -236,15 +303,7 @@ size_t mbstrlen(const char *pointer)
size_t count = 0;
while (*pointer != '\0') {
#ifdef ENABLE_UTF8
if ((signed char)*pointer < 0) {
int length = mblen(pointer, MAXCHARLEN);
pointer += (length < 0 ? 1 : length);
} else
#endif
pointer++;
pointer += char_length(pointer);
count++;
}
@@ -255,19 +314,7 @@ size_t mbstrlen(const char *pointer)
* given string, and return a copy of this character in *thechar. */
int collect_char(const char *string, char *thechar)
{
int charlen;
#ifdef ENABLE_UTF8
/* If this is a UTF-8 starter byte, get the number of bytes of the character. */
if ((signed char)*string < 0) {
charlen = mblen(string, MAXCHARLEN);
/* When the multibyte sequence is invalid, only take the first byte. */
if (charlen <= 0)
charlen = 1;
} else
#endif
charlen = 1;
int charlen = char_length(string);
for (int i = 0; i < charlen; i++)
thechar[i] = string[i];
@@ -280,20 +327,29 @@ int collect_char(const char *string, char *thechar)
int advance_over(const char *string, size_t *column)
{
#ifdef ENABLE_UTF8
if ((signed char)*string < 0) {
int charlen = mblen(string, MAXCHARLEN);
if (charlen > 0) {
if (is_cntrl_char(string))
*column += 2;
else
*column += mbwidth(string);
if ((signed char)*string < 0 && use_utf8) {
/* A UTF-8 upper control code has two bytes and takes two columns. */
if (((unsigned char)string[0] == 0xC2 && (signed char)string[1] < -96)) {
*column += 2;
return 2;
} else {
charlen = 1;
*column += 1;
}
wchar_t wc;
int charlen = mbtowide(&wc, string);
return charlen;
if (charlen < 0) {
*column += 1;
return 1;
}
int width = wcwidth(wc);
#if defined(__OpenBSD__)
*column += (width < 0 || wc >= 0xF0000) ? 1 : width;
#else
*column += (width < 0) ? 1 : width;
#endif
return charlen;
}
}
#endif
@@ -302,12 +358,8 @@ int advance_over(const char *string, size_t *column)
*column += tabsize - *column % tabsize;
else
*column += 2;
} else if (*string == 0x7F)
} else if (0x7E < (unsigned char)*string && (unsigned char)*string < 0xA0)
*column += 2;
#ifndef ENABLE_UTF8
else if (0x7F < (unsigned char)*string && (unsigned char)*string < 0xA0)
*column += 2;
#endif
else
*column += 1;
@@ -374,8 +426,24 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
wchar_t wc1, wc2;
while (*s1 != '\0' && *s2 != '\0' && n > 0) {
bool bad1 = (mbtowc(&wc1, s1, MAXCHARLEN) < 0);
bool bad2 = (mbtowc(&wc2, s2, MAXCHARLEN) < 0);
if ((signed char)*s1 >= 0 && (signed char)*s2 >= 0) {
if ('A' <= (*s1 & 0x5F) && (*s1 & 0x5F) <= 'Z') {
if ('A' <= (*s2 & 0x5F) && (*s2 & 0x5F) <= 'Z') {
if ((*s1 & 0x5F) != (*s2 & 0x5F))
return ((*s1 & 0x5F) - (*s2 & 0x5F));
} else
return ((*s1 | 0x20) - *s2);
} else if ('A' <= (*s2 & 0x5F) && (*s2 & 0x5F) <= 'Z')
return (*s1 - (*s2 | 0x20));
else if (*s1 != *s2)
return (*s1 - *s2);
s1++; s2++; n--;
continue;
}
bool bad1 = (mbtowide(&wc1, s1) < 0);
bool bad2 = (mbtowide(&wc2, s2) < 0);
if (bad1 || bad2) {
if (*s1 != *s2)
@@ -430,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)
@@ -450,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)
@@ -472,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;
@@ -500,13 +568,13 @@ char *mbstrchr(const char *string, const char *chr)
bool bad_s = FALSE, bad_c = FALSE;
wchar_t ws, wc;
if (mbtowc(&wc, chr, MAXCHARLEN) < 0) {
if (mbtowide(&wc, chr) < 0) {
wc = (unsigned char)*chr;
bad_c = TRUE;
}
while (*string != '\0') {
int symlen = mbtowc(&ws, string, MAXCHARLEN);
int symlen = mbtowide(&ws, string);
if (symlen < 0) {
ws = (unsigned char)*string;
@@ -568,22 +636,15 @@ char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer)
#endif /* !NANO_TINY */
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || defined(ENABLE_JUSTIFY))
/* Return TRUE if the given string contains at least one blank character,
* and FALSE otherwise. */
/* Return TRUE if the given string contains at least one blank character. */
bool has_blank_char(const char *string)
{
char symbol[MAXCHARLEN];
while (*string != '\0' && !is_blank_char(string))
string += char_length(string);
while (*string != '\0') {
string += collect_char(string, symbol);
if (is_blank_char(symbol))
return TRUE;
}
return FALSE;
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)
@@ -593,14 +654,3 @@ bool white_string(const char *string)
return !*string;
}
#ifdef ENABLE_UTF8
/* Return TRUE if wc is valid Unicode, and FALSE otherwise. */
bool is_valid_unicode(wchar_t wc)
{
return ((0 <= wc && wc <= 0xD7FF) ||
(0xE000 <= wc && wc <= 0xFDCF) ||
(0xFDF0 <= wc && wc <= 0xFFFD) ||
(0xFFFF < wc && wc <= 0x10FFFF && (wc & 0xFFFF) <= 0xFFFD));
}
#endif

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* color.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017 Benno Schulenberg *
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
* 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 *
@@ -29,15 +29,6 @@
#endif
#include <string.h>
/* For early versions of ncurses-6.0, use an additional A_PROTECT attribute
* for all colors, in order to work around an ncurses miscoloring bug. */
#if defined(NCURSES_VERSION_MAJOR) && (NCURSES_VERSION_MAJOR == 6) && \
(NCURSES_VERSION_MINOR == 0) && (NCURSES_VERSION_PATCH < 20151017)
#define A_BANDAID A_PROTECT
#else
#define A_BANDAID A_NORMAL
#endif
static bool defaults_allowed = FALSE;
/* Whether ncurses accepts -1 to mean "default color". */
@@ -61,17 +52,20 @@ void set_interface_colorpairs(void)
combo->bg = COLOR_BLACK;
}
init_pair(index + 1, combo->fg, combo->bg);
interface_color_pair[index] = COLOR_PAIR(index + 1) | A_BANDAID |
combo->attributes;
interface_color_pair[index] = COLOR_PAIR(index + 1) | combo->attributes;
} else {
if (index == FUNCTION_TAG)
if (index == FUNCTION_TAG || index == SCROLL_BAR)
interface_color_pair[index] = A_NORMAL;
else if (index == GUIDE_STRIPE)
interface_color_pair[index] = A_REVERSE;
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 == 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);
interface_color_pair[index] = COLOR_PAIR(index + 1) |
A_BOLD | A_BANDAID;
interface_color_pair[index] = COLOR_PAIR(index + 1) | A_BOLD;
} else
interface_color_pair[index] = hilite_attribute;
}
@@ -102,7 +96,7 @@ void set_syntax_colorpairs(syntaxtype *sntx)
ink->pairnum = (older != ink) ? older->pairnum : ++number;
ink->attributes |= COLOR_PAIR(ink->pairnum) | A_BANDAID;
ink->attributes |= COLOR_PAIR(ink->pairnum);
}
}
@@ -125,19 +119,9 @@ void prepare_palette(void)
* the list starting at head. Return TRUE upon success. */
bool found_in_list(regexlisttype *head, const char *shibboleth)
{
regexlisttype *item;
regex_t rgx;
for (item = head; item != NULL; item = item->next) {
regcomp(&rgx, item->full_regex, NANO_REG_EXTENDED);
if (regexec(&rgx, shibboleth, 0, NULL, 0) == 0) {
regfree(&rgx);
for (regexlisttype *item = head; item != NULL; item = item->next)
if (regexec(item->one_rgx, shibboleth, 0, NULL, 0) == 0)
return TRUE;
}
regfree(&rgx);
}
return FALSE;
}
@@ -189,8 +173,8 @@ void find_and_prime_applicable_syntax(void)
}
#ifdef HAVE_LIBMAGIC
/* If we still don't have an answer, try using magic. */
if (sntx == NULL && !inhelp) {
/* If we still don't have an answer, try using magic (when requested). */
if (sntx == NULL && !inhelp && ISSET(USE_MAGIC)) {
struct stat fileinfo;
magic_t cookie = NULL;
const char *magicstring = NULL;
@@ -240,15 +224,6 @@ void find_and_prime_applicable_syntax(void)
openfile->syntax = sntx;
}
/* Allocate and initialize (for the given line) the cache for multiline info. */
void set_up_multicache(linestruct *line)
{
line->multidata = (short *)nmalloc(openfile->syntax->nmultis * sizeof(short));
for (short index = 0; index < openfile->syntax->nmultis; index++)
line->multidata[index] = -1;
}
/* Determine whether the matches of multiline regexes are still the same,
* and if not, schedule a screen refresh, so things will be repainted. */
void check_the_multis(linestruct *line)
@@ -262,8 +237,10 @@ void check_the_multis(linestruct *line)
if (openfile->syntax == NULL || openfile->syntax->nmultis == 0)
return;
if (line->multidata == NULL)
set_up_multicache(line);
if (line->multidata == NULL) {
refresh_needed = TRUE;
return;
}
for (ink = openfile->syntax->color; ink != NULL; ink = ink->next) {
/* If it's not a multiline regex, skip. */
@@ -275,19 +252,22 @@ void check_the_multis(linestruct *line)
anend = (regexec(ink->end, afterstart, 1, &endmatch, 0) == 0);
/* Check whether the multidata still matches the current situation. */
if (line->multidata[ink->id] == CNONE ||
line->multidata[ink->id] == CWHOLELINE) {
if (line->multidata[ink->id] == NOTHING) {
if (!astart)
continue;
} else if (line->multidata[ink->id] & (WHOLELINE|WOULDBE)) {
if (!astart && !anend)
continue;
} else if (line->multidata[ink->id] == CSTARTENDHERE) {
if (astart && anend && startmatch.rm_so < endmatch.rm_so)
} else if (line->multidata[ink->id] == JUSTONTHIS) {
if (astart && anend && regexec(ink->start, line->data + endmatch.rm_eo,
1, &startmatch, 0) != 0)
continue;
} else if (line->multidata[ink->id] == CBEGINBEFORE) {
if (!astart && anend)
continue;
} else if (line->multidata[ink->id] == CENDAFTER) {
} else if (line->multidata[ink->id] == STARTSHERE) {
if (astart && !anend)
continue;
} else if (line->multidata[ink->id] == ENDSHERE) {
if (!astart && anend)
continue;
}
/* There is a mismatch, so something changed: repaint. */
@@ -304,13 +284,19 @@ void precalc_multicolorinfo(void)
regmatch_t startmatch, endmatch;
linestruct *line, *tailline;
if (openfile->syntax == NULL || openfile->syntax->nmultis == 0 ||
openfile->filetop->multidata || ISSET(NO_SYNTAX))
if (!openfile->syntax || openfile->syntax->nmultis == 0 || ISSET(NO_SYNTAX))
return;
//#define TIMEPRECALC 123
#ifdef TIMEPRECALC
#include <time.h>
clock_t start = clock();
#endif
/* For each line, allocate cache space for the multiline-regex info. */
for (line = openfile->filetop; line != NULL; line = line->next)
set_up_multicache(line);
if (!line->multidata)
line->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short));
for (ink = openfile->syntax->color; ink != NULL; ink = ink->next) {
/* If this is not a multi-line regex, skip it. */
@@ -321,66 +307,68 @@ void precalc_multicolorinfo(void)
int index = 0;
/* Assume nothing applies until proven otherwise below. */
line->multidata[ink->id] = CNONE;
line->multidata[ink->id] = NOTHING;
/* For an unpaired start match, mark all remaining lines. */
if (line->prev && line->prev->multidata[ink->id] == CWOULDBE) {
line->multidata[ink->id] = CWOULDBE;
continue;
}
/* When the line contains a start match, look for an end, and if
* found, mark all the lines that are affected. */
while (regexec(ink->start, line->data + index, 1,
&startmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
/* When the line contains a start match, look for an end,
* and if found, mark all the lines that are affected. */
while (regexec(ink->start, line->data + index, 1, &startmatch,
(index == 0) ? 0 : REG_NOTBOL) == 0) {
/* Begin looking for an end match after the start match. */
index += startmatch.rm_eo;
/* If there is an end match on this line, mark the line, but
* continue looking for other starts after it. */
if (regexec(ink->end, line->data + index, 1,
&endmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
line->multidata[ink->id] = CSTARTENDHERE;
/* If there is an end match on this same line, mark the line,
* but continue looking for other starts after it. */
if (regexec(ink->end, line->data + index, 1, &endmatch,
(index == 0) ? 0 : REG_NOTBOL) == 0) {
line->multidata[ink->id] = JUSTONTHIS;
index += endmatch.rm_eo;
/* If both start and end are mere anchors, step ahead. */
if (startmatch.rm_so == startmatch.rm_eo &&
endmatch.rm_so == endmatch.rm_eo) {
/* When at end-of-line, we're done. */
/* If the total match has zero length, force an advance. */
if (startmatch.rm_eo - startmatch.rm_so + endmatch.rm_eo == 0) {
/* When at end-of-line, there is no other start. */
if (line->data[index] == '\0')
break;
index = step_right(line->data, index);
}
continue;
}
/* Look for an end match on later lines. */
tailline = line->next;
while (tailline != NULL) {
if (regexec(ink->end, tailline->data, 1, &endmatch, 0) == 0)
break;
while (tailline && regexec(ink->end, tailline->data,
1, &endmatch, 0) != 0)
tailline = tailline->next;
}
/* When there is no end match, mark relevant lines as such. */
if (tailline == NULL) {
line->multidata[ink->id] = CWOULDBE;
for (; line->next != NULL; line = line->next)
line->multidata[ink->id] = WOULDBE;
line->multidata[ink->id] = WOULDBE;
break;
}
/* We found it, we found it, la la la la la. Mark all
* the lines in between and the end properly. */
line->multidata[ink->id] = CENDAFTER;
/* We found it, we found it, la lala lala. Mark the lines. */
line->multidata[ink->id] = STARTSHERE;
// Note that this also advances the line in the main loop.
for (line = line->next; line != tailline; line = line->next)
line->multidata[ink->id] = CWHOLELINE;
line->multidata[ink->id] = WHOLELINE;
tailline->multidata[ink->id] = CBEGINBEFORE;
tailline->multidata[ink->id] = ENDSHERE;
/* Begin looking for a new start after the end match. */
/* Look for a possible new start after the end match. */
index = endmatch.rm_eo;
}
}
}
#ifdef TIMEPRECALC
statusline(INFO, "Precalculation: %.1f ms", 1000 * (double)(clock() - start) / CLOCKS_PER_SEC);
napms(1200);
#endif
}
#endif /* ENABLE_COLOR */

View File

@@ -1,9 +1,9 @@
/**************************************************************************
* cut.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014 Mark Majeres *
* Copyright (C) 2016, 2018, 2019 Benno Schulenberg *
* Copyright (C) 2016, 2018-2020 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 *
@@ -34,7 +34,7 @@ void do_deletion(undo_type action)
int charlen = char_length(openfile->current->data + openfile->current_x);
size_t line_len = strlen(openfile->current->data + openfile->current_x);
#ifndef NANO_TINY
size_t old_amount = openfile->current->extrarows;
size_t old_amount = ISSET(SOFTWRAP) ? extra_chunks_in(openfile->current) : 0;
/* If the type of action changed or the cursor moved to a different
* line, create a new undo item, otherwise update the existing item. */
@@ -49,13 +49,9 @@ void do_deletion(undo_type action)
&openfile->current->data[openfile->current_x + charlen],
line_len - charlen + 1);
#ifndef NANO_TINY
/* When softwrapping, recompute the number of chunks in the line,
* and schedule a refresh if the number changed. */
if (ISSET(SOFTWRAP)) {
openfile->current->extrarows = extra_chunks_in(openfile->current);
if (openfile->current->extrarows != old_amount)
refresh_needed = TRUE;
}
/* When softwrapping, a changed number of chunks requires a refresh. */
if (ISSET(SOFTWRAP) && extra_chunks_in(openfile->current) != old_amount)
refresh_needed = TRUE;
/* Adjust the mark if it is after the cursor on the current line. */
if (openfile->mark == openfile->current &&
@@ -88,16 +84,12 @@ void do_deletion(undo_type action)
openfile->current->has_anchor |= joining->has_anchor;
#endif
/* Add the content of the next line to that of the current one. */
openfile->current->data = charealloc(openfile->current->data,
openfile->current->data = nrealloc(openfile->current->data,
strlen(openfile->current->data) + strlen(joining->data) + 1);
strcat(openfile->current->data, joining->data);
unlink_node(joining);
#ifndef NANO_TINY
if (ISSET(SOFTWRAP))
openfile->current->extrarows = extra_chunks_in(openfile->current);
#endif
/* Two lines were joined, so do a renumbering and refresh the screen. */
renumber_from(openfile->current);
refresh_needed = TRUE;
@@ -121,7 +113,14 @@ void do_delete(void)
zap_text();
else
#endif
{
do_deletion(DEL);
#ifdef ENABLE_UTF8
while (openfile->current->data[openfile->current_x] != '\0' &&
is_zerowidth(openfile->current->data + openfile->current_x))
do_deletion(DEL);
#endif
}
}
/* Backspace over one character. That is, move the cursor left one
@@ -133,7 +132,10 @@ void do_backspace(void)
zap_text();
else
#endif
if (openfile->current_x > 0 || openfile->current != openfile->filetop) {
if (openfile->current_x > 0) {
openfile->current_x = step_left(openfile->current->data, openfile->current_x);
do_deletion(BACK);
} else if (openfile->current != openfile->filetop) {
do_left();
do_deletion(BACK);
}
@@ -247,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;
@@ -289,7 +293,7 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
if (bot->next)
bot->next->prev = top;
top->data = charealloc(top->data, top_x + strlen(bot->data + bot_x) + 1);
top->data = nrealloc(top->data, top_x + strlen(bot->data + bot_x) + 1);
strcpy(top->data + top_x, bot->data + bot_x);
last = bot;
@@ -307,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 = charealloc(cutbottom->data,
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);
@@ -324,10 +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;
if (ISSET(SOFTWRAP))
openfile->current->extrarows = extra_chunks_in(openfile->current);
openfile->current->has_anchor = had_anchor;
if (post_marked || same_line)
openfile->mark = openfile->current;
@@ -375,16 +382,12 @@ void ingraft_buffer(linestruct *topline)
if (extralen > 0) {
/* Insert the text of topline at the current cursor position. */
line->data = charealloc(line->data, length + extralen + 1);
line->data = nrealloc(line->data, length + extralen + 1);
memmove(line->data + xpos + extralen, line->data + xpos, length - xpos + 1);
strncpy(line->data + xpos, topline->data, extralen);
}
if (topline != botline) {
#ifndef NANO_TINY
/* First compute the softwrapped chunks for each line in the graft. */
compute_the_extra_rows_per_line_from(topline);
#endif
/* When inserting at end-of-buffer, update the relevant pointer. */
if (line->next == NULL)
openfile->filebot = botline;
@@ -401,7 +404,7 @@ void ingraft_buffer(linestruct *topline)
/* Add the text after the cursor position at the end of botline. */
length = strlen(botline->data);
extralen = strlen(tailtext);
botline->data = charealloc(botline->data, length + extralen + 1);
botline->data = nrealloc(botline->data, length + extralen + 1);
strcpy(botline->data + length, tailtext);
/* Put the cursor at the end of the grafted text. */
@@ -417,11 +420,6 @@ void ingraft_buffer(linestruct *topline)
openfile->mark_x += length - xpos;
} else if (mark_follows)
openfile->mark_x += extralen;
if (ISSET(SOFTWRAP)) {
line->extrarows = extra_chunks_in(line);
openfile->current->extrarows = extra_chunks_in(openfile->current);
}
#endif
delete_node(topline);
@@ -696,13 +694,16 @@ 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) {
statusbar(_("Cutbuffer is empty"));
statusline(AHEM, _("Cutbuffer is empty"));
return;
}
@@ -718,12 +719,22 @@ 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
/* If we pasted less than a screenful, don't center the cursor. */
if (less_than_a_screenful(was_lineno, was_leftedge))
focusing = FALSE;
#ifdef ENABLE_COLOR
else
precalc_multicolorinfo();
#endif
/* Set the desired x position to where the pasted text ends. */
openfile->placewewant = xplustabs();

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* definitions.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -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>
@@ -41,10 +45,55 @@
#include <limits.h>
#endif
/* Set a default value for PATH_MAX if there isn't one. */
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#include <dirent.h>
#include <regex.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/stat.h>
/* Prefer wide ncurses over normal ncurses over curses. */
#if defined(HAVE_NCURSESW_NCURSES_H)
#include <ncursesw/ncurses.h>
#elif defined(HAVE_NCURSES_H)
#include <ncurses.h>
#else
#include <curses.h>
#endif
/* Native language support. */
#ifdef ENABLE_NLS
#ifdef HAVE_LIBINTL_H
#include <libintl.h>
#endif
#define _(string) gettext(string)
#define P_(singular, plural, number) ngettext(singular, plural, number)
#else
#define _(string) (string)
#define P_(singular, plural, number) (number == 1 ? singular : plural)
#endif
/* For marking a string on which gettext() will be called later. */
#define gettext_noop(string) (string)
#define N_(string) gettext_noop(string)
/* If we aren't using an ncurses with mouse support, then
* exclude the mouse routines, as they are useless then. */
#ifndef NCURSES_MOUSE_VERSION
#undef ENABLE_MOUSE
#endif
#if defined(ENABLE_WRAPPING) || defined(ENABLE_JUSTIFY)
#define ENABLED_WRAPORJUSTIFY 1
#endif
/* Suppress warnings for __attribute__((warn_unused_result)). */
#define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0)
@@ -56,74 +105,6 @@
#define ISSET(flag) ((FLAGS(flag) & FLAGMASK(flag)) != 0)
#define TOGGLE(flag) FLAGS(flag) ^= FLAGMASK(flag)
/* Macros for allocation of character strings. */
#define charalloc(howmuch) (char *)nmalloc(howmuch)
#define charealloc(ptr, howmuch) (char *)nrealloc(ptr, howmuch)
/* In UTF-8 a character is at most six bytes long. */
#ifdef ENABLE_UTF8
#define MAXCHARLEN 6
#else
#define MAXCHARLEN 1
#endif
/* Set a default value for PATH_MAX if there isn't one. */
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
#ifdef USE_SLANG
/* Slang support. */
#include <slcurses.h>
/* Slang curses emulation brain damage, part 3: Slang doesn't define the
* curses equivalents of the Insert or Delete keys. */
#define KEY_DC SL_KEY_DELETE
#define KEY_IC SL_KEY_IC
/* Ncurses support. */
#elif defined(HAVE_NCURSESW_NCURSES_H)
#include <ncursesw/ncurses.h>
#elif defined(HAVE_NCURSES_H)
#include <ncurses.h>
#else
/* Curses support. */
#include <curses.h>
#endif /* CURSES_H */
#if defined(NCURSES_VERSION_MAJOR) && (NCURSES_VERSION_MAJOR < 6)
#define USING_OLD_NCURSES yes
#endif
#ifdef ENABLE_NLS
/* Native language support. */
#ifdef HAVE_LIBINTL_H
#include <libintl.h>
#endif
#define _(string) gettext(string)
#define P_(singular, plural, number) ngettext(singular, plural, number)
#else
#define _(string) (string)
#define P_(singular, plural, number) (number == 1 ? singular : plural)
#endif
#define gettext_noop(string) (string)
#define N_(string) gettext_noop(string)
/* Mark a string that will be sent to gettext() later. */
#include <dirent.h>
#include <regex.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/stat.h>
/* If we aren't using an ncurses with mouse support, exclude any
* mouse routines, as they are useless then. */
#ifndef NCURSES_MOUSE_VERSION
#undef ENABLE_MOUSE
#endif
#if defined(ENABLE_WRAPPING) || defined(ENABLE_JUSTIFY)
#define ENABLED_WRAPORJUSTIFY 1
#endif
#define BACKWARD FALSE
#define FORWARD TRUE
@@ -134,30 +115,160 @@
#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
#else
#define MAXCHARLEN 1
#endif
/* The default width of a tab in spaces. */
#define WIDTH_OF_TAB 8
/* The default number of columns from end of line where wrapping occurs. */
#define COLUMNS_FROM_EOL 8
/* The default comment character when a syntax does not specify any. */
#define GENERAL_COMMENT_CHARACTER "#"
/* The maximum number of search/replace history strings saved. */
#define MAX_SEARCH_HISTORY 100
/* The largest size_t number that doesn't have the high bit set. */
#define HIGHEST_POSITIVE ((~(size_t)0) >> 1)
#ifdef ENABLE_COLOR
#define THE_DEFAULT -1
#define BAD_COLOR -2
/* Flags for indicating how a multiline regex pair apply to a line. */
#define NOTHING (1<<1)
/* The start/end regexes don't cover this line at all. */
#define STARTSHERE (1<<2)
/* The start regex matches on this line, the end regex on a later one. */
#define WHOLELINE (1<<3)
/* The start regex matches on an earlier line, the end regex on a later one. */
#define ENDSHERE (1<<4)
/* The start regex matches on an earlier line, the end regex on this one. */
#define JUSTONTHIS (1<<5)
/* Both the start and end regexes match within this line. */
#define WOULDBE (1<<6)
/* An unpaired start match is on or before this line. */
#endif
#define STANDARD_INPUT 0
/* Basic control codes. */
#define ESC_CODE 0x1B
#define DEL_CODE 0x7F
/* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */
#define CONTROL_LEFT 0x401
#define CONTROL_RIGHT 0x402
#define CONTROL_UP 0x403
#define CONTROL_DOWN 0x404
#define CONTROL_HOME 0x405
#define CONTROL_END 0x406
#define CONTROL_DELETE 0x40D
#define SHIFT_CONTROL_LEFT 0x411
#define SHIFT_CONTROL_RIGHT 0x412
#define SHIFT_CONTROL_UP 0x413
#define SHIFT_CONTROL_DOWN 0x414
#define SHIFT_CONTROL_HOME 0x415
#define SHIFT_CONTROL_END 0x416
#define CONTROL_SHIFT_DELETE 0x41D
#define ALT_LEFT 0x421
#define ALT_RIGHT 0x422
#define ALT_UP 0x423
#define ALT_DOWN 0x424
#define ALT_PAGEUP 0x427
#define ALT_PAGEDOWN 0x428
#define ALT_INSERT 0x42C
#define ALT_DELETE 0x42D
#define SHIFT_ALT_LEFT 0x431
#define SHIFT_ALT_RIGHT 0x432
#define SHIFT_ALT_UP 0x433
#define SHIFT_ALT_DOWN 0x434
//#define SHIFT_LEFT 0x451
//#define SHIFT_RIGHT 0x452
#define SHIFT_UP 0x453
#define SHIFT_DOWN 0x454
#define SHIFT_HOME 0x455
#define SHIFT_END 0x456
#define SHIFT_PAGEUP 0x457
#define SHIFT_PAGEDOWN 0x458
#define SHIFT_DELETE 0x45D
#define SHIFT_TAB 0x45F
/* A special keycode for when <Tab> is pressed while the mark is on. */
#define INDENT_KEY 0x4F1
/* A special keycode to signal the beginning and end of a bracketed paste. */
#define BRACKETED_PASTE_MARKER 0x4FB
/* A special keycode for when a key produces an unknown escape sequence. */
#define FOREIGN_SEQUENCE 0x4FC
/* A special keycode for plugging into the input stream after a suspension. */
#define KEY_FLUSH KEY_F0
#ifndef NANO_TINY
/* A special keycode for when we get a SIGWINCH (a window resize). */
#define KEY_WINCH -2
/* Some extra flags for the undo function. */
#define WAS_BACKSPACE_AT_EOF (1<<1)
#define WAS_WHOLE_LINE (1<<2)
#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. */
#define MMAIN (1<<0)
#define MWHEREIS (1<<1)
#define MREPLACE (1<<2)
#define MREPLACEWITH (1<<3)
#define MGOTOLINE (1<<4)
#define MWRITEFILE (1<<5)
#define MINSERTFILE (1<<6)
#define MEXECUTE (1<<7)
#define MHELP (1<<8)
#define MSPELL (1<<9)
#define MBROWSER (1<<10)
#define MWHEREISFILE (1<<11)
#define MGOTODIR (1<<12)
#define MYESNO (1<<13)
#define MLINTER (1<<14)
#define MFINDINHELP (1<<15)
/* This is an abbreviation for all menus except Help and Browser and YesNo. */
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\
MEXECUTE|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER)
#ifndef NANO_TINY
#define MSOME MMOST|MBROWSER
#else
#define MSOME MMAIN|MBROWSER
#endif
/* Enumeration types. */
typedef enum {
NIX_FILE, DOS_FILE, MAC_FILE
UNSPECIFIED, NIX_FILE, DOS_FILE, MAC_FILE
} format_type;
typedef enum {
VACUUM, HUSH, NOTICE, MILD, ALERT
VACUUM, HUSH, REMARK, INFO, NOTICE, AHEM, MILD, ALERT
} message_type;
typedef enum {
OVERWRITE, APPEND, PREPEND
} kind_of_writing_type;
typedef enum {
SOFTMARK, HARDMARK
} mark_type;
typedef enum {
CENTERING, FLOWING, STATIONARY
} update_type;
@@ -176,6 +287,76 @@ typedef enum {
COUPLE_BEGIN, COUPLE_END, OTHER
} undo_type;
/* The elements of the interface that can be colored differently. */
enum {
TITLE_BAR = 0,
LINE_NUMBER,
GUIDE_STRIPE,
SCROLL_BAR,
SELECTED_TEXT,
SPOTLIGHTED,
MINI_INFOBAR,
PROMPT_BAR,
STATUS_BAR,
ERROR_MESSAGE,
KEY_COMBO,
FUNCTION_TAG,
NUMBER_OF_ELEMENTS
};
/* Enumeration used in the flags array. See the definition of FLAGMASK. */
enum {
DONTUSE = 0,
CASE_SENSITIVE,
CONSTANT_SHOW,
NO_HELP,
SUSPENDABLE,
NO_WRAP,
AUTOINDENT,
VIEW_MODE,
USE_MOUSE,
USE_REGEXP,
SAVE_ON_EXIT,
CUT_FROM_CURSOR,
BACKWARDS_SEARCH,
MULTIBUFFER,
REBIND_DELETE,
RAW_SEQUENCES,
NO_CONVERT,
MAKE_BACKUP,
INSECURE_BACKUP,
NO_SYNTAX,
PRESERVE,
HISTORYLOG,
RESTRICTED,
SMART_HOME,
WHITESPACE_DISPLAY,
TABS_TO_SPACES,
QUICK_BLANK,
WORD_BOUNDS,
NO_NEWLINES,
BOLD_TEXT,
SOFTWRAP,
POSITIONLOG,
LOCKING,
NOREAD_MODE,
MAKE_IT_UNIX,
TRIM_BLANKS,
SHOW_CURSOR,
LINE_NUMBERS,
AT_BLANKS,
AFTER_ENDS,
LET_THEM_ZAP,
BREAK_LONG_LINES,
JUMPY_SCROLLING,
EMPTY_LINE,
INDICATOR,
BOOKSTYLE,
STATEFLAGS,
USE_MAGIC,
MINIBAR
};
/* Structure types. */
#ifdef ENABLE_COLOR
typedef struct colortype {
@@ -198,8 +379,8 @@ typedef struct colortype {
} colortype;
typedef struct regexlisttype {
char *full_regex;
/* A regex string to match things that imply a certain syntax. */
regex_t *one_rgx;
/* A regex to match things that imply a certain syntax. */
struct regexlisttype *next;
/* The next regex. */
} regexlisttype;
@@ -222,7 +403,7 @@ typedef struct syntaxtype {
/* File where the syntax is defined, or NULL if not an included file. */
size_t lineno;
/* The line number where the 'syntax' command was found. */
struct augmentstruct *augmentations;
augmentstruct *augmentations;
/* List of extendsyntax commands to apply when loaded. */
regexlisttype *extensions;
/* The list of extensions that this syntax applies to. */
@@ -262,20 +443,6 @@ typedef struct lintstruct {
struct lintstruct *prev;
/* Previous error. */
} lintstruct;
/* Flags that indicate how a multiline regex applies to a line. */
#define CNONE (1<<1)
/* Yay, regex doesn't apply to this line at all! */
#define CBEGINBEFORE (1<<2)
/* Regex starts on an earlier line, ends on this one. */
#define CENDAFTER (1<<3)
/* Regex starts on this line and ends on a later one. */
#define CWHOLELINE (1<<4)
/* Whole line engulfed by the regex, start < me, end > me. */
#define CSTARTENDHERE (1<<5)
/* Regex starts and ends within this line. */
#define CWOULDBE (1<<6)
/* An unpaired start match on or before this line. */
#endif /* ENABLE_COLOR */
/* More structure types. */
@@ -284,10 +451,6 @@ typedef struct linestruct {
/* The text of this line. */
ssize_t lineno;
/* The number of this line. */
#ifndef NANO_TINY
ssize_t extrarows;
/* The extra rows that this line occupies when softwrapping. */
#endif
struct linestruct *next;
/* Next node. */
struct linestruct *prev;
@@ -345,11 +508,11 @@ typedef struct undostruct {
#ifdef ENABLE_HISTORIES
typedef struct poshiststruct {
char *filename;
/* The file. */
ssize_t lineno;
/* Line number we left off on. */
ssize_t xno;
/* The x position in the file we left off on. */
/* The full path plus name of the file. */
ssize_t linenumber;
/* The line where the cursor was when we closed the file. */
ssize_t columnnumber;
/* The column where the cursor was. */
struct poshiststruct *next;
/* The next item of position history. */
} poshiststruct;
@@ -388,8 +551,8 @@ typedef struct openfilestruct {
/* The line in the file where the mark is set; NULL if not set. */
size_t mark_x;
/* The mark's x position in the above line. */
mark_type kind_of_mark;
/* Whether it is a soft (with Shift) or a hard mark. */
bool softmark;
/* Whether a marked region was made by holding Shift. */
format_type fmt;
/* The file's format -- Unix or DOS or Mac. */
char *lock_filename;
@@ -410,6 +573,8 @@ typedef struct openfilestruct {
/* The syntax that applies to this file, if any. */
#endif
#ifdef ENABLE_MULTIBUFFER
char *errormessage;
/* The ALERT message (if any) that occurred when opening the file. */
struct openfilestruct *next;
/* The next open file, if any. */
struct openfilestruct *prev;
@@ -453,8 +618,6 @@ typedef struct keystruct {
typedef struct funcstruct {
void (*func)(void);
/* The actual function to call. */
int menus;
/* In what menus this function applies. */
const char *desc;
/* The function's short description, for example "Where Is". */
#ifdef ENABLE_HELP
@@ -466,197 +629,15 @@ typedef struct funcstruct {
#endif
bool viewok;
/* Is this function allowed when in view mode? */
long toggle;
/* If this is a toggle, which toggle to affect. */
int menus;
/* In what menus this function applies. */
struct funcstruct *next;
/* Next item in the list. */
} funcstruct;
#ifdef ENABLE_WORDCOMPLETION
typedef struct completion_word {
typedef struct completionstruct {
char *word;
struct completion_word *next;
} completion_word;
struct completionstruct *next;
} completionstruct;
#endif
/* The elements of the interface that can be colored differently. */
enum
{
TITLE_BAR = 0,
LINE_NUMBER,
GUIDE_STRIPE,
SELECTED_TEXT,
STATUS_BAR,
ERROR_MESSAGE,
KEY_COMBO,
FUNCTION_TAG,
NUMBER_OF_ELEMENTS
};
/* Enumeration used in the flags array. See the definition of FLAGMASK. */
enum
{
DONTUSE,
CASE_SENSITIVE,
CONSTANT_SHOW,
NO_HELP,
SUSPENDABLE,
NO_WRAP,
AUTOINDENT,
VIEW_MODE,
USE_MOUSE,
USE_REGEXP,
SAVE_ON_EXIT,
CUT_FROM_CURSOR,
BACKWARDS_SEARCH,
MULTIBUFFER,
SMOOTH_SCROLL,
REBIND_DELETE,
RAW_SEQUENCES,
NO_CONVERT,
MAKE_BACKUP,
INSECURE_BACKUP,
NO_SYNTAX,
PRESERVE,
HISTORYLOG,
RESTRICTED,
SMART_HOME,
WHITESPACE_DISPLAY,
MORE_SPACE,
TABS_TO_SPACES,
QUICK_BLANK,
WORD_BOUNDS,
NO_NEWLINES,
BOLD_TEXT,
SOFTWRAP,
POSITIONLOG,
LOCKING,
NOREAD_MODE,
MAKE_IT_UNIX,
TRIM_BLANKS,
SHOW_CURSOR,
LINE_NUMBERS,
NO_PAUSES,
AT_BLANKS,
AFTER_ENDS,
LET_THEM_ZAP,
BREAK_LONG_LINES,
JUMPY_SCROLLING,
EMPTY_LINE,
INDICATOR,
BOOKSTYLE
};
/* Flags for the menus in which a given function should be present. */
#define MMAIN (1<<0)
#define MWHEREIS (1<<1)
#define MREPLACE (1<<2)
#define MREPLACEWITH (1<<3)
#define MGOTOLINE (1<<4)
#define MWRITEFILE (1<<5)
#define MINSERTFILE (1<<6)
#define MEXECUTE (1<<7)
#define MHELP (1<<8)
#define MSPELL (1<<9)
#define MBROWSER (1<<10)
#define MWHEREISFILE (1<<11)
#define MGOTODIR (1<<12)
#define MYESNO (1<<13)
#define MLINTER (1<<14)
#define MFINDINHELP (1<<15)
/* This is an abbreviation for all menus except Help and Browser and YesNo. */
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\
MEXECUTE|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER)
#ifndef NANO_TINY
#define MSOME MMOST|MBROWSER
#else
#define MSOME MMAIN|MBROWSER
#endif
/* Basic control codes. */
#define ESC_CODE 0x1B
#define DEL_CODE 0x7F
/* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */
#define CONTROL_LEFT 0x401
#define CONTROL_RIGHT 0x402
#define CONTROL_UP 0x403
#define CONTROL_DOWN 0x404
#define CONTROL_HOME 0x405
#define CONTROL_END 0x406
#define CONTROL_DELETE 0x40D
#define SHIFT_CONTROL_LEFT 0x411
#define SHIFT_CONTROL_RIGHT 0x412
#define SHIFT_CONTROL_UP 0x413
#define SHIFT_CONTROL_DOWN 0x414
#define SHIFT_CONTROL_HOME 0x415
#define SHIFT_CONTROL_END 0x416
#define CONTROL_SHIFT_DELETE 0x41D
#define ALT_LEFT 0x421
#define ALT_RIGHT 0x422
#define ALT_UP 0x423
#define ALT_DOWN 0x424
#define ALT_PAGEUP 0x427
#define ALT_PAGEDOWN 0x428
#define ALT_INSERT 0x42C
#define ALT_DELETE 0x42D
#define SHIFT_ALT_LEFT 0x431
#define SHIFT_ALT_RIGHT 0x432
#define SHIFT_ALT_UP 0x433
#define SHIFT_ALT_DOWN 0x434
//#define SHIFT_LEFT 0x451
//#define SHIFT_RIGHT 0x452
#define SHIFT_UP 0x453
#define SHIFT_DOWN 0x454
#define SHIFT_HOME 0x455
#define SHIFT_END 0x456
#define SHIFT_PAGEUP 0x457
#define SHIFT_PAGEDOWN 0x458
#define SHIFT_DELETE 0x45D
#define SHIFT_TAB 0x45F
/* A special keycode for when <Tab> is pressed while the mark is on. */
#define INDENT_KEY 0x4F1
/* A special keycode to signal the beginning and end of a bracketed paste. */
#define BRACKETED_PASTE_MARKER 0x4FB
/* A special keycode for when a key produces an unknown escape sequence. */
#define FOREIGN_SEQUENCE 0x4FC
#ifdef USE_SLANG
#ifdef ENABLE_UTF8
#define KEY_BAD 0xFF /* Clipped error code. */
#endif
#define KEY_FLUSH 0x91 /* User-definable control code. */
#else
#define KEY_FLUSH KEY_F0 /* Nonexistent function key. */
#endif
#ifndef NANO_TINY
/* An imaginary key for when we get a SIGWINCH (window resize). */
#define KEY_WINCH -2
/* Some extra flags for the undo function. */
#define WAS_BACKSPACE_AT_EOF (1<<1)
#define WAS_WHOLE_LINE (1<<2)
#define INCLUDED_LAST_LINE (1<<3)
#define MARK_WAS_SET (1<<4)
#define CURSOR_WAS_AT_HEAD (1<<5)
#endif /* !NANO_TINY */
/* The default number of columns from end of line where wrapping occurs. */
#define COLUMNS_FROM_EOL 8
/* The default width of a tab in spaces. */
#define WIDTH_OF_TAB 8
/* The default comment character when a syntax does not specify any. */
#define GENERAL_COMMENT_CHARACTER "#"
/* The maximum number of search/replace history strings saved, not
* counting the blank lines at their ends. */
#define MAX_SEARCH_HISTORY 100
/* The largest size_t number that doesn't have the high bit set. */
#define HIGHEST_POSITIVE ((~(size_t)0) >> 1)

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* global.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014-2020 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -49,7 +49,8 @@ bool we_are_running = FALSE;
/* Becomes TRUE as soon as all options and files have been read. */
bool more_than_one = FALSE;
/* Whether more than one buffer is or has been open. */
bool report_size = TRUE;
/* Whether to show the number of lines when the minibar is used. */
bool ran_a_tool = FALSE;
/* Whether a tool has been run at the Execute-Command prompt. */
@@ -79,6 +80,8 @@ linestruct *pletion_line = NULL;
bool also_the_last = FALSE;
/* Whether indenting/commenting should include the last line of
* the marked region. */
bool hide_cursor = FALSE;
/* Whether to suppress the cursor when highlighting a search match. */
char *answer = NULL;
/* The answer string used by the status-bar prompt. */
@@ -298,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)
{
}
@@ -381,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;
@@ -477,7 +474,8 @@ size_t shown_entries_for(int menu)
}
/* When --saveonexit is not used, widen the grid of the WriteOut menu. */
if (menu == MWRITEFILE && first_sc_for(menu, discard_buffer) == NULL)
if (menu == MWRITEFILE && item == NULL &&
first_sc_for(menu, discard_buffer) == NULL)
count--;
return count;
@@ -529,6 +527,7 @@ functionptrtype interpret(int *keycode)
return do_findnext;
switch (tolower(*keycode)) {
case 'b':
case '-':
return do_page_up;
case ' ':
@@ -728,10 +727,11 @@ void shortcut_init(void)
#endif
/* Start populating the different menus with functions. */
#ifdef ENABLE_HELP
add_to_funcs(do_help, (MMOST | MBROWSER) & ~MFINDINHELP,
/* TRANSLATORS: Try to keep the next thirteen strings at most 10 characters. */
N_("Help"), WITHORSANS(help_gist), TOGETHER, VIEW);
#endif
add_to_funcs(do_cancel, ((MMOST & ~MMAIN) | MYESNO),
N_("Cancel"), WITHORSANS(cancel_gist), BLANKAFTER, VIEW);
@@ -746,6 +746,15 @@ void shortcut_init(void)
close_tag, WITHORSANS(exitbrowser_gist), TOGETHER, VIEW);
#endif
#ifndef ENABLE_HELP
add_to_funcs(full_refresh, MMAIN|MREPLACE, "Refresh", "x", 0, VIEW);
#ifndef NANO_TINY
add_to_funcs(full_refresh, MINSERTFILE|MEXECUTE, "Refresh", "x", 0, VIEW);
#endif
add_to_funcs(flip_goto, MWHEREIS, "Go To Line", "x", 0, VIEW);
add_to_funcs(flip_goto, MGOTOLINE, "Go To Text", "x", 0, VIEW);
#endif
add_to_funcs(do_writeout_void, MMAIN,
N_("Write Out"), WITHORSANS(writeout_gist), TOGETHER, NOVIEW);
@@ -761,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
@@ -778,6 +787,16 @@ void shortcut_init(void)
add_to_funcs(do_replace, MMAIN,
N_("Replace"), WITHORSANS(replace_gist), TOGETHER, NOVIEW);
#ifdef NANO_TINY
add_to_funcs(do_search_backward, MHELP,
N_("Where Was"), WITHORSANS(wherewas_gist), TOGETHER, VIEW);
add_to_funcs(do_findprevious, MMAIN|MHELP,
N_("Previous"), WITHORSANS(findprev_gist), TOGETHER, VIEW);
add_to_funcs(do_findnext, MMAIN|MHELP,
N_("Next"), WITHORSANS(findnext_gist), BLANKAFTER, VIEW);
#endif
add_to_funcs(cut_text, MMAIN,
N_("Cut"), WITHORSANS(cut_gist), TOGETHER, NOVIEW);
@@ -790,12 +809,13 @@ 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
}
add_to_funcs(report_cursor_position, MMAIN,
/* TRANSLATORS: This refers to the position of the cursor. */
N_("Location"), WITHORSANS(cursorpos_gist), TOGETHER, VIEW);
#if defined(NANO_TINY) || defined(ENABLE_JUSTIFY)
@@ -815,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,
@@ -827,7 +847,6 @@ void shortcut_init(void)
add_to_funcs(flip_replace, MWHEREIS,
N_("Replace"), WITHORSANS(replace_gist), BLANKAFTER, VIEW);
add_to_funcs(flip_replace, MREPLACE,
N_("No Replace"), WITHORSANS(whereis_gist), BLANKAFTER, VIEW);
@@ -838,40 +857,49 @@ void shortcut_init(void)
N_("Newer"), WITHORSANS(newer_gist), BLANKAFTER, VIEW);
#endif
#ifdef ENABLE_HELP
add_to_funcs(flip_goto, MWHEREIS,
N_("Go To Line"), WITHORSANS(gotoline_gist), BLANKAFTER, VIEW);
#endif
#ifdef ENABLE_BROWSER
add_to_funcs(goto_dir, MBROWSER,
/* TRANSLATORS: Try to keep the next seven strings at most 10 characters. */
N_("Go To Dir"), WITHORSANS(gotodir_gist), TOGETHER, VIEW);
#ifdef ENABLE_HELP
add_to_funcs(full_refresh, MBROWSER,
N_("Refresh"), WITHORSANS(browserrefresh_gist), BLANKAFTER, VIEW);
#endif
add_to_funcs(do_search_forward, MBROWSER,
N_("Where Is"), WITHORSANS(browserwhereis_gist), TOGETHER, VIEW);
add_to_funcs(do_search_backward, MBROWSER,
N_("Where Was"), WITHORSANS(browserwherewas_gist), TOGETHER, VIEW);
add_to_funcs(do_findprevious, MBROWSER,
N_("Previous"), WITHORSANS(findprev_gist), TOGETHER, VIEW);
add_to_funcs(do_findnext, MBROWSER,
N_("Next"), WITHORSANS(findnext_gist), BLANKAFTER, VIEW);
#endif
#ifndef NANO_TINY
#ifdef NANO_TINY
add_to_funcs(to_prev_word, MMAIN,
"Prev Word", WITHORSANS(prevword_gist), TOGETHER, VIEW);
add_to_funcs(to_next_word, MMAIN,
"Next Word", WITHORSANS(nextword_gist), BLANKAFTER, VIEW);
#else
add_to_funcs(do_find_bracket, MMAIN,
N_("To Bracket"), WITHORSANS(bracket_gist), BLANKAFTER, VIEW);
add_to_funcs(do_search_backward, MMAIN|MHELP,
/* TRANSLATORS: This starts a backward search. */
N_("Where Was"), WITHORSANS(wherewas_gist), TOGETHER, VIEW);
#else
add_to_funcs(do_search_backward, MHELP,
N_("Where Was"), WITHORSANS(wherewas_gist), TOGETHER, VIEW);
#endif
add_to_funcs(do_findprevious, MMAIN|MBROWSER|MHELP,
add_to_funcs(do_findprevious, MMAIN|MHELP,
/* TRANSLATORS: This refers to searching the preceding occurrence. */
N_("Previous"), WITHORSANS(findprev_gist), TOGETHER, VIEW);
add_to_funcs(do_findnext, MMAIN|MBROWSER|MHELP,
add_to_funcs(do_findnext, MMAIN|MHELP,
N_("Next"), WITHORSANS(findnext_gist), BLANKAFTER, VIEW);
#endif
add_to_funcs(do_left, MMAIN,
/* TRANSLATORS: This means move the cursor one character back. */
@@ -885,11 +913,13 @@ void shortcut_init(void)
N_("Forward"), WITHORSANS(forwardfile_gist), TOGETHER, VIEW);
#endif
#ifndef NANO_TINY
add_to_funcs(to_prev_word, MMAIN,
/* TRANSLATORS: Try to keep the next ten strings at most 12 characters. */
N_("Prev Word"), WITHORSANS(prevword_gist), TOGETHER, VIEW);
add_to_funcs(to_next_word, MMAIN,
N_("Next Word"), WITHORSANS(nextword_gist), TOGETHER, VIEW);
#endif
add_to_funcs(do_home, MMAIN,
N_("Home"), WITHORSANS(home_gist), TOGETHER, VIEW);
@@ -913,7 +943,7 @@ void shortcut_init(void)
N_("Next Block"), WITHORSANS(nextblock_gist), TOGETHER, VIEW);
#ifdef ENABLE_JUSTIFY
add_to_funcs(to_para_begin, MMAIN|MGOTOLINE,
/* TRANSLATORS: Try to keep these two strings at most 15 characters. */
/* TRANSLATORS: Try to keep these two strings at most 16 characters. */
N_("Begin of Paragr."), WITHORSANS(parabegin_gist), TOGETHER, VIEW);
add_to_funcs(to_para_end, MMAIN|MGOTOLINE,
N_("End of Paragraph"), WITHORSANS(paraend_gist), BLANKAFTER, VIEW);
@@ -982,8 +1012,10 @@ void shortcut_init(void)
add_to_funcs(do_verbatim_input, MMAIN,
N_("Verbatim"), WITHORSANS(verbatim_gist), BLANKAFTER, NOVIEW);
#ifdef ENABLE_HELP
add_to_funcs(full_refresh, MMAIN,
N_("Refresh"), WITHORSANS(refresh_gist), TOGETHER, VIEW);
#endif
add_to_funcs(do_suspend_void, MMAIN,
N_("Suspend"), WITHORSANS(suspend_gist), BLANKAFTER, VIEW);
@@ -1002,6 +1034,7 @@ void shortcut_init(void)
add_to_funcs(complete_a_word, MMAIN,
N_("Complete"), WITHORSANS(completion_gist), BLANKAFTER, NOVIEW);
#endif
#ifndef NANO_TINY
add_to_funcs(record_macro, MMAIN,
N_("Record"), WITHORSANS(recordmacro_gist), TOGETHER, VIEW);
@@ -1032,10 +1065,12 @@ void shortcut_init(void)
#endif
}
#endif /* !NANO_TINY */
#ifdef NANO_TINY
add_to_funcs(do_search_backward, MMAIN,
N_("Where Was"), WITHORSANS(wherewas_gist), BLANKAFTER, VIEW);
#endif
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
add_to_funcs(do_center, MMAIN,
N_("Center"), WITHORSANS(center_gist), BLANKAFTER, VIEW);
@@ -1070,8 +1105,10 @@ void shortcut_init(void)
N_("Formatter"), WITHORSANS(formatter_gist), BLANKAFTER, NOVIEW);
#endif
#ifdef ENABLE_HELP
add_to_funcs(flip_goto, MGOTOLINE,
N_("Go To Text"), WITHORSANS(whereis_gist), BLANKAFTER, VIEW);
#endif
#ifndef NANO_TINY
add_to_funcs(dos_format_void, MWRITEFILE,
@@ -1108,6 +1145,7 @@ void shortcut_init(void)
N_("Suspend"), WITHORSANS(suspend_gist), BLANKAFTER, VIEW);
}
#endif /* !NANO_TINY */
#ifdef ENABLE_BROWSER
/* The file browser is only available when not in restricted mode. */
if (!ISSET(RESTRICTED))
@@ -1124,6 +1162,7 @@ void shortcut_init(void)
N_("First File"), WITHORSANS(firstfile_gist), TOGETHER, VIEW);
add_to_funcs(to_last_file, MBROWSER|MWHEREISFILE,
N_("Last File"), WITHORSANS(lastfile_gist), BLANKAFTER, VIEW);
#ifndef NANO_TINY
add_to_funcs(to_prev_word, MBROWSER,
N_("Left Column"), WITHORSANS(browserlefthand_gist), TOGETHER, VIEW);
@@ -1147,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);
@@ -1175,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);
@@ -1188,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);
@@ -1203,7 +1249,12 @@ void shortcut_init(void)
add_to_sclist(MMAIN|MHELP, "^End", CONTROL_END, to_last_line, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP, "M-W", 0, do_findnext, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP, "M-Q", 0, do_findprevious, 0);
#ifndef NANO_TINY
#ifdef NANO_TINY
add_to_sclist(MMAIN, "M-B", 0, to_prev_word, 0);
add_to_sclist(MMAIN, "M-D", 0, to_prev_word, 0);
add_to_sclist(MMAIN, "M-N", 0, to_next_word, 0);
add_to_sclist(MMAIN, "M-F", 0, to_next_word, 0);
#else
add_to_sclist(MMAIN, "M-]", 0, do_find_bracket, 0);
add_to_sclist(MMAIN, "M-A", 0, do_mark, 0);
add_to_sclist(MMAIN, "^6", 0, do_mark, 0);
@@ -1236,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
@@ -1260,12 +1311,6 @@ void shortcut_init(void)
}
#endif
}
#ifdef NANO_TINY
add_to_sclist(MMAIN, "M-B", 0, to_prev_word, 0);
add_to_sclist(MMAIN, "M-D", 0, to_prev_word, 0);
add_to_sclist(MMAIN, "M-F", 0, to_next_word, 0);
add_to_sclist(MMAIN, "M-N", 0, to_next_word, 0);
#endif
add_to_sclist(MMOST, "M-Space", 0, to_prev_word, 0);
add_to_sclist(MMOST, "^Space", 0, to_next_word, 0);
add_to_sclist(MMOST, "^A", 0, do_home, 0);
@@ -1276,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
{
@@ -1299,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
{
@@ -1325,6 +1370,8 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "M-T", 0, cut_till_eof, 0);
add_to_sclist(MEXECUTE, "^V", 0, cut_till_eof, 0);
add_to_sclist(MMAIN, "M-D", 0, do_wordlinechar_count, 0);
#else
add_to_sclist(MMAIN, "M-H", 0, do_help, 0);
#endif
#ifdef ENABLE_JUSTIFY
add_to_sclist(MMAIN, "M-J", 0, do_full_justify, 0);
@@ -1382,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
{
@@ -1395,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);
@@ -1409,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);
@@ -1460,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

@@ -1,7 +1,7 @@
/**************************************************************************
* help.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2000-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2000-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2017 Rishabh Dave *
* Copyright (C) 2014-2019 Benno Schulenberg *
* *
@@ -50,7 +50,7 @@ void help_init(void)
char *ptr;
/* First, set up the initial help text for the current function. */
if (currmenu == MWHEREIS || currmenu == MREPLACE || currmenu == MREPLACEWITH) {
if (currmenu & (MWHEREIS|MREPLACE|MREPLACEWITH)) {
htx[0] = N_("Search Command Help Text\n\n "
"Enter the words or characters you would like to "
"search for, and then press Enter. If there is a "
@@ -240,7 +240,7 @@ void help_init(void)
#endif
/* Allocate memory for the help text. */
help_text = charalloc(allocsize + 1);
help_text = nmalloc(allocsize + 1);
/* Now add the text we want. */
strcpy(help_text, htx[0]);
@@ -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. */
@@ -457,9 +457,13 @@ void show_help(void)
/* Show the cursor when we searched and found something. */
kbinput = get_kbinput(edit, didfind == 1 || ISSET(SHOW_CURSOR));
didfind = 0;
#ifndef NANO_TINY
spotlighted = FALSE;
hide_cursor = FALSE;
if (bracketed_paste || kbinput == BRACKETED_PASTE_MARKER) {
beep();
continue;
@@ -475,14 +479,13 @@ void show_help(void)
} else if (func == do_up || func == do_scroll_up) {
do_scroll_up();
} else if (func == do_down || func == do_scroll_down) {
if (openfile->edittop->lineno + editwinrows - 1 <
openfile->filebot->lineno)
if (openfile->edittop->lineno + editwinrows - 1 < openfile->filebot->lineno)
do_scroll_down();
} else if (func == do_page_up || func == do_page_down ||
func == to_first_line || func == to_last_line ||
func == do_findprevious || func == do_findnext) {
func == to_first_line || func == to_last_line) {
func();
} else if (func == do_search_forward || func == do_search_backward) {
} else if (func == do_search_backward || func == do_search_forward ||
func == do_findprevious || func == do_findnext) {
func();
bottombars(MHELP);
#ifdef ENABLE_NANORC
@@ -503,7 +506,6 @@ void show_help(void)
} else
unbound_key(kbinput);
currmenu = MHELP;
edit_refresh();
location = 0;
@@ -550,7 +552,7 @@ void show_help(void)
}
#ifdef ENABLE_BROWSER
if (oldmenu == MBROWSER || oldmenu == MWHEREISFILE || oldmenu == MGOTODIR)
if (oldmenu & (MBROWSER|MWHEREISFILE|MGOTODIR))
browser_refresh();
else
#endif
@@ -568,8 +570,8 @@ void do_help(void)
#ifdef ENABLE_HELP
show_help();
#else
if (currmenu == MMAIN)
say_there_is_no_help();
if (currmenu & (MMAIN|MBROWSER))
statusbar(_("^W = Ctrl+W M-W = Alt+W"));
else
beep();
#endif

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* history.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2003-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2003-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2016, 2017, 2019 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -299,17 +299,17 @@ void load_history(void)
}
linestruct **history = &search_history;
char *line = NULL;
size_t buf_len = 0;
char *stanza = NULL;
size_t dummy = 0;
ssize_t read;
/* Load the three history lists (first search, then replace, then execute)
* from oldest entry to newest. Between two lists there is an empty line. */
while ((read = getline(&line, &buf_len, histfile)) > 0) {
line[--read] = '\0';
while ((read = getline(&stanza, &dummy, histfile)) > 0) {
stanza[--read] = '\0';
if (read > 0) {
recode_NUL_to_LF(line, read);
update_history(history, line);
recode_NUL_to_LF(stanza, read);
update_history(history, stanza);
} else if (history == &search_history)
history = &replace_history;
else
@@ -320,7 +320,7 @@ void load_history(void)
jot_error(N_("Error reading %s: %s"), histname, strerror(errno));
free(histname);
free(line);
free(stanza);
/* Reading in the lists has marked them as changed; undo this side effect. */
history_changed = FALSE;
@@ -361,20 +361,21 @@ void save_history(void)
histfile = fopen(histname, "wb");
if (histfile == NULL) {
jot_error(N_("Error writing %s: %s\n"), histname, strerror(errno));
jot_error(N_("Error writing %s: %s"), histname, strerror(errno));
free(histname);
return;
}
/* 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))
jot_error(N_("Error writing %s: %s\n"), histname, strerror(errno));
jot_error(N_("Error writing %s: %s"), histname, strerror(errno));
if (fclose(histfile) == EOF)
jot_error(N_("Error writing %s: %s\n"), histname, strerror(errno));
jot_error(N_("Error writing %s: %s"), histname, strerror(errno));
free(histname);
}
@@ -393,34 +394,35 @@ void load_poshistory(void)
if (histfile == NULL)
return;
char *line = NULL, *lineptr, *xptr;
size_t buf_len = 0;
ssize_t read, count = 0;
struct stat fileinfo;
poshiststruct *record_ptr = NULL, *newrecord;
char *lineptr, *columnptr;
char *stanza = NULL;
size_t dummy = 0;
/* Read and parse each line, and store the extracted data. */
while ((read = getline(&line, &buf_len, histfile)) > 5) {
while ((read = getline(&stanza, &dummy, histfile)) > 5) {
/* Decode NULs as embedded newlines. */
recode_NUL_to_LF(line, read);
recode_NUL_to_LF(stanza, read);
/* Find where the x index and line number are in the line. */
xptr = revstrstr(line, " ", line + read - 3);
if (xptr == NULL)
/* Find the spaces before column number and line number. */
columnptr = revstrstr(stanza, " ", stanza + read - 3);
if (columnptr == NULL)
continue;
lineptr = revstrstr(line, " ", xptr - 2);
lineptr = revstrstr(stanza, " ", columnptr - 2);
if (lineptr == NULL)
continue;
/* Now separate the three elements of the line. */
*(xptr++) = '\0';
*(columnptr++) = '\0';
*(lineptr++) = '\0';
/* Create a new position record. */
newrecord = (poshiststruct *)nmalloc(sizeof(poshiststruct));
newrecord->filename = copy_of(line);
newrecord->lineno = atoi(lineptr);
newrecord->xno = atoi(xptr);
newrecord = nmalloc(sizeof(poshiststruct));
newrecord->filename = copy_of(stanza);
newrecord->linenumber = atoi(lineptr);
newrecord->columnnumber = atoi(columnptr);
newrecord->next = NULL;
/* Add the record to the list. */
@@ -445,7 +447,7 @@ void load_poshistory(void)
if (fclose(histfile) == EOF)
jot_error(N_("Error reading %s: %s"), poshistname, strerror(errno));
free(line);
free(stanza);
if (stat(poshistname, &fileinfo) == 0)
latest_timestamp = fileinfo.st_mtime;
@@ -459,12 +461,13 @@ void save_poshistory(void)
FILE *histfile = fopen(poshistname, "wb");
if (histfile == NULL) {
jot_error(N_("Error writing %s: %s\n"), poshistname, strerror(errno));
jot_error(N_("Error writing %s: %s"), poshistname, strerror(errno));
return;
}
/* 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;
@@ -472,9 +475,9 @@ void save_poshistory(void)
/* Assume 20 decimal positions each for line and column number,
* plus two spaces, plus the line feed, plus the null byte. */
path_and_place = charalloc(strlen(posptr->filename) + 44);
path_and_place = nmalloc(strlen(posptr->filename) + 44);
sprintf(path_and_place, "%s %zd %zd\n",
posptr->filename, posptr->lineno, posptr->xno);
posptr->filename, posptr->linenumber, posptr->columnnumber);
length = strlen(path_and_place);
/* Encode newlines in filenames as NULs. */
@@ -483,13 +486,13 @@ void save_poshistory(void)
path_and_place[length - 1] = '\n';
if (fwrite(path_and_place, sizeof(char), length, histfile) < length)
jot_error(N_("Error writing %s: %s\n"), poshistname, strerror(errno));
jot_error(N_("Error writing %s: %s"), poshistname, strerror(errno));
free(path_and_place);
}
if (fclose(histfile) == EOF)
jot_error(N_("Error writing %s: %s\n"), poshistname, strerror(errno));
jot_error(N_("Error writing %s: %s"), poshistname, strerror(errno));
if (stat(poshistname, &fileinfo) == 0)
latest_timestamp = fileinfo.st_mtime;
@@ -556,7 +559,7 @@ void update_poshistory(void)
/* If we didn't find it, make a new node; otherwise, if we're
* not at the end, move the matching one to the end. */
if (theone == NULL) {
theone = (poshiststruct *)nmalloc(sizeof(poshiststruct));
theone = nmalloc(sizeof(poshiststruct));
theone->filename = copy_of(fullpath);
if (position_history == NULL)
position_history = theone;
@@ -573,8 +576,8 @@ void update_poshistory(void)
}
/* Store the last cursor position. */
theone->lineno = openfile->current->lineno;
theone->xno = xplustabs() + 1;
theone->linenumber = openfile->current->lineno;
theone->columnnumber = xplustabs() + 1;
theone->next = NULL;
free(fullpath);
@@ -604,8 +607,8 @@ bool has_old_position(const char *file, ssize_t *line, ssize_t *column)
if (posptr == NULL)
return FALSE;
*line = posptr->lineno;
*column = posptr->xno;
*line = posptr->linenumber;
*column = posptr->columnnumber;
return TRUE;
}
#endif /* ENABLE_HISTORIES */

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* move.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014-2018 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -115,6 +115,7 @@ void do_page_up(void)
int mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
size_t leftedge, target_column;
#ifndef NANO_TINY
/* If we're not in smooth scrolling mode, put the cursor at the
* beginning of the top line of the edit window, as Pico does. */
if (ISSET(JUMPY_SCROLLING)) {
@@ -123,6 +124,7 @@ void do_page_up(void)
openfile->current_y = 0;
target_column = 0;
} else
#endif
get_edge_and_target(&leftedge, &target_column);
/* Move up the required number of lines or chunks. If we can't, we're
@@ -145,6 +147,7 @@ void do_page_down(void)
int mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
size_t leftedge, target_column;
#ifndef NANO_TINY
/* If we're not in smooth scrolling mode, put the cursor at the
* beginning of the top line of the edit window, as Pico does. */
if (ISSET(JUMPY_SCROLLING)) {
@@ -153,6 +156,7 @@ void do_page_down(void)
openfile->current_y = 0;
target_column = 0;
} else
#endif
get_edge_and_target(&leftedge, &target_column);
/* Move down the required number of lines or chunks. If we can't, we're
@@ -287,6 +291,10 @@ void do_prev_word(bool allow_punct)
/* If at the head of a line now, this surely is a word start. */
if (openfile->current_x == 0)
break;
#ifdef ENABLE_UTF8
} else if (is_zerowidth(openfile->current->data + openfile->current_x)) {
; /* skip */
#endif
} else if (seen_a_word) {
/* This is space now: we've overshot the start of the word. */
step_forward = TRUE;
@@ -335,11 +343,20 @@ bool do_next_word(bool after_ends, bool allow_punct)
if (is_word_char(openfile->current->data + openfile->current_x,
allow_punct))
seen_word = TRUE;
#ifdef ENABLE_UTF8
else if (is_zerowidth(openfile->current->data + openfile->current_x))
; /* skip */
#endif
else if (seen_word)
break;
} else
#endif
{
#ifdef ENABLE_UTF8
if (is_zerowidth(openfile->current->data + openfile->current_x))
; /* skip */
else
#endif
/* If this is not a word character, then it's a separator; else
* if we've already seen a separator, then it's a word start. */
if (!is_word_char(openfile->current->data + openfile->current_x,
@@ -577,10 +594,16 @@ void do_left(void)
{
linestruct *was_current = openfile->current;
if (openfile->current_x > 0)
if (openfile->current_x > 0) {
openfile->current_x = step_left(openfile->current->data,
openfile->current_x);
else if (openfile->current != openfile->filetop) {
#ifdef ENABLE_UTF8
while (openfile->current_x > 0 &&
is_zerowidth(openfile->current->data + openfile->current_x))
openfile->current_x = step_left(openfile->current->data,
openfile->current_x);
#endif
} else if (openfile->current != openfile->filetop) {
openfile->current = openfile->current->prev;
openfile->current_x = strlen(openfile->current->data);
}
@@ -593,10 +616,16 @@ void do_right(void)
{
linestruct *was_current = openfile->current;
if (openfile->current->data[openfile->current_x] != '\0')
if (openfile->current->data[openfile->current_x] != '\0') {
openfile->current_x = step_right(openfile->current->data,
openfile->current_x);
else if (openfile->current != openfile->filebot) {
#ifdef ENABLE_UTF8
while (openfile->current->data[openfile->current_x] != '\0' &&
is_zerowidth(openfile->current->data + openfile->current_x))
openfile->current_x = step_right(openfile->current->data,
openfile->current_x);
#endif
} else if (openfile->current != openfile->filebot) {
openfile->current = openfile->current->next;
openfile->current_x = 0;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* prompt.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2016, 2018 Benno Schulenberg *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2016, 2018, 2020 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 *
@@ -57,9 +57,18 @@ void do_statusbar_next_word(void)
* and if we've already seen a word, then it's a word end. */
if (is_word_char(answer + typing_x, FALSE))
seen_word = TRUE;
#ifdef ENABLE_UTF8
else if (is_zerowidth(answer + typing_x))
; /* skip */
#endif
else if (seen_word)
break;
} else {
#ifdef ENABLE_UTF8
if (is_zerowidth(answer + typing_x))
; /* skip */
else
#endif
/* If this is not a word character, then it's a separator; else
* if we've already seen a separator, then it's a word start. */
if (!is_word_char(answer + typing_x, FALSE))
@@ -81,6 +90,10 @@ void do_statusbar_prev_word(void)
if (is_word_char(answer + typing_x, FALSE))
seen_a_word = TRUE;
#ifdef ENABLE_UTF8
else if (is_zerowidth(answer + typing_x))
; /* skip */
#endif
else if (seen_a_word) {
/* This is space now: we've overshot the start of the word. */
step_forward = TRUE;
@@ -97,15 +110,25 @@ void do_statusbar_prev_word(void)
/* Move left one character in the answer. */
void do_statusbar_left(void)
{
if (typing_x > 0)
if (typing_x > 0) {
typing_x = step_left(answer, typing_x);
#ifdef ENABLE_UTF8
while (typing_x > 0 && is_zerowidth(answer + typing_x))
typing_x = step_left(answer, typing_x);
#endif
}
}
/* Move right one character in the answer. */
void do_statusbar_right(void)
{
if (answer[typing_x] != '\0')
if (answer[typing_x] != '\0') {
typing_x = step_right(answer, typing_x);
#ifdef ENABLE_UTF8
while (answer[typing_x] != '\0' && is_zerowidth(answer + typing_x))
typing_x = step_right(answer, typing_x);
#endif
}
}
/* Delete one character in the answer. */
@@ -116,6 +139,10 @@ void do_statusbar_delete(void)
memmove(answer + typing_x, answer + typing_x + charlen,
strlen(answer) - typing_x - charlen + 1);
#ifdef ENABLE_UTF8
if (is_zerowidth(answer + typing_x))
do_statusbar_delete();
#endif
}
}
@@ -123,8 +150,10 @@ void do_statusbar_delete(void)
void do_statusbar_backspace(void)
{
if (typing_x > 0) {
size_t was_x = typing_x;
typing_x = step_left(answer, typing_x);
do_statusbar_delete();
memmove(answer + typing_x, answer + was_x, strlen(answer) - was_x + 1);
}
}
@@ -141,7 +170,7 @@ void do_statusbar_cut_text(void)
void paste_into_answer(void)
{
size_t pastelen = strlen(cutbuffer->data);
char *fusion = charalloc(strlen(answer) + pastelen + 1);
char *fusion = nmalloc(strlen(answer) + pastelen + 1);
/* Concatenate: the current answer before the cursor, the first line
* of the cutbuffer, plus the rest of the current answer. */
@@ -184,7 +213,7 @@ void inject_into_answer(char *burst, size_t count)
if (burst[index] == '\0')
burst[index] = '\n';
answer = charealloc(answer, strlen(answer) + count + 1);
answer = nrealloc(answer, strlen(answer) + count + 1);
memmove(answer + typing_x + count, answer + typing_x,
strlen(answer) - typing_x + 1);
strncpy(answer + typing_x, burst , count);
@@ -253,7 +282,7 @@ int do_statusbar_input(bool *finished)
beep();
else if (!ISSET(RESTRICTED) || currmenu != MWRITEFILE ||
openfile->filename[0] == '\0') {
puddle = charealloc(puddle, depth + 2);
puddle = nrealloc(puddle, depth + 2);
puddle[depth++] = (char)input;
}
}
@@ -351,18 +380,19 @@ void put_cursor_at_end_of_answer(void)
typing_x = HIGHEST_POSITIVE;
}
/* Redraw the promptbar and place the cursor at the right spot. */
/* Redraw the prompt bar and place the cursor at the right spot. */
void draw_the_promptbar(void)
{
size_t base = breadth(prompt) + 2;
size_t the_page, end_page, column;
size_t column = base + wideness(answer, typing_x);
size_t the_page, end_page;
char *expanded;
the_page = get_statusbar_page_start(base, base + wideness(answer, typing_x));
the_page = get_statusbar_page_start(base, column);
end_page = get_statusbar_page_start(base, base + breadth(answer) - 1);
/* Color the promptbar over its full width. */
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
/* Color the prompt bar over its full width. */
wattron(bottomwin, interface_color_pair[PROMPT_BAR]);
mvwprintw(bottomwin, 0, 0, "%*s", COLS, " ");
mvwaddstr(bottomwin, 0, 0, prompt);
@@ -373,18 +403,21 @@ void draw_the_promptbar(void)
waddstr(bottomwin, expanded);
free(expanded);
if (base + breadth(answer) != COLS && the_page < end_page)
if (the_page < end_page && base + breadth(answer) - the_page > COLS)
mvwaddch(bottomwin, 0, COLS - 1, '>');
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
wattroff(bottomwin, interface_color_pair[PROMPT_BAR]);
/* Work around a cursor-misplacement bug in VTEs. */
wmove(bottomwin, 0, 0);
wrefresh(bottomwin);
#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH < 20210220)
/* Work around a cursor-misplacement bug -- https://sv.gnu.org/bugs/?59808. */
if (ISSET(NO_HELP)) {
wmove(bottomwin, 0, 0);
wrefresh(bottomwin);
}
#endif
/* Place the cursor at the right spot. */
column = base + wideness(answer, typing_x);
wmove(bottomwin, 0, column - get_statusbar_page_start(base, column));
wmove(bottomwin, 0, column - the_page);
wnoutrefresh(bottomwin);
}
@@ -393,11 +426,11 @@ 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 {
answer = charealloc(answer, strlen(answer) + 2);
answer = nrealloc(answer, strlen(answer) + 2);
memmove(answer + 1, answer, strlen(answer) + 1);
answer[0] = '|';
typing_x++;
@@ -465,8 +498,7 @@ functionptrtype acquire_an_answer(int *actual, bool *listed,
} else
#endif
/* Allow tab completion of filenames, but not in restricted mode. */
if ((currmenu == MINSERTFILE || currmenu == MWRITEFILE ||
currmenu == MGOTODIR) && !ISSET(RESTRICTED))
if ((currmenu & (MINSERTFILE|MWRITEFILE|MGOTODIR)) && !ISSET(RESTRICTED))
answer = input_tab(answer, &typing_x, refresh_func, listed);
} else
#endif /* ENABLE_TABCOMP */
@@ -566,7 +598,7 @@ int do_prompt(int menu, const char *provided, linestruct **history_list,
#ifndef NANO_TINY
redo_theprompt:
#endif
prompt = charalloc((COLS * MAXCHARLEN) + 1);
prompt = nmalloc((COLS * MAXCHARLEN) + 1);
va_start(ap, msg);
vsnprintf(prompt, COLS * MAXCHARLEN, msg, ap);
va_end(ap);
@@ -659,11 +691,11 @@ int do_yesno_prompt(bool all, const char *msg)
post_one_key(cancelshortcut->keystr, _("Cancel"), width);
}
/* Color the promptbar over its full width and display the question. */
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
/* Color the prompt bar over its full width and display the question. */
wattron(bottomwin, interface_color_pair[PROMPT_BAR]);
mvwprintw(bottomwin, 0, 0, "%*s", COLS, " ");
mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
wattroff(bottomwin, interface_color_pair[PROMPT_BAR]);
wnoutrefresh(bottomwin);
currmenu = MYESNO;
@@ -734,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

@@ -1,7 +1,7 @@
/**************************************************************************
* prototypes.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -36,7 +36,7 @@ extern bool bracketed_paste;
extern bool we_are_running;
extern bool more_than_one;
extern bool report_size;
extern bool ran_a_tool;
extern bool inhelp;
@@ -53,6 +53,7 @@ extern message_type lastmessage;
extern linestruct *pletion_line;
extern bool also_the_last;
extern bool hide_cursor;
extern char *answer;
@@ -186,15 +187,12 @@ extern size_t light_to_col;
typedef void (*functionptrtype)(void);
/* Most functions in browser.c. */
/* The two needed functions from browser.c. */
#ifdef ENABLE_BROWSER
char *browse_in(const char *inpath);
void read_the_list(const char *path, DIR *dir);
void browser_refresh(void);
void browser_select_dirname(const char *needle);
void do_filesearch(bool forwards);
void do_fileresearch(bool forwards);
char *strip_last_component(const char *path);
char *browse_in(const char *inpath);
void to_first_file(void);
void to_last_file(void);
#endif
/* Most functions in chars.c. */
@@ -208,8 +206,9 @@ bool is_cntrl_char(const char *c);
bool is_word_char(const char *c, bool allow_punct);
char control_mbrep(const char *c, bool isdata);
#ifdef ENABLE_UTF8
int mbwidth(const char *c);
char *make_mbchar(long code, int *length);
int mbtowide(wchar_t *wc, const char *c);
bool is_doublewidth(const char *ch);
bool is_zerowidth(const char *ch);
#endif
int char_length(const char *pointer);
size_t mbstrlen(const char *pointer);
@@ -233,16 +232,12 @@ char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer);
bool has_blank_char(const char *string);
#endif
bool white_string(const char *string);
#ifdef ENABLE_UTF8
bool is_valid_unicode(wchar_t wc);
#endif
/* Most functions in color.c. */
#ifdef ENABLE_COLOR
void set_interface_colorpairs(void);
void prepare_palette(void);
void find_and_prime_applicable_syntax(void);
void set_up_multicache(linestruct *line);
void check_the_multis(linestruct *line);
void precalc_multicolorinfo(void);
#endif
@@ -301,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);
@@ -395,9 +390,6 @@ void free_lines(linestruct *src);
void renumber_from(linestruct *line);
void print_view_warning(void);
bool in_restricted_mode(void);
#ifndef ENABLE_HELP
void say_there_is_no_help(void);
#endif
void finish(void);
void close_and_go(void);
void do_exit(void);
@@ -405,19 +397,20 @@ void die(const char *msg, ...);
void window_init(void);
void install_handler_for_Ctrl_C(void);
void restore_handler_for_Ctrl_C(void);
#ifndef NANO_TINY
void reconnect_and_store_state(void);
RETSIGTYPE handle_hupterm(int signal);
#ifndef DEBUG
RETSIGTYPE handle_crash(int signal);
#endif
RETSIGTYPE do_suspend(int signal);
RETSIGTYPE do_continue(int signal);
void handle_hupterm(int signal);
#ifndef DEBUG
void handle_crash(int signal);
#endif
void do_suspend(int signal);
void do_continue(int signal);
#if !defined(NANO_TINY) || defined(ENABLE_SPELLER) || defined(ENABLE_COLOR)
void block_sigwinch(bool blockit);
#endif
#ifndef NANO_TINY
RETSIGTYPE handle_sigwinch(int signal);
void compute_the_extra_rows_per_line_from(linestruct *fromline);
void handle_sigwinch(int signal);
void regenerate_screen(void);
void do_toggle(int flag);
#endif
@@ -516,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
@@ -537,9 +529,7 @@ void complete_a_word(void);
void get_homedir(void);
const char *tail(const char *path);
char *concatenate(const char *path, const char *name);
#ifdef ENABLE_LINENUMBERS
int digits(ssize_t n);
#endif
bool parse_num(const char *str, ssize_t *result);
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column);
void recode_NUL_to_LF(char *string, size_t length);
@@ -595,9 +585,11 @@ void blank_statusbar(void);
void wipe_statusbar(void);
void blank_bottombars(void);
void check_statusblank(void);
void set_blankdelay_to_one(void);
char *display_string(const char *buf, size_t column, size_t span,
bool isdata, bool isprompt);
void titlebar(const char *path);
void minibar(void);
void statusline(message_type importance, const char *msg, ...);
void statusbar(const char *msg);
void warn_and_briefly_pause(const char *msg);
@@ -646,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

@@ -1,7 +1,7 @@
/**************************************************************************
* rcfile.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2014 Mike Frysinger *
* Copyright (C) 2019 Brand Huntsman *
* Copyright (C) 2014-2020 Benno Schulenberg *
@@ -48,18 +48,18 @@ static const rcoption rcopts[] = {
#endif
{"casesensitive", CASE_SENSITIVE},
{"constantshow", CONSTANT_SHOW},
{"emptyline", EMPTY_LINE},
#ifdef ENABLED_WRAPORJUSTIFY
{"fill", 0},
#endif
#ifdef ENABLE_HISTORIES
{"historylog", HISTORYLOG},
#endif
{"jumpyscrolling", JUMPY_SCROLLING},
#ifdef ENABLE_LINENUMBERS
{"linenumbers", LINE_NUMBERS},
#endif
{"morespace", MORE_SPACE}, /* Deprecated; remove in 2021. */
#ifdef HAVE_LIBMAGIC
{"magic", USE_MAGIC},
#endif
#ifdef ENABLE_MOUSE
{"mouse", USE_MOUSE},
#endif
@@ -68,9 +68,8 @@ static const rcoption rcopts[] = {
#endif
{"nohelp", NO_HELP},
{"nonewlines", NO_NEWLINES},
{"nopauses", NO_PAUSES}, /* Obsolete; remove in 2021. */
#ifdef ENABLE_WRAPPING
{"nowrap", NO_WRAP}, /* Deprecated; remove in 2021. */
{"nowrap", NO_WRAP}, /* Deprecated; remove in 2024. */
#endif
#ifdef ENABLE_OPERATINGDIR
{"operatingdir", 0},
@@ -93,9 +92,7 @@ static const rcoption rcopts[] = {
#endif
{"suspend", SUSPENDABLE}, /* Deprecated; remove in 2022. */
{"suspendable", SUSPENDABLE},
{"tabsize", 0},
{"tempfile", SAVE_ON_EXIT}, /* Deprecated; remove in 2022. */
{"view", VIEW_MODE},
#ifndef NANO_TINY
{"afterends", AFTER_ENDS},
{"allow_insecure_backup", INSECURE_BACKUP},
@@ -105,15 +102,19 @@ static const rcoption rcopts[] = {
{"backupdir", 0},
{"bookstyle", BOOKSTYLE},
{"cutfromcursor", CUT_FROM_CURSOR},
{"emptyline", EMPTY_LINE},
{"guidestripe", 0},
{"indicator", INDICATOR},
{"jumpyscrolling", JUMPY_SCROLLING},
{"locking", LOCKING},
{"matchbrackets", 0},
{"minibar", MINIBAR},
{"noconvert", NO_CONVERT},
{"showcursor", SHOW_CURSOR},
{"smarthome", SMART_HOME},
{"smooth", SMOOTH_SCROLL}, /* Deprecated; remove in 2021. */
{"softwrap", SOFTWRAP},
{"stateflags", STATEFLAGS},
{"tabsize", 0},
{"tabstospaces", TABS_TO_SPACES},
{"trimblanks", TRIM_BLANKS},
{"unix", MAKE_IT_UNIX},
@@ -126,7 +127,11 @@ static const rcoption rcopts[] = {
{"titlecolor", 0},
{"numbercolor", 0},
{"stripecolor", 0},
{"scrollercolor", 0},
{"selectedcolor", 0},
{"spotlightcolor", 0},
{"minicolor", 0},
{"promptcolor", 0},
{"statuscolor", 0},
{"errorcolor", 0},
{"keycolor", 0},
@@ -286,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"))
@@ -469,7 +474,8 @@ keystruct *strtosc(const char *input)
else if (!strcmp(input, "cutfromcursor"))
s->toggle = CUT_FROM_CURSOR;
#ifdef ENABLE_WRAPPING
else if (!strcmp(input, "nowrap"))
else if (!strcmp(input, "breaklonglines") ||
!strcmp(input, "nowrap")) /* Deprecated; remove in 2024. */
s->toggle = BREAK_LONG_LINES;
#endif
else if (!strcmp(input, "tabstospaces"))
@@ -612,14 +618,12 @@ bool compile(const char *expression, int rex_flags, regex_t **packed)
if (outcome != 0) {
size_t length = regerror(outcome, compiled, NULL, 0);
char *message = charalloc(length);
char *message = nmalloc(length);
regerror(outcome, compiled, message, length);
jot_error(N_("Bad regex \"%s\": %s"), expression, message);
free(message);
}
if (packed == NULL || outcome != 0) {
regfree(compiled);
free(compiled);
} else
@@ -662,7 +666,7 @@ void begin_new_syntax(char *ptr)
}
/* Initialize a new syntax struct. */
live_syntax = (syntaxtype *)nmalloc(sizeof(syntaxtype));
live_syntax = nmalloc(sizeof(syntaxtype));
live_syntax->name = copy_of(nameptr);
live_syntax->filename = copy_of(nanorc);
live_syntax->lineno = lineno;
@@ -988,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. */
@@ -1010,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;
@@ -1166,7 +1163,7 @@ void parse_rule(char *ptr, int rex_flags)
}
/* Allocate a rule, fill in the data, and link it into the list. */
newcolor = (colortype *)nmalloc(sizeof(colortype));
newcolor = nmalloc(sizeof(colortype));
newcolor->start = start_rgx;
newcolor->end = end_rgx;
@@ -1196,14 +1193,11 @@ colortype *parse_interface_color(char *combostr)
{
colortype *trio = nmalloc(sizeof(colortype));
if (parse_combination(combostr, &trio->fg, &trio->bg, &trio->attributes)) {
free(combostr);
return trio;
} else {
free(combostr);
if (!parse_combination(combostr, &trio->fg, &trio->bg, &trio->attributes)) {
free(trio);
return NULL;
}
} else
return trio;
}
/* Read regex strings enclosed in double quotes from the line pointed at
@@ -1237,6 +1231,8 @@ void grab_and_store(const char *kind, char *ptr, regexlisttype **storage)
/* Now gather any valid regexes and add them to the linked list. */
while (*ptr != '\0') {
regex_t *packed_rgx = NULL;
regexstring = ++ptr;
ptr = parse_next_regex(ptr);
@@ -1244,12 +1240,12 @@ void grab_and_store(const char *kind, char *ptr, regexlisttype **storage)
return;
/* If the regex string is malformed, skip it. */
if (!compile(regexstring, NANO_REG_EXTENDED | REG_NOSUB, NULL))
if (!compile(regexstring, NANO_REG_EXTENDED | REG_NOSUB, &packed_rgx))
continue;
/* Copy the regex into a struct, and hook this in at the end. */
newthing = (regexlisttype *)nmalloc(sizeof(regexlisttype));
newthing->full_regex = copy_of(regexstring);
newthing = nmalloc(sizeof(regexlisttype));
newthing->one_rgx = packed_rgx;
newthing->next = NULL;
if (lastthing == NULL)
@@ -1542,8 +1538,6 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
continue;
}
#endif
argument = copy_of(argument);
#ifdef ENABLE_COLOR
if (strcmp(option, "titlecolor") == 0)
color_combo[TITLE_BAR] = parse_interface_color(argument);
@@ -1551,8 +1545,16 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
color_combo[LINE_NUMBER] = parse_interface_color(argument);
else if (strcmp(option, "stripecolor") == 0)
color_combo[GUIDE_STRIPE] = parse_interface_color(argument);
else if (strcmp(option, "scrollercolor") == 0)
color_combo[SCROLL_BAR] = parse_interface_color(argument);
else if (strcmp(option, "selectedcolor") == 0)
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)
color_combo[STATUS_BAR] = parse_interface_color(argument);
else if (strcmp(option, "errorcolor") == 0)
@@ -1565,7 +1567,7 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
#endif
#ifdef ENABLE_OPERATINGDIR
if (strcmp(option, "operatingdir") == 0)
operating_dir = argument;
operating_dir = copy_of(argument);
else
#endif
#ifdef ENABLED_WRAPORJUSTIFY
@@ -1574,31 +1576,21 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
jot_error(N_("Requested fill size \"%s\" is invalid"), argument);
fill = -COLUMNS_FROM_EOL;
}
free(argument);
} else
#endif
#ifndef NANO_TINY
if (strcmp(option, "guidestripe") == 0) {
if (!parse_num(argument, &stripe_column) || stripe_column <= 0) {
jot_error(N_("Guide column \"%s\" is invalid"), argument);
stripe_column = 0;
}
free(argument);
} else if (strcmp(option, "matchbrackets") == 0) {
if (has_blank_char(argument)) {
if (strcmp(option, "matchbrackets") == 0) {
if (has_blank_char(argument))
jot_error(N_("Non-blank characters required"));
free(argument);
} else if (mbstrlen(argument) % 2 != 0) {
else if (mbstrlen(argument) % 2 != 0)
jot_error(N_("Even number of characters required"));
free(argument);
} else
matchbrackets = argument;
else
matchbrackets = copy_of(argument);
} else if (strcmp(option, "whitespace") == 0) {
if (mbstrlen(argument) != 2 || breadth(argument) != 2) {
if (mbstrlen(argument) != 2 || breadth(argument) != 2)
jot_error(N_("Two single-column characters required"));
free(argument);
} else {
whitespace = argument;
else {
whitespace = copy_of(argument);
whitelen[0] = char_length(whitespace);
whitelen[1] = char_length(whitespace + whitelen[0]);
}
@@ -1606,41 +1598,43 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
#endif
#ifdef ENABLE_JUSTIFY
if (strcmp(option, "punct") == 0) {
if (has_blank_char(argument)) {
if (has_blank_char(argument))
jot_error(N_("Non-blank characters required"));
free(argument);
} else
punct = argument;
else
punct = copy_of(argument);
} else if (strcmp(option, "brackets") == 0) {
if (has_blank_char(argument)) {
if (has_blank_char(argument))
jot_error(N_("Non-blank characters required"));
free(argument);
} else
brackets = argument;
else
brackets = copy_of(argument);
} else if (strcmp(option, "quotestr") == 0)
quotestr = argument;
else
#endif
#ifndef NANO_TINY
if (strcmp(option, "backupdir") == 0)
backup_dir = argument;
else
if (strcmp(option, "wordchars") == 0)
word_chars = argument;
quotestr = copy_of(argument);
else
#endif
#ifdef ENABLE_SPELLER
if (strcmp(option, "speller") == 0)
alt_speller = argument;
alt_speller = copy_of(argument);
else
#endif
if (strcmp(option, "tabsize") == 0) {
#ifndef NANO_TINY
if (strcmp(option, "backupdir") == 0)
backup_dir = copy_of(argument);
else if (strcmp(option, "wordchars") == 0)
word_chars = copy_of(argument);
else if (strcmp(option, "guidestripe") == 0) {
if (!parse_num(argument, &stripe_column) || stripe_column <= 0) {
jot_error(N_("Guide column \"%s\" is invalid"), argument);
stripe_column = 0;
}
} else if (strcmp(option, "tabsize") == 0) {
if (!parse_num(argument, &tabsize) || tabsize <= 0) {
jot_error(N_("Requested tab size \"%s\" is invalid"), argument);
tabsize = -1;
}
free(argument);
}
#else
; /* Properly terminate any earlier 'else'. */
#endif
}
if (intros_only)

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* search.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2015-2019 Benno Schulenberg *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2015-2020 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 *
@@ -22,6 +22,7 @@
#include "prototypes.h"
#include <string.h>
#include <time.h>
static bool came_full_circle = FALSE;
/* Have we reached the starting line again while searching? */
@@ -38,10 +39,10 @@ bool regexp_init(const char *regexp)
/* If regex compilation failed, show the error message. */
if (value != 0) {
size_t len = regerror(value, &search_regexp, NULL, 0);
char *str = charalloc(len);
char *str = nmalloc(len);
regerror(value, &search_regexp, str, len);
statusline(ALERT, _("Bad regex \"%s\": %s"), regexp, str);
statusline(AHEM, _("Bad regex \"%s\": %s"), regexp, str);
free(str);
return FALSE;
@@ -78,10 +79,10 @@ void search_init(bool replacing, bool retain_answer)
if (*last_search != '\0') {
char *disp = display_string(last_search, 0, COLS / 3, FALSE, FALSE);
thedefault = charalloc(strlen(disp) + 7);
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("");
@@ -250,7 +251,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
line = (ISSET(BACKWARDS_SEARCH)) ? openfile->filebot : openfile->filetop;
if (modus == JUSTFIND) {
statusbar(_("Search Wrapped"));
statusline(REMARK, _("Search Wrapped"));
/* Delay the "Searching..." message for at least two seconds. */
feedback = -2;
}
@@ -321,11 +322,19 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
if (match_len != NULL)
*match_len = found_len;
/* Wipe the "Searching..." message and unsuppress cursor-position display. */
if (feedback > 0) {
wipe_statusbar();
lastmessage = VACUUM;
#ifndef NANO_TINY
if (modus == JUSTFIND && (!openfile->mark || openfile->softmark)) {
spotlighted = TRUE;
light_from_col = xplustabs();
light_to_col = wideness(line->data, found_x + found_len);
if (!ISSET(SHOW_CURSOR))
hide_cursor = TRUE;
edit_refresh();
}
#endif
if (feedback > 0)
wipe_statusbar();
return 1;
}
@@ -355,7 +364,7 @@ void do_research(void)
#endif
if (*last_search == '\0') {
statusbar(_("No current search pattern"));
statusline(AHEM, _("No current search pattern"));
return;
}
@@ -365,7 +374,8 @@ void do_research(void)
/* Use the search-menu key bindings, to allow cancelling. */
currmenu = MWHEREIS;
wipe_statusbar();
if (LINES > 1)
wipe_statusbar();
go_looking();
@@ -392,7 +402,7 @@ void not_found_msg(const char *str)
char *disp = display_string(str, 0, (COLS / 2) + 1, FALSE, FALSE);
size_t numchars = actual_x(disp, wideness(disp, COLS / 2));
statusline(HUSH, _("\"%.*s%s\" not found"), numchars, disp,
statusline(AHEM, _("\"%.*s%s\" not found"), numchars, disp,
(disp[numchars] == '\0') ? "" : "...");
free(disp);
}
@@ -418,13 +428,13 @@ 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)
statusbar(_("This is the only occurrence"));
openfile->current_x == was_current_x)
statusline(REMARK, _("This is the only occurrence"));
else if (didfind == 0)
not_found_msg(last_search);
#ifdef TIMEIT
statusline(HUSH, "Took: %.2f", (double)(clock() - start) / CLOCKS_PER_SEC);
statusline(INFO, "Took: %.2f", (double)(clock() - start) / CLOCKS_PER_SEC);
#endif
edit_redraw(was_current, CENTERING);
@@ -460,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;
}
}
@@ -489,7 +498,7 @@ char *replace_line(const char *needle)
new_size += strlen(answer) - match_len;
}
copy = charalloc(new_size);
copy = nmalloc(new_size);
/* Copy the head of the original line. */
strncpy(copy, openfile->current->data, openfile->current_x);
@@ -506,19 +515,6 @@ char *replace_line(const char *needle)
return copy;
}
#ifdef ENABLE_COLOR
/* Reset the multiline coloring info and then recalculate it. */
void wipe_and_recalculate_colorinfo(void)
{
for (linestruct *line = openfile->filetop; line != NULL; line = line->next)
if (line->multidata)
for (short index = 0; index < openfile->syntax->nmultis; index++)
line->multidata[index] = -1;
precalc_multicolorinfo();
}
#endif
/* Step through each occurrence of the search string and prompt the user
* before replacing it. We seek for needle, and replace it with answer.
* The parameters real_current and real_current_x are needed in order to
@@ -554,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;
@@ -610,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) {
@@ -636,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)
@@ -645,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. */
@@ -659,21 +655,10 @@ 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;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP))
openfile->current->extrarows = extra_chunks_in(openfile->current);
#endif
#ifdef ENABLE_COLOR
/* Check whether the replacement requires a change in the coloring. */
check_the_multis(openfile->current);
if (refresh_needed && !replaceall)
wipe_and_recalculate_colorinfo();
#endif
set_modified();
as_an_at = TRUE;
numreplaced++;
@@ -683,11 +668,6 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
if (numreplaced == -1)
not_found_msg(needle);
#ifdef ENABLE_COLOR
if (refresh_needed)
wipe_and_recalculate_colorinfo();
#endif
#ifndef NANO_TINY
openfile->mark = was_mark;
#endif
@@ -720,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. */
@@ -743,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(HUSH, P_("Replaced %zd occurrence",
"Replaced %zd occurrences", numreplaced), numreplaced);
statusline(REMARK, P_("Replaced %zd occurrence",
"Replaced %zd occurrences", numreplaced), numreplaced);
}
/* Go to the specified line and x position. */
@@ -794,7 +775,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool retain_answer,
/* Try to extract one or two numbers from the user's response. */
if (!parse_line_column(answer, &line, &column)) {
statusline(ALERT, _("Invalid line or column number"));
statusline(AHEM, _("Invalid line or column number"));
return;
}
} else {
@@ -942,7 +923,7 @@ void do_find_bracket(void)
ch = mbstrchr(matchbrackets, openfile->current->data + openfile->current_x);
if (ch == NULL) {
statusbar(_("Not a bracket"));
statusline(AHEM, _("Not a bracket"));
return;
}
@@ -985,7 +966,7 @@ void do_find_bracket(void)
}
}
statusbar(_("No matching bracket"));
statusline(AHEM, _("No matching bracket"));
/* Restore the cursor position. */
openfile->current = was_current;
@@ -1000,9 +981,9 @@ void put_or_lift_anchor(void)
update_line(openfile->current, openfile->current_x);
if (openfile->current->has_anchor)
statusbar(_("Placed anchor"));
statusline(REMARK, _("Placed anchor"));
else
statusbar(_("Removed anchor"));
statusline(REMARK, _("Removed anchor"));
}
/* Make the given line the current line, or report the anchoredness. */
@@ -1016,9 +997,9 @@ void go_to_and_confirm(linestruct *line)
edit_redraw(was_current, CENTERING);
statusbar(_("Jumped to anchor"));
} else if (openfile->current->has_anchor)
statusbar(_("This is the only anchor"));
statusline(REMARK, _("This is the only anchor"));
else
statusbar(_("There are no anchors"));
statusline(AHEM, _("There are no anchors"));
}
/* Jump to the first anchor before the current line; wrap around at the top. */

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* utils.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2021 Free Software Foundation, Inc. *
* Copyright (C) 2016, 2017, 2019 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -61,14 +61,14 @@ 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. */
char *concatenate(const char *path, const char *name)
{
size_t pathlen = strlen(path);
char *joined = charalloc(pathlen + strlen(name) + 1);
char *joined = nmalloc(pathlen + strlen(name) + 1);
strcpy(joined, path);
strcpy(joined + pathlen, name);
@@ -76,7 +76,6 @@ char *concatenate(const char *path, const char *name)
return joined;
}
#ifdef ENABLE_LINENUMBERS
/* Return the number of digits that the given integer n takes up. */
int digits(ssize_t n)
{
@@ -106,21 +105,20 @@ int digits(ssize_t n)
}
}
}
#endif
/* Read an integer from str. If it parses okay, store it in *result
* and return TRUE; otherwise, return FALSE. */
bool parse_num(const char *str, ssize_t *result)
/* Read an integer from the given string. If it parses okay,
* store it in *result and return TRUE; otherwise, return FALSE. */
bool parse_num(const char *string, ssize_t *result)
{
char *first_error;
ssize_t value;
char *excess;
/* The manual page for strtol() says this is required. */
/* Clear the error number so that we can check it afterward. */
errno = 0;
value = (ssize_t)strtol(str, &first_error, 10);
value = (ssize_t)strtol(string, &excess, 10);
if (errno == ERANGE || *str == '\0' || *first_error != '\0')
if (errno == ERANGE || *string == '\0' || *excess != '\0')
return FALSE;
*result = value;
@@ -195,22 +193,18 @@ void free_chararray(char **array, size_t len)
#endif
#ifdef ENABLE_SPELLER
/* Is the word starting at the given position in buf and of the given length
* a separate word? That is: is it not part of a longer word?*/
bool is_separate_word(size_t position, size_t length, const char *buf)
/* Is the word starting at the given position in 'text' and of the given
* length a separate word? That is: is it not part of a longer word? */
bool is_separate_word(size_t position, size_t length, const char *text)
{
char before[MAXCHARLEN], after[MAXCHARLEN];
size_t word_end = position + length;
/* Get the characters before and after the word, if any. */
collect_char(buf + step_left(buf, position), before);
collect_char(buf + word_end, after);
const char *before = text + step_left(text, position);
const char *after = text + position + length;
/* If the word starts at the beginning of the line OR the character before
* the word isn't a letter, and if the word ends at the end of the line OR
* the character after the word isn't a letter, we have a whole word. */
return ((position == 0 || !is_alpha_char(before)) &&
(buf[word_end] == '\0' || !is_alpha_char(after)));
(*after == '\0' || !is_alpha_char(after)));
}
#endif /* ENABLE_SPELLER */
@@ -294,7 +288,10 @@ void *nmalloc(size_t howmuch)
{
void *r = malloc(howmuch);
if (r == NULL && howmuch != 0)
if (howmuch == 0)
die("Allocating zero bytes. Please report a bug.\n");
if (r == NULL)
die(_("Nano is out of memory!\n"));
return r;
@@ -306,7 +303,10 @@ void *nrealloc(void *ptr, size_t howmuch)
{
void *r = realloc(ptr, howmuch);
if (r == NULL && howmuch != 0)
if (howmuch == 0)
die("Allocating zero bytes. Please report a bug.\n");
if (r == NULL)
die(_("Nano is out of memory!\n"));
return r;
@@ -318,7 +318,7 @@ char *mallocstrcpy(char *dest, const char *src)
{
size_t count = strlen(src) + 1;
dest = charealloc(dest, count);
dest = nrealloc(dest, count);
strncpy(dest, src, count);
return dest;
@@ -328,7 +328,7 @@ char *mallocstrcpy(char *dest, const char *src)
* of the given string, and NUL-terminate the copy. */
char *measured_copy(const char *string, size_t count)
{
char *thecopy = charalloc(count + 1);
char *thecopy = nmalloc(count + 1);
memcpy(thecopy, string, count);
thecopy[count] = '\0';
@@ -349,14 +349,12 @@ char *free_and_assign(char *dest, char *src)
return src;
}
/* When not in softwrap mode, nano scrolls horizontally within a line in
* chunks (a bit smaller than the chunks used in softwrapping). Return the
* column number of the first character displayed in the edit window when the
* cursor is at the given column. Note that (0 <= column -
* get_page_start(column) < COLS). */
/* When not softwrapping, nano scrolls the current line horizontally by
* chunks ("pages"). Return the column number of the first character
* displayed in the edit window when the cursor is at the given column. */
size_t get_page_start(size_t column)
{
if (column + 2 < editwincols || ISSET(SOFTWRAP) || column == 0)
if (column == 0 || column + 2 < editwincols || ISSET(SOFTWRAP))
return 0;
else if (editwincols > 8)
return column - 6 - (column - 6) % (editwincols - 8);
@@ -431,9 +429,6 @@ void new_magicline(void)
openfile->filebot->next = make_new_node(openfile->filebot);
openfile->filebot->next->data = copy_of("");
openfile->filebot = openfile->filebot->next;
#ifndef NANO_TINY
openfile->filebot->extrarows = 0;
#endif
openfile->totsize++;
}

File diff suppressed because it is too large Load Diff

View File

@@ -8,8 +8,8 @@ color red "\<[A-Z_]{2,}\>"
color brightgreen "\.(data|subsection|text)"
color green "\.(align|file|globl|global|hidden|section|size|type|weak)"
color brightyellow "\.(ascii|asciz|byte|double|float|hword|int|long|short|single|struct|word)"
color brightred "^[[:space:]]*[.0-9A-Za-z_]*:"
color brightcyan "^[[:space:]]*#[[:space:]]*(define|undef|include|ifn?def|endif|elif|else|if|warning|error)"
color brightred "^[[:blank:]]*[.0-9A-Za-z_]*:"
color brightcyan "^[[:blank:]]*#[[:blank:]]*(define|undef|include|ifn?def|endif|elif|else|if|warning|error)"
# Strings.
color brightyellow "<[^= ]*>" ""(\\.|[^"])*""

View File

@@ -1,5 +1,8 @@
## Syntax highlighting for Autoconf.
## Original author: Benno Schulenberg
## License: GPL version 3 or newer
syntax autoconf "\.(ac|m4)$"
comment "#"
@@ -20,7 +23,7 @@ color red ""[^"]*"" "'[^']*'"
color green "`[^`]*`"
# Error lines:
color brightred "^[[:space:]]*\*\*\*.*"
color brightred "^[[:blank:]]*\*\*\*.*"
# Brackets:
color magenta "\[|\]|\(|\)"

View File

@@ -31,7 +31,7 @@ color magenta "\<(bindtextdomain|dcgettext|dcngettext)\>"
# Strings.
color brightyellow "<[^= ]*>" ""(\\.|[^"])*""
# Comments.
color brightblue "(^|[[:space:]])#.*$"
color brightblue "(^|[[:blank:]])#.*$"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -1,33 +1,40 @@
## Syntax highlighting for C and C++ files.
syntax c "\.([ch](pp|xx)?|C|cc|c\+\+|cu|H|hh|ii?)$"
header "-\*-.*\<C(\+\+)?((;|\s).*)?-\*-"
header "-\*-.*\<C(\+\+)?((;|[[:blank:]]).*)?-\*-"
magic "^(C|C\+\+) (source|program)"
comment "//"
# Constants.
color brightred "\<[A-Z_][0-9A-Z_]+\>"
color brightred "\<[A-Z_][0-9A-Z_]*\>"
# Labels.
color brightmagenta "^[[:space:]]*[A-Z_a-z]+:[[:space:]]*$"
color brightmagenta "^[[:blank:]]*[A-Z_a-z][0-9A-Z_a-z]*:[[:blank:]]*$"
color normal ":[[:blank:]]*$"
color green "\<(float|double|bool|char|int|short|long|sizeof|enum|void|auto|static|const|struct|union|typedef|extern|(un)?signed|inline)\>"
# Types and related keywords.
color green "\<(auto|bool|char|const|double|enum|extern|float|inline|int|long|restrict|short|signed|sizeof|static|struct|typedef|union|unsigned|void)\>"
color green "\<([[:lower:]][[:lower:]_]*|(u_?)?int(8|16|32|64))_t\>"
color green "\<(class|namespace|template|public|protected|private|typename|this|friend|virtual|override|using|mutable|volatile|register|explicit)\>"
color brightyellow "\<(for|if|while|do|else|case|default|switch)\>"
color green "\<(_(Alignas|Alignof|Atomic|Bool|Complex|Generic|Imaginary|Noreturn|Static_assert|Thread_local))\>"
color green "\<(class|explicit|friend|mutable|namespace|override|private|protected|public|register|template|this|typename|using|virtual|volatile)\>"
# Flow control.
color brightyellow "\<(if|else|for|while|do|switch|case|default)\>"
color brightyellow "\<(try|throw|catch|operator|new|delete)\>"
color magenta "\<(goto|continue|break|return)\>"
color brightmagenta "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
color magenta "\<(break|continue|goto|return)\>"
# Single-quoted stuff (characters, backslash escapes, hex and octal byte codes).
color brightmagenta "'([^'\]|\\(["'\abfnrtv]|x[0-9A-Fa-f]{1,2}|[0-3]?[0-7]{1,2}))'"
# GCC builtins.
color cyan "__attribute__[[:space:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
color cyan "__attribute__[[:blank:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
# Strings. In general you will want your strings and comments to come last,
# because highlighting rules are applied in the order they are read in.
color brightyellow ""([^"]|\\")*"" "#[[:space:]]*include[[:space:]]+<[^[:blank:]=]*>"
# Strings. (In general you will want your strings and comments to come last,
# because highlighting rules are applied in the order they are read in.)
color brightyellow ""([^"]|\\")*"" "#[[:blank:]]*include[[:blank:]]*<[^>]+>"
# Preprocessor directives.
color brightcyan start="^[[:space:]]*#[[:space:]]*(if(n?def)?|elif|warning|error|pragma)\>" end="(\`|[^\\])$"
color brightcyan "^[[:space:]]*#[[:space:]]*(define|else|endif|include(_next)?|undef)\>"
color brightcyan start="^[[:blank:]]*#[[:blank:]]*(if(n?def)?|elif|warning|error|pragma)\>" end="(\`|[^\\])$"
color brightcyan "^[[:blank:]]*#[[:blank:]]*((define|else|endif|include(_next)?|line|undef)\>|$)"
# Comments.
color brightblue "//.*"

View File

@@ -1,5 +1,8 @@
## Syntax highlighting for Changelogs.
## Original author: Benno Schulenberg
## License: GPL version 3 or newer
syntax changelog "Change[Ll]og[^/]*$"
# Author lines.
@@ -10,7 +13,7 @@ color red "^(19|20)[0-9-]{8}"
color yellow "<[^>]*@[^>]*>"
# Command-line options.
color cyan "[[:space:]]-[a-zA-Z\$]" "--[8a-z-]+"
color cyan "[[:blank:]]-[a-zA-Z\$]" "--[8a-z-]+"
# Bug and patch numbers.
color cyan "(BZ|bug|patch)[ ]#[0-9]+" "PR [[:alnum:]]+/[0-9]+"
# Probable constants, for variety.

View File

@@ -3,17 +3,17 @@
syntax cmake "(CMakeLists\.txt|\.cmake)$"
comment "#"
color green "^[[:space:]]*[0-9A-Za-z_]+"
icolor brightyellow "^[[:space:]]*(include|include_directories|include_external_msproject)\>"
color green "^[[:blank:]]*[0-9A-Za-z_]+"
icolor brightyellow "^[[:blank:]]*(include|include_directories|include_external_msproject)\>"
icolor brightgreen "^[[:space:]]*((else|end)?if|else|(end)?while|(end)?foreach|break)\>"
color brightgreen "\<(NOT|COMMAND|POLICY|TARGET|EXISTS|IS_(DIRECTORY|ABSOLUTE)|DEFINED)[[:space:]]"
color brightgreen "[[:space:]](OR|AND|IS_NEWER_THAN|MATCHES|(STR|VERSION_)?(LESS|GREATER|EQUAL))[[:space:]]"
icolor brightgreen "^[[:blank:]]*((else|end)?if|else|(end)?while|(end)?foreach|break)\>"
color brightgreen "\<(NOT|COMMAND|POLICY|TARGET|EXISTS|IS_(DIRECTORY|ABSOLUTE)|DEFINED)[[:blank:]]"
color brightgreen "[[:blank:]](OR|AND|IS_NEWER_THAN|MATCHES|(STR|VERSION_)?(LESS|GREATER|EQUAL))[[:blank:]]"
icolor brightred "^[[:space:]]*((end)?(function|macro)|return)"
icolor brightred "^[[:blank:]]*((end)?(function|macro)|return)"
icolor cyan start="\$(ENV)?\{" end="\}"
color magenta "\<(APPLE|UNIX|WIN32|CYGWIN|BORLAND|MINGW|MSVC(_IDE|60|71|80|90)?)\>"
color brightblue "(^|[[:space:]])#.*"
color brightblue "(^|[[:blank:]])#.*"
color ,green "[[:space:]]+$"

View File

@@ -5,7 +5,7 @@ syntax default
comment "#"
# Comments.
color cyan "^[[:space:]]*#.*"
color cyan "^[[:blank:]]*#.*"
# Spaces in front of tabs.
color ,red " + +"

View File

@@ -30,4 +30,4 @@ color blue ":(\w|[?-])+"
color yellow start="^[[:blank:]]+"" end="[^\]""
color yellow ""(\\.|[^"])*""
# Comments
color cyan "(^|[[:space:]]);.*"
color cyan "(^|[[:blank:]]);.*"

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

@@ -1,5 +1,8 @@
## Syntax highlighting for Go.
## Original author: Robert Clausecker
## License: CC0 (public domain)
syntax go "\.go$"
comment "//"
@@ -8,7 +11,7 @@ formatter gofmt -w
# Types.
color green "\<(bool|u?int(8|16|32|64)?|float(32|64)|complex(64|128)|byte|rune|uintptr|string|error)\>"
color green "\<(chan|const|func|interface|map|struct|type|var)\>"
color green "<-[[:space:]]*chan\>|\<chan[[:space:]]*<-"
color green "<-[[:blank:]]*chan\>|\<chan[[:blank:]]*<-"
# Predefined functions.
color blue "\<(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)\>"
@@ -33,14 +36,14 @@ color red "\<[0-9]+i\>"
color red "\<(true|false|nil|iota|_)\>"
color red "'(\\.|[^'])+'"
color red ""(\\.|[^"])*""
color red start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
color red start=""(\\.|[^"])*\\[[:blank:]]*$" end="^(\\.|[^"])*""
# Comments.
color brightblue "//.*"
color brightblue start="/\*" end="\*/"
# Special comments.
color brightcyan "//[[:space:]]*\+build[[:space:]]+(([a-zA-Z_0-9]+[[:space:]]*)+,[[:space:]]*)*[a-zA-Z_0-9]+"
color brightcyan "//[[:blank:]]*\+build[[:blank:]]+(([a-zA-Z_0-9]+[[:blank:]]*)+,[[:blank:]]*)*[a-zA-Z_0-9]+"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -13,7 +13,7 @@ color brightmagenta "\\f(.|\(..)" "\\s(\+|\-)?[0-9]"
color cyan "\\(\\)?n(.|\(..)"
color cyan start="\\(\\)?n\[" end="]"
# Requests
color brightgreen "^\.[[:space:]]*[^[:space:]]*"
color brightgreen "^\.[[:blank:]]*[^[:space:]]*"
# Comments
color yellow "^\.\\".*"
# Strings

View File

@@ -21,4 +21,4 @@ color blue "#?:(\w|[?-])+"
color yellow start="^[[:blank:]]+"" end="[^\]""
color yellow ""(\\.|[^"])*""
# Comments
color cyan "(^|[[:space:]]);.*"
color cyan "(^|[[:blank:]]);.*"

View File

@@ -19,7 +19,7 @@ color cyan "\<(true|false|null|undefined)\>"
# Strings.
color brightmagenta ""(\\.|[^"])*"" "'(\\.|[^'])*'" "`(\\.|[^`])*`"
# Comments.
color brightblue "(^|[[:space:]])//.*"
color brightblue "(^|[[:blank:]])//.*"
color brightblue start="/\*" end="\*/"
# Trailing whitespace.

View File

@@ -8,18 +8,18 @@ syntax json "\.json$"
comment ""
# Numbers (used as value).
color green ":[[:space:]]*\-?(0|[1-9][0-9]*)(\.[0-9]+)?([Ee]?[-+]?[0-9]+)?"
color green ":[[:blank:]]*\-?(0|[1-9][0-9]*)(\.[0-9]+)?([Ee]?[-+]?[0-9]+)?"
# Values (well, any string).
color brightmagenta "".+""
# Hex numbers (used as value).
color green ":[[:space:]]*"#[0-9abcdefABCDEF]+""
color green ":[[:blank:]]*"#[0-9abcdefABCDEF]+""
# Escapes.
color green "\\\\" "\\"" "\\[bfnrt]" "\\u[0-9abcdefABCDEF]{4})"
# Special words.
color green "\<(true|false|null)\>"
# Names (very unlikely to contain a quote).
color brightblue ""[^"]+"[[:space:]]*:"
color brightblue ""[^"]+"[[:blank:]]*:"
# Brackets, braces, and separators.
color brightblue "\[" "\]"
@@ -27,7 +27,7 @@ color brightred "\{" "\}"
color brightred "," ":"
# Comments.
color cyan "(^|[[:space:]]+)(//|#).*"
color cyan "(^|[[:blank:]]+)(//|#).*"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -20,7 +20,7 @@ color normal "\.\.\."
color brightblue "\<(do|end|while|repeat|until|if|elseif|then|else|for|in|function|local|return|break)\>"
# Keywords
color brightyellow "\<(_G|_VERSION|assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|module|next|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\s*\("
color brightyellow "\<(_G|_VERSION|assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|module|next|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)[[:blank:]]*\("
# Standard library
color brightyellow "\<coroutine\.(create|isyieldable|resume|running|status|wrap|yield)\>"

View File

@@ -18,7 +18,7 @@ color blue "\$+[{(][a-zA-Z0-9_-]+[})]"
color brightblue "^[^ ]+:"
# Comments.
color green "(^|[[:space:]]+)#.*"
color green "(^|[[:blank:]]+)#.*"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -1,5 +1,8 @@
## Syntax highlighting for Markdown files.
## Original authors: Ryan Westlund and Benno Schulenberg
## License: GPL version 3 or newer
syntax markdown "\.md$"
comment "<!--|-->"

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,32 +1,36 @@
## 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 "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|finalnewline|historylog|indicator|jumpyscrolling|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|smooth|softwrap|suspendable|tabstospaces|trimblanks|unix|view|wordbounds|zap)\>"
color yellow "^[[:space:]]*set[[:space:]]+((error|function|key|number|selected|status|stripe|title)color)[[:space:]]+(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 "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|selectedcolor|speller|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:space:]]+"
color brightgreen "^[[:space:]]*set[[:space:]]+(fill[[:space:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:space:]]+[1-9][0-9]*)\>"
color brightgreen "^[[:space:]]*bind[[:space:]]+((\^([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)[[:space:]]+([a-z]+|".*")[[:space:]]+(main|help|search|replace(with)?|yesno|gotoline|writeout|insert|browser|whereisfile|gotodir|execute|spell|linter|all)([[:space:]]+#|[[:space:]]*$)"
color brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([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)[[:space:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
color brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|comment|formatter|linter|tabgives)[[:space:]]+.*"
color brightgreen "^[[:space:]]*(syntax[[:space:]]+[^[:blank:]]+|(formatter|linter)[[:space:]]+.+)"
color green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|formatter|linter|tabgives|extendsyntax)\>"
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 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:]]*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)\>"
# Strings
color brightmagenta "([[:space:]]|(start|end)=)".+"([[:space:]]|$)"
color brightmagenta "([[:blank:]]|(start|end)=)".+"([[:blank:]]|$)"
# Colors
color yellow "^[[:space:]]*i?color[[:space:]]*(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 magenta "^[[:space:]]*i?color\>" "\<(start|end)="
# Control codes
color bold,pink "[[:cntrl:]]"
# Color commands
color magenta "^[[:blank:]]*i?color\>" "\<(start|end)="
# Comments
color brightblue "(^|[[:space:]]+)#.*"
color cyan "^[[:space:]]*##.*"
color brightblue "(^|[[:blank:]]+)#.*"
color cyan "^[[:blank:]]*##.*"
# Trailing whitespace
color ,green "[[:space:]]+$"

View File

@@ -1,5 +1,8 @@
## Syntax highlighting for the packet-filtering rules of Netfilter.
## Original author: Arturo Borrero González <arturo@debian.org>
## License: GPL version 3 or newer
syntax nftables "\.(nft|nftables)$"
header "^#!.*(nft|nftables)"
comment "#"
@@ -17,7 +20,7 @@ color red "\<(drop|reject)\>"
color brightblue "\<(accept|continue|(d|s)nat|goto|jump|masquerade|return)\>"
# Comments
color cyan "(^|[[:space:]])#.*"
color cyan "(^|[[:blank:]])#.*"
# Trailing whitespace
color ,green "[[:space:]]+$"

View File

@@ -15,13 +15,13 @@ color brightgreen "\<(goto|continue|break|return)\>"
color brightgreen "@(encode|end|implementation|interface)|selector)\>"
# GCC builtins.
color cyan "__attribute__[[:space:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
color cyan "__attribute__[[:blank:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
# Selector/method.
color brightmagenta "(^|[[:space:]])\[.*[[:space:]].*\]"
color brightmagenta "(^|[[:blank:]])\[.*[[:blank:]].*\]"
color white ":[[:alnum:]]*"
color magenta "[[:alnum:]]*:"
color white "\[[^][:space:]]*\]"
color white "\[[^][:blank:]]*\]"
# Strings.
color brightblack "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
@@ -29,7 +29,7 @@ color brightblack "<[^= ]*>" ""(\\.|[^"])*""
color brightblue "@"(\\.|[^"])*""
# Preprocessor commands.
color brightblue "^[[:space:]]*#[[:space:]]*(define|include|import|(un|ifn?)def|endif|el(if|se)|if|warning|error)"
color brightblue "^[[:blank:]]*#[[:blank:]]*(define|include|import|(un|ifn?)def|endif|el(if|se)|if|warning|error)"
# Comments.
color yellow "//.*"

View File

@@ -12,13 +12,11 @@ color magenta "\<(continue|else|elsif|do|for|foreach|if|unless|until|while|eq|ne
color cyan "[$%&@]([A-Za-z_][0-9A-Za-z_]*|\^[][A-Z?\^_]|[0-9]+)\>"
color cyan "[$%&@]\{(\^?[A-Za-z_][0-9A-Za-z_]*|\^[][?\^][0-9]+)\}"
color cyan "[$%&@]([][!"#'()*+,.:;<=>?`|~-]|\{[][!-/:-@\`|~]\})|\$[$%&@]"
color cyan "(^|[[:space:]])[$%@][/\]"
color cyan "(^|[[:blank:]])[$%@][/\]"
color yellow "".*"|qq\|.*\|"
color white "[sm]/.*/"
color white start="(^use| = new)" end=";"
# Comments.
color green "(^|[[:space:]])#.*"
color yellow start="<< 'STOP'" end="STOP"
color green "(^|[[:blank:]])#.*"

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]*\("
@@ -28,7 +28,7 @@ color magenta "\<(break|continue|goto|return)\>"
color brightyellow ""(\.|[^"])*"" "'(\.|[^'])*'"
# Comments.
color brightblue "(^|[[:space:]]+)//.*"
color brightblue "(^|[[:blank:]]+)//.*"
color brightblue start="/\*" end="\*/"
# Trailing whitespace.

View File

@@ -1,5 +1,8 @@
## Syntax highlighting for PO files.
## Original author: Benno Schulenberg
## License: GPL version 3 or newer
syntax po "\.pot?$"
comment "#"
@@ -19,7 +22,7 @@ color brightblue "^(msgid|msgid_plural|msgstr)\>"
color red " fuzzy(,|$)"
color yellow " (no-)?[-[:alpha:]]+-format(,|$)"
# Format specifiers.
color brightmagenta "%([1-9]\$)?[a-z]*"
color brightmagenta "%([1-9]\$)?[#0 +'I-]?(\*([1-9]\$)?|[1-9](\.[0-9]?)?)?[hlLjzt]?[diouxXeEfFgGaAcspnm%]"
# Quotes and escaped characters.
color yellow """
color cyan "\\([abcefnrtv"\]|x[0-9abcdefABCDEF]{2}|[0-7]{3})"
@@ -27,3 +30,7 @@ color cyan "\\([abcefnrtv"\]|x[0-9abcdefABCDEF]{2}|[0-7]{3})"
color brightwhite,yellow "\<(FIXME|TODO|XXX)\>"
# Obsolete strings.
color red "#~.*"
# Stray control codes.
color bold,pink,red "[[:cntrl:]]"
# Tabs.
color mint "[[:blank:]]"

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 "//"

Some files were not shown because too many files have changed in this diff Show More