Compare commits

..

224 Commits
v5.0 ... v5.4

Author SHA1 Message Date
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
Benno Schulenberg
070c9c60ec po: update translations and regenerate POT file and PO files 2020-08-24 11:08:23 +02:00
Benno Schulenberg
63ac050733 bump version numbers and add a news item for the 5.2 release 2020-08-24 09:53:07 +02:00
Benno Schulenberg
3ade8b29cc build: stop distributing the README.GIT file
There is no need for normal users to build from git.  Do not give
the impression that that procedure is in any way recommended.
2020-08-24 09:29:05 +02:00
Benno Schulenberg
51a6d5897e gnulib: back away from a commit that causes trouble when using clang
The issue has been reported here:
  https://lists.gnu.org/archive/html/bug-gnulib/2020-08/msg00202.html
2020-08-23 10:52:20 +02:00
Benno Schulenberg
785d28d5d1 gnulib: update to its current upstream state 2020-08-23 09:10:35 +02:00
Benno Schulenberg
4873cc26f2 build: stop mentioning Slang in two ./configure messages
Nobody ought to be using Slang, so don't give people the wrong
impression by mentioning it (and even mentioning it *first*).
2020-08-23 09:05:47 +02:00
Benno Schulenberg
0f8423eb4c tweaks: elide an unneeded variable
Storing the orientation of the marked region beforehand is not needed,
as this orientation is readily available also after the justification.

(By the way, cursor and mark need to be swapped after justifying
a backward-marked region because the rule is that the cursor gets
placed *after* the justified paragraph.  Maybe that should change?)
2020-08-22 19:35:48 +02:00
Benno Schulenberg
b60fec5db3 history: do not interpret a failing stat() as an error
The most likely reason for stat() returning -1 is that the file
does not exist.  And an absent positionlog file is not an error.
(In some cases it is, like immediately after writing the file,
but even then we don't want to complain, because it may have
been some other process that deleted the file straightaway.)

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

Bug existed since version 5.0, commit fcb9e58b.
2020-08-22 10:27:02 +02:00
Benno Schulenberg
7ffbf01607 tweaks: improve three comments and an indentation 2020-08-21 16:06:38 +02:00
Benno Schulenberg
f6b4c243d8 tweaks: reshuffle four declarations, and rename two variables 2020-08-21 16:03:59 +02:00
Benno Schulenberg
0287be7660 tweaks: move the keyboard-checking code to the end of the search loop 2020-08-20 10:51:19 +02:00
Benno Schulenberg
e6709d684b tweaks: condense two fragments of code, for compactness 2020-08-20 10:44:06 +02:00
Benno Schulenberg
aa257ef58e display: restore the ability to resize the screen while searching
This ability was lost in commit 92298349 from two hours ago, which
bypasses the keystroke buffer and its integrated screen resizing.

This new implementation is better than it was before, because it
responds almost instantly to a resize instead of with a delay of
up to a second.
2020-08-20 10:31:58 +02:00
Benno Schulenberg
8daa7cbda0 tweaks: remove a variable and two functions that have become redundant 2020-08-20 09:17:48 +02:00
Benno Schulenberg
8a5449cebe input: allow also a Meta keystroke to abort a Search command
(Still, this does not allow a full escape sequence to be used as
the Cancel command, but I think that is an acceptable limitation,
because 1) nobody ought to be using --rawsequences, and 2) very
few people will bind Cancel to something like F3 or Ins.)

This improves the fix for https://savannah.gnu.org/bugs/?58825.
2020-08-20 09:17:03 +02:00
Benno Schulenberg
9229834935 search: poll the input stream directly, not nano's own keystroke buffer
When checking (during a Search command) whether the user has pressed
the Cancel keystroke, look at ncurses' input stream directly instead
of at nano's own keystroke buffer, because the latter may contain the
copied keystrokes of a macro and we don't want to discard those.

(This does not yet allow a Meta keystroke to be used for Cancel, but
the next commit will fix that.)

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

Bug existed since version 2.9.0, since the macro was introduced.
2020-08-20 08:25:26 +02:00
Benno Schulenberg
6469e9668b tweaks: condense two declarations 2020-08-19 16:52:28 +02:00
Benno Schulenberg
68d71f649e rcfile: make sure that "bright"/"light" are prefixes, not separate words
This fixes https://savannah.gnu.org/bugs/?58984.

The bug was old -- it existed since at least version 2.0.6.
2020-08-19 16:18:29 +02:00
Benno Schulenberg
71752f47cb docs: reshuffle the section about the file browser to a better place
First mention the three main 'pieces' of the editor: Editing window,
Help viewer, and File browser.  Then mention how to change settings:
with the toggles or with nanorc files.
2020-08-19 08:54:30 +02:00
Benno Schulenberg
51f27d3f0c input: hold on to a shift-selected region when an unbound key is struck
There is no reason to deselect the region, as nothing has changed.

(This also retains the shift-selected region when a non-shortcut key is
typed in view mode, which makes sense, as again nothing was changed.)

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

Bug existed since version 4.9, commit 0ed62e84.
2020-08-19 08:36:00 +02:00
Benno Schulenberg
b38265cfb8 search: retain the current answer when something is toggled
This fixes https://savannah.gnu.org/bugs/?58972.

Bug existed since version 5.0, commit bccb0ea0.
2020-08-18 09:17:39 +02:00
Benno Schulenberg
b5fb41e963 docs: mention in the FAQ how to change the escape sequences of urxvt
Replace an obsolete question that doesn't have a good answer: setting
TERM to vt100 is unlikely to make the more complicated keystrokes work,
which are the ones that are most likely not to work.
2020-08-18 09:00:56 +02:00
Benno Schulenberg
a14c894325 docs: add a cross-reference from 'findbracket' to 'set matchbrackets' 2020-08-17 14:20:03 +02:00
Benno Schulenberg
bc6b9bf955 tweaks: rename a variable, to not seem to refer to the scrollbar 2020-08-17 13:36:03 +02:00
Benno Schulenberg
4b6090ded3 replacing: do not try to wipe nonexistent multidata, to avoid crashing
This fixes https://savannah.gnu.org/bugs/?58970.
Reported-by: Matteo Raso <mraso@uoguelph.ca>

Bug existed since version 5.0, commit 569d0056.
2020-08-17 10:05:25 +02:00
Benno Schulenberg
fb98f0ced7 tweaks: adjust a comment, and reshuffle the setting of a boolean 2020-08-15 16:07:30 +02:00
Benno Schulenberg
d09055db43 input: dawdle after an ESC also when --rawsequences is used
When keypad() is set to FALSE, like for verbatim input, ncurses is
not waiting its fifty milliseconds after an ESC to see if another
code will follow it, so nano itself will have to pause a little.

Otherwise 'solitary' could get set to TRUE when in fact the ESC
is followed very closely by another code.

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

Bug existed since version 2.6.2, commit f2150d3f.
2020-08-15 14:45:02 +02:00
Benno Schulenberg
50b61bef6f input: discard any multibyte character when <Alt> is being held
Otherwise the <Alt> key would simply be ignored.  It's better to reject
the combination, to compel the user to be precise in what they type.
2020-08-15 14:00:53 +02:00
Benno Schulenberg
3d0bfb0a00 input: do not enter invalid bytes when holding down both Alt keys
This fixes https://savannah.gnu.org/bugs/?58954.

Bug existed since version 5.1, commit 49231191.
2020-08-15 13:18:48 +02:00
Benno Schulenberg
3cb55c8b27 verbatim: reserve enough space for the result also in non-UTF-8 locales
Also when each character is just one byte, parse_verbatim_kbinput()
can produce two bytes; plus the terminating NUL that is three bytes.

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

Bug existed since version 4.9, commit 03d296eb.
2020-08-15 11:55:48 +02:00
Benno Schulenberg
306906a8a7 docs: adjust description of ^T in cheatsheet, and mention M-Bsp 2020-08-13 07:21:21 +02:00
Benno Schulenberg
6e2c245ecc po: update translations and regenerate POT file and PO files 2020-08-12 08:35:14 +02:00
Benno Schulenberg
74a0ffcbc5 tweaks: baptize the release 2020-08-12 08:24:06 +02:00
Benno Schulenberg
b1a0f5e65a bump version numbers and add a news item for the 5.1 release 2020-08-12 07:57:31 +02:00
Benno Schulenberg
7e8b1ed420 build: stop distributing the two old Changelogs
For installing and using nano, those two Changelogs are useless,
and for inspecting the history of nano, 'git log' is much better.

Only the most recent Changelog is somewhat useful for some users,
for walking in some detail through the changes that were made in
the last few versions.
2020-08-11 20:12:56 +02:00
Benno Schulenberg
b2ea7d29d0 build: fix compilation for --enable-tiny --enable-nanorc --enable-color 2020-08-11 20:10:40 +02:00
Benno Schulenberg
e597ad4908 build: fix compilation when configured with --enable-tiny 2020-08-11 19:59:24 +02:00
Benno Schulenberg
100747f56b verbatim: discard entire keystroke when it's not valid for Unicode Input
This will not work for the deviant escape sequences for F1 to F5
on the Linux console nor for Alt+arrow on urxvt and such, but...
I can't be bothered to handle those too.

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

Bug existed since commit be203832 from earlier today.
2020-08-10 16:18:03 +02:00
Benno Schulenberg
d7b2b55bf5 display: show the cursor position also right after the screen is resized
Bug existed since commit 8e226a9f from half an hour ago.
2020-08-10 12:16:18 +02:00
Benno Schulenberg
9875252fd7 tweaks: remove an unneeded beep, and reshuffle the lines for compactness
The beep is produced later, after get_verbatim_kbinput() returns.
2020-08-10 12:07:16 +02:00
Benno Schulenberg
1551c1c771 verbatim: do not report "Invalid code" when a Unicode character is typed
This fixes https://savannah.gnu.org/bugs/?58928.

Bug existed since version 5.0, commit 5899181a.
2020-08-10 11:48:31 +02:00
Benno Schulenberg
8e226a9f28 verbatim: do not report "Invalid code" when the terminal is resized
During verbatim input at most four integers are produced (the longest
possible unicode sequence), so use the value 999 to indicate a special
condition (a screen resize) that should not enter anything into the
buffer AND should not produce any error message or beep.

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

Bug existed since version 5.0, commit 5899181a.
2020-08-10 11:42:09 +02:00
Benno Schulenberg
be20383240 verbatim: report and ignore an invalid keystroke for Unicode input
When Unicode Input has started (by typing 0 or 1 at the Verbatim Input
"prompt"), and something is typed that is not a hexadecimal digit, then
don't try to enter this character into the buffer but simply report it
as invalid and ignore it.  Because most likely the user mistyped and
actually meant to enter a valid hex digit.

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

The bug was old -- it existed since at least version 2.0.6.
2020-08-10 09:31:24 +02:00
Benno Schulenberg
cf769bbd2f tweaks: adjust the indentation after the previous change 2020-08-10 07:55:00 +02:00
Benno Schulenberg
4ec96f9f2e tweaks: reshuffle a few lines, to condense the code, and improve comment 2020-08-10 07:53:41 +02:00
Benno Schulenberg
bdc856812f tweaks: read keycodes from the keystroke buffer without copying them
Allocating and freeing memory for reading every single keycode
is a waste of time and effort.

This addresses https://savannah.gnu.org/bugs/?58806.
2020-08-10 07:39:29 +02:00
Benno Schulenberg
96bb8149e9 moving: make <Ctrl+Up> go to the top when above the cursor all is blank
Just like <Ctrl+Down> goes to the end of the buffer when after the
cursor there are only blank lines.

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

Bug existed since version 2.6.2, since <Ctrl+Up/Down> were introduced.
2020-08-09 16:57:25 +02:00
Benno Schulenberg
07e69d54b2 tweaks: elide two variables that are no longer needed, and update comment 2020-08-09 15:40:53 +02:00
Benno Schulenberg
aeb15e9549 tweaks: parse the escape-sequence bytes without copying them first 2020-08-09 15:25:22 +02:00
Benno Schulenberg
435d9acb5c tweaks: exclude old and mistaken "Esc O" sequences from the tiny version
The correct sequences begin with "Esc [" instead.  I cannot find in the
histories of VTE and Gnome Terminal when these sequences were corrected.

Also exclude a bug check from the tiny version.
2020-08-09 10:48:03 +02:00
Benno Schulenberg
12fe0a3b29 tweaks: normalize the indentation after the previous change
This finally gets rid of the piece of specially reduced indentation
(<-<- ... ->->) that made it hard to see the structure of the code.
2020-08-09 10:48:03 +02:00
Benno Schulenberg
c14e77ce9e tweaks: split a function into two, one for "Esc O" and one for "Esc [" 2020-08-09 10:48:03 +02:00
Benno Schulenberg
2c8c061e67 tweaks: pass first byte of sequence directly to the decoding function
Don't bother stuffing it back into the keyboard buffer when it will be
taken out again straight afterward.
2020-08-09 10:48:03 +02:00
Benno Schulenberg
5fab1e6754 verbatim: pause a little after an ESC, to not miss a succeeding code
When we get an ESC from the keyboard, it might be the start of an
escape sequence, but the keyboard routines will need a little time
(tens of microseconds, probably) to get these codes to ncurses.
So, when doing verbatim input, pause a moment after an ESC.

This completes the fix for https://savannah.gnu.org/bugs/?58909.
2020-08-08 07:51:47 +02:00
Benno Schulenberg
b0e3767af5 input: understand M-Bsp also when terminfo does not match the terminal
Always interpret ESC followed by BS or DEL as <Alt+Backspace>.

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

Bug existed since commit 40b03162 from one week ago,
since M-Bsp was hard-bound to deleting a word backwards.
2020-08-07 19:17:36 +02:00
Benno Schulenberg
4923119174 tweaks: reshuffle some fragments, to make the next change easier 2020-08-07 18:46:55 +02:00
Benno Schulenberg
cdd6882541 verbatim: insert the full code sequence when <Alt+Backspace> is pressed
(This could lead to unwanted behavior when the user wants to enter
a literal escape character (0x1B) while the input is somehow getting
stalled, because then a command keystroke after the M-V <Esc> would
get inserted verbatim too, instead of getting acted upon.  But that
is a small price to pay for getting the correct behavior for both
M-V M-Bsp and M-V M-Enter.)

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

