Compare commits

...

132 Commits
v5.1 ... v5.3

Author SHA1 Message Date
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
78 changed files with 18126 additions and 17999 deletions

159
ChangeLog
View File

@@ -1,3 +1,150 @@
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:
------------------------------
@@ -180,7 +327,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
@@ -240,7 +387,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
@@ -840,7 +987,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
@@ -1304,7 +1451,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
@@ -1324,7 +1471,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
@@ -1530,7 +1677,7 @@ Benno Schulenberg (85):
tweaks: rename a variable, to be more distinct and more descriptive
tweaks: rename a variable, to get out of the way for another rename
tweaks: rename some variables, for more contrast and to match others
tweaks: rename some variables, to be less repititious
tweaks: rename some variables, to be less repetitious
tweaks: rename two variables, for more contrast
tweaks: rename two variables, to be more distinct and more fitting
tweaks: rename two variables, to make more sense

View File

@@ -2,6 +2,8 @@ Improvements in GNU nano
========================
Since 5.0:
- 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.

View File

@@ -6,7 +6,7 @@ if USE_COLOR
SUBDIRS += syntax
endif
EXTRA_DIST = IMPROVEMENTS README.GIT
EXTRA_DIST = IMPROVEMENTS
ACLOCAL_AMFLAGS = -I m4

212
NEWS
View File

@@ -1,3 +1,20 @@
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
@@ -523,7 +540,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,
@@ -765,28 +782,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
@@ -918,7 +934,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!
@@ -1099,7 +1115,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,
@@ -1321,38 +1337,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
@@ -1413,19 +1428,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
@@ -1695,7 +1710,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.
@@ -1916,19 +1931,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! =)
@@ -1943,23 +1958,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
@@ -1969,31 +1983,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.

View File

@@ -2,7 +2,7 @@
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="50bf1b6fe4fe406568884bce97ddcff935571a0a"
gnulib_hash="6160ee8e4d2b88d934c3c4c8c5930a75b835723f"
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.1], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [5.3], [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
@@ -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>

View File

@@ -41,7 +41,7 @@
<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>
@@ -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.1</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.3</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.1" "August 2020"
.TH NANO 1 "version 5.3" "October 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
@@ -295,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).
@@ -319,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.
@@ -329,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
@@ -351,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.1
@set UPDATED August 2020
@set VERSION 5.3
@set UPDATED October 2020
@dircategory Editors
@direntry
@@ -23,7 +23,7 @@
@titlepage
@title GNU @command{nano}
@subtitle a small and friendly text editor
@subtitle version 5.1
@subtitle version 5.3
@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.1.
This manual documents the GNU @command{nano} editor, version 5.3.
@menu
* Introduction::
@@ -71,9 +71,9 @@ This manual documents the GNU @command{nano} editor, version 5.1.
* 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.
@@ -468,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
@@ -537,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
@@ -564,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
@@ -650,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
@@ -786,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.
@@ -861,11 +893,18 @@ Display line numbers to the left of the text area.
@item set locking
Enable vim-style lock-files for when editing files.
@item set magic
When neither the file's name nor its first line give a clue,
try using libmagic to determine the applicable syntax.
(Calling libmagic can be relatively time consuming.
It is therefore not done by default.)
@anchor{@code{set matchbrackets}}
@item set matchbrackets "@var{characters}"
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.
@@ -922,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
@@ -930,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.
@@ -954,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.
@@ -983,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.
@@ -1050,6 +1103,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.
@@ -1117,7 +1173,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
@@ -1423,8 +1479,8 @@ 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.
@@ -1658,25 +1714,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.1" "August 2020"
.TH NANORC 5 "version 5.3" "October 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.
@@ -171,8 +170,14 @@ Display line numbers to the left of the text area.
.B set locking
Enable vim-style lock-files for when editing files.
.TP
.B set magic
When neither the file's name nor its first line give a clue,
try using libmagic to determine the applicable syntax.
(Calling libmagic can be relatively time consuming.
It is therefore not done by default.)
.TP
.BI "set matchbrackets """ characters """
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".
@@ -261,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.
@@ -287,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.
@@ -386,13 +405,13 @@ Start the definition of a syntax with this \fIname\fR.
All subsequent \fBcolor\fR and other such commands
will be added to this syntax, until a new \fBsyntax\fR
command is encountered.
.sp
When \fBnano\fR is run, this syntax will be automatically
activated if the current filename matches the extended regular
expression \fIfileregex\fR. Or the syntax can be explicitly
activated by using the \fB\-Y\fR or \fB\-\-syntax\fR
command-line option followed by the \fIname\fR.
.sp
The syntax \fBdefault\fP is special: it takes no \fIfileregex\fR,
and applies to files that don't match any syntax's regexes.
The syntax \fBnone\fP is reserved; specifying it on the command line
@@ -529,11 +548,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.
@@ -626,8 +644,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).
@@ -723,8 +741,8 @@ 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.
@@ -961,6 +979,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.1" "August 2020"
.TH RNANO 1 "version 5.3" "October 2020"
.SH NAME
rnano \- a restricted nano

View File

@@ -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.)
@@ -203,15 +210,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 +230,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 +239,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':

919
po/bg.po

File diff suppressed because it is too large Load Diff

940
po/ca.po

File diff suppressed because it is too large Load Diff

921
po/cs.po

File diff suppressed because it is too large Load Diff

1017
po/da.po

File diff suppressed because it is too large Load Diff

927
po/de.po

File diff suppressed because it is too large Load Diff

925
po/eo.po

File diff suppressed because it is too large Load Diff

925
po/es.po

File diff suppressed because it is too large Load Diff

919
po/eu.po

File diff suppressed because it is too large Load Diff

919
po/fi.po

File diff suppressed because it is too large Load Diff

925
po/fr.po

File diff suppressed because it is too large Load Diff

919
po/ga.po

File diff suppressed because it is too large Load Diff

919
po/gl.po

File diff suppressed because it is too large Load Diff

927
po/hr.po

File diff suppressed because it is too large Load Diff

919
po/hu.po

File diff suppressed because it is too large Load Diff

919
po/id.po

File diff suppressed because it is too large Load Diff

919
po/it.po

File diff suppressed because it is too large Load Diff

925
po/ja.po

File diff suppressed because it is too large Load Diff

937
po/ko.po

File diff suppressed because it is too large Load Diff

937
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

925
po/nb.po

File diff suppressed because it is too large Load Diff

927
po/nl.po

File diff suppressed because it is too large Load Diff

919
po/nn.po

File diff suppressed because it is too large Load Diff

919
po/pl.po

File diff suppressed because it is too large Load Diff

925
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1068
po/ro.po

File diff suppressed because it is too large Load Diff

919
po/ru.po

File diff suppressed because it is too large Load Diff

919
po/sl.po

File diff suppressed because it is too large Load Diff

919
po/sr.po

File diff suppressed because it is too large Load Diff

919
po/sv.po

File diff suppressed because it is too large Load Diff

927
po/tr.po

File diff suppressed because it is too large Load Diff

929
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 || \

921
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.1"
VERSION="5.3"
./configure -C --enable-tiny && make && ./configure -C &&

View File

@@ -39,6 +39,361 @@ 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 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 = 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] = nmalloc(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);
}
/* 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;
}
}
/* 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 = 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++ == 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;
}
/* 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)
@@ -161,29 +516,25 @@ 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--;
@@ -245,7 +596,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);
}
@@ -359,7 +710,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 +734,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

@@ -202,7 +202,7 @@ int mbwidth(const char *c)
* 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 +374,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

@@ -64,7 +64,7 @@ void set_interface_colorpairs(void)
interface_color_pair[index] = COLOR_PAIR(index + 1) | A_BANDAID |
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;
@@ -189,8 +189,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 +243,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

@@ -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);
@@ -289,7 +289,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 +308,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 +375,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 +401,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
@@ -345,11 +341,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 +449,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 +460,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 +479,7 @@ enum
TITLE_BAR = 0,
LINE_NUMBER,
GUIDE_STRIPE,
SCROLL_BAR,
SELECTED_TEXT,
STATUS_BAR,
ERROR_MESSAGE,
@@ -544,7 +539,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 +622,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. */
@@ -689,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;
@@ -719,7 +719,6 @@ 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()) {
@@ -728,6 +727,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
terminal_init();
doupdate();
}
#endif
/* If there was a real error during the reading, let the user know. */
if (ferror(f) && errornumber != EINTR && errornumber != 0)
@@ -889,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) {
@@ -916,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);
}
@@ -1307,7 +1307,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,
@@ -1321,7 +1321,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 {
@@ -1340,7 +1340,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, "/");
}
}
@@ -1367,14 +1367,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 {
@@ -1393,7 +1393,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);
}
@@ -1439,7 +1439,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);
@@ -1465,7 +1465,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.
@@ -1514,7 +1514,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
@@ -1556,10 +1556,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;
@@ -1571,7 +1572,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);
@@ -1586,7 +1587,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);
@@ -1678,7 +1679,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);
@@ -2066,11 +2067,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
@@ -2214,7 +2213,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);
@@ -2332,7 +2331,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);
@@ -2356,11 +2355,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
@@ -2395,8 +2396,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);
}
@@ -2444,7 +2445,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);
@@ -2470,7 +2471,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);
@@ -2482,7 +2483,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);
}
@@ -2553,7 +2554,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);
@@ -2562,7 +2563,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)))
@@ -2570,7 +2571,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

@@ -728,10 +728,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 +747,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 +788,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 +816,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 +848,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 +858,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 +914,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 +1013,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 +1035,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 +1066,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 +1106,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 +1146,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 +1163,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 +1243,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);
@@ -1260,12 +1305,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);
@@ -1325,6 +1364,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]);
@@ -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

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)
@@ -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,6 +807,7 @@ 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)
{
@@ -856,6 +865,7 @@ bool scoop_stdin(void)
return TRUE;
}
#endif
/* Register half a dozen signal handlers. */
void signal_init(void)
@@ -882,25 +892,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 +918,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 +957,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 +974,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 +988,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 +1016,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 +1099,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 +1118,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 +1219,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();
@@ -1299,6 +1313,7 @@ void unbound_key(int code)
else
statusline(ALERT, _("Unbound key: %c"), code);
#endif
set_blankdelay_to_one();
}
#ifdef ENABLE_MOUSE
@@ -1403,7 +1418,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)
@@ -1447,7 +1462,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);
@@ -1522,6 +1537,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. */
@@ -1552,16 +1571,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,
@@ -1587,6 +1606,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
@@ -1653,6 +1679,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
}
@@ -1683,7 +1712,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
@@ -1691,7 +1722,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
@@ -1702,7 +1732,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
@@ -1710,14 +1739,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
@@ -1749,15 +1776,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}
};
@@ -1814,7 +1849,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':
@@ -1864,9 +1899,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);
@@ -1903,7 +1940,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);
@@ -1911,6 +1947,7 @@ int main(int argc, char **argv)
exit(1);
}
break;
#endif
case 'U':
SET(QUICK_BLANK);
break;
@@ -1949,9 +1986,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);
@@ -1963,17 +2002,16 @@ int main(int argc, char **argv)
break;
#endif
case 'h':
case '?':
usage();
exit(0);
#ifndef NANO_TINY
case 'i':
SET(AUTOINDENT);
break;
#endif
case 'j':
SET(JUMPY_SCROLLING);
break;
#ifndef NANO_TINY
case 'k':
SET(CUT_FROM_CURSOR);
break;
@@ -1988,9 +2026,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);
@@ -2048,6 +2088,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);
@@ -2075,9 +2125,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;
@@ -2088,7 +2139,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])];
@@ -2117,8 +2167,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;
@@ -2127,6 +2175,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)) {
@@ -2146,8 +2198,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))
@@ -2185,9 +2235,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. */
@@ -2233,7 +2289,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);
@@ -2297,6 +2353,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;
@@ -2406,13 +2463,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. */

View File

@@ -141,7 +141,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 +184,7 @@ void inject_into_answer(char *burst, size_t count)
if (burst[index] == '\0')
burst[index] = '\n';
answer = charealloc(answer, strlen(answer) + count + 1);
answer = nrealloc(answer, strlen(answer) + count + 1);
memmove(answer + typing_x + count, answer + typing_x,
strlen(answer) - typing_x + 1);
strncpy(answer + typing_x, burst , count);
@@ -253,7 +253,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;
}
}
@@ -397,7 +397,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 +566,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. */
@@ -395,9 +390,6 @@ void free_lines(linestruct *src);
void renumber_from(linestruct *line);
void print_view_warning(void);
bool in_restricted_mode(void);
#ifndef ENABLE_HELP
void say_there_is_no_help(void);
#endif
void finish(void);
void close_and_go(void);
void do_exit(void);
@@ -405,18 +397,20 @@ void die(const char *msg, ...);
void window_init(void);
void install_handler_for_Ctrl_C(void);
void restore_handler_for_Ctrl_C(void);
#ifndef NANO_TINY
void reconnect_and_store_state(void);
RETSIGTYPE handle_hupterm(int signal);
#ifndef DEBUG
RETSIGTYPE handle_crash(int signal);
#endif
RETSIGTYPE do_suspend(int signal);
RETSIGTYPE do_continue(int signal);
void handle_hupterm(int signal);
#ifndef DEBUG
void handle_crash(int signal);
#endif
void do_suspend(int signal);
void do_continue(int signal);
#if !defined(NANO_TINY) || defined(ENABLE_SPELLER) || defined(ENABLE_COLOR)
void block_sigwinch(bool blockit);
#endif
#ifndef NANO_TINY
RETSIGTYPE handle_sigwinch(int signal);
void 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 +589,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 +629,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,7 +94,6 @@ 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
@@ -105,8 +105,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 +116,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 +130,7 @@ static const rcoption rcopts[] = {
{"titlecolor", 0},
{"numbercolor", 0},
{"stripecolor", 0},
{"scrollercolor", 0},
{"selectedcolor", 0},
{"statuscolor", 0},
{"errorcolor", 0},
@@ -612,7 +617,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 +667,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;
@@ -996,11 +1001,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 +1171,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;
@@ -1247,7 +1253,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;
@@ -1550,6 +1556,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)
@@ -1577,13 +1585,7 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
} 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 (strcmp(option, "matchbrackets") == 0) {
if (has_blank_char(argument)) {
jot_error(N_("Non-blank characters required"));
free(argument);
@@ -1620,26 +1622,32 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
quotestr = argument;
else
#endif
#ifndef NANO_TINY
if (strcmp(option, "backupdir") == 0)
backup_dir = argument;
else
if (strcmp(option, "wordchars") == 0)
word_chars = argument;
else
#endif
#ifdef ENABLE_SPELLER
if (strcmp(option, "speller") == 0)
alt_speller = argument;
else
#endif
if (strcmp(option, "tabsize") == 0) {
#ifndef NANO_TINY
if (strcmp(option, "backupdir") == 0)
backup_dir = argument;
else if (strcmp(option, "wordchars") == 0)
word_chars = 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;
}
free(argument);
} 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

@@ -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, " ");
}
@@ -2214,27 +2213,17 @@ void 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);
@@ -2288,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..."));
@@ -2312,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;
}
@@ -2444,13 +2429,13 @@ void 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;
}
@@ -2659,13 +2644,13 @@ void do_linter(void)
/* 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;
}
@@ -2783,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,"
@@ -3047,7 +3032,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';
@@ -3111,7 +3096,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)
@@ -3166,7 +3151,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);
@@ -318,7 +318,7 @@ char *mallocstrcpy(char *dest, const char *src)
{
size_t count = strlen(src) + 1;
dest = charealloc(dest, count);
dest = nrealloc(dest, count);
strncpy(dest, src, count);
return dest;
@@ -328,7 +328,7 @@ char *mallocstrcpy(char *dest, const char *src)
* of the given string, and NUL-terminate the copy. */
char *measured_copy(const char *string, size_t count)
{
char *thecopy = charalloc(count + 1);
char *thecopy = nmalloc(count + 1);
memcpy(thecopy, string, count);
thecopy[count] = '\0';

View File

@@ -45,8 +45,6 @@ static bool solitary = FALSE;
/* Whether an Esc arrived by itself -- not as leader of a sequence. */
static int digit_count = 0;
/* How many digits of a three-digit character code we've eaten. */
static bool waiting_mode = TRUE;
/* Whether getting a character will wait for a key to be pressed. */
static bool reveal_cursor = FALSE;
/* Whether the cursor should be shown when waiting for input. */
static bool linger_after_escape = FALSE;
@@ -75,7 +73,7 @@ static size_t macro_length = 0;
void add_to_macrobuffer(int code)
{
macro_length++;
macro_buffer = (int*)nrealloc(macro_buffer, macro_length * sizeof(int));
macro_buffer = nrealloc(macro_buffer, macro_length * sizeof(int));
macro_buffer[macro_length - 1] = code;
}
@@ -99,6 +97,9 @@ void record_macro(void)
snip_last_keystroke();
statusbar(_("Stopped recording"));
}
if (ISSET(STATEFLAGS))
titlebar(NULL);
}
/* Copy the stored sequence of codes into the regular key buffer,
@@ -116,7 +117,7 @@ void run_macro(void)
return;
}
key_buffer = (int *)nrealloc(key_buffer, macro_length * sizeof(int));
key_buffer = nrealloc(key_buffer, macro_length * sizeof(int));
key_buffer_len = macro_length;
for (size_t i = 0; i < macro_length; i++)
@@ -185,7 +186,7 @@ void read_keys_from(WINDOW *win)
#endif
}
/* Read in the first keycode using whatever mode we're in. */
/* Read in the first keycode, waiting for it to arrive. */
while (input == ERR) {
input = wgetch(win);
@@ -195,11 +196,6 @@ void read_keys_from(WINDOW *win)
input = KEY_WINCH;
}
#endif
if (input == ERR && !waiting_mode) {
curs_set(0);
return;
}
/* When we've failed to get a keycode over a hundred times in a row,
* assume our input source is gone and die gracefully. We could
* check if errno is set to EIO ("Input/output error") and die in
@@ -211,7 +207,7 @@ void read_keys_from(WINDOW *win)
curs_set(0);
/* Initiate the keystroke buffer, and save the keycode in it. */
key_buffer = (int *)nrealloc(key_buffer, sizeof(int));
key_buffer = nrealloc(key_buffer, sizeof(int));
key_buffer[0] = input;
key_buffer_len = 1;
@@ -221,12 +217,12 @@ void read_keys_from(WINDOW *win)
return;
#endif
/* Read in the remaining characters using non-blocking input. */
/* Read in any remaining key codes using non-blocking input. */
nodelay(win, TRUE);
/* When taking verbatim input, pause a moment after receiving an ESC,
* to give the keyboard some time to bring the next code to ncurses. */
if (linger_after_escape && input == ESC_CODE)
/* After an ESC, when ncurses does not translate escape sequences,
* give the keyboard some time to bring the next code to ncurses. */
if (input == ESC_CODE && (linger_after_escape || ISSET(RAW_SEQUENCES)))
napms(20);
while (TRUE) {
@@ -242,13 +238,12 @@ void read_keys_from(WINDOW *win)
/* Extend the keystroke buffer, and save the keycode at its end. */
key_buffer_len++;
key_buffer = (int *)nrealloc(key_buffer, key_buffer_len * sizeof(int));
key_buffer = nrealloc(key_buffer, key_buffer_len * sizeof(int));
key_buffer[key_buffer_len - 1] = input;
}
/* Restore waiting mode if it was on. */
if (waiting_mode)
nodelay(win, FALSE);
/* Restore blocking-input mode. */
nodelay(win, FALSE);
#ifdef DEBUG
fprintf(stderr, "\nSequence of hex codes:");
@@ -272,7 +267,7 @@ void put_back(int keycode)
return;
/* Extend the keystroke buffer to make room for the extra keycode. */
key_buffer = (int *)nrealloc(key_buffer, ++key_buffer_len * sizeof(int));
key_buffer = nrealloc(key_buffer, ++key_buffer_len * sizeof(int));
/* If the keystroke buffer wasn't empty before, move all the
* existing content one step further away. */
@@ -330,10 +325,10 @@ int arrow_from_ABCD(int letter)
int convert_SS3_sequence(const int *seq, size_t length, int *consumed)
{
switch (seq[0]) {
#ifndef NANO_TINY
case '1':
if (length > 3 && seq[1] == ';') {
*consumed = 4;
#ifndef NANO_TINY
switch (seq[2]) {
case '2':
if ('A' <= seq[3] && seq[3] <= 'D') {
@@ -358,9 +353,9 @@ int convert_SS3_sequence(const int *seq, size_t length, int *consumed)
}
break;
}
#endif
}
break;
#endif
case '2': /* Shift */
case '3': /* Alt */
case '4': /* Shift+Alt */
@@ -396,6 +391,7 @@ int convert_SS3_sequence(const int *seq, size_t length, int *consumed)
case 'C': /* Esc O C == Right on VT100/VT320. */
case 'D': /* Esc O D == Left on VT100/VT320. */
return arrow_from_ABCD(seq[0]);
#ifndef NANO_TINY
case 'F': /* Esc O F == End on old xterm. */
return KEY_END;
case 'H': /* Esc O H == Home on old xterm. */
@@ -403,10 +399,13 @@ int convert_SS3_sequence(const int *seq, size_t length, int *consumed)
case 'M': /* Esc O M == Enter on numeric keypad
* with NumLock off on VT100/VT220/VT320. */
return KEY_ENTER;
case 'P': /* Esc O P == F1 on VT100/VT220/VT320/Mach console. */
case 'Q': /* Esc O Q == F2 on VT100/VT220/VT320/Mach console. */
case 'R': /* Esc O R == F3 on VT100/VT220/VT320/Mach console. */
case 'S': /* Esc O S == F4 on VT100/VT220/VT320/Mach console. */
#endif
case 'P': /* Esc O P == F1 on VT100/VT220/VT320/xterm/Mach console. */
case 'Q': /* Esc O Q == F2 on VT100/VT220/VT320/xterm/Mach console. */
case 'R': /* Esc O R == F3 on VT100/VT220/VT320/xterm/Mach console. */
case 'S': /* Esc O S == F4 on VT100/VT220/VT320/xterm/Mach console. */
return KEY_F(seq[0] - 'O');
#ifndef NANO_TINY
case 'T': /* Esc O T == F5 on Mach console. */
case 'U': /* Esc O U == F6 on Mach console. */
case 'V': /* Esc O V == F7 on Mach console. */
@@ -457,6 +456,7 @@ int convert_SS3_sequence(const int *seq, size_t length, int *consumed)
return KEY_UP;
case 'y': /* Esc O y == PageUp (9) on the same. */
return KEY_PPAGE;
#endif
}
return FOREIGN_SEQUENCE;
@@ -475,10 +475,12 @@ int convert_CSI_sequence(const int *seq, size_t length, int *consumed)
else if (length > 2 && seq[2] == '~') {
*consumed = 3;
switch (seq[1]) {
#ifndef NANO_TINY
case '1': /* Esc [ 1 1 ~ == F1 on rxvt/Eterm. */
case '2': /* Esc [ 1 2 ~ == F2 on rxvt/Eterm. */
case '3': /* Esc [ 1 3 ~ == F3 on rxvt/Eterm. */
case '4': /* Esc [ 1 4 ~ == F4 on rxvt/Eterm. */
#endif
case '5': /* Esc [ 1 5 ~ == F5 on xterm/rxvt/Eterm. */
return KEY_F(seq[1] - '0');
case '7': /* Esc [ 1 7 ~ == F6 on VT220/VT320/
@@ -489,6 +491,7 @@ int convert_CSI_sequence(const int *seq, size_t length, int *consumed)
}
} else if (length > 3 && seq[1] == ';') {
*consumed = 4;
#ifndef NANO_TINY
switch (seq[2]) {
case '2':
switch (seq[3]) {
@@ -498,15 +501,12 @@ int convert_CSI_sequence(const int *seq, size_t length, int *consumed)
case 'D': /* Esc [ 1 ; 2 D == Shift-Left on xterm. */
shift_held = TRUE;
return arrow_from_ABCD(seq[3]);
#ifndef NANO_TINY
case 'F': /* Esc [ 1 ; 2 F == Shift-End on xterm. */
return SHIFT_END;
case 'H': /* Esc [ 1 ; 2 H == Shift-Home on xterm. */
return SHIFT_HOME;
#endif
}
break;
#ifndef NANO_TINY
case '9': /* To accommodate iTerm2 in "xterm mode". */
case '3':
switch (seq[3]) {
@@ -534,7 +534,6 @@ int convert_CSI_sequence(const int *seq, size_t length, int *consumed)
return SHIFT_HOME;
}
break;
#endif
case '5':
switch (seq[3]) {
case 'A': /* Esc [ 1 ; 5 A == Ctrl-Up on xterm. */
@@ -551,7 +550,6 @@ int convert_CSI_sequence(const int *seq, size_t length, int *consumed)
return CONTROL_HOME;
}
break;
#ifndef NANO_TINY
case '6':
switch (seq[3]) {
case 'A': /* Esc [ 1 ; 6 A == Shift-Ctrl-Up on xterm. */
@@ -568,8 +566,8 @@ int convert_CSI_sequence(const int *seq, size_t length, int *consumed)
return shiftcontrolhome;
}
break;
#endif
}
#endif /* !NANO-TINY */
} else if (length > 4 && seq[2] == ';' && seq[4] == '~')
/* Esc [ 1 n ; 2 ~ == F17...F20 on some terminals. */
*consumed = 5;
@@ -749,48 +747,40 @@ int convert_CSI_sequence(const int *seq, size_t length, int *consumed)
return KEY_PPAGE;
case 'L': /* Esc [ L == Insert on ANSI/FreeBSD console. */
return KEY_IC;
#ifndef NANO_TINY
case 'M': /* Esc [ M == F1 on FreeBSD console. */
return KEY_F(1);
case 'N': /* Esc [ N == F2 on FreeBSD console. */
return KEY_F(2);
case 'O':
if (length > 1) {
*consumed = 2;
if ('O' < seq[1] && seq[1] < 'T')
/* Esc [ O P == F1 on xterm. */
/* Esc [ O Q == F2 on xterm. */
/* Esc [ O R == F3 on xterm. */
/* Esc [ O S == F4 on xterm. */
return KEY_F(seq[1] - 'O');
} else
/* Esc [ O == F3 on FreeBSD console. */
return KEY_F(3);
break;
case 'O': /* Esc [ O == F3 on FreeBSD console. */
case 'P': /* Esc [ P == F4 on FreeBSD console. */
case 'Q': /* Esc [ Q == F5 on FreeBSD console. */
case 'R': /* Esc [ R == F6 on FreeBSD console. */
case 'S': /* Esc [ S == F7 on FreeBSD console. */
case 'T': /* Esc [ T == F8 on FreeBSD console. */
return KEY_F(4 + seq[0] - 'P');
return KEY_F(seq[0] - 'L');
#endif
case 'U': /* Esc [ U == PageDown on Mach console. */
return KEY_NPAGE;
case 'V': /* Esc [ V == PageUp on Mach console. */
return KEY_PPAGE;
#ifndef NANO_TINY
case 'W': /* Esc [ W == F11 on FreeBSD console. */
return KEY_F(11);
case 'X': /* Esc [ X == F12 on FreeBSD console. */
return KEY_F(12);
#endif
case 'Y': /* Esc [ Y == End on Mach console. */
return KEY_END;
case 'Z': /* Esc [ Z == Shift-Tab on ANSI/Linux console/
* FreeBSD console/xterm/rxvt/Terminal. */
return SHIFT_TAB;
#ifndef NANO_TINY
case 'a': /* Esc [ a == Shift-Up on rxvt/Eterm. */
case 'b': /* Esc [ b == Shift-Down on rxvt/Eterm. */
case 'c': /* Esc [ c == Shift-Right on rxvt/Eterm. */
case 'd': /* Esc [ d == Shift-Left on rxvt/Eterm. */
shift_held = TRUE;
return arrow_from_ABCD(seq[0] - 0x20);
#endif
case '[':
if (length > 1) {
*consumed = 2;
@@ -926,7 +916,7 @@ int parse_kbinput(WINDOW *win)
if (escapes == 0) {
/* Most key codes in byte range cannot be special keys. */
if (keycode <= 0xFF && keycode != '\t' && keycode != DEL_CODE)
if (keycode < 0xFF && keycode != '\t' && keycode != DEL_CODE)
return keycode;
} else if (escapes == 1) {
escapes = 0;
@@ -939,7 +929,14 @@ int parse_kbinput(WINDOW *win)
keycode == DEL_CODE)
return CONTROL_SHIFT_DELETE;
#endif
else if (!solitary)
#ifdef ENABLE_UTF8
else if (0xC0 <= keycode && keycode <= 0xFF && using_utf8()) {
while (key_buffer_len > 0 && 0x80 <= *key_buffer && *key_buffer <= 0xBF)
get_input(NULL);
return FOREIGN_SEQUENCE;
}
#endif
else if (!solitary && keycode < 0x20)
meta_key = TRUE;
} else if (key_buffer_len == 0 || *key_buffer == ESC_CODE ||
(keycode != 'O' && keycode != '[')) {
@@ -1248,9 +1245,6 @@ int parse_kbinput(WINDOW *win)
#endif
#ifdef KEY_RESIZE /* Slang and SunOS 5.7-5.9 don't support KEY_RESIZE. */
case KEY_RESIZE:
#endif
#if defined(USE_SLANG) && defined(ENABLE_UTF8)
case KEY_BAD:
#endif
case KEY_FLUSH:
return ERR; /* Ignore this keystroke. */
@@ -1365,13 +1359,10 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
int keycode, *yield;
reveal_cursor = TRUE;
linger_after_escape = TRUE;
/* Read in the first code. */
keycode = get_input(win);
linger_after_escape = FALSE;
#ifndef NANO_TINY
/* When the window was resized, abort and return nothing. */
if (keycode == KEY_WINCH) {
@@ -1381,7 +1372,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
#endif
/* Reserve ample space for the possible result. */
yield = (int *)nmalloc(6 * sizeof(int));
yield = nmalloc(6 * sizeof(int));
#ifdef ENABLE_UTF8
/* If the first code is a valid Unicode starter digit (0 or 1),
@@ -1391,15 +1382,12 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
char *multibyte;
reveal_cursor = FALSE;
linger_after_escape = TRUE;
while (unicode == PROCEED) {
keycode = get_input(win);
unicode = assemble_unicode(keycode);
}
linger_after_escape = FALSE;
#ifndef NANO_TINY
if (keycode == KEY_WINCH) {
*count = 999;
@@ -1449,7 +1437,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
* an escape sequence, and return the resulting number of bytes in count. */
char *get_verbatim_kbinput(WINDOW *win, size_t *count)
{
char *bytes = charalloc(MAXCHARLEN + 1);
char *bytes = nmalloc(MAXCHARLEN + 2);
int *input;
/* Turn off flow control characters if necessary so that we can type
@@ -1457,15 +1445,18 @@ char *get_verbatim_kbinput(WINDOW *win, size_t *count)
* don't get extended keypad values. */
if (ISSET(PRESERVE))
disable_flow_control();
#ifndef USE_SLANG
if (!ISSET(RAW_SEQUENCES))
keypad(win, FALSE);
#endif
#ifndef NANO_TINY
/* Turn bracketed-paste mode off. */
printf("\x1B[?2004l");
fflush(stdout);
#endif
linger_after_escape = TRUE;
/* Read in a single byte or two escapes. */
input = parse_verbatim_kbinput(win, count);
@@ -1479,6 +1470,8 @@ char *get_verbatim_kbinput(WINDOW *win, size_t *count)
*count = 0;
}
linger_after_escape = FALSE;
#ifndef NANO_TINY
/* Turn bracketed-paste mode back on. */
printf("\x1B[?2004h");
@@ -1489,12 +1482,14 @@ char *get_verbatim_kbinput(WINDOW *win, size_t *count)
* keypad back on if necessary now that we're done. */
if (ISSET(PRESERVE))
enable_flow_control();
#ifndef USE_SLANG
/* Use the global window pointers, because a resize may have freed
* the data that the win parameter points to. */
if (!ISSET(RAW_SEQUENCES)) {
keypad(edit, TRUE);
keypad(bottomwin, TRUE);
}
#endif
if (*count < 999) {
for (size_t i = 0; i < *count; i++)
@@ -1697,6 +1692,12 @@ void check_statusblank(void)
edit_refresh();
}
/* Ensure that the status bar will be wiped upon the next keystroke. */
void set_blankdelay_to_one(void)
{
statusblank = 1;
}
/* Convert buf into a string that can be displayed on screen. The caller
* wants to display buf starting with the given column, and extending for
* at most span columns. column is zero-based, and span is one-based, so
@@ -1725,7 +1726,7 @@ char *display_string(const char *buf, size_t column, size_t span,
buf += start_index;
/* Allocate enough space for converting the relevant part of the line. */
converted = charalloc(strlen(buf) * (MAXCHARLEN + tabsize) + 1);
converted = nmalloc(strlen(buf) * (MAXCHARLEN + tabsize) + 1);
#ifndef NANO_TINY
if (span > HIGHEST_POSITIVE) {
@@ -1924,8 +1925,8 @@ void titlebar(const char *path)
/* The state of the current buffer -- "Modified", "View", or "". */
char *caption;
/* The presentable form of the pathname. */
char *indicator = NULL;
/* The buffer sequence number plus buffer count. */
char *ranking = NULL;
/* The buffer sequence number plus the total buffer count. */
/* If the screen is too small, there is no title bar. */
if (topwin == NULL)
@@ -1957,10 +1958,10 @@ void titlebar(const char *path)
#ifdef ENABLE_MULTIBUFFER
/* If there are/were multiple buffers, show which out of how many. */
if (more_than_one) {
indicator = charalloc(24);
sprintf(indicator, "[%i/%i]", buffer_number(openfile),
ranking = nmalloc(24);
sprintf(ranking, "[%i/%i]", buffer_number(openfile),
buffer_number(startfile->prev));
upperleft = indicator;
upperleft = ranking;
} else
#endif
upperleft = BRANDING;
@@ -1970,10 +1971,14 @@ void titlebar(const char *path)
else
path = openfile->filename;
if (openfile->modified)
state = _("Modified");
else if (ISSET(VIEW_MODE))
if (ISSET(VIEW_MODE))
state = _("View");
#ifndef NANO_TINY
else if (ISSET(STATEFLAGS))
state = "+.xxxxx";
#endif
else if (openfile->modified)
state = _("Modified");
else if (ISSET(RESTRICTED))
state = _("Restricted");
else
@@ -2005,7 +2010,7 @@ void titlebar(const char *path)
}
}
free(indicator);
free(ranking);
/* If we have side spaces left, center the path name. */
if (verlen > 0)
@@ -2033,11 +2038,29 @@ void titlebar(const char *path)
free(caption);
}
/* Right-align the state if there's room; otherwise, trim it. */
if (statelen > 0 && statelen <= COLS)
mvwaddstr(topwin, 0, COLS - statelen, state);
else if (statelen > 0)
mvwaddnstr(topwin, 0, 0, state, actual_x(state, COLS));
#ifndef NANO_TINY
/* When requested, show on the title bar the state of three options and
* the state of the mark and whether a macro is being recorded. */
if (ISSET(STATEFLAGS) && !ISSET(VIEW_MODE)) {
if (openfile->modified && COLS > 1)
waddstr(topwin, " *");
if (statelen < COLS) {
wmove(topwin, 0, COLS + 2 - statelen);
waddstr(topwin, ISSET(AUTOINDENT) ? "I" : " ");
waddstr(topwin, openfile->mark ? "M" : " ");
waddstr(topwin, ISSET(BREAK_LONG_LINES) ? "L" : " ");
waddstr(topwin, recording ? "R" : " ");
waddstr(topwin, ISSET(SOFTWRAP) ? "S" : " ");
}
} else
#endif
{
/* If there's room, right-align the state word; otherwise, clip it. */
if (statelen > 0 && statelen <= COLS)
mvwaddstr(topwin, 0, COLS - statelen, state);
else if (statelen > 0)
mvwaddnstr(topwin, 0, 0, state, actual_x(state, COLS));
}
wattroff(topwin, interface_color_pair[TITLE_BAR]);
@@ -2095,7 +2118,7 @@ void statusline(message_type importance, const char *msg, ...)
blank_statusbar();
/* Construct the message out of all the arguments. */
compound = charalloc(MAXCHARLEN * (COLS + 1));
compound = nmalloc(MAXCHARLEN * (COLS + 1));
va_start(ap, msg);
vsnprintf(compound, MAXCHARLEN * (COLS + 1), msg, ap);
va_end(ap);
@@ -2133,6 +2156,11 @@ void statusline(message_type importance, const char *msg, ...)
statusblank = 1;
else
statusblank = 26;
#ifdef USE_SLANG
/* Work around a shy cursor -- https://sv.gnu.org/bugs/?59091. */
bottombars(MGOTODIR);
#endif
}
/* Display a normal message on the status bar, quietly. */
@@ -2300,7 +2328,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
#endif
wprintw(edit, " ");
}
#endif
#endif /* ENABLE_LINENUMBERS */
/* First simply write the converted line -- afterward we'll add colors
* and the marking highlight on just the pieces that need it. */
@@ -2885,7 +2913,8 @@ void draw_scrollbar(void)
highest = editwinrows;
for (int row = 0; row < editwinrows; row++) {
bardata[row] = ' '|((row >= lowest && row <= highest) ? A_REVERSE : 0);
bardata[row] = ' '|interface_color_pair[SCROLL_BAR]|
((row < lowest || row > highest) ? A_NORMAL : A_REVERSE);
mvwaddch(edit, row, COLS - 1, bardata[row]);
}
}
@@ -3280,47 +3309,40 @@ void draw_all_subwindows(void)
#endif
if (currmenu != MBROWSER && currmenu != MWHEREISFILE && currmenu != MGOTODIR)
edit_refresh();
wipe_statusbar();
bottombars(currmenu);
}
/* Display details about the current cursor position on the status bar. */
/* Display on the status bar details about the current cursor position. */
void report_cursor_position(void)
{
char saved_byte;
size_t sum, cur_xpt = xplustabs() + 1;
size_t cur_lenpt = breadth(openfile->current->data) + 1;
size_t fullwidth = breadth(openfile->current->data) + 1;
size_t column = xplustabs() + 1;
int linepct, colpct, charpct;
char saved_byte;
size_t sum;
/* Determine the size of the file up to the cursor. */
saved_byte = openfile->current->data[openfile->current_x];
openfile->current->data[openfile->current_x] = '\0';
/* Determine the size of the file up to the cursor. */
sum = number_of_characters_in(openfile->filetop, openfile->current);
openfile->current->data[openfile->current_x] = saved_byte;
/* Display the current cursor position on the status bar. */
/* Calculate the percentages. */
linepct = 100 * openfile->current->lineno / openfile->filebot->lineno;
colpct = 100 * cur_xpt / cur_lenpt;
colpct = 100 * column / fullwidth;
charpct = (openfile->totsize == 0) ? 0 : 100 * sum / openfile->totsize;
statusline(HUSH,
_("line %zd/%zd (%d%%), col %zu/%zu (%d%%), char %zu/%zu (%d%%)"),
openfile->current->lineno, openfile->filebot->lineno, linepct,
cur_xpt, cur_lenpt, colpct, sum, openfile->totsize, charpct);
}
_("line %zd/%zd (%d%%), col %zu/%zu (%d%%), char %zu/%zu (%d%%)"),
openfile->current->lineno, openfile->filebot->lineno, linepct,
column, fullwidth, colpct, sum, openfile->totsize, charpct);
void disable_waiting(void)
{
waiting_mode = FALSE;
nodelay(edit, TRUE);
}
void enable_waiting(void)
{
waiting_mode = TRUE;
nodelay(edit, FALSE);
#ifdef USE_SLANG
/* Restore the help lines after the above call overwrote them. */
bottombars(MMAIN);
#endif
}
/* Highlight the text between the given two columns on the current line. */

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

@@ -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,9 +7,9 @@ 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|view|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:]]*$)"

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"