Bug existed since version 2.6.3, commit 08c51cfd,
but also occurred erratically beforehand.
2020-08-07 16:21:21 +02:00
Benno Schulenberg
5a6a74fe70 gnulib: update to its current upstream state 2020-08-06 16:03:03 +02:00
Benno Schulenberg
d7c2b98ead feedback: when creating a pipe fails, report also the reason
After commit 59bbc0b8 from five days ago (that made a divergent pipe
failure to be treated in the same way as the other two), this became
possible without having two different pipe-failure messages.
2020-08-06 08:47:52 +02:00
Benno Schulenberg
4c63ef204d tweaks: make a few more direct returns, and reshuffle another bit of code 2020-08-05 11:03:35 +02:00
Benno Schulenberg
4c6b6cad99 tweaks: elide an unneeded variable, by transforming the key code directly 2020-08-05 10:51:02 +02:00
Benno Schulenberg
cc6d1d59a6 tweaks: optimize for byte-range characters, and shorten some comments 2020-08-05 10:12:03 +02:00
Benno Schulenberg
f80ce71d13 tweaks: adjust the indentation after the previous change 2020-08-05 10:09:49 +02:00
Benno Schulenberg
2bbbd85852 tweaks: stop using a 'switch' when there are just three possibilities 2020-08-05 10:08:51 +02:00
Benno Schulenberg
54238a5c46 tweaks: reshuffle the zeroing of a counter, to allow some direct returns 2020-08-05 10:06:43 +02:00
Benno Schulenberg
8b2114a25f rcfile: allow to bind M-[ (even though it is an escape-sequence starter)
The user had better avoid using the keystroke in a macro, but
when typing directly at a responsive machine there is no problem,
M-[ is a perfectly valid and recognizable keystroke.

This fulfills https://savannah.gnu.org/bugs/?58820.
2020-08-04 17:28:16 +02:00
Benno Schulenberg
65da6341ba tweaks: avoid a maybe-uninitialized-variable warning from gcc 2020-08-04 17:08:02 +02:00
Benno Schulenberg
c8a87b4d2a softwrap: initialize the 'extrarows' value for the magic line correctly
The make_new_node() function initializes 'extrarows' to a bad value
on purpose, to catch cases like this one where it doesn't get updated
properly.

This fixes https://savannah.gnu.org/bugs/?58890.
Reported-by: Jerry Kindall <kindall@gmail.com>

Bug existed since version 5.0, since the indicator was introduced.
2020-08-04 09:40:25 +02:00
Benno Schulenberg
551a971e16 tweaks: reshuffle four lines, for esthetics 2020-08-03 11:36:35 +02:00
Benno Schulenberg
c2b6eb01cd feedback: use three dots to indicate processing, like everywhere else
For all occurrences, run:  grep '\.\.\."))' src/*.c
2020-08-03 11:33:28 +02:00
Benno Schulenberg
e9e26934ea speller: give startup feedback (relevant when running on a Linux console)
This fixes https://savannah.gnu.org/bugs/?58856.

Bug existed since version 4.8, commit 8b2f7bd5.
2020-08-03 11:21:19 +02:00
Benno Schulenberg
5b56791aef docs: mention that anchors are visible when line numbers are shown
Suggested-by: Tomáš Mudruňka <mudrunka@spoje.net>
2020-08-03 10:27:57 +02:00
Benno Schulenberg
71c0cde5ce anchor: show an anchor also when the line is horizontally scrolled
This fixes https://savannah.gnu.org/bugs/?58884.

Bug existed since version 5.0, since anchors were introduced.
2020-08-03 10:02:09 +02:00
Benno Schulenberg
18a4658d4f anchor: in a UTF-8 locale, show an anchor as a diamond, for visibility 2020-08-03 09:43:55 +02:00
Benno Schulenberg
6fa81ca5b8 formatter: force the mark off, to not crash by accessing empty cutbuffer
More generally, after invoking the formatter, the entire buffer should
be cut (to be replaced with the reformatted text) and not just the part
before the mark, because then everything after it would be duplicated.

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

Bug existed since version 4.9, commit 19517fc5.
2020-08-02 19:29:31 +02:00
Michalis Kokologiannakis
4940b02ae0 build: avoid compilation warnings by using memcpy() instead of strncpy()
When compiling with GCC 10.1.0 and -O2 -Wall, the strncpy() call
in measured_copy() produced two stringop-truncation warnings.

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

Signed-off-by: Michalis Kokologiannakis <michalis@mpi-sws.org>
2020-08-02 16:47:05 +02:00
Benno Schulenberg
7942dab014 tweaks: make a misplaced call of statusline() more obvious by crashing
Also, reshuffle the lines, to take advantage of an other #ifndef.
2020-08-02 14:50:50 +02:00
Benno Schulenberg
312bcebf44 files: do not try writing to the status bar while not in curses mode
Between an endwin() and a doupdate() there should be no calls of
statusline() or statusbar() -- these two functions may be called
only when in curses mode.

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

Bug existed since version 4.3, commit 57390cff.
2020-08-02 10:29:29 +02:00
Benno Schulenberg
eb57b10273 docs: fix a closing tag in the FAQ [tidy] 2020-08-01 20:58:29 +02:00
Benno Schulenberg
844f95e6df speller: give proper feedback when the user tries to check emptiness
(The wording is general, because it should cover also the formatter.)

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

Bug existed since version 4.6, commit d2fb371f.
2020-08-01 20:57:23 +02:00
Benno Schulenberg
67d22f4cce tweaks: simplify two functions, as they now return always NULL 2020-08-01 19:00:07 +02:00
Benno Schulenberg
59bbc0b858 tweaks: print error message directly instead of passing it to the caller
This will allow a simplification in the next commit.
2020-08-01 11:50:55 +02:00
Benno Schulenberg
731fd935ff feedback: add the reason to the error message when forking fails
This makes all the "Could not fork" messages the same again
after the change in commit 3eff34b0 from yesterday.
2020-08-01 11:34:23 +02:00
Benno Schulenberg
0e1f7fe2ef tweaks: normalize the indentation, and regroup two lines 2020-07-31 20:39:28 +02:00
Benno Schulenberg
3eff34b075 speller: re-enter curses mode before trying to report an error
If forking fails, we must first return to curses mode before we can show
an error message on the status bar.  (This additionally requires storing
the error number, because doupdate() apparently sets it to zero.)

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

Bug existed since version 4.8, commit 61197563.
2020-07-31 20:28:10 +02:00
Benno Schulenberg
40b03162c3 bindings: make <Alt+Backspace> delete a word backwards, like in Bash
It jars a bit that it is <Ctrl+Delete> that deletes a word rightward
and <Alt+Backspace> that deletes a word leftward.  But it's good to
also have a two-key keystroke bound by default to 'chopwordleft',
and not just the three-key <Ctrl+Shift+Delete>.

This fulfills https://savannah.gnu.org/bugs/?58709.
Requested-by: Axel Scheepers <axel.scheepers76+gnu@gmail.com>
2020-07-31 18:52:51 +02:00
Benno Schulenberg
34f4ceb77e help: list again the keystroke for toggling the help lines (M-X)
This fixes https://savannah.gnu.org/bugs/?58855.

Bug existed since version 5.0, commit d8249917.
2020-07-30 10:23:35 +02:00
Michalis Kokologiannakis
d0ad1e42d9 files: ignore only EPERM when fchmod() or fchown() fails
While ignoring permission errors from fchmod() and fchown() is okay
(since normal users are not always privileged to make such changes),
ignoring also more serious errors (like EIO) is not ideal.

Signed-off-by: Michalis Kokologiannakis <michalis@mpi-sws.org>
2020-07-30 09:48:12 +02:00
Benno Schulenberg
59bdce9503 syntax: default: colorize also "GNU nano 5.x" 2020-07-30 09:25:56 +02:00
Benno Schulenberg
9517766aab syntax: css: differentiate pseudo-classes (now cyan) from comments (blue)
Also, add comments, remove a duplicated ":link", and add ":checked".
2020-07-30 09:25:12 +02:00
82 changed files with 26409 additions and 25156 deletions

266
ChangeLog
View File

@@ -1,3 +1,252 @@
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:
------------------------------
Benno Schulenberg (30):
build: stop distributing the README.GIT file
build: stop mentioning Slang in two ./configure messages
bump version numbers and add a news item for the 5.2 release
display: restore the ability to resize the screen while searching
docs: add a cross-reference from 'findbracket' to 'set matchbrackets'
docs: adjust description of ^T in cheatsheet, and mention M-Bsp
docs: mention in the FAQ how to change the escape sequences of urxvt
docs: reshuffle the section about the file browser to a better place
gnulib: back away from a commit that causes trouble when using clang
gnulib: update to its current upstream state
history: do not interpret a failing stat() as an error
input: allow also a Meta keystroke to abort a Search command
input: dawdle after an ESC also when --rawsequences is used
input: discard any multibyte character when <Alt> is being held
input: do not enter invalid bytes when holding down both Alt keys
input: hold on to a shift-selected region when an unbound key is struck
rcfile: make sure that "bright"/"light" are prefixes, not separate words
replacing: do not try to wipe nonexistent multidata, to avoid crashing
search: poll the input stream directly, not nano's own keystroke buffer
search: retain the current answer when something is toggled
tweaks: adjust a comment, and reshuffle the setting of a boolean
tweaks: condense two declarations
tweaks: condense two fragments of code, for compactness
tweaks: elide an unneeded variable
tweaks: improve three comments and an indentation
tweaks: move the keyboard-checking code to the end of the search loop
tweaks: remove a variable and two functions that have become redundant
tweaks: rename a variable, to not seem to refer to the scrollbar
tweaks: reshuffle four declarations, and rename two variables
verbatim: reserve enough space for the result also in non-UTF-8 locales
Changes between v5.0 and v5.1:
------------------------------
Benno Schulenberg (55):
anchor: in a UTF-8 locale, show an anchor as a diamond, for visibility
anchor: show an anchor also when the line is horizontally scrolled
bindings: make <Alt+Backspace> delete a word backwards, like in Bash
build: fix compilation for --enable-tiny --enable-nanorc --enable-color
build: fix compilation when configured with --enable-tiny
build: stop distributing the two old Changelogs
bump version numbers and add a news item for the 5.1 release
display: show the cursor position also right after the screen is resized
docs: fix a closing tag in the FAQ [tidy]
docs: mention that anchors are visible when line numbers are shown
feedback: add the reason to the error message when forking fails
feedback: use three dots to indicate processing, like everywhere else
feedback: when creating a pipe fails, report also the reason
files: do not try writing to the status bar while not in curses mode
formatter: force the mark off, to not crash by accessing empty cutbuffer
gnulib: update to its current upstream state
help: list again the keystroke for toggling the help lines (M-X)
input: understand M-Bsp also when terminfo does not match the terminal
moving: make <Ctrl+Up> go to the top when above the cursor all is blank
rcfile: allow to bind M-[ (even though it is an escape-sequence starter)
softwrap: initialize the 'extrarows' value for the magic line correctly
speller: give proper feedback when the user tries to check emptiness
speller: give startup feedback (relevant when running on a Linux console)
speller: re-enter curses mode before trying to report an error
syntax: css: differentiate pseudo-classes (now cyan) from comments (blue)
syntax: default: colorize also "GNU nano 5.x"
tweaks: adjust the indentation after the previous change
tweaks: adjust the indentation after the previous change
tweaks: avoid a maybe-uninitialized-variable warning from gcc
tweaks: elide an unneeded variable, by transforming the key code directly
tweaks: elide two variables that are no longer needed, and update comment
tweaks: exclude old and mistaken "Esc O" sequences from the tiny version
tweaks: make a few more direct returns, and reshuffle another bit of code
tweaks: make a misplaced call of statusline() more obvious by crashing
tweaks: normalize the indentation after the previous change
tweaks: normalize the indentation, and regroup two lines
tweaks: optimize for byte-range characters, and shorten some comments
tweaks: parse the escape-sequence bytes without copying them first
tweaks: pass first byte of sequence directly to the decoding function
tweaks: print error message directly instead of passing it to the caller
tweaks: read keycodes from the keystroke buffer without copying them
tweaks: remove an unneeded beep, and reshuffle the lines for compactness
tweaks: reshuffle a few lines, to condense the code, and improve comment
tweaks: reshuffle four lines, for esthetics
tweaks: reshuffle some fragments, to make the next change easier
tweaks: reshuffle the zeroing of a counter, to allow some direct returns
tweaks: simplify two functions, as they now return always NULL
tweaks: split a function into two, one for "Esc O" and one for "Esc ["
tweaks: stop using a 'switch' when there are just three possibilities
verbatim: discard entire keystroke when it's not valid for Unicode Input
verbatim: do not report "Invalid code" when a Unicode character is typed
verbatim: do not report "Invalid code" when the terminal is resized
verbatim: insert the full code sequence when <Alt+Backspace> is pressed
verbatim: pause a little after an ESC, to not miss a succeeding code
verbatim: report and ignore an invalid keystroke for Unicode input
Michalis Kokologiannakis (2):
build: avoid compilation warnings by using memcpy() instead of strncpy()
files: ignore only EPERM when fchmod() or fchown() fails
Changes between v4.9 and v5.0:
------------------------------
@@ -115,7 +364,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
@@ -175,7 +424,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
@@ -775,7 +1024,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
@@ -1239,7 +1488,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
@@ -1259,7 +1508,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
@@ -1465,7 +1714,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
@@ -4089,3 +4338,8 @@ Mike Scalora (3):
Rishabh Dave (2):
browser: keep the same file selected when the directory contents change
browser: move all openings and closings of a directory to the same function
======================================================================
For older changes, see in https://ftp.gnu.org/gnu/nano/nano-5.0.tar.xz
======================================================================

View File

@@ -2,6 +2,11 @@ Improvements in GNU nano
========================
Since 5.0:
- 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.
- Toggling help lines (M-X) and Refresh (^L) work nearly everywhere.

View File

@@ -6,8 +6,7 @@ if USE_COLOR
SUBDIRS += syntax
endif
EXTRA_DIST = ChangeLog.1999-2006 ChangeLog.2007-2015 \
IMPROVEMENTS README.GIT
EXTRA_DIST = IMPROVEMENTS
ACLOCAL_AMFLAGS = -I m4

228
NEWS
View File

@@ -1,3 +1,36 @@
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.
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.
• Using --positionlog does not complain at the first start.
• A macro containing a Search command will not sometimes fail.
2020.08.12 - GNU nano 5.1 "Cantabria"
• M-Bsp (Alt+Backspace) deletes a word backwards, like in Bash.
• M-[ has become bindable. (Be careful, though: as it is the
starting combination of many escape sequences, avoid gluing
it together with other keystrokes, like in a macro.)
• With --indicator and --softwrap, the first keystroke in an
empty buffer does not crash.
• Invoking the formatter while text is marked does not crash.
• In UTF-8 locales, an anchor is shown as a diamond.
2020.07.29 - GNU nano 5.0 "Among the fields of barley"
• With --indicator (or -q or 'set indicator') nano will show a kind
of scrollbar on the righthand side of the screen to indicate where
@@ -513,7 +546,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,
@@ -755,28 +788,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
@@ -908,7 +940,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!
@@ -1089,7 +1121,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,
@@ -1311,38 +1343,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
@@ -1403,19 +1434,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
@@ -1685,7 +1716,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.
@@ -1906,19 +1937,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! =)
@@ -1933,23 +1964,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
@@ -1959,31 +1989,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.

15
README
View File

@@ -25,7 +25,7 @@ Overview
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 +33,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,8 +52,10 @@ 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.

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

View File

@@ -2,7 +2,7 @@
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="ac34618e85013bfec4650f02e8e79c5de6d80fb3"
gnulib_hash="387d654cabd7bc1594b1fc8d195cd9b66f820296"
modules="
futimens

View File

@@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see https://www.gnu.org/licenses/.
AC_INIT([GNU nano], [5.0], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [5.4], [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
@@ -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
@@ -92,7 +92,8 @@ 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])
AC_MSG_ERROR([
*** --with-slang is supported only together with --enable-tiny])
fi
fi
@@ -112,7 +113,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 +122,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 +138,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 +164,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 +173,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 +208,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 +303,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
@@ -528,16 +547,11 @@ dnl Checks for functions.
if test "x$enable_utf8" != xno; then
AC_CHECK_FUNCS(iswalnum iswpunct mblen mbstowcs mbtowc 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 +581,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 +597,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 +608,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,8 +624,6 @@ 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)
@@ -628,18 +640,16 @@ if test "x$enable_utf8" != xno && \
else
if test "x$enable_utf8" = xyes; then
AC_MSG_ERROR([
*** UTF-8 support was requested, but insufficient UTF-8 support was
*** detected in your curses and/or C libraries. Please verify that
*** your Slang was built with UTF-8 support or your curses was built
*** with wide-character support, and that your C library was built
*** UTF-8 support was requested, but insufficient support was
*** detected in your curses and/or C libraries. Please verify
*** that both your curses library and your C library were built
*** with wide-character support.])
elif test "x$enable_utf8" != xno; then
AC_MSG_WARN([
*** Insufficient UTF-8 support was detected in your curses and/or C
*** libraries. If you want UTF-8 support, please verify that your
*** Slang was built with UTF-8 support or your curses was built with
*** wide-character support, and that your C library was built with
*** wide-character support.])
*** Insufficient UTF-8 support was detected in your curses
*** and/or C libraries. If you want UTF-8 support, please
*** verify that both your curses library and your C library
*** were built with wide-character support.])
fi
fi
@@ -666,16 +676,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
@@ -684,35 +694,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.
@@ -721,8 +734,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

@@ -55,15 +55,15 @@
<table><tbody>
<tr><td>Ctrl+H</td><td>Delete character before cursor &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>
<tr><td>Ctrl+D</td><td>Delete character under cursor</td></tr>
<tr><td>Ctrl+Shift+Del &nbsp;&nbsp;</td><td>Delete word to the left</td></tr>
<tr><td>Ctrl+Del</td><td>Delete word to the right</td></tr>
<tr><td>Alt+Bsp</td><td>Delete word to the left</td></tr>
<tr><td>Ctrl+Del &nbsp;&nbsp;</td><td>Delete word to the right</td></tr>
<tr><td>Alt+Del</td><td>Delete current line</td></tr>
</tbody></table>
<br>
<b>Operations</b>
<table><tbody>
<tr><td>Ctrl+T &nbsp;&nbsp;</td><td>Run a spell check</td></tr>
<tr><td>Ctrl+T &nbsp;&nbsp;</td><td>Execute some command</td></tr>
<tr><td>Ctrl+J</td><td>Justify paragraph or region</td></tr>
<tr><td>Alt+J</td><td>Justify entire buffer</td></tr>
<tr><td>Alt+B</td><td>Run a syntax check</td></tr>
@@ -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>

View File

@@ -41,12 +41,12 @@
<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.2">4.2. Ack! My Backspace/Delete/Enter/Meta/double bucky key doesn't seem to work! What can I do?</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>
<a href="#4.5">4.5. How do I select text for or paste text from the clipboard when nano's mouse support is turned on?</a><br>
<a href="#4.6">4.6. When I paste text into a document, each line gets indented further than the last. Why? And how can I stop this?</a><br>
<a href="#4.7">4.7. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?<a><br>
<a href="#4.7">4.7. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?</a><br>
<a href="#4.8">4.8. I've compiled nano with color support, but I don't see any color when I run it!</a><br>
<a href="#4.9">4.9. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
</p></blockquote>
@@ -89,7 +89,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.0</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.4</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%">
@@ -182,10 +182,27 @@
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.2"></a>4.2. Ack! My Backspace/Delete/Enter/Meta/double bucky key doesn't seem to work! What can I do?</h3>
<blockquote><p>Try setting your $TERM variable to 'vt100'. nano doesn't yet support every term entry under the sun.</p>
<p>Bourne shell users (bash and sh): <b>export TERM=vt100</b><br>
C Shell users (tcsh and csh): <b>setenv TERM vt100</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>
URxvt.iso14755_52: False
URxvt.keysym.C-S-Up: \033[1;6A
URxvt.keysym.C-S-Down: \033[1;6B
URxvt.keysym.C-S-Right: \033[1;6C
URxvt.keysym.C-S-Left: \033[1;6D
URxvt.keysym.M-Up: \033[1;3A
URxvt.keysym.M-Down: \033[1;3B
URxvt.keysym.M-Right: \033[1;3C
URxvt.keysym.M-Left: \033[1;3D
URxvt.keysym.M-Insert: \033[2;3~
URxvt.keysym.M-Delete: \033[3;3~
URxvt.keysym.M-Page_Up: \033[5;3~
URxvt.keysym.M-Page_Down: \033[6;3~</pre>
<p>Then run <b>xrdb ~/.Xresources</b> and restart your urxvt terminal. Now <b>Ctrl+Shift+Left</b> and <b>Ctrl+Shift+Right</b> will select words, <b>Alt+Up</b> and <b>Alt+Down</b> will scroll the text without moving the cursor, and several such things more.</p></blockquote>
<h3><a name="4.3"></a>4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</h3>
<blockquote><p>You can use the <b>-K</b> or <b>--rawsequences</b> option on the command line, or add the line <b>set rawsequences</b> to your .nanorc. However, nano's mouse support will be disabled if you do any of these things.</p></blockquote>
<h3><a name="4.4"></a>4.4. With what keystroke can I paste text from the clipboard into nano?</h3>

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 5.0" "July 2020"
.TH NANO 1 "version 5.4" "December 2020"
.SH NAME
nano \- Nano's ANOther editor, inspired by Pico
@@ -165,7 +165,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,7 +187,7 @@ 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
@@ -261,6 +261,7 @@ position to the end of the line, instead of cutting the entire line.
.TP
.BR \-l ", " \-\-linenumbers
Display line numbers to the left of the text area.
(Any line with an anchor additionally gets a mark in the margin.)
.TP
.BR \-m ", " \-\-mouse
Enable mouse support, if available for your system. When enabled, mouse
@@ -294,11 +295,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).
@@ -318,7 +319,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.
@@ -328,6 +328,18 @@ 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 \-! ", " \-\-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
@@ -350,6 +362,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

@@ -8,8 +8,8 @@
@smallbook
@set EDITION 0.5
@set VERSION 5.0
@set UPDATED July 2020
@set VERSION 5.4
@set UPDATED December 2020
@dircategory Editors
@direntry
@@ -23,7 +23,7 @@
@titlepage
@title GNU @command{nano}
@subtitle a small and friendly text editor
@subtitle version 5.0
@subtitle version 5.4
@author Chris Allegretta
@page
@@ -63,7 +63,7 @@ e-mail: @email{chrisa@@asty.org}@*
@node Top
@top
This manual documents the GNU @command{nano} editor, version 5.0.
This manual documents the GNU @command{nano} editor, version 5.4.
@menu
* Introduction::
@@ -71,9 +71,9 @@ This manual documents the GNU @command{nano} editor, version 5.0.
* Command-line Options::
* Editor Basics::
* Built-in Help::
* The File Browser::
* Feature Toggles::
* Nanorc Files::
* The File Browser::
* Pico Compatibility::
* Building and Configure Options::
@end menu
@@ -99,14 +99,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}).
Please report bugs via @url{https://savannah.gnu.org/bugs/?group=nano}.
For background information see @url{https://nano-editor.org/}.
@node Invoking
@chapter Invoking
@@ -252,7 +252,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.
@@ -370,6 +370,7 @@ position to the end of the line, instead of cutting the entire line.
@item -l
@itemx --linenumbers
Display line numbers to the left of the text area.
(Any line with an anchor additionally gets a mark in the margin.)
@item -m
@itemx --mouse
@@ -467,6 +468,20 @@ 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 --magic
When neither the file's name nor its first line give a clue,
try using libmagic to determine the applicable syntax.
@end table
@@ -536,23 +551,22 @@ 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
@@ -563,8 +577,8 @@ 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
@@ -630,6 +644,8 @@ inherits the anchor. After performing an operation on the entire buffer
spell check on it), any anchors that were present are gone. And when
you close the buffer, all its anchors simply disappear; they are not saved.
Anchors are visualized in the margin when line numbers are activated.
@node Limitations
@section Limitations
@@ -647,6 +663,25 @@ editor and the available keystrokes. Navigation is via the @kbd{^Y} (Page Up)
and @kbd{^V} (Page Down) keys. @kbd{^X} exits from the help system.
@node The File Browser
@chapter The File Browser
When in the Read-File (@kbd{^R}) or Write-Out menu (@kbd{^O}),
pressing @kbd{^T} will invoke the file browser.
Here, one can navigate directories in a graphical manner in order to
find the desired file.
Basic movement in the file browser is accomplished with the arrow and
other cursor-movement keys. More targeted movement is accomplished by
searching, via @kbd{^W} or @kbd{w}, or by changing directory, via
@kbd{^_} or @kbd{g}. The behavior of the @kbd{Enter} key (or @kbd{s})
varies by what is currently selected.
If the currently selected object is a directory, the file browser will
enter and display the contents of the directory. If the object is a
file, this filename and path are copied to the status bar, and the file
browser exits.
@node Feature Toggles
@chapter Feature Toggles
@@ -783,7 +818,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.
@@ -853,15 +888,23 @@ in the two help lines at the bottom of the screen.
@item set linenumbers
Display line numbers to the left of the text area.
(Any line with an anchor additionally gets a mark in the margin.)
@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}"
Set the opening and closing brackets that can be found by bracket
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.
@@ -918,7 +961,7 @@ 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
@@ -926,7 +969,7 @@ keystroke instead of 25. Note that @option{constantshow} overrides 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.
@@ -950,6 +993,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.
@@ -979,6 +1028,14 @@ 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 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.
@@ -1010,11 +1067,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
@@ -1046,6 +1098,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.
@@ -1113,7 +1168,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
@@ -1419,11 +1474,12 @@ Goes to a specific line (and column if specified). Negative numbers count
from the end of the file (and end of the line).
@item findbracket
Moves the cursor to the bracket (brace, parenthesis, etc.) that matches
(pairs) with the one under the cursor.
Moves the cursor to the bracket (or brace or parenthesis, etc.) that matches
(pairs) with the one under the cursor. @xref{@code{set matchbrackets}}.
@item anchor
Places an anchor at the current line, or removes it when already present.
(An anchor is visible when line numbers are activated.)
@item prevanchor
Goes to the first anchor before the current line.
@@ -1653,25 +1709,6 @@ it means all menus where the specified @code{key} exists.
@end table
@node The File Browser
@chapter The File Browser
When in the Read-File (@kbd{^R}) or Write-Out menu (@kbd{^O}),
pressing @kbd{^T} will invoke the file browser.
Here, one can navigate directories in a graphical manner in order to
find the desired file.
Basic movement in the file browser is accomplished with the arrow and
other cursor-movement keys. More targeted movement is accomplished by
searching, via @kbd{^W} or @kbd{w}, or by changing directory, via
@kbd{^_} or @kbd{g}. The behavior of the @kbd{Enter} key (or @kbd{s})
varies by what is currently selected.
If the currently selected object is a directory, the file browser will
enter and display the contents of the directory. If the object is a
file, this filename and path are copied to the status bar, and the file
browser exits.
@node Pico Compatibility
@chapter Pico Compatibility

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 5.0" "July 2020"
.TH NANORC 5 "version 5.4" "December 2020"
.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.
@@ -166,12 +165,19 @@ See \fBset titlecolor\fR for more details.
.TP
.B set linenumbers
Display line numbers to the left of the text area.
(Any line with an anchor additionally gets a mark in the margin.)
.TP
.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 """
Set the opening and closing brackets that can be found by bracket
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".
@@ -260,6 +266,12 @@ 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
Specify the color combination to use 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.
See \fBset titlecolor\fR for more details.
@@ -286,7 +298,15 @@ 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 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.
@@ -332,11 +352,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
@@ -385,13 +400,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
@@ -528,11 +543,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.
@@ -625,8 +639,8 @@ 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).
@@ -722,11 +736,12 @@ Goes to a specific line (and column if specified). Negative numbers count
from the end of the file (and end of the line).
.TP
.B findbracket
Moves the cursor to the bracket (brace, parenthesis, etc.) that matches
(pairs) with the one under the cursor.
Moves the cursor to the bracket (or brace or parenthesis, etc.) that matches
(pairs) with the one under the cursor. See \fBset matchbrackets\fR.
.TP
.B anchor
Places an anchor at the current line, or removes it when already present.
(An anchor is visible when line numbers are activated.)
.TP
.B prevanchor
Goes to the first anchor before the current line.
@@ -959,6 +974,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

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH RNANO 1 "version 5.0" "July 2020"
.TH RNANO 1 "version 5.4" "December 2020"
.SH NAME
rnano \- a restricted nano

View File

@@ -68,7 +68,7 @@
## Scroll the buffer contents per half-screen instead of per line.
# set jumpyscrolling
## Display line numbers to the left of the text.
## Display line numbers to the left (and any anchors in the margin).
# set linenumbers
## Enable vim-style lock-files. This is just to let a vim user know you
@@ -76,6 +76,9 @@
## no plans to implement vim-style undo state in these files.
# set locking
## Fall back to slow libmagic to try and determine an applicable syntax.
# set magic
## The opening and closing brackets that can be found by bracket
## searches. They cannot contain blank characters. The former set must
## come before the latter set, and both must be in the same order.
@@ -159,6 +162,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.)
@@ -172,9 +179,6 @@
## 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.
@@ -203,15 +207,18 @@
# set errorcolor bold,lightwhite,red
# 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 selectedcolor lightwhite,cyan
# set stripecolor ,yellow
# set scrollercolor magenta
# set numbercolor magenta
# set keycolor lightmagenta
# set functioncolor magenta
@@ -220,7 +227,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 +236,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':

1260
po/bg.po

File diff suppressed because it is too large Load Diff

1249
po/ca.po

File diff suppressed because it is too large Load Diff

1327
po/cs.po

File diff suppressed because it is too large Load Diff

1340
po/da.po

File diff suppressed because it is too large Load Diff

1268
po/de.po

File diff suppressed because it is too large Load Diff

1246
po/eo.po

File diff suppressed because it is too large Load Diff

1379
po/es.po

File diff suppressed because it is too large Load Diff

1260
po/eu.po

File diff suppressed because it is too large Load Diff

1234
po/fi.po

File diff suppressed because it is too large Load Diff

1242
po/fr.po

File diff suppressed because it is too large Load Diff

1245
po/ga.po

File diff suppressed because it is too large Load Diff

1869
po/gl.po

File diff suppressed because it is too large Load Diff

1776
po/hr.po

File diff suppressed because it is too large Load Diff

1236
po/hu.po

File diff suppressed because it is too large Load Diff

1257
po/id.po

File diff suppressed because it is too large Load Diff

1236
po/it.po

File diff suppressed because it is too large Load Diff

1239
po/ja.po

File diff suppressed because it is too large Load Diff

1392
po/ko.po

File diff suppressed because it is too large Load Diff

1305
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1244
po/nb.po

File diff suppressed because it is too large Load Diff

1244
po/nl.po

File diff suppressed because it is too large Load Diff

1256
po/nn.po

File diff suppressed because it is too large Load Diff

1239
po/pl.po

File diff suppressed because it is too large Load Diff

1248
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1384
po/ro.po

File diff suppressed because it is too large Load Diff

1265
po/ru.po

File diff suppressed because it is too large Load Diff

1266
po/sl.po

File diff suppressed because it is too large Load Diff

1406
po/sr.po

File diff suppressed because it is too large Load Diff

1236
po/sv.po

File diff suppressed because it is too large Load Diff

1255
po/tr.po

File diff suppressed because it is too large Load Diff

1249
po/uk.po

File diff suppressed because it is too large Load Diff

View File

@@ -26,6 +26,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 || \

1235
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.0"
VERSION="5.4"
./configure -C --enable-tiny && make && ./configure -C &&

View File

@@ -2,7 +2,7 @@
* 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) 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,360 @@ 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
}
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);
}
}
/* 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 +487,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 +515,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 +559,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 +571,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 +595,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 +615,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 +689,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 +709,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 +733,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

@@ -2,7 +2,7 @@
* 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) 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 *
@@ -197,12 +197,18 @@ int mbwidth(const char *c)
return 1;
}
/* Return TRUE when the given character occupies zero cells. */
bool is_zerowidth(const char *ch)
{
return (use_utf8 && mbwidth(ch) == 0);
}
/* 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);
char *mb_char = nmalloc(MAXCHARLEN);
*length = wctomb(mb_char, (wchar_t)code);
@@ -374,6 +380,22 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
wchar_t wc1, wc2;
while (*s1 != '\0' && *s2 != '\0' && n > 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 = (mbtowc(&wc1, s1, MAXCHARLEN) < 0);
bool bad2 = (mbtowc(&wc2, s2, MAXCHARLEN) < 0);

View File

@@ -2,7 +2,7 @@
* 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) 2014-2017, 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 *
@@ -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,15 @@ 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 == 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 +91,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);
}
}
@@ -189,8 +178,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;
@@ -243,7 +232,7 @@ void find_and_prime_applicable_syntax(void)
/* 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));
line->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short));
for (short index = 0; index < openfile->syntax->nmultis; index++)
line->multidata[index] = -1;

View File

@@ -3,7 +3,7 @@
* *
* Copyright (C) 1999-2011, 2013-2020 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 *
@@ -88,7 +88,7 @@ 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);
@@ -121,7 +121,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 +140,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);
}
@@ -289,7 +299,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;
@@ -308,7 +318,7 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
cutbuffer = taken;
cutbottom = last;
} else {
cutbottom->data = charealloc(cutbottom->data,
cutbottom->data = nrealloc(cutbottom->data,
strlen(cutbottom->data) + strlen(taken->data) + 1);
strcat(cutbottom->data, taken->data);
@@ -375,7 +385,7 @@ 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);
}
@@ -401,7 +411,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. */

View File

@@ -56,10 +56,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
@@ -89,10 +85,6 @@
#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
@@ -139,8 +131,6 @@
#define BAD_COLOR -2
#endif
#define STANDARD_INPUT 0
/* Enumeration types. */
typedef enum {
NIX_FILE, DOS_FILE, MAC_FILE
@@ -345,11 +335,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;
@@ -453,8 +443,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,8 +454,8 @@ 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;
@@ -485,6 +473,7 @@ enum
TITLE_BAR = 0,
LINE_NUMBER,
GUIDE_STRIPE,
SCROLL_BAR,
SELECTED_TEXT,
STATUS_BAR,
ERROR_MESSAGE,
@@ -544,7 +533,9 @@ enum
JUMPY_SCROLLING,
EMPTY_LINE,
INDICATOR,
BOOKSTYLE
BOOKSTYLE,
STATEFLAGS,
USE_MAGIC
};
/* Flags for the menus in which a given function should be present. */
@@ -625,10 +616,7 @@ enum
#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. */
#define KEY_FLUSH 0xFF /* Clipped error code. */
#else
#define KEY_FLUSH KEY_F0 /* Nonexistent function key. */
#endif

View File

@@ -159,7 +159,7 @@ bool write_lockfile(const char *lockfilename, const char *filename, bool modifie
return FALSE;
}
lockdata = charalloc(LOCKSIZE);
lockdata = nmalloc(LOCKSIZE);
memset(lockdata, 0, LOCKSIZE);
/* This is the lock data we will store (other bytes remain 0x00):
@@ -212,7 +212,7 @@ char *do_lockfile(const char *filename, bool ask_the_user)
char *secondcopy = copy_of(filename);
size_t locknamesize = strlen(filename) + strlen(locking_prefix) +
strlen(locking_suffix) + 3;
char *lockfilename = charalloc(locknamesize);
char *lockfilename = nmalloc(locknamesize);
struct stat fileinfo;
snprintf(lockfilename, locknamesize, "%s/%s%s%s", dirname(namecopy),
@@ -235,7 +235,7 @@ char *do_lockfile(const char *filename, bool ask_the_user)
return NULL;
}
lockbuf = charalloc(LOCKSIZE);
lockbuf = nmalloc(LOCKSIZE);
readamt = read(lockfd, lockbuf, LOCKSIZE);
@@ -258,7 +258,7 @@ char *do_lockfile(const char *filename, bool ask_the_user)
lockuser[16] = '\0';
free(lockbuf);
pidstring = charalloc(11);
pidstring = nmalloc(11);
sprintf (pidstring, "%u", (unsigned int)lockpid);
/* Display newlines in filenames as ^J. */
@@ -273,7 +273,7 @@ char *do_lockfile(const char *filename, bool ask_the_user)
else if (room < breadth(filename)) {
char *fragment = display_string(filename,
breadth(filename) - room + 3, room, FALSE, FALSE);
postedname = charalloc(strlen(fragment) + 4);
postedname = nmalloc(strlen(fragment) + 4);
strcpy(postedname, "...");
strcat(postedname, fragment);
free(fragment);
@@ -282,7 +282,7 @@ char *do_lockfile(const char *filename, bool ask_the_user)
/* Allow extra space for username (14), program name (8), PID (8),
* and terminating \0 (1), minus the %s (2) for the file name. */
promptstr = charalloc(strlen(question) + 29 + strlen(postedname));
promptstr = nmalloc(strlen(question) + 29 + strlen(postedname));
sprintf(promptstr, question, postedname, lockuser, lockprog, pidstring);
free(postedname);
free(pidstring);
@@ -314,7 +314,7 @@ char *do_lockfile(const char *filename, bool ask_the_user)
void stat_with_alloc(const char *filename, struct stat **pstat)
{
if (*pstat == NULL)
*pstat = (struct stat *)nmalloc(sizeof(struct stat));
*pstat = nmalloc(sizeof(struct stat));
if (stat(filename, *pstat) != 0) {
free(*pstat);
@@ -615,7 +615,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
/* The length of the current line of the file. */
size_t bufsize = LUMPSIZE;
/* The size of the line buffer; increased as needed. */
char *buf = charalloc(bufsize);
char *buf = nmalloc(bufsize);
/* The buffer in which we assemble each line of the file. */
linestruct *topline;
/* The top of the new buffer where we store the read file. */
@@ -658,10 +658,8 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
while ((onevalue = getc_unlocked(f)) != EOF) {
char input = (char)onevalue;
if (control_C_was_pressed) {
statusline(ALERT, _("Interrupted"));
if (control_C_was_pressed)
break;
}
/* When the byte before the current one is a CR and we're doing
* format conversion, then strip this CR when it's before a LF
@@ -691,7 +689,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
* decreasing it -- it gets freed when reading is finished. */
if (len == bufsize) {
bufsize += LUMPSIZE;
buf = charealloc(buf, bufsize);
buf = nrealloc(buf, bufsize);
}
continue;
@@ -721,20 +719,23 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
#ifndef NANO_TINY
block_sigwinch(FALSE);
#endif
/* When reading from stdin, restore the terminal and reenter curses mode. */
if (isendwin()) {
if (!isatty(STANDARD_INPUT))
if (!isatty(STDIN_FILENO))
reconnect_and_store_state();
terminal_init();
doupdate();
}
#endif
/* If there was a real error during the reading, let the user know. */
if (ferror(f) && errornumber != EINTR && errornumber != 0)
statusline(ALERT, strerror(errornumber));
if (control_C_was_pressed)
statusline(ALERT, _("Interrupted"));
fclose(f);
if (fd > 0 && !undoable && !ISSET(VIEW_MODE))
@@ -888,7 +889,7 @@ char *get_next_filename(const char *name, const char *suffix)
/* Reserve space for: the name plus the suffix plus a dot plus
* possibly five digits plus a null byte. */
buf = charalloc(wholenamelen + 7);
buf = nmalloc(wholenamelen + 7);
sprintf(buf, "%s%s", name, suffix);
while (TRUE) {
@@ -915,7 +916,7 @@ static pid_t pid_of_command = -1;
/* The PID of a forked process -- needed when wanting to abort it. */
/* Send an unconditional kill signal to the running external command. */
RETSIGTYPE cancel_the_command(int signal)
void cancel_the_command(int signal)
{
kill(pid_of_command, SIGKILL);
}
@@ -950,7 +951,7 @@ bool execute_command(const char *command)
/* Create a pipe to read the command's output from, and, if needed,
* a pipe to feed the command's input through. */
if (pipe(from_fd) == -1 || (should_pipe && pipe(to_fd) == -1)) {
statusline(ALERT, _("Could not create pipe"));
statusline(ALERT, _("Could not create pipe: %s"), strerror(errno));
return FALSE;
}
@@ -965,13 +966,16 @@ bool execute_command(const char *command)
close(from_fd[0]);
/* Connect the write end of the output pipe to the process' output streams. */
dup2(from_fd[1], fileno(stdout));
dup2(from_fd[1], fileno(stderr));
if (dup2(from_fd[1], STDOUT_FILENO) < 0)
exit(3);
if (dup2(from_fd[1], STDERR_FILENO) < 0)
exit(4);
/* If the parent sends text, connect the read end of the
* feeding pipe to the child's input stream. */
if (should_pipe) {
dup2(to_fd[0], fileno(stdin));
if (dup2(to_fd[0], STDIN_FILENO) < 0)
exit(5);
close(to_fd[1]);
}
@@ -979,14 +983,14 @@ bool execute_command(const char *command)
execl(theshell, tail(theshell), "-c", should_pipe ? &command[1] : command, NULL);
/* If the exec call returns, there was an error. */
exit(1);
exit(6);
}
/* Parent: close the unused write end of the pipe. */
close(from_fd[1]);
if (pid_of_command == -1) {
statusline(ALERT, _("Could not fork"));
statusline(ALERT, _("Could not fork: %s"), strerror(errno));
close(from_fd[0]);
return FALSE;
}
@@ -1306,7 +1310,7 @@ char *get_full_path(const char *origpath)
if (origpath == NULL)
return NULL;
allocation = charalloc(PATH_MAX + 1);
allocation = nmalloc(PATH_MAX + 1);
here = getcwd(allocation, PATH_MAX + 1);
/* If getting the current directory failed, go up one level and try again,
@@ -1320,7 +1324,7 @@ char *get_full_path(const char *origpath)
/* If we found a directory, make sure its path ends in a slash. */
if (here != NULL) {
if (strcmp(here, "/") != 0) {
here = charealloc(here, strlen(here) + 2);
here = nrealloc(here, strlen(here) + 2);
strcat(here, "/");
}
} else {
@@ -1339,7 +1343,7 @@ char *get_full_path(const char *origpath)
size_t length = strlen(target);
if (target[length - 1] != '/') {
target = charealloc(target, length + 2);
target = nrealloc(target, length + 2);
strcat(target, "/");
}
}
@@ -1366,14 +1370,14 @@ char *get_full_path(const char *origpath)
} else {
free(target);
allocation = charalloc(PATH_MAX + 1);
allocation = nmalloc(PATH_MAX + 1);
target = getcwd(allocation, PATH_MAX + 1);
/* If we got a result, make sure it ends in a slash.
* Otherwise, ensure that we return NULL. */
if (target != NULL) {
if (strcmp(target, "/") != 0) {
target = charealloc(target, strlen(target) + 2);
target = nrealloc(target, strlen(target) + 2);
strcat(target, "/");
}
} else {
@@ -1392,7 +1396,7 @@ char *get_full_path(const char *origpath)
/* If we were given more than a bare path, concatenate the target path
* with the filename portion to get the full, absolute file path. */
if (!path_only && target != NULL) {
target = charealloc(target, strlen(target) + strlen(just_filename) + 1);
target = nrealloc(target, strlen(target) + strlen(just_filename) + 1);
strcat(target, just_filename);
}
@@ -1438,7 +1442,7 @@ char *safe_tempfile(FILE **stream)
if (tempdir == NULL)
tempdir = copy_of("/tmp/");
tempfile_name = charealloc(tempdir, strlen(tempdir) + 12);
tempfile_name = nrealloc(tempdir, strlen(tempdir) + 12);
strcat(tempfile_name, "nano.XXXXXX");
fd = mkstemp(tempfile_name);
@@ -1464,7 +1468,7 @@ void init_operating_dir(void)
die(_("Invalid operating directory: %s\n"), operating_dir);
free(operating_dir);
operating_dir = charealloc(target, strlen(target) + 1);
operating_dir = nrealloc(target, strlen(target) + 1);
}
/* Check whether the given path is outside of the operating directory.
@@ -1513,7 +1517,7 @@ void init_backup_dir(void)
die(_("Invalid backup directory: %s\n"), backup_dir);
free(backup_dir);
backup_dir = charealloc(target, strlen(target) + 1);
backup_dir = nrealloc(target, strlen(target) + 1);
}
#endif
@@ -1555,10 +1559,11 @@ int copy_file(FILE *inn, FILE *out, bool close_out)
bool make_backup_of(char *realname)
{
FILE *original = NULL, *backup_file = NULL;
int creation_flags, descriptor, verdict;
static struct timespec filetime[2];
int creation_flags, descriptor;
bool second_attempt = FALSE;
char *backupname = NULL;
int verdict = 0;
/* Remember the original file's access and modification times. */
filetime[0].tv_sec = openfile->statinfo->st_atime;
@@ -1570,7 +1575,7 @@ bool make_backup_of(char *realname)
* by appending a tilde to the original file name. Otherwise,
* we create a numbered backup in the specified directory. */
if (backup_dir == NULL) {
backupname = charalloc(strlen(realname) + 2);
backupname = nmalloc(strlen(realname) + 2);
sprintf(backupname, "%s~", realname);
} else {
char *thename = get_full_path(realname);
@@ -1585,7 +1590,7 @@ bool make_backup_of(char *realname)
} else
thename = copy_of(tail(realname));
backupname = charalloc(strlen(backup_dir) + strlen(thename) + 1);
backupname = nmalloc(strlen(backup_dir) + strlen(thename) + 1);
sprintf(backupname, "%s%s", backup_dir, thename);
free(thename);
@@ -1619,14 +1624,20 @@ bool make_backup_of(char *realname)
goto problem;
/* Try to change owner and group to those of the original file;
* ignore errors, as a normal user cannot change the owner. */
IGNORE_CALL_RESULT(fchown(descriptor, openfile->statinfo->st_uid,
openfile->statinfo->st_gid));
* ignore permission errors, as a normal user cannot change the owner. */
if (fchown(descriptor, openfile->statinfo->st_uid,
openfile->statinfo->st_gid) < 0 && errno != EPERM) {
fclose(backup_file);
goto problem;
}
/* Set the backup's permissions to those of the original file.
* It is not a security issue if this fails, as we have created
* the file with just read and write permission for the owner. */
IGNORE_CALL_RESULT(fchmod(descriptor, openfile->statinfo->st_mode));
if (fchmod(descriptor, openfile->statinfo->st_mode) < 0 && errno != EPERM) {
fclose(backup_file);
goto problem;
}
original = fopen(realname, "rb");
@@ -1671,7 +1682,7 @@ bool make_backup_of(char *realname)
warn_and_briefly_pause(_("Trying again in your home directory"));
currmenu = MMOST;
backupname = charalloc(strlen(homedir) + strlen(tail(realname)) + 9);
backupname = nmalloc(strlen(homedir) + strlen(tail(realname)) + 9);
sprintf(backupname, "%s/%s~XXXXXX", homedir, tail(realname));
descriptor = mkstemp(backupname);
@@ -2035,12 +2046,11 @@ bool write_marked_file(const char *name, FILE *stream, bool tmp,
* the buffer is to be discarded. */
int do_writeout(bool exiting, bool withprompt)
{
bool result = FALSE;
kind_of_writing_type method = OVERWRITE;
char *given;
/* The filename we offer, or what the user typed so far. */
bool maychange = (openfile->filename[0] == '\0');
/* Whether it's okay to save the file under a different name. */
kind_of_writing_type method = OVERWRITE;
#ifdef ENABLE_EXTRA
static bool did_credits = FALSE;
#endif
@@ -2059,11 +2069,9 @@ int do_writeout(bool exiting, bool withprompt)
functionptrtype func;
const char *msg;
#ifndef NANO_TINY
const char *formatstr, *backupstr;
formatstr = (openfile->fmt == DOS_FILE) ? _(" [DOS Format]") :
const char *formatstr = (openfile->fmt == DOS_FILE) ? _(" [DOS Format]") :
(openfile->fmt == MAC_FILE) ? _(" [Mac Format]") : "";
backupstr = ISSET(MAKE_BACKUP) ? _(" [Backup]") : "";
const char *backupstr = ISSET(MAKE_BACKUP) ? _(" [Backup]") : "";
/* When the mark is on, offer to write the selection to disk, but
* not when in restricted mode, because it would allow writing to
@@ -2099,7 +2107,8 @@ int do_writeout(bool exiting, bool withprompt)
if (response < 0) {
statusbar(_("Cancelled"));
break;
free(given);
return 0;
}
func = func_from_key(&response);
@@ -2141,9 +2150,8 @@ int do_writeout(bool exiting, bool withprompt)
continue;
}
#endif
if (func == do_help) {
if (func == do_help)
continue;
}
#ifdef ENABLE_EXTRA
/* If the user pressed Ctrl-X in the edit window, and answered "Y" at
@@ -2157,7 +2165,9 @@ int do_writeout(bool exiting, bool withprompt)
} else
/* TRANSLATORS: Concisely say the screen is too small. */
statusbar(_("Too tiny"));
break;
free(given);
return 0;
}
#endif
@@ -2170,6 +2180,7 @@ int do_writeout(bool exiting, bool withprompt)
full_filename = get_full_path(openfile->filename);
name_exists = (stat((full_answer == NULL) ?
answer : full_answer, &st) != -1);
if (openfile->filename[0] == '\0')
do_warning = name_exists;
else
@@ -2207,7 +2218,7 @@ int do_writeout(bool exiting, bool withprompt)
char *question = _("File \"%s\" exists; OVERWRITE? ");
char *name = display_string(answer, 0,
COLS - breadth(question) + 1, FALSE, FALSE);
char *message = charalloc(strlen(question) +
char *message = nmalloc(strlen(question) +
strlen(name) + 1);
sprintf(message, question, name);
@@ -2256,23 +2267,19 @@ int do_writeout(bool exiting, bool withprompt)
#endif
}
/* Here's where we allow the selected text to be written to
* a separate file. If we're using restricted mode, this
* function is disabled, since it allows reading from or
* writing to files not specified on the command line. */
#ifndef NANO_TINY
if (openfile->mark && !exiting && withprompt && !ISSET(RESTRICTED))
result = write_marked_file(answer, NULL, FALSE, method);
else
#endif
result = write_file(answer, NULL, FALSE, method, TRUE);
free(given);
break;
}
free(given);
return result ? 1 : 0;
/* When the mark is on (and we've prompted for a name and we're
* not exiting and we're not in restricted mode), then write out
* the marked region; otherwise, write out the whole buffer. */
#ifndef NANO_TINY
if (openfile->mark && withprompt && !exiting && !ISSET(RESTRICTED))
return write_marked_file(answer, NULL, FALSE, method);
else
#endif
return write_file(answer, NULL, FALSE, method, TRUE);
}
/* Write the current buffer to disk, or discard it. */
@@ -2325,7 +2332,7 @@ char *real_dir_from_tilde(const char *path)
#endif
}
retval = charalloc(strlen(tilded) + strlen(path + i) + 1);
retval = nmalloc(strlen(tilded) + strlen(path + i) + 1);
sprintf(retval, "%s%s", tilded, path + i);
free(tilded);
@@ -2349,11 +2356,13 @@ int diralphasort(const void *va, const void *vb)
if (!aisdir && bisdir)
return 1;
/* Standard function brain damage: We should be sorting
* alphabetically and case-insensitively according to the current
* locale, but there's no standard strcasecoll() function, so we
* have to use multibyte strcasecmp() instead. */
return mbstrcasecmp(a, b);
int difference = mbstrcasecmp(a, b);
/* If two names are equivalent when ignoring case, compare them bytewise. */
if (difference == 0)
return strcmp(a, b);
else
return difference;
}
#endif
@@ -2388,8 +2397,8 @@ char **username_completion(const char *morsel, size_t length, size_t *num_matche
if (outside_of_confinement(userdata->pw_dir, TRUE))
continue;
#endif
matches = (char **)nrealloc(matches, (*num_matches + 1) * sizeof(char *));
matches[*num_matches] = charalloc(strlen(userdata->pw_name) + 2);
matches = nrealloc(matches, (*num_matches + 1) * sizeof(char *));
matches[*num_matches] = nmalloc(strlen(userdata->pw_name) + 2);
sprintf(matches[*num_matches], "~%s", userdata->pw_name);
++(*num_matches);
}
@@ -2437,7 +2446,7 @@ char **filename_completion(const char *morsel, size_t length, size_t *num_matche
dirname = real_dir_from_tilde(dirname);
/* A non-absolute path is relative to the current browser directory. */
if (dirname[0] != '/') {
dirname = charealloc(dirname, strlen(present_path) + strlen(wasdirname) + 1);
dirname = nrealloc(dirname, strlen(present_path) + strlen(wasdirname) + 1);
sprintf(dirname, "%s%s", present_path, wasdirname);
}
free(wasdirname);
@@ -2463,7 +2472,7 @@ char **filename_completion(const char *morsel, size_t length, size_t *num_matche
if (strncmp(entry->d_name, filename, filenamelen) == 0 &&
strcmp(entry->d_name, ".") != 0 &&
strcmp(entry->d_name, "..") != 0) {
fullname = charealloc(fullname, strlen(dirname) +
fullname = nrealloc(fullname, strlen(dirname) +
strlen(entry->d_name) + 1);
sprintf(fullname, "%s%s", dirname, entry->d_name);
@@ -2475,7 +2484,7 @@ char **filename_completion(const char *morsel, size_t length, size_t *num_matche
if (currmenu == MGOTODIR && !is_dir(fullname))
continue;
matches = (char **)nrealloc(matches, (*num_matches + 1) * sizeof(char *));
matches = nrealloc(matches, (*num_matches + 1) * sizeof(char *));
matches[*num_matches] = copy_of(entry->d_name);
++(*num_matches);
}
@@ -2546,7 +2555,7 @@ char *input_tab(char *morsel, size_t *place, void (*refresh_func)(void), bool *l
common_len += len1;
}
shared = charalloc(length_of_path + common_len + 1);
shared = nmalloc(length_of_path + common_len + 1);
strncpy(shared, morsel, length_of_path);
strncpy(shared + length_of_path, matches[0], common_len);
@@ -2555,7 +2564,7 @@ char *input_tab(char *morsel, size_t *place, void (*refresh_func)(void), bool *l
shared[common_len] = '\0';
/* Cover also the case of the user specifying a relative path. */
glued = charalloc(strlen(present_path) + common_len + 1);
glued = nmalloc(strlen(present_path) + common_len + 1);
sprintf(glued, "%s%s", present_path, shared);
if (num_matches == 1 && (is_dir(shared) || is_dir(glued)))
@@ -2563,7 +2572,7 @@ char *input_tab(char *morsel, size_t *place, void (*refresh_func)(void), bool *l
/* If the matches have something in common, copy that part. */
if (common_len != *place) {
morsel = charealloc(morsel, common_len + 1);
morsel = nrealloc(morsel, common_len + 1);
strncpy(morsel, shared, common_len);
morsel[common_len] = '\0';
*place = common_len;

View File

@@ -477,7 +477,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 +530,7 @@ functionptrtype interpret(int *keycode)
return do_findnext;
switch (tolower(*keycode)) {
case 'b':
case '-':
return do_page_up;
case ' ':
@@ -728,10 +730,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 +749,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);
@@ -778,6 +790,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);
@@ -796,6 +818,7 @@ void shortcut_init(void)
}
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)
@@ -827,7 +850,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 +860,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 +916,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);
@@ -982,8 +1015,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 +1037,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 +1068,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 +1108,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 +1148,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 +1165,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);
@@ -1203,7 +1245,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);
@@ -1218,6 +1265,7 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "M-;", 0, run_macro, 0);
add_to_sclist(MMAIN, "M-U", 0, do_undo, 0);
add_to_sclist(MMAIN, "M-E", 0, do_redo, 0);
add_to_sclist(MMAIN, "M-Bsp", CONTROL_SHIFT_DELETE, chop_previous_word, 0);
add_to_sclist(MMAIN, "Sh-^Del", CONTROL_SHIFT_DELETE, chop_previous_word, 0);
add_to_sclist(MMAIN, "^Del", CONTROL_DELETE, chop_next_word, 0);
add_to_sclist(MMAIN, "M-Del", ALT_DELETE, zap_text, 0);
@@ -1259,12 +1307,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);
@@ -1324,6 +1366,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);

View File

@@ -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]);
@@ -302,7 +302,7 @@ void help_init(void)
counter++;
for (s = sclist; s != NULL; s = s->next)
if (s->toggle && s->ordinal == counter) {
ptr += sprintf(ptr, "%s\t\t %s %s\n", (s->menus == MMAIN ? s->keystr : ""),
ptr += sprintf(ptr, "%s\t\t %s %s\n", (s->menus & MMAIN ? s->keystr : ""),
_(flagtostr(s->toggle)), _("enable/disable"));
if (s->toggle == NO_SYNTAX || s->toggle == TABS_TO_SPACES)
ptr += sprintf(ptr, "\n");
@@ -475,14 +475,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 +502,6 @@ void show_help(void)
} else
unbound_key(kbinput);
currmenu = MHELP;
edit_refresh();
location = 0;
@@ -568,8 +566,8 @@ void do_help(void)
#ifdef ENABLE_HELP
show_help();
#else
if (currmenu == MMAIN)
say_there_is_no_help();
if (currmenu == MMAIN || currmenu == MBROWSER)
statusbar(_("^W = Ctrl+W M-W = Alt+W"));
else
beep();
#endif

View File

@@ -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,7 +361,7 @@ 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;
}
@@ -371,10 +371,10 @@ void save_history(void)
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 +393,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,11 +446,9 @@ 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) == -1)
jot_error(N_("Error reading %s: %s\n"), poshistname, strerror(errno));
else
if (stat(poshistname, &fileinfo) == 0)
latest_timestamp = fileinfo.st_mtime;
}
@@ -461,7 +460,7 @@ 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;
}
@@ -474,9 +473,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. */
@@ -485,17 +484,15 @@ 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) == -1)
jot_error(N_("Error writing %s: %s\n"), poshistname, strerror(errno));
else
if (stat(poshistname, &fileinfo) == 0)
latest_timestamp = fileinfo.st_mtime;
}
@@ -504,9 +501,7 @@ void reload_positions_if_needed(void)
{
struct stat fileinfo;
if (stat(poshistname, &fileinfo) == -1)
jot_error(N_("Error reading %s: %s\n"), poshistname, strerror(errno));
else if (fileinfo.st_mtime != latest_timestamp) {
if (stat(poshistname, &fileinfo) == 0 && fileinfo.st_mtime != latest_timestamp) {
poshiststruct *item, *nextone;
for (item = position_history; item != NULL; item = nextone) {
@@ -562,7 +557,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;
@@ -579,8 +574,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);
@@ -610,8 +605,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

@@ -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
@@ -234,8 +238,8 @@ void to_prev_block(void)
seen_text = seen_text || is_text;
}
/* Step forward one line again if this one is blank. */
if (openfile->current->next != NULL &&
/* Step forward one line again if we passed text but this line is blank. */
if (seen_text && openfile->current->next != NULL &&
white_string(openfile->current->data))
openfile->current = openfile->current->next;
@@ -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;
}

View File

@@ -62,6 +62,10 @@ static struct termios original_state;
static struct sigaction oldaction, newaction;
/* Containers for the original and the temporary handler for SIGINT. */
#ifdef USE_SLANG
static bool selfinduced = FALSE;
/* Whether a suspension was caused from inside nano or from outside. */
#endif
/* Create a new linestruct node. Note that we do not set prevnode->next. */
linestruct *make_new_node(linestruct *prevnode)
@@ -211,14 +215,6 @@ bool in_restricted_mode(void)
return FALSE;
}
#ifndef ENABLE_HELP
/* Indicate that help texts are unavailable. */
void say_there_is_no_help(void)
{
statusbar(_("Help is not available"));
}
#endif
/* Make sure the cursor is visible, then exit from curses mode, disable
* bracketed-paste mode, and restore the original terminal settings. */
void restore_terminal(void)
@@ -229,7 +225,7 @@ void restore_terminal(void)
printf("\x1B[?2004l");
fflush(stdout);
#endif
tcsetattr(0, TCSANOW, &original_state);
tcsetattr(STDIN_FILENO, TCSANOW, &original_state);
}
/* Exit normally: restore terminal state and report any startup errors. */
@@ -426,11 +422,13 @@ void window_init(void)
/* In case the terminal shrunk, make sure the status line is clear. */
wipe_statusbar();
#ifndef USE_SLANG
/* When not disabled, turn escape-sequence translation on. */
if (!ISSET(RAW_SEQUENCES)) {
keypad(edit, TRUE);
keypad(bottomwin, TRUE);
}
#endif
#ifdef ENABLED_WRAPORJUSTIFY
/* Set up the wrapping point, accounting for screen width when negative. */
@@ -487,6 +485,7 @@ void print_opt(const char *shortflag, const char *longflag, const char *desc)
void usage(void)
{
printf(_("Usage: nano [OPTIONS] [[+LINE[,COLUMN]] FILE]...\n\n"));
#ifndef NANO_TINY
/* TRANSLATORS: The next two strings are part of the --help output.
* It's best to keep its lines within 80 characters. */
printf(_("To place the cursor on a specific line of a file, put the line number with\n"
@@ -494,7 +493,6 @@ void usage(void)
printf(_("When a filename is '-', nano reads data from standard input.\n\n"));
/* TRANSLATORS: The next three are column headers of the --help output. */
print_opt(_("Option"), _("Long option"), N_("Meaning"));
#ifndef NANO_TINY
/* TRANSLATORS: The next forty or so strings are option descriptions
* for the --help output. Try to keep them at most 40 characters. */
print_opt("-A", "--smarthome", N_("Enable smart home key"));
@@ -528,8 +526,10 @@ void usage(void)
print_opt(_("-J <number>"), _("--guidestripe=<number>"),
N_("Show a guiding bar at this column"));
#endif
#ifndef USE_SLANG
print_opt("-K", "--rawsequences",
N_("Fix numeric keypad key confusion problem"));
#endif
#ifndef NANO_TINY
print_opt("-L", "--nonewlines",
N_("Don't add an automatic newline"));
@@ -559,9 +559,9 @@ void usage(void)
print_opt("-R", "--restricted", N_("Restrict access to the filesystem"));
#ifndef NANO_TINY
print_opt("-S", "--softwrap", N_("Display overlong lines on multiple rows"));
#endif
print_opt(_("-T <number>"), _("--tabsize=<number>"),
N_("Make a tab this number of columns wide"));
#endif
print_opt("-U", "--quickblank", N_("Wipe status bar upon next keystroke"));
print_opt("-V", "--version", N_("Print version information and exit"));
#ifndef NANO_TINY
@@ -585,7 +585,9 @@ void usage(void)
print_opt("-c", "--constantshow", N_("Constantly show cursor position"));
print_opt("-d", "--rebinddelete",
N_("Fix Backspace/Delete confusion problem"));
#ifndef NANO_TINY
print_opt("-e", "--emptyline", N_("Keep the line below the title bar empty"));
#endif
#ifdef ENABLE_NANORC
print_opt(_("-f <file>"), _("--rcfile=<file>"),
N_("Use only this file for configuring nano"));
@@ -596,9 +598,7 @@ void usage(void)
print_opt("-h", "--help", N_("Show this help text and exit"));
#ifndef NANO_TINY
print_opt("-i", "--autoindent", N_("Automatically indent new lines"));
#endif
print_opt("-j", "--jumpyscrolling", N_("Scroll per half-screen, not per line"));
#ifndef NANO_TINY
print_opt("-k", "--cutfromcursor", N_("Cut from cursor to end of line"));
#endif
#ifdef ENABLE_LINENUMBERS
@@ -607,7 +607,9 @@ void usage(void)
#ifdef ENABLE_MOUSE
print_opt("-m", "--mouse", N_("Enable the use of the mouse"));
#endif
#ifndef NANO_TINY
print_opt("-n", "--noread", N_("Do not read the file (only write it)"));
#endif
#ifdef ENABLE_OPERATINGDIR
print_opt(_("-o <dir>"), _("--operatingdir=<dir>"),
N_("Set operating directory"));
@@ -639,11 +641,16 @@ void usage(void)
#endif
if (!ISSET(RESTRICTED))
print_opt("-z", "--suspendable", N_("Enable suspension"));
#ifndef NANO_TINY
print_opt("-%", "--stateflags", N_("Show some states on the title bar"));
#endif
#ifdef HAVE_LIBMAGIC
print_opt("-!", "--magic", N_("Also try magic to determine syntax"));
#endif
}
/* Display the current version of nano, the date and time it was
* compiled, contact information for it, and the configuration options
* it was compiled with. */
/* Display the version number of this nano, a copyright notice, some contact
* information, and the configuration options this nano was compiled with. */
void version(void)
{
#ifdef REVISION
@@ -651,10 +658,11 @@ void version(void)
#else
printf(_(" GNU nano, version %s\n"), VERSION);
#endif
#ifndef NANO_TINY
printf(" (C) 1999-2011, 2013-2020 Free Software Foundation, Inc.\n");
printf(_(" (C) 2014-%s the contributors to nano\n"), "2020");
printf(_(" Email: nano@nano-editor.org Web: https://nano-editor.org/"));
printf(_("\n Compiled options:"));
#endif
printf(_(" Compiled options:"));
#ifdef NANO_TINY
printf(" --enable-tiny");
@@ -775,7 +783,7 @@ void version(void)
}
/* Register that Ctrl+C was pressed during some system call. */
RETSIGTYPE make_a_note(int signal)
void make_a_note(int signal)
{
control_C_was_pressed = TRUE;
}
@@ -799,20 +807,20 @@ void restore_handler_for_Ctrl_C(void)
disable_kb_interrupt();
}
#ifndef NANO_TINY
/* Reconnect standard input to the tty, and store its state. */
void reconnect_and_store_state(void)
{
int thetty = open("/dev/tty", O_RDONLY);
if (thetty < 1)
if (thetty < 0 || dup2(thetty, STDIN_FILENO) < 0)
die(_("Could not reconnect stdin to keyboard\n"));
dup2(thetty, STANDARD_INPUT);
close(thetty);
/* If input was not cut short, store the current state of the terminal. */
if (!control_C_was_pressed)
tcgetattr(0, &original_state);
tcgetattr(STDIN_FILENO, &original_state);
}
/* Read whatever comes from standard input into a new buffer. */
@@ -823,7 +831,7 @@ bool scoop_stdin(void)
restore_terminal();
/* When input comes from a terminal, show a helpful message. */
if (isatty(STANDARD_INPUT))
if (isatty(STDIN_FILENO))
fprintf(stderr, _("Reading data from keyboard; "
"type ^D or ^D^D to finish.\n"));
@@ -856,6 +864,7 @@ bool scoop_stdin(void)
return TRUE;
}
#endif
/* Register half a dozen signal handlers. */
void signal_init(void)
@@ -882,25 +891,17 @@ void signal_init(void)
sigaction(SIGWINCH, &deed, NULL);
#endif
if (ISSET(SUSPENDABLE)) {
/* Block all other signals in the suspend and continue handlers.
* If we don't do this, other stuff interrupts them! */
sigfillset(&deed.sa_mask);
/* In the suspend and continue handlers, block all other signals.
* If we don't do this, other stuff interrupts them! */
sigfillset(&deed.sa_mask);
#ifdef SIGTSTP
/* Trap a normal suspend (^Z) so we can handle it ourselves. */
deed.sa_handler = do_suspend;
sigaction(SIGTSTP, &deed, NULL);
deed.sa_handler = do_suspend;
sigaction(SIGTSTP, &deed, NULL);
#endif
#ifdef SIGCONT
deed.sa_handler = do_continue;
sigaction(SIGCONT, &deed, NULL);
deed.sa_handler = do_continue;
sigaction(SIGCONT, &deed, NULL);
#endif
} else {
#ifdef SIGTSTP
deed.sa_handler = SIG_IGN;
sigaction(SIGTSTP, &deed, NULL);
#endif
}
#if !defined(NANO_TINY) && !defined(DEBUG)
if (getenv("NANO_NOCATCH") == NULL) {
@@ -916,21 +917,21 @@ void signal_init(void)
}
/* Handler for SIGHUP (hangup) and SIGTERM (terminate). */
RETSIGTYPE handle_hupterm(int signal)
void handle_hupterm(int signal)
{
die(_("Received SIGHUP or SIGTERM\n"));
}
#if !defined(NANO_TINY) && !defined(DEBUG)
/* Handler for SIGSEGV (segfault) and SIGABRT (abort). */
RETSIGTYPE handle_crash(int signal)
void handle_crash(int signal)
{
die(_("Sorry! Nano crashed! Code: %d. Please report a bug.\n"), signal);
}
#endif
/* Handler for SIGTSTP (suspend). */
RETSIGTYPE do_suspend(int signal)
void do_suspend(int signal)
{
#ifdef ENABLE_MOUSE
disable_mouse_support();
@@ -955,9 +956,15 @@ RETSIGTYPE do_suspend(int signal)
/* Put nano to sleep (if suspension is enabled). */
void do_suspend_void(void)
{
if (ISSET(SUSPENDABLE))
if (ISSET(SUSPENDABLE)) {
#ifdef USE_SLANG
selfinduced = TRUE;
do_suspend(0);
else {
selfinduced = FALSE;
#else
do_suspend(0);
#endif
} else {
statusbar(_("Suspension is not enabled"));
beep();
}
@@ -966,7 +973,7 @@ void do_suspend_void(void)
}
/* Handler for SIGCONT (continue after suspend). */
RETSIGTYPE do_continue(int signal)
void do_continue(int signal)
{
#ifdef ENABLE_MOUSE
if (ISSET(USE_MOUSE))
@@ -980,8 +987,13 @@ RETSIGTYPE do_continue(int signal)
/* Put the terminal in the desired state again. */
terminal_init();
#endif
/* Tickle the input routine so it will update the screen. */
#ifdef USE_SLANG
if (!selfinduced)
full_refresh();
#else
/* Insert a fake keystroke, to neutralize a key-eating issue. */
ungetch(KEY_FLUSH);
#endif
}
#if !defined(NANO_TINY) || defined(ENABLE_SPELLER) || defined(ENABLE_COLOR)
@@ -1003,7 +1015,7 @@ void block_sigwinch(bool blockit)
#ifndef NANO_TINY
/* Handler for SIGWINCH (window size change). */
RETSIGTYPE handle_sigwinch(int signal)
void handle_sigwinch(int signal)
{
/* Let the input routine know that a SIGWINCH has occurred. */
the_window_resized = TRUE;
@@ -1086,9 +1098,6 @@ void do_toggle(int flag)
mouse_init();
break;
#endif
case SUSPENDABLE:
signal_init();
break;
case SOFTWRAP:
if (ISSET(SOFTWRAP))
compute_the_extra_rows_per_line_from(openfile->filetop);
@@ -1108,6 +1117,10 @@ void do_toggle(int flag)
#endif
}
if (ISSET(STATEFLAGS) && (flag == AUTOINDENT ||
flag == BREAK_LONG_LINES || flag == SOFTWRAP))
titlebar(NULL);
enabled = ISSET(flag);
if (flag == NO_HELP || flag == NO_SYNTAX)
@@ -1205,19 +1218,19 @@ void terminal_init(void)
nonl();
noecho();
disable_extended_io();
if (ISSET(PRESERVE))
enable_flow_control();
#ifdef USE_SLANG
else
disable_flow_control();
tcgetattr(0, &desired_state);
have_new_state = TRUE;
} else
tcsetattr(0, TCSANOW, &desired_state);
SLang_init_tty(-1, 0, 0);
#endif
if (ISSET(PRESERVE))
enable_flow_control();
#ifdef USE_SLANG
else
disable_flow_control();
#endif
disable_kb_interrupt();
@@ -1280,17 +1293,16 @@ void unbound_key(int code)
else if (code > 0x7F)
statusline(ALERT, _("Unbound key"));
else if (meta_key) {
if (code == '[')
statusline(ALERT, _("Unbindable key: M-["));
#ifndef NANO_TINY
else if (code < 0x20)
if (code < 0x20)
statusline(ALERT, _("Unbindable key: M-^%c"), code + 0x40);
else
#endif
#ifdef ENABLE_NANORC
else if (shifted_metas && 'A' <= code && code <= 'Z')
if (shifted_metas && 'A' <= code && code <= 'Z')
statusline(ALERT, _("Unbound key: Sh-M-%c"), code);
#endif
else
#endif
statusline(ALERT, _("Unbound key: M-%c"), toupper(code));
} else if (code == ESC_CODE)
statusline(ALERT, _("Unbindable key: ^["));
@@ -1300,6 +1312,7 @@ void unbound_key(int code)
else
statusline(ALERT, _("Unbound key: %c"), code);
#endif
set_blankdelay_to_one();
}
#ifdef ENABLE_MOUSE
@@ -1404,7 +1417,7 @@ void suck_up_input_and_paste_it(void)
index = 0;
} else if ((0x20 <= input && input <= 0xFF && input != DEL_CODE) ||
input == '\t') {
line->data = charealloc(line->data, index + 2);
line->data = nrealloc(line->data, index + 2);
line->data[index++] = (char)input;
line->data[index] = '\0';
} else if (input != BRACKETED_PASTE_MARKER)
@@ -1448,7 +1461,7 @@ void inject(char *burst, size_t count)
#endif
/* Make room for the new bytes and copy them into the line. */
thisline->data = charealloc(thisline->data, datalen + count + 1);
thisline->data = nrealloc(thisline->data, datalen + count + 1);
memmove(thisline->data + openfile->current_x + count,
thisline->data + openfile->current_x,
datalen - openfile->current_x + 1);
@@ -1523,6 +1536,10 @@ void process_a_keystroke(void)
/* The input buffer for actual characters. */
static size_t depth = 0;
/* The length of the input buffer. */
#ifndef NANO_TINY
linestruct *was_mark = openfile->mark;
#endif
static bool give_a_hint = TRUE;
const keystruct *shortcut;
/* Read in a keystroke, and show the cursor while waiting. */
@@ -1553,16 +1570,16 @@ void process_a_keystroke(void)
else if (ISSET(VIEW_MODE))
print_view_warning();
else {
#ifndef NANO_TINY
if (openfile->mark && openfile->kind_of_mark == SOFTMARK) {
openfile->mark = NULL;
refresh_needed = TRUE;
}
#endif
/* Store the byte, and leave room for a terminating zero. */
puddle = charealloc(puddle, depth + 2);
puddle = nrealloc(puddle, depth + 2);
puddle[depth++] = (char)input;
}
#ifndef NANO_TINY
if (openfile->mark && openfile->kind_of_mark == SOFTMARK) {
openfile->mark = NULL;
refresh_needed = TRUE;
}
#endif
}
/* If we have a command, or if there aren't any other key codes waiting,
@@ -1588,6 +1605,13 @@ void process_a_keystroke(void)
return;
}
if (input == '\b' && give_a_hint && openfile->current_x == 0 &&
openfile->current == openfile->filetop && !ISSET(NO_HELP)) {
statusbar(_("^W = Ctrl+W M-W = Alt+W"));
give_a_hint = FALSE;
} else if (meta_key)
give_a_hint = FALSE;
/* When not cutting or copying text, drop the cutbuffer the next time. */
if (shortcut->func != cut_text) {
#ifndef NANO_TINY
@@ -1654,6 +1678,9 @@ void process_a_keystroke(void)
#ifndef NANO_TINY
if (bracketed_paste)
suck_up_input_and_paste_it();
if (ISSET(STATEFLAGS) && openfile->mark != was_mark)
titlebar(NULL);
#endif
}
@@ -1684,7 +1711,9 @@ int main(int argc, char **argv)
#ifdef ENABLE_NANORC
{"ignorercfiles", 0, NULL, 'I'},
#endif
#ifndef USE_SLANG
{"rawsequences", 0, NULL, 'K'},
#endif
#ifdef ENABLED_WRAPORJUSTIFY
{"trimblanks", 0, NULL, 'M'},
#endif
@@ -1692,7 +1721,6 @@ int main(int argc, char **argv)
{"quotestr", 1, NULL, 'Q'},
#endif
{"restricted", 0, NULL, 'R'},
{"tabsize", 1, NULL, 'T'},
{"quickblank", 0, NULL, 'U'},
{"version", 0, NULL, 'V'},
#ifdef ENABLE_COLOR
@@ -1703,7 +1731,6 @@ int main(int argc, char **argv)
#endif
{"constantshow", 0, NULL, 'c'},
{"rebinddelete", 0, NULL, 'd'},
{"emptyline", 0, NULL, 'e'},
#ifdef ENABLE_NANORC
{"rcfile", 1, NULL, 'f'},
#endif
@@ -1711,14 +1738,12 @@ int main(int argc, char **argv)
{"showcursor", 0, NULL, 'g'},
#endif
{"help", 0, NULL, 'h'},
{"jumpyscrolling", 0, NULL, 'j'},
#ifdef ENABLE_LINENUMBERS
{"linenumbers", 0, NULL, 'l'},
#endif
#ifdef ENABLE_MOUSE
{"mouse", 0, NULL, 'm'},
#endif
{"noread", 0, NULL, 'n'},
#ifdef ENABLE_OPERATINGDIR
{"operatingdir", 1, NULL, 'o'},
#endif
@@ -1750,15 +1775,23 @@ int main(int argc, char **argv)
{"bookstyle", 0, NULL, 'O'},
{"positionlog", 0, NULL, 'P'},
{"softwrap", 0, NULL, 'S'},
{"tabsize", 1, NULL, 'T'},
{"wordbounds", 0, NULL, 'W'},
{"wordchars", 1, NULL, 'X'},
{"zap", 0, NULL, 'Z'},
{"atblanks", 0, NULL, 'a'},
{"emptyline", 0, NULL, 'e'},
{"autoindent", 0, NULL, 'i'},
{"jumpyscrolling", 0, NULL, 'j'},
{"cutfromcursor", 0, NULL, 'k'},
{"noread", 0, NULL, 'n'},
{"indicator", 0, NULL, 'q'},
{"unix", 0, NULL, 'u'},
{"afterends", 0, NULL, 'y'},
{"stateflags", 0, NULL, '%'},
#endif
#ifdef HAVE_LIBMAGIC
{"magic", 0, NULL, '!'},
#endif
{NULL, 0, NULL, 0}
};
@@ -1767,16 +1800,16 @@ int main(int argc, char **argv)
struct vt_stat dummy;
/* Check whether we're running on a Linux console. */
on_a_vt = (ioctl(1, VT_GETSTATE, &dummy) == 0);
on_a_vt = (ioctl(STDOUT_FILENO, VT_GETSTATE, &dummy) == 0);
#endif
/* Back up the terminal settings so that they can be restored. */
tcgetattr(0, &original_state);
tcgetattr(STDIN_FILENO, &original_state);
/* Get the state of standard input and ensure it uses blocking mode. */
stdin_flags = fcntl(0, F_GETFL, 0);
stdin_flags = fcntl(STDIN_FILENO, F_GETFL, 0);
if (stdin_flags != -1)
fcntl(0, F_SETFL, stdin_flags & ~O_NONBLOCK);
fcntl(STDIN_FILENO, F_SETFL, stdin_flags & ~O_NONBLOCK);
#ifdef ENABLE_UTF8
/* If setting the locale is successful and it uses UTF-8, we need
@@ -1815,7 +1848,7 @@ int main(int argc, char **argv)
SET(RESTRICTED);
while ((optchr = getopt_long(argc, argv, "ABC:DEFGHIJ:KLMNOPQ:RST:UVWX:Y:Z"
"abcdef:ghijklmno:pqr:s:tuvwxyz$", long_options, NULL)) != -1) {
"abcdef:ghijklmno:pqr:s:tuvwxyz$%!", long_options, NULL)) != -1) {
switch (optchr) {
#ifndef NANO_TINY
case 'A':
@@ -1865,9 +1898,11 @@ int main(int argc, char **argv)
}
break;
#endif
#ifndef USE_SLANG
case 'K':
SET(RAW_SEQUENCES);
break;
#endif
#ifndef NANO_TINY
case 'L':
SET(NO_NEWLINES);
@@ -1904,7 +1939,6 @@ int main(int argc, char **argv)
case '$': /* Deprecated; remove in 2024. */
SET(SOFTWRAP);
break;
#endif
case 'T':
if (!parse_num(optarg, &tabsize) || tabsize <= 0) {
fprintf(stderr, _("Requested tab size \"%s\" is invalid"), optarg);
@@ -1912,6 +1946,7 @@ int main(int argc, char **argv)
exit(1);
}
break;
#endif
case 'U':
SET(QUICK_BLANK);
break;
@@ -1950,9 +1985,11 @@ int main(int argc, char **argv)
case 'd':
SET(REBIND_DELETE);
break;
#ifndef NANO_TINY
case 'e':
SET(EMPTY_LINE);
break;
#endif
#ifdef ENABLE_NANORC
case 'f':
custom_nanorc = mallocstrcpy(custom_nanorc, optarg);
@@ -1970,11 +2007,9 @@ int main(int argc, char **argv)
case 'i':
SET(AUTOINDENT);
break;
#endif
case 'j':
SET(JUMPY_SCROLLING);
break;
#ifndef NANO_TINY
case 'k':
SET(CUT_FROM_CURSOR);
break;
@@ -1989,9 +2024,11 @@ int main(int argc, char **argv)
SET(USE_MOUSE);
break;
#endif
#ifndef NANO_TINY
case 'n':
SET(NOREAD_MODE);
break;
#endif
#ifdef ENABLE_OPERATINGDIR
case 'o':
operating_dir = mallocstrcpy(operating_dir, optarg);
@@ -2049,6 +2086,16 @@ int main(int argc, char **argv)
case 'z':
SET(SUSPENDABLE);
break;
#ifndef NANO_TINY
case '%':
SET(STATEFLAGS);
break;
#endif
#ifdef HAVE_LIBMAGIC
case '!':
SET(USE_MAGIC);
break;
#endif
default:
printf(_("Type '%s -h' for a list of available options.\n"), argv[0]);
exit(1);
@@ -2076,9 +2123,10 @@ int main(int argc, char **argv)
ssize_t fill_cmdline = fill;
#endif
#ifndef NANO_TINY
size_t stripeclm_cmdline = stripe_column;
char *backup_dir_cmdline = backup_dir;
char *word_chars_cmdline = word_chars;
size_t stripeclm_cmdline = stripe_column;
ssize_t tabsize_cmdline = tabsize;
#endif
#ifdef ENABLE_OPERATINGDIR
char *operating_dir_cmdline = operating_dir;
@@ -2089,7 +2137,6 @@ int main(int argc, char **argv)
#ifdef ENABLE_SPELLER
char *alt_speller_cmdline = alt_speller;
#endif
ssize_t tabsize_cmdline = tabsize;
/* Back up the command-line flags. */
unsigned flags_cmdline[sizeof(flags) / sizeof(flags[0])];
@@ -2118,8 +2165,6 @@ int main(int argc, char **argv)
fill = fill_cmdline;
#endif
#ifndef NANO_TINY
if (stripeclm_cmdline > 0)
stripe_column = stripeclm_cmdline;
if (backup_dir_cmdline != NULL) {
free(backup_dir);
backup_dir = backup_dir_cmdline;
@@ -2128,6 +2173,10 @@ int main(int argc, char **argv)
free(word_chars);
word_chars = word_chars_cmdline;
}
if (stripeclm_cmdline > 0)
stripe_column = stripeclm_cmdline;
if (tabsize_cmdline != -1)
tabsize = tabsize_cmdline;
#endif
#ifdef ENABLE_OPERATINGDIR
if (operating_dir_cmdline != NULL || ISSET(RESTRICTED)) {
@@ -2147,8 +2196,6 @@ int main(int argc, char **argv)
alt_speller = alt_speller_cmdline;
}
#endif
if (tabsize_cmdline != -1)
tabsize = tabsize_cmdline;
/* If an rcfile undid the default settings, copy it to the new flags. */
if (!ISSET(NO_WRAP))
@@ -2186,9 +2233,15 @@ int main(int argc, char **argv)
#endif
}
#ifdef USE_SLANG
/* When using Slang, do not let Slang translate escape sequences to
* key codes, because it does it wrong for the longer sequences. */
SET(RAW_SEQUENCES);
#else
/* When getting untranslated escape sequences, the mouse cannot be used. */
if (ISSET(RAW_SEQUENCES))
UNSET(USE_MOUSE);
#endif
#ifdef ENABLE_HISTORIES
/* Initialize the pointers for the Search/Replace/Execute histories. */
@@ -2234,7 +2287,7 @@ int main(int argc, char **argv)
quoterc = regcomp(&quotereg, quotestr, NANO_REG_EXTENDED);
if (quoterc != 0) {
size_t size = regerror(quoterc, &quotereg, NULL, 0);
char *message = charalloc(size);
char *message = nmalloc(size);
regerror(quoterc, &quotereg, message, size);
die(_("Bad quoting regex \"%s\": %s\n"), quotestr, message);
@@ -2298,6 +2351,7 @@ int main(int argc, char **argv)
interface_color_pair[TITLE_BAR] = hilite_attribute;
interface_color_pair[LINE_NUMBER] = hilite_attribute;
interface_color_pair[GUIDE_STRIPE] = A_REVERSE;
interface_color_pair[SCROLL_BAR] = A_NORMAL;
interface_color_pair[SELECTED_TEXT] = hilite_attribute;
interface_color_pair[STATUS_BAR] = hilite_attribute;
interface_color_pair[ERROR_MESSAGE] = hilite_attribute;
@@ -2407,13 +2461,16 @@ int main(int argc, char **argv)
statusline(ALERT, _("Invalid line or column number"));
}
#ifndef NANO_TINY
/* If the filename is a dash, read from standard input; otherwise,
* open the file; skip positioning the cursor if either failed. */
if (strcmp(argv[optind], "-") == 0) {
optind++;
if (!scoop_stdin())
continue;
} else if (!open_buffer(argv[optind++], TRUE))
} else
#endif
if (!open_buffer(argv[optind++], TRUE))
continue;
/* If a position was given on the command line, go there. */
@@ -2461,6 +2518,9 @@ int main(int argc, char **argv)
if (ISSET(VIEW_MODE))
SET(MULTIBUFFER);
}
#else
if (optind < argc)
die(_("Can open just one file\n"));
#endif
prepare_for_display();

View File

@@ -2,7 +2,7 @@
* 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) 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);
@@ -195,14 +224,14 @@ void inject_into_answer(char *burst, size_t count)
/* Get a verbatim keystroke and insert it into the answer. */
void do_statusbar_verbatim_input(void)
{
size_t count = 1;
char *bytes;
size_t count;
bytes = get_verbatim_kbinput(bottomwin, &count);
if (count > 0)
if (0 < count && count < 999)
inject_into_answer(bytes, count);
else
else if (count == 0)
beep();
free(bytes);
@@ -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;
}
}
@@ -378,10 +407,6 @@ void draw_the_promptbar(void)
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
/* Work around a cursor-misplacement bug in VTEs. */
wmove(bottomwin, 0, 0);
wrefresh(bottomwin);
/* Place the cursor at the right spot. */
column = base + wideness(answer, typing_x);
wmove(bottomwin, 0, column - get_statusbar_page_start(base, column));
@@ -397,7 +422,7 @@ void add_or_remove_pipe_symbol_from_answer(void)
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++;
@@ -566,7 +591,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);

View File

@@ -186,15 +186,10 @@ 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);
#endif
/* Most functions in chars.c. */
@@ -209,6 +204,7 @@ 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);
bool is_zerowidth(const char *ch);
char *make_mbchar(long code, int *length);
#endif
int char_length(const char *pointer);
@@ -395,9 +391,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,18 +398,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 handle_sigwinch(int signal);
void compute_the_extra_rows_per_line_from(linestruct *fromline);
void regenerate_screen(void);
void do_toggle(int flag);
@@ -595,6 +590,7 @@ 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);
@@ -634,8 +630,6 @@ void spotlight(size_t from_col, size_t to_col);
void spotlight_softwrapped(size_t from_col, size_t to_col);
#endif
void do_suspend_void(void);
void disable_waiting(void);
void enable_waiting(void);
#ifdef ENABLE_EXTRA
void do_credits(void);
#endif

View File

@@ -48,16 +48,17 @@ 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
#ifdef HAVE_LIBMAGIC
{"magic", USE_MAGIC},
#endif
{"morespace", MORE_SPACE}, /* Deprecated; remove in 2021. */
#ifdef ENABLE_MOUSE
@@ -93,9 +94,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,8 +104,10 @@ 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},
{"noconvert", NO_CONVERT},
@@ -114,6 +115,8 @@ static const rcoption rcopts[] = {
{"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,6 +129,7 @@ static const rcoption rcopts[] = {
{"titlecolor", 0},
{"numbercolor", 0},
{"stripecolor", 0},
{"scrollercolor", 0},
{"selectedcolor", 0},
{"statuscolor", 0},
{"errorcolor", 0},
@@ -612,7 +616,7 @@ 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);
@@ -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;
@@ -853,8 +857,8 @@ void parse_binding(char *ptr, bool dobind)
newsc->keystr = keycopy;
newsc->keycode = keycode;
/* Disallow rebinding ^[ and frequent escape-sequence starter "Esc [". */
if (newsc->keycode == ESC_CODE || newsc->keycode == '[') {
/* Disallow rebinding <Esc> (^[). */
if (newsc->keycode == ESC_CODE) {
jot_error(N_("Keystroke %s may not be rebound"), keycopy);
free_things:
free(keycopy);
@@ -996,11 +1000,12 @@ short indices[9] = { 204, 163, 134, 38, 48, 148, 215, 208, 137 };
* vivid to TRUE for a lighter color, and thick for a heavier typeface. */
short color_to_short(const char *colorname, bool *vivid, bool *thick)
{
if (strncmp(colorname, "bright", 6) == 0) { /* Deprecated; remove in 2023. */
if (strncmp(colorname, "bright", 6) == 0 && colorname[6] != '\0') {
/* Prefix "bright" is deprecated; remove in 2024. */
*vivid = TRUE;
*thick = TRUE;
colorname += 6;
} else if (strncmp(colorname, "light", 5) == 0) {
} else if (strncmp(colorname, "light", 5) == 0 && colorname[5] != '\0') {
*vivid = TRUE;
*thick = FALSE;
colorname += 5;
@@ -1165,7 +1170,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;
@@ -1195,14 +1200,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
@@ -1247,7 +1249,7 @@ void grab_and_store(const char *kind, char *ptr, regexlisttype **storage)
continue;
/* Copy the regex into a struct, and hook this in at the end. */
newthing = (regexlisttype *)nmalloc(sizeof(regexlisttype));
newthing = nmalloc(sizeof(regexlisttype));
newthing->full_regex = copy_of(regexstring);
newthing->next = NULL;
@@ -1541,8 +1543,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);
@@ -1550,6 +1550,8 @@ 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, "statuscolor") == 0)
@@ -1564,7 +1566,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
@@ -1573,31 +1575,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]);
}
@@ -1605,41 +1597,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

@@ -2,7 +2,7 @@
* 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) 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,7 +39,7 @@ 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);
@@ -78,7 +79,7 @@ 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) ? "..." : "");
@@ -132,6 +133,8 @@ void search_init(bool replacing, bool retain_answer)
break;
}
retain_answer = TRUE;
func = func_from_key(&response);
/* If we're here, one of the five toggles was pressed, or
@@ -183,35 +186,12 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
/* The time we last looked at the keyboard. */
/* Set non-blocking input so that we can just peek for a Cancel. */
disable_waiting();
nodelay(edit, TRUE);
if (begin == NULL)
came_full_circle = FALSE;
/* Start searching through the lines, looking for the needle. */
while (TRUE) {
/* Glance at the keyboard once every second. */
if (time(NULL) - lastkbcheck > 0) {
int input = parse_kbinput(edit);
lastkbcheck = time(NULL);
/* Consume all waiting keystrokes until a Cancel. */
while (input != ERR) {
if (func_from_key(&input) == do_cancel) {
statusbar(_("Cancelled"));
enable_waiting();
return -2;
}
input = parse_kbinput(NULL);
}
if (++feedback > 0)
/* TRANSLATORS: This is shown when searching takes
* more than half a second. */
statusbar(_("Searching..."));
}
/* When starting a new search, skip the first character, then
* (in either case) search for the needle in the current line. */
if (skipone) {
@@ -243,30 +223,32 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
break;
}
#ifndef NANO_TINY
if (the_window_resized) {
regenerate_screen();
nodelay(edit, TRUE);
statusbar(_("Searching..."));
feedback = 1;
}
#endif
/* If we're back at the beginning, then there is no needle. */
if (came_full_circle) {
enable_waiting();
nodelay(edit, FALSE);
return 0;
}
/* Move to the previous or next line in the file. */
if (ISSET(BACKWARDS_SEARCH))
line = line->prev;
else
line = line->next;
line = (ISSET(BACKWARDS_SEARCH)) ? line->prev : line->next;
/* If we've reached the start or end of the buffer, wrap around;
* but stop when spell-checking or replacing in a region. */
if (line == NULL) {
if (whole_word_only || modus == INREGION) {
enable_waiting();
nodelay(edit, FALSE);
return 0;
}
if (ISSET(BACKWARDS_SEARCH))
line = openfile->filebot;
else
line = openfile->filetop;
line = (ISSET(BACKWARDS_SEARCH)) ? openfile->filebot : openfile->filetop;
if (modus == JUSTFIND) {
statusbar(_("Search Wrapped"));
@@ -283,11 +265,48 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
from = line->data;
if (ISSET(BACKWARDS_SEARCH))
from += strlen(line->data);
/* Glance at the keyboard once every second, to check for a Cancel. */
if (time(NULL) - lastkbcheck > 0) {
int input = wgetch(edit);
lastkbcheck = time(NULL);
/* Consume any queued-up keystrokes, until a Cancel or nothing. */
while (input != ERR) {
if (input == ESC_CODE) {
napms(20);
input = wgetch(edit);
meta_key = TRUE;
} else
meta_key = FALSE;
if (func_from_key(&input) == do_cancel) {
#ifndef NANO_TINY
if (the_window_resized)
regenerate_screen();
#endif
statusbar(_("Cancelled"));
/* Clear out the key buffer (in case a macro is running). */
while (input != ERR)
input = parse_kbinput(NULL);
nodelay(edit, FALSE);
return -2;
}
input = wgetch(edit);
}
if (++feedback > 0)
/* TRANSLATORS: This is shown when searching takes
* more than half a second. */
statusbar(_("Searching..."));
}
}
found_x = found - line->data;
enable_waiting();
nodelay(edit, FALSE);
/* Ensure that the found occurrence is not beyond the starting x. */
if (came_full_circle && ((!ISSET(BACKWARDS_SEARCH) && (found_x > begin_x ||
@@ -347,7 +366,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();
@@ -402,6 +422,8 @@ void go_looking(void)
if (didfind == 1 && openfile->current == was_current &&
openfile->current_x == was_current_x)
statusbar(_("This is the only occurrence"));
else if (didfind == 1 && LINES == 1)
refresh_needed = TRUE;
else if (didfind == 0)
not_found_msg(last_search);
@@ -471,7 +493,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);
@@ -493,8 +515,9 @@ char *replace_line(const char *needle)
void wipe_and_recalculate_colorinfo(void)
{
for (linestruct *line = openfile->filetop; line != NULL; line = line->next)
for (short index = 0; index < openfile->syntax->nmultis; index++)
line->multidata[index] = -1;
if (line->multidata)
for (short index = 0; index < openfile->syntax->nmultis; index++)
line->multidata[index] = -1;
precalc_multicolorinfo();
}

View File

@@ -28,6 +28,7 @@
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/wait.h>
@@ -70,7 +71,7 @@ void do_tab(void)
#endif
#ifndef NANO_TINY
if (ISSET(TABS_TO_SPACES)) {
char *spaces = charalloc(tabsize + 1);
char *spaces = nmalloc(tabsize + 1);
size_t length = tabsize - (xplustabs() % tabsize);
memset(spaces, ' ', length);
@@ -96,7 +97,7 @@ void indent_a_line(linestruct *line, char *indentation)
return;
/* Add the fabricated indentation to the beginning of the line. */
line->data = charealloc(line->data, length + indent_len + 1);
line->data = nrealloc(line->data, length + indent_len + 1);
memmove(line->data + indent_len, line->data, length + 1);
memcpy(line->data, indentation, indent_len);
@@ -133,7 +134,7 @@ void do_indent(void)
if (top == bot->next)
return;
indentation = charalloc(tabsize + 1);
indentation = nmalloc(tabsize + 1);
/* Set the indentation to either a bunch of spaces or a single tab. */
#ifdef ENABLE_COLOR
@@ -331,7 +332,7 @@ bool comment_line(undo_type action, linestruct *line, const char *comment_seq)
if (action == COMMENT) {
/* Make room for the comment sequence(s), move the text right and
* copy them in. */
line->data = charealloc(line->data, line_len + pre_len + post_len + 1);
line->data = nrealloc(line->data, line_len + pre_len + post_len + 1);
memmove(line->data + pre_len, line->data, line_len + 1);
memmove(line->data, comment_seq, pre_len);
if (post_len > 0)
@@ -543,7 +544,7 @@ void do_undo(void)
* case, adjust the positions to return to and to scoop data from. */
original_x = (u->head_x == 0) ? u->tail_x : u->head_x;
regain_from_x = (u->head_x == 0) ? 0 : u->tail_x;
line->data = charealloc(line->data, strlen(line->data) +
line->data = nrealloc(line->data, strlen(line->data) +
strlen(&u->strdata[regain_from_x]) + 1);
strcat(line->data, &u->strdata[regain_from_x]);
line->has_anchor |= line->next->has_anchor;
@@ -554,7 +555,7 @@ void do_undo(void)
case BACK:
case DEL:
undidmsg = _("deletion");
data = charalloc(strlen(line->data) + strlen(u->strdata) + 1);
data = nmalloc(strlen(line->data) + strlen(u->strdata) + 1);
strncpy(data, line->data, u->head_x);
strcpy(&data[u->head_x], u->strdata);
strcpy(&data[u->head_x + strlen(u->strdata)], &line->data[u->head_x]);
@@ -711,7 +712,7 @@ void do_redo(void)
redidmsg = _("addition");
if ((u->xflags & INCLUDED_LAST_LINE) && !ISSET(NO_NEWLINES))
new_magicline();
data = charalloc(strlen(line->data) + strlen(u->strdata) + 1);
data = nmalloc(strlen(line->data) + strlen(u->strdata) + 1);
strncpy(data, line->data, u->head_x);
strcpy(&data[u->head_x], u->strdata);
strcpy(&data[u->head_x + strlen(u->strdata)], &line->data[u->head_x]);
@@ -746,7 +747,7 @@ void do_redo(void)
goto_line_posx(u->tail_lineno, u->tail_x);
break;
}
line->data = charealloc(line->data, strlen(line->data) + strlen(u->strdata) + 1);
line->data = nrealloc(line->data, strlen(line->data) + strlen(u->strdata) + 1);
strcat(line->data, u->strdata);
unlink_node(line->next);
renumber_from(line);
@@ -876,7 +877,7 @@ void do_enter(void)
allblanks = TRUE;
}
#endif /* NANO_TINY */
newnode->data = charalloc(strlen(openfile->current->data +
newnode->data = nmalloc(strlen(openfile->current->data +
openfile->current_x) + extra + 1);
strcpy(&newnode->data[extra], openfile->current->data +
openfile->current_x);
@@ -1112,7 +1113,7 @@ void update_multiline_undo(ssize_t lineno, char *indentation)
u->grouping->bottom_line++;
number_of_lines = u->grouping->bottom_line - u->grouping->top_line + 1;
u->grouping->indentations = (char **)nrealloc(u->grouping->indentations,
u->grouping->indentations = nrealloc(u->grouping->indentations,
number_of_lines * sizeof(char *));
u->grouping->indentations[number_of_lines - 1] = copy_of(indentation);
} else {
@@ -1123,7 +1124,7 @@ void update_multiline_undo(ssize_t lineno, char *indentation)
born->top_line = lineno;
born->bottom_line = lineno;
u->grouping->indentations = (char **)nmalloc(sizeof(char *));
u->grouping->indentations = nmalloc(sizeof(char *));
u->grouping->indentations[0] = copy_of(indentation);
}
@@ -1148,7 +1149,7 @@ void update_undo(undo_type action)
switch (u->type) {
case ADD:
newlen = openfile->current_x - u->head_x;
u->strdata = charealloc(u->strdata, newlen + 1);
u->strdata = nrealloc(u->strdata, newlen + 1);
strncpy(u->strdata, openfile->current->data + u->head_x, newlen);
u->strdata[newlen] = '\0';
u->tail_x = openfile->current_x;
@@ -1164,13 +1165,13 @@ void update_undo(undo_type action)
datalen = strlen(u->strdata);
if (openfile->current_x == u->head_x) {
/* They deleted more: add removed character after earlier stuff. */
u->strdata = charealloc(u->strdata, datalen + charlen + 1);
u->strdata = nrealloc(u->strdata, datalen + charlen + 1);
strncpy(u->strdata + datalen, textposition, charlen);
u->strdata[datalen + charlen] = '\0';
u->tail_x = openfile->current_x;
} else if (openfile->current_x == u->head_x - charlen) {
/* They backspaced further: add removed character before earlier. */
u->strdata = charealloc(u->strdata, datalen + charlen + 1);
u->strdata = nrealloc(u->strdata, datalen + charlen + 1);
memmove(u->strdata + charlen, u->strdata, datalen + 1);
strncpy(u->strdata, textposition, charlen);
u->head_x = openfile->current_x;
@@ -1302,7 +1303,7 @@ bool do_wrap(void)
#ifndef NANO_TINY
add_undo(ADD, NULL);
#endif
line->data = charealloc(line->data, line_len + 2);
line->data = nrealloc(line->data, line_len + 2);
line->data[line_len] = ' ';
line->data[line_len + 1] = '\0';
rest_length++;
@@ -1352,7 +1353,7 @@ bool do_wrap(void)
if (quot_len > 0) {
line = line->next;
line_len = strlen(line->data);
line->data = charealloc(line->data, lead_len + line_len + 1);
line->data = nrealloc(line->data, lead_len + line_len + 1);
memmove(line->data + lead_len, line->data, line_len + 1);
strncpy(line->data, line->prev->data, lead_len);
@@ -1586,12 +1587,12 @@ void concat_paragraph(linestruct *line, size_t count)
/* We're just about to tack the next line onto this one. If
* this line isn't empty, make sure it ends in a space. */
if (line_len > 0 && line->data[line_len - 1] != ' ') {
line->data = charealloc(line->data, line_len + 2);
line->data = nrealloc(line->data, line_len + 2);
line->data[line_len++] = ' ';
line->data[line_len] = '\0';
}
line->data = charealloc(line->data,
line->data = nrealloc(line->data,
line_len + next_line_len - next_lead_len + 1);
strcat(line->data, next_line->data + next_lead_len);
#ifndef NANO_TINY
@@ -1688,7 +1689,7 @@ void rewrap_paragraph(linestruct **line, char *lead_string, size_t lead_len)
/* Insert a new line after the current one, and copy the leading part
* plus the text after the breaking point into it. */
splice_node(*line, make_new_node(*line));
(*line)->next->data = charalloc(lead_len + line_len - break_pos + 1);
(*line)->next->data = nmalloc(lead_len + line_len - break_pos + 1);
strncpy((*line)->next->data, lead_string, lead_len);
strcpy((*line)->next->data + lead_len, (*line)->data + break_pos);
@@ -1761,8 +1762,6 @@ void do_justify(bool full_justify)
linestruct *jusline;
/* The line that we're justifying in the current cutbuffer. */
#ifndef NANO_TINY
bool right_side_up = (openfile->mark && mark_is_before_cursor());
/* Whether the mark (if any) is before the cursor. */
bool before_eol = FALSE;
/* Whether the end of a marked region is before the end of its line. */
char *primary_lead = NULL;
@@ -1840,7 +1839,7 @@ void do_justify(bool full_justify)
other_white_len = indent_length(sampleline->data + other_quot_len);
secondary_len = quot_len + other_white_len;
secondary_lead = charalloc(secondary_len + 1);
secondary_lead = nmalloc(secondary_len + 1);
strncpy(secondary_lead, startline->data, quot_len);
strncpy(secondary_lead + quot_len, sampleline->data + other_quot_len,
@@ -1921,7 +1920,7 @@ void do_justify(bool full_justify)
/* Then copy back in the leading part that it should have. */
if (primary_len > 0) {
line->data = charealloc(line->data, primary_len + text_len + 1);
line->data = nrealloc(line->data, primary_len + text_len + 1);
memmove(line->data + primary_len, line->data, text_len + 1);
strncpy(line->data, primary_lead, primary_len);
}
@@ -1980,7 +1979,7 @@ void do_justify(bool full_justify)
update_undo(PASTE);
/* After justifying a backward-marked text, swap mark and cursor. */
if (openfile->mark && !right_side_up) {
if (openfile->mark && !mark_is_before_cursor()) {
linestruct *bottom = openfile->current;
size_t bottom_x = openfile->current_x;
@@ -2038,7 +2037,7 @@ void construct_argument_list(char ***arguments, char *command, char *filename)
int count = 2;
while (element != NULL) {
*arguments = (char **)nrealloc(*arguments, ++count * sizeof(char *));
*arguments = nrealloc(*arguments, ++count * sizeof(char *));
(*arguments)[count - 3] = element;
element = strtok(NULL, " ");
}
@@ -2087,7 +2086,7 @@ bool replace_buffer(const char *filename, undo_type action, const char *operatio
}
/* Execute the given program, with the given temp file as last argument. */
const char *treat(char *tempfile_name, char *theprogram, bool spelling)
void treat(char *tempfile_name, char *theprogram, bool spelling)
{
ssize_t lineno_save = openfile->current->lineno;
size_t current_x_save = openfile->current_x;
@@ -2098,14 +2097,21 @@ const char *treat(char *tempfile_name, char *theprogram, bool spelling)
long timestamp_nsec = 0;
static char **arguments = NULL;
pid_t thepid;
int program_status;
int program_status, errornumber;
bool replaced = FALSE;
/* Stat the temporary file. If that succeeds and its size is zero,
* there is nothing to do; otherwise, store its time of modification. */
if (stat(tempfile_name, &fileinfo) == 0) {
if (fileinfo.st_size == 0)
return NULL;
if (fileinfo.st_size == 0) {
#ifndef NANO_TINY
if (spelling && openfile->mark)
statusline(ALERT, _("Selection is empty"));
else
#endif
statusbar(_("Buffer is empty"));
return;
}
timestamp_sec = (long)fileinfo.st_mtim.tv_sec;
timestamp_nsec = (long)fileinfo.st_mtim.tv_nsec;
@@ -2122,22 +2128,26 @@ const char *treat(char *tempfile_name, char *theprogram, bool spelling)
/* Terminate the child if the program is not found. */
exit(9);
} else if (thepid < 0)
return _("Could not fork");
} else if (thepid > 0) {
/* Block SIGWINCHes while waiting for the forked program to end,
* so nano doesn't get pushed past the wait(). */
block_sigwinch(TRUE);
wait(&program_status);
block_sigwinch(FALSE);
}
/* Block SIGWINCHes while waiting for the program to end,
* so nano doesn't get pushed past the wait(). */
block_sigwinch(TRUE);
wait(&program_status);
block_sigwinch(FALSE);
errornumber = errno;
/* Restore the terminal state and reenter curses mode. */
terminal_init();
doupdate();
if (!WIFEXITED(program_status) || WEXITSTATUS(program_status) > 2) {
if (thepid < 0) {
statusline(ALERT, _("Could not fork: %s"), strerror(errornumber));
return;
} else if (!WIFEXITED(program_status) || WEXITSTATUS(program_status) > 2) {
statusline(ALERT, _("Error invoking '%s'"), arguments[0]);
return NULL;
return;
} else if (WEXITSTATUS(program_status) != 0)
statusline(ALERT, _("Program '%s' complained"), arguments[0]);
@@ -2146,7 +2156,7 @@ const char *treat(char *tempfile_name, char *theprogram, bool spelling)
(long)fileinfo.st_mtim.tv_sec == timestamp_sec &&
(long)fileinfo.st_mtim.tv_nsec == timestamp_nsec) {
statusbar(_("Nothing changed"));
return NULL;
return;
}
#ifndef NANO_TINY
@@ -2196,8 +2206,6 @@ const char *treat(char *tempfile_name, char *theprogram, bool spelling)
statusbar(_("Finished checking spelling"));
else
statusbar(_("Buffer has been processed"));
return NULL;
}
#endif /* ENABLE_SPELLER || ENABLE_COLOR */
@@ -2205,27 +2213,17 @@ const char *treat(char *tempfile_name, char *theprogram, bool spelling)
/* Let the user edit the misspelled word. Return FALSE if the user cancels. */
bool fix_spello(const char *word)
{
char *save_search;
size_t firstcolumn_save = openfile->firstcolumn;
size_t current_x_save = openfile->current_x;
linestruct *edittop_save = openfile->edittop;
linestruct *current_save = openfile->current;
/* Save where we are. */
linestruct *was_edittop = openfile->edittop;
linestruct *was_current = openfile->current;
size_t was_firstcolumn = openfile->firstcolumn;
size_t was_x = openfile->current_x;
bool proceed = FALSE;
/* The return value of this function. */
bool result;
/* The return value of searching for a misspelled word. */
int result;
#ifndef NANO_TINY
bool right_side_up = (openfile->mark && mark_is_before_cursor());
linestruct *top, *bot;
size_t top_x, bot_x;
bool right_side_up = (openfile->mark && mark_is_before_cursor());
#endif
/* Save the current search string, then set it to the misspelled word. */
save_search = last_search;
last_search = copy_of(word);
#ifndef NANO_TINY
/* If the mark is on, start at the beginning of the marked region. */
if (openfile->mark) {
get_region(&top, &top_x, &bot, &bot_x);
@@ -2279,7 +2277,7 @@ bool fix_spello(const char *word)
/* If a replacement was given, go through all occurrences. */
if (proceed && strcmp(word, answer) != 0) {
do_replace_loop(word, TRUE, current_save, &current_x_save);
do_replace_loop(word, TRUE, was_current, &was_x);
/* TRANSLATORS: Shown after fixing misspellings in one word. */
statusbar(_("Next word..."));
@@ -2303,17 +2301,13 @@ bool fix_spello(const char *word)
#endif
{
/* Restore the (compensated) cursor position. */
openfile->current = current_save;
openfile->current_x = current_x_save;
openfile->current = was_current;
openfile->current_x = was_x;
}
/* Restore the string that was last searched for. */
free(last_search);
last_search = save_search;
/* Restore the viewport to where it was. */
openfile->edittop = edittop_save;
openfile->firstcolumn = firstcolumn_save;
openfile->edittop = was_edittop;
openfile->firstcolumn = was_firstcolumn;
return proceed;
}
@@ -2321,8 +2315,8 @@ bool fix_spello(const char *word)
/* Run a spell-check on the given file, using 'spell' to produce a list of all
* misspelled words, then feeding those through 'sort' and 'uniq' to obtain an
* alphabetical list, which words are then offered one by one to the user for
* correction. Return NULL when okay, and the error string otherwise. */
const char *do_int_speller(const char *tempfile_name)
* correction. */
void do_int_speller(const char *tempfile_name)
{
char *misspellings, *pointer, *oneword;
long pipesize;
@@ -2332,8 +2326,12 @@ const char *do_int_speller(const char *tempfile_name)
int spell_status, sort_status, uniq_status;
/* Create all three pipes up front. */
if (pipe(spell_fd) == -1 || pipe(sort_fd) == -1 || pipe(uniq_fd) == -1)
return _("Could not create pipe");
if (pipe(spell_fd) == -1 || pipe(sort_fd) == -1 || pipe(uniq_fd) == -1) {
statusline(ALERT, _("Could not create pipe: %s"), strerror(errno));
return;
}
statusbar(_("Invoking spell checker..."));
/* Fork a process to run spell in. */
if ((pid_spell = fork()) == 0) {
@@ -2342,11 +2340,11 @@ const char *do_int_speller(const char *tempfile_name)
exit(6);
/* Connect standard input to the temporary file. */
if (dup2(tempfile_fd, STDIN_FILENO) != STDIN_FILENO)
if (dup2(tempfile_fd, STDIN_FILENO) < 0)
exit(7);
/* Connect standard output to the write end of the first pipe. */
if (dup2(spell_fd[1], STDOUT_FILENO) != STDOUT_FILENO)
if (dup2(spell_fd[1], STDOUT_FILENO) < 0)
exit(8);
close(tempfile_fd);
@@ -2367,11 +2365,11 @@ const char *do_int_speller(const char *tempfile_name)
/* Fork a process to run sort in. */
if ((pid_sort = fork()) == 0) {
/* Connect standard input to the read end of the first pipe. */
if (dup2(spell_fd[0], STDIN_FILENO) != STDIN_FILENO)
if (dup2(spell_fd[0], STDIN_FILENO) < 0)
exit(7);
/* Connect standard output to the write end of the second pipe. */
if (dup2(sort_fd[1], STDOUT_FILENO) != STDOUT_FILENO)
if (dup2(sort_fd[1], STDOUT_FILENO) < 0)
exit(8);
close(spell_fd[0]);
@@ -2389,10 +2387,10 @@ const char *do_int_speller(const char *tempfile_name)
/* Fork a process to run uniq in. */
if ((pid_uniq = fork()) == 0) {
if (dup2(sort_fd[0], STDIN_FILENO) != STDIN_FILENO)
if (dup2(sort_fd[0], STDIN_FILENO) < 0)
exit(7);
if (dup2(uniq_fd[1], STDOUT_FILENO) != STDOUT_FILENO)
if (dup2(uniq_fd[1], STDOUT_FILENO) < 0)
exit(8);
close(sort_fd[0]);
@@ -2409,16 +2407,18 @@ const char *do_int_speller(const char *tempfile_name)
/* When some child process was not forked successfully... */
if (pid_spell < 0 || pid_sort < 0 || pid_uniq < 0) {
statusline(ALERT, _("Could not fork: %s"), strerror(errno));
close(uniq_fd[0]);
return _("Could not fork");
return;
}
/* Get the system pipe buffer size. */
pipesize = fpathconf(uniq_fd[0], _PC_PIPE_BUF);
if (pipesize < 1) {
statusline(ALERT, _("Could not get size of pipe buffer"));
close(uniq_fd[0]);
return _("Could not get size of pipe buffer");
return;
}
/* Leave curses mode so that error messages go to the original screen. */
@@ -2429,13 +2429,13 @@ const char *do_int_speller(const char *tempfile_name)
totalread = 0;
buffersize = pipesize + 1;
misspellings = charalloc(buffersize);
misspellings = nmalloc(buffersize);
pointer = misspellings;
while ((bytesread = read(uniq_fd[0], pointer, pipesize)) > 0) {
totalread += bytesread;
buffersize += pipesize;
misspellings = charealloc(misspellings, buffersize);
misspellings = nrealloc(misspellings, buffersize);
pointer = misspellings + totalread;
}
@@ -2484,17 +2484,13 @@ const char *do_int_speller(const char *tempfile_name)
waitpid(pid_uniq, &uniq_status, 0);
if (WIFEXITED(uniq_status) == 0 || WEXITSTATUS(uniq_status))
return _("Error invoking \"uniq\"");
if (WIFEXITED(sort_status) == 0 || WEXITSTATUS(sort_status))
return _("Error invoking \"sort\"");
if (WIFEXITED(spell_status) == 0 || WEXITSTATUS(spell_status))
return _("Error invoking \"spell\"");
/* When all went okay. */
statusbar(_("Finished checking spelling"));
return NULL;
statusline(ALERT, _("Error invoking \"uniq\""));
else if (WIFEXITED(sort_status) == 0 || WEXITSTATUS(sort_status))
statusline(ALERT, _("Error invoking \"sort\""));
else if (WIFEXITED(spell_status) == 0 || WEXITSTATUS(spell_status))
statusline(ALERT, _("Error invoking \"spell\""));
else
statusbar(_("Finished checking spelling"));
}
/* Spell check the current file. If an alternate spell checker is
@@ -2504,7 +2500,6 @@ void do_spell(void)
FILE *stream;
char *temp_name;
unsigned stash[sizeof(flags) / sizeof(flags[0])];
const char *result_msg;
bool okay;
ran_a_tool = TRUE;
@@ -2541,9 +2536,9 @@ void do_spell(void)
blank_bottombars();
if (alt_speller)
result_msg = treat(temp_name, alt_speller, TRUE);
treat(temp_name, alt_speller, TRUE);
else
result_msg = do_int_speller(temp_name);
do_int_speller(temp_name);
unlink(temp_name);
free(temp_name);
@@ -2554,14 +2549,6 @@ void do_spell(void)
/* Ensure the help lines will be redrawn and a selection is retained. */
currmenu = MMOST;
shift_held = TRUE;
if (result_msg != NULL) {
/* Avoid giving a failure reason of "Success". */
if (errno == 0)
statusline(ALERT, result_msg);
else
statusline(ALERT, _("%s: %s"), result_msg, strerror(errno));
}
}
#endif /* ENABLE_SPELLER */
@@ -2607,22 +2594,22 @@ void do_linter(void)
/* Create a pipe up front. */
if (pipe(lint_fd) == -1) {
statusline(ALERT, _("Could not create pipe"));
statusline(ALERT, _("Could not create pipe: %s"), strerror(errno));
return;
}
blank_bottombars();
currmenu = MLINTER;
statusbar(_("Invoking linter, please wait"));
statusbar(_("Invoking linter..."));
construct_argument_list(&lintargs, openfile->syntax->linter, openfile->filename);
/* Fork a process to run the linter in. */
if ((pid_lint = fork()) == 0) {
/* Redirect standard output and standard error into the pipe. */
if (dup2(lint_fd[1], STDOUT_FILENO) != STDOUT_FILENO)
if (dup2(lint_fd[1], STDOUT_FILENO) < 0)
exit(7);
if (dup2(lint_fd[1], STDERR_FILENO) != STDERR_FILENO)
if (dup2(lint_fd[1], STDERR_FILENO) < 0)
exit(8);
close(lint_fd[0]);
@@ -2640,8 +2627,8 @@ void do_linter(void)
/* If the child process was not forked successfully... */
if (pid_lint < 0) {
statusline(ALERT, _("Could not fork: %s"), strerror(errno));
close(lint_fd[0]);
statusline(ALERT, _("Could not fork"));
return;
}
@@ -2649,21 +2636,21 @@ void do_linter(void)
pipesize = fpathconf(lint_fd[0], _PC_PIPE_BUF);
if (pipesize < 1) {
close(lint_fd[0]);
statusline(ALERT, _("Could not get size of pipe buffer"));
close(lint_fd[0]);
return;
}
/* Read in the returned syntax errors. */
totalread = 0;
buffersize = pipesize + 1;
lintings = charalloc(buffersize);
lintings = nmalloc(buffersize);
pointer = lintings;
while ((bytesread = read(lint_fd[0], pointer, pipesize)) > 0) {
totalread += bytesread;
buffersize += pipesize;
lintings = charealloc(lintings, buffersize);
lintings = nrealloc(lintings, buffersize);
pointer = lintings + totalread;
}
@@ -2781,7 +2768,7 @@ void do_linter(void)
if (openfile->statinfo == NULL ||
openfile->statinfo->st_ino != lintfileinfo.st_ino) {
char *msg = charalloc(1024 + strlen(curlint->filename));
char *msg = nmalloc(1024 + strlen(curlint->filename));
int choice;
sprintf(msg, _("This message is for unopened file %s,"
@@ -2836,7 +2823,10 @@ void do_linter(void)
}
if (tmplint != curlint) {
/* Put the cursor at the reported position, but don't go beyond EOL
* when the second number is a column number instead of an index. */
goto_line_posx(curlint->lineno, curlint->colno - 1);
openfile->current_x = actual_x(openfile->current->data, openfile->placewewant);
titlebar(NULL);
adjust_viewport(CENTERING);
#ifdef ENABLE_LINENUMBERS
@@ -2914,7 +2904,6 @@ void do_formatter(void)
FILE *stream;
char *temp_name;
bool okay = FALSE;
const char *result_msg;
ran_a_tool = TRUE;
@@ -2926,6 +2915,10 @@ void do_formatter(void)
return;
}
#ifndef NANO_TINY
openfile->mark = NULL;
#endif
temp_name = safe_tempfile(&stream);
if (temp_name != NULL)
@@ -2937,10 +2930,7 @@ void do_formatter(void)
return;
}
result_msg = treat(temp_name, openfile->syntax->formatter, FALSE);
if (result_msg != NULL)
statusline(ALERT, result_msg);
treat(temp_name, openfile->syntax->formatter, FALSE);
unlink(temp_name);
free(temp_name);
@@ -2997,17 +2987,20 @@ void do_wordlinechar_count(void)
openfile->current = was_current;
openfile->current_x = was_x;
/* Display the total word, line, and character counts on the status bar. */
statusline(HUSH, _("%sWords: %zu Lines: %zd Chars: %zu"), openfile->mark ?
_("In Selection: ") : "", words, lines, chars);
/* Report on the status bar the number of lines, words, and characters. */
statusline(HUSH, _("%s%zd %s, %zu %s, %zu %s"),
openfile->mark ? _("In Selection: ") : "",
lines, P_("line", "lines", lines),
words, P_("word", "words", words),
chars, P_("character", "characters", chars));
}
#endif /* !NANO_TINY */
/* Get verbatim input. */
void do_verbatim_input(void)
{
size_t count = 1;
char *bytes;
size_t count;
/* TRANSLATORS: Shown when the next keystroke will be inserted verbatim. */
statusbar(_("Verbatim Input"));
@@ -3022,7 +3015,9 @@ void do_verbatim_input(void)
if (ISSET(CONSTANT_SHOW))
lastmessage = VACUUM;
inject(bytes, count);
if (count < 999)
inject(bytes, count);
wipe_statusbar();
} else
/* TRANSLATORS: An invalid verbatim Unicode code was typed. */
@@ -3043,7 +3038,7 @@ char *copy_completion(char *text)
length = step_right(text, length);
/* Now copy this candidate to a new string. */
word = charalloc(length + 1);
word = nmalloc(length + 1);
while (index < length)
word[index++] = *(text++);
word[index] = '\0';
@@ -3107,7 +3102,7 @@ void complete_a_word(void)
return;
}
shard = charalloc(openfile->current_x - start_of_shard + 1);
shard = nmalloc(openfile->current_x - start_of_shard + 1);
/* Copy the fragment that has to be searched for. */
while (start_of_shard < openfile->current_x)
@@ -3162,7 +3157,7 @@ void complete_a_word(void)
}
/* Add the found word to the list of completions. */
some_word = (completion_word *)nmalloc(sizeof(completion_word));
some_word = nmalloc(sizeof(completion_word));
some_word->word = completion;
some_word->next = list_of_completions;
list_of_completions = some_word;

View File

@@ -68,7 +68,7 @@ const char *tail(const char *path)
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);
@@ -108,19 +108,19 @@ 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;
@@ -294,7 +294,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 +309,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 +324,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,9 +334,9 @@ 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);
strncpy(thecopy, string, count);
memcpy(thecopy, string, count);
thecopy[count] = '\0';
return thecopy;
@@ -431,6 +437,9 @@ 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

@@ -1,5 +1,8 @@
## Syntax highlighting for Autoconf.
## Original author: Benno Schulenberg
## License: GPL version 3 or newer
syntax autoconf "\.(ac|m4)$"
comment "#"

View File

@@ -6,28 +6,34 @@ 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 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)__"
# 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.
# 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:]=]*>"
# 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 "^[[:space:]]*#[[:space:]]*((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.

View File

@@ -3,9 +3,18 @@
syntax css "\.css$"
comment "/*|*/"
# First make everything red:
color brightred "."
# Then everything between braces yellow:
color brightyellow start="\{" end="\}"
color brightwhite start=":" end="([;^\{]|$)"
color brightblue ":active|:focus|:hover|:link|:visited|:link|:after|:before"
# Then everything after a colon white:
color brightwhite start=":" end="([;^{]|$)"
# Pseudo-classes:
color brightcyan ":(active|checked|focus|hover|link|visited|after|before)\>"
# Comments:
color brightblue start="/\*" end="\*/"
# Syntactic characters:
color green ";|:|\{|\}"

View File

@@ -11,7 +11,7 @@ color cyan "^[[:space:]]*#.*"
color ,red " + +"
# Nano's name, including version.
color brightred "(GNU )?[Nn]ano [1-4]\.[0-9][-.[:alnum:]]*\>"
color brightred "(GNU )?[Nn]ano [1-5]\.[0-9][-.[:alnum:]]*\>"
# Email addresses.
color magenta "<[[:alnum:].%_+-]+@[[:alnum:].-]+\.[[:alpha:]]{2,}>"

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

@@ -7,12 +7,12 @@ comment "#"
color brightred ".*"
# 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|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|boldtext|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|historylog|indicator|jumpyscrolling|linenumbers|locking|magic|mouse|multibuffer|noconvert|nohelp|nonewlines|positionlog|preserve|quickblank|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|softwrap|stateflags|suspendable|tabstospaces|trimblanks|unix|wordbounds|zap)\>"
color yellow "^[[:space:]]*set[[:space:]]+((error|function|key|number|scroller|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|scrollercolor|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:]]*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)\>"

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

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 "#"
@@ -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

@@ -2,6 +2,7 @@
syntax sh "(\.sh|(\.|/)(a|ba|c|da|k|mk|pdk|tc|z)sh(rc|_profile)?|/(etc/|\.)profile)$"
header "^#!.*/(((a|ba|c|da|k|mk|pdk|tc|z)?sh)|(busybox|env) +sh|openrc-run|runscript)"
header "-\*-.*shell-script.*-\*-"
magic "(POSIX|Bourne-Again) shell script.*text"
comment "#"

View File

@@ -1,5 +1,8 @@
## Syntax highlighting for Texinfo files.
## Original author: Benno Schulenberg
## License: GPL version 3 or newer
syntax texinfo "\.texi$"
header "^\\input texinfo"
magic "Texinfo source"