Compare commits

...

577 Commits
v4.9 ... 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
Benno Schulenberg
6e2c245ecc po: update translations and regenerate POT file and PO files 2020-08-12 08:35:14 +02:00
Benno Schulenberg
74a0ffcbc5 tweaks: baptize the release 2020-08-12 08:24:06 +02:00
Benno Schulenberg
b1a0f5e65a bump version numbers and add a news item for the 5.1 release 2020-08-12 07:57:31 +02:00
Benno Schulenberg
7e8b1ed420 build: stop distributing the two old Changelogs
For installing and using nano, those two Changelogs are useless,
and for inspecting the history of nano, 'git log' is much better.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Michalis Kokologiannakis <michalis@mpi-sws.org>
2020-07-30 09:48:12 +02:00
Benno Schulenberg
59bdce9503 syntax: default: colorize also "GNU nano 5.x" 2020-07-30 09:25:56 +02:00
Benno Schulenberg
9517766aab syntax: css: differentiate pseudo-classes (now cyan) from comments (blue)
Also, add comments, remove a duplicated ":link", and add ":checked".
2020-07-30 09:25:12 +02:00
Benno Schulenberg
c561b4280f po: update translations and regenerate POT file and PO files 2020-07-29 10:10:15 +02:00
Benno Schulenberg
df9ca85961 bump version numbers and add a news item for the 5.0 release 2020-07-29 09:44:39 +02:00
Benno Schulenberg
7475b4d3bf tweaks: reshuffle a few lines, and remove a few unneeded comments 2020-07-28 19:12:02 +02:00
Benno Schulenberg
f502f6fdb2 syntaxes: remove unneeded backslash escapes before quotes
(They may have been needed in the past to avoid miscoloring of the
nanorc file itself, but they are no longer needed now.)
2020-07-27 13:23:13 +02:00
Benno Schulenberg
fd667b5191 tweaks: add four more translator hints 2020-07-27 10:33:42 +02:00
Benno Schulenberg
aabfefde7e syntax: css: color multiline comments correctly
A forward slash does not need to be escaped, and the backslash itself
should not be escaped: it serves to escape the star, to make it literal.

Also, remove a stray end-of-line anchor ($).
2020-07-26 19:54:02 +02:00
Benno Schulenberg
bccb0ea0bb tweaks: handle two similar things in the same way 2020-07-26 11:51:34 +02:00
Benno Schulenberg
6ca22b80ef tweaks: elide a redundant intermediate function
It hasn't been used elsewhere since commit 7f203100 from two years ago.
2020-07-25 15:08:32 +02:00
Benno Schulenberg
cf52f2ed62 tweaks: rename a variable, and condense a comment 2020-07-25 13:51:34 +02:00
Benno Schulenberg
294051769c tweaks: remove a superfluous check on the length of the key buffer
None of the calls of get_input() ask for more codes than those which
already were or will now have become available in the key buffer.
2020-07-25 13:42:06 +02:00
Benno Schulenberg
7157f5a3ce tabbing: properly terminate the answer when the sole match is a folder
When there is just one match when <Tab> is pressed, and this match
is a directory, then a slash is added to 'shared', overwriting the
terminating NUL character.  So, strcpy() cannot be used for copying
this 'shared' string, but strncpy() is needed, and the result needs
to be NUL terminated afterward.

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

Bug existed since commit b0f56398 from eleven days ago.
2020-07-25 13:25:48 +02:00
Benno Schulenberg
5ca4e9f5b3 tweaks: remove three unneeded while loops from two input routines
The whiles are unneeded because the result of get_input() can
never be NULL when in waiting mode -- and only when searching
for something are we NOT in waiting mode.
2020-07-25 12:11:48 +02:00
Benno Schulenberg
3e899b15c2 tweaks: reduce the indentation after the previous change 2020-07-24 17:12:31 +02:00
Benno Schulenberg
a33b04ce90 tweaks: cascade the ifs properly: without increasing the indentation 2020-07-24 17:08:53 +02:00
Benno Schulenberg
36ab5d91de input: interpret an escape sequence only when it starts with "[" or "O"
This fixes https://savannah.gnu.org/bugs/?58818.

Bug existed since version 2.9.0, since macros were introduced.
2020-07-24 16:49:39 +02:00
Benno Schulenberg
8dc1b97465 tweaks: three escapes is the same as either zero escapes or one escape 2020-07-24 13:38:44 +02:00
Benno Schulenberg
350115242d bindings: stop supporting <Esc> <Esc> <numeric slash> without NumLock
<Ctrl+numeric slash> does not invoke Go To Line, so it is fitting
that <Esc> <Esc> <numeric slash> does neither.  If some user does
want the double escape plus slash to work, they can use --raw.

(Also, if someone really uses <Esc> <Esc> <numeric slash>, they
probably also type the desired line number on the numeric keypad,
and for that to work they needed to have NumLock engaged, and in
that case the double escape plus slash will work fine.)

(Getting rid of this numeric-slash support makes the three-escapes
case very similar to the one-escape case, allowing the first to be
folded into the latter in the next commit.)
2020-07-24 13:16:41 +02:00
Benno Schulenberg
7bf413db76 tweaks: rename two parameters, away from an abbreviation 2020-07-23 09:56:38 +02:00
Benno Schulenberg
aafda2358f tweaks: rename two variables, away from abbreviations 2020-07-23 09:44:14 +02:00
Benno Schulenberg
6b9084ad09 tweaks: reshuffle a few lines, to elide an 'if' from the most common path
And for compactness.
2020-07-22 20:32:38 +02:00
Benno Schulenberg
d0501d0ebd tweaks: update a translator hint, and add another 2020-07-22 11:38:29 +02:00
Benno Schulenberg
ba5a191f26 gnulib: update to its current upstream state 2020-07-22 11:25:04 +02:00
Benno Schulenberg
364a1518de tweaks: reshuffle some lines, to better separate the three cases 2020-07-22 11:07:20 +02:00
Benno Schulenberg
93b2877758 tweaks: use three switches instead of cascading ifs, for brevity 2020-07-22 10:56:41 +02:00
Benno Schulenberg
832037e2ec tweaks: condense some cases to a single line, for more clarity
And return directly for codes that will not be changed any more.
2020-07-22 10:43:24 +02:00
Benno Schulenberg
ad2920acd0 tweaks: handle the double escapes directly, instead of going round again
Immediately pull the available extra character from the keyboard buffer,
instead of cycling through the whole circus again.
2020-07-22 10:17:48 +02:00
Benno Schulenberg
e59a0f5e77 build: replace the non-standard backslash escape "\e" with "\x1B"
Older compilers do not understand "\e".  Also, it's not in the standard
(see http://open-std.org/JTC1/SC22/WG14/www/docs/n1570.pdf, §6.4.4.4).

This addresses https://savannah.gnu.org/bugs/?58799.
Reported-by: Henry Bent <henry.r.bent@gmail.com>
2020-07-22 09:17:57 +02:00
Benno Schulenberg
fd10c0eadd tweaks: rake a common statement to the end of the case
With the two situations that need to preserve the escape counter
now returning directly, the resetting of this counter can happen
at the end of each case block.
2020-07-21 14:03:18 +02:00
Benno Schulenberg
7e53fcb581 tweaks: remove two redundant conditions, and make a more direct return
The escape-parsing routine nowadays returns FOREIGN_SEQUENCE instead
of ERR when encountering an unknown sequence.  So, with the two cases
that demand ERR now handled directly, there is no need to check for
ERR any more.
2020-07-21 14:02:55 +02:00
Benno Schulenberg
8249f3560f tweaks: normalize the indentation after the previous change 2020-07-20 19:46:27 +02:00
Benno Schulenberg
dd1b16cd54 tweaks: trim an ASCII case, as the function is called only for UTF-8 2020-07-20 19:37:40 +02:00
Benno Schulenberg
43b39ed04f tweaks: use knowledge of Unicode to skip the general multibyte conversion
The relevant range is so small (128 bytes) that "manual" conversion
is much faster (and a bit shorter, eliding two variables).
2020-07-20 19:31:25 +02:00
Benno Schulenberg
17a8b24fe5 tweaks: skip the conversion to multibyte for plain ASCII codes
Converting an ASCII code to "multibyte" is a no-op: it stays one byte.
2020-07-20 19:16:45 +02:00
Benno Schulenberg
b9db967bc4 tweaks: reshuffle some lines, for esthetics
There is no need to reset the digit counter (because this counter
matters only when the escape counter equals two) -- resetting the
escape counter is enough.
2020-07-20 19:06:16 +02:00
Benno Schulenberg
2a5d129738 tweaks: rename a variable, and normalize the indentation 2020-07-20 18:25:19 +02:00
Benno Schulenberg
6980cfbf70 tweaks: change a 'switch' to 'if', to elide a dummy 'return' 2020-07-20 18:21:43 +02:00
Benno Schulenberg
a0d2e63c8e tweaks: improve four comments 2020-07-20 17:15:06 +02:00
Benno Schulenberg
57c52de99a tweaks: rename a function, and move it to before the one that calls it 2020-07-20 17:04:48 +02:00
Benno Schulenberg
9067f7a0c7 tweaks: elide a variable, by returning the result directly 2020-07-20 16:54:22 +02:00
Benno Schulenberg
e4fa0b54a2 tweaks: remove two superfluous assignments
The digit counter will be reset to zero the next time when <Esc>
is pressed, and the byte holder gets re-initialized when the next
first digit is pressed.  And the escape counter is reset to zero
after returning from a result-giving call of get_byte_kbinput().
2020-07-20 16:28:36 +02:00
Benno Schulenberg
b41405233f tweaks: remove some superfluous conditions
When get_byte_kbinput() is called, it has already been determined that
the keyboard input is a digit from zero to nine (or from zero to two
for the first digit), so there is no need to check this again.
2020-07-20 12:40:26 +02:00
Benno Schulenberg
88561506c9 tweaks: improve two comments, and reshuffle some lines for conciseness 2020-07-20 11:47:10 +02:00
Benno Schulenberg
a08ca026f0 input: reset the counters when a three-digit sequence is not completed
When <Esc><Esc> is followed by digit 0 or 1 or 2 but then NOT two more
digits follow, then both the escape counter and the digit counter should
start afresh when a new ESC code arrives.

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

Bug existed since before version 2.0.6.
2020-07-20 11:19:44 +02:00
Benno Schulenberg
180a53cc0c files: warn the root user when all the write bits are missing
Root has carte blanche to both read unreadable files and write
unwritable files -- the file system does not prevent this.  So,
alert root when opening a file that is intended to be read-only.

This fulfills https://savannah.gnu.org/bugs/?58685.
Requested-by: Marius Bakke <mbakke@fastmail.com>
2020-07-20 10:26:45 +02:00
Benno Schulenberg
d18cfb26cd tweaks: adjust the indentation after the previous change 2020-07-19 11:52:57 +02:00
Benno Schulenberg
eb70578c5e tweaks: do not use 'switch' when there are just two possibilities
Also, remove an unneeded 'if', as parse_escape_sequence() is only
ever called when there are at least two bytes after the Esc code.
(If there were not, the 'for' loop after calling convert_sequence()
would use an uninitialized 'consumed' value.)
2020-07-19 11:52:47 +02:00
Benno Schulenberg
63efc59758 tweaks: don't check for escape sequences that start with a lowercase "o"
Such escape sequences don't exist -- those mistaken sequences were
removed in commit 4991b3bb from half a year ago.
2020-07-19 11:50:30 +02:00
Benno Schulenberg
dcd34b246a tweaks: move a function to the file where it is used the most
Also, fully exclude the function from the tiny version.
2020-07-19 10:43:26 +02:00
Benno Schulenberg
b0dcb15f94 tweaks: elide a function that is too sparse
The two calls of the function can be replaced with two lines each.
2020-07-17 18:40:34 +02:00
Benno Schulenberg
7dbfbbb8d6 tweaks: reshuffle a few lines, for conciseness 2020-07-17 17:13:43 +02:00
Benno Schulenberg
4cefd699ca tweaks: shorten an error message, to be appropriate in all situations
Saying "Cannot write backup %s" is misleading when it is the original
file that cannot be reread.
2020-07-17 17:10:46 +02:00
Benno Schulenberg
8eddf7bc26 tweaks: reshuffle a condition, to avoid a repetition of code 2020-07-17 16:53:48 +02:00
Benno Schulenberg
2623f39c7b backup: when rereading the original file fails, ask the user what to do
Rereading is unlikely to fail, but *if* it fails, maybe there is a
serious problem and the user wants to try and fix it before saving
the buffer and thus overwriting the original file.
2020-07-17 16:50:25 +02:00
Benno Schulenberg
da71322000 tweaks: rename two labels, for brevity 2020-07-17 16:24:53 +02:00
Benno Schulenberg
292e505e01 tweaks: rename two variables, to avoid a repetitive prefix
Also, fold a condition into an assignment, for conciseness.
2020-07-17 16:23:22 +02:00
Benno Schulenberg
a322dab482 tweaks: elide a function that is called just once
It also nicely groups the backup stuff together in a single function.
2020-07-16 15:03:06 +02:00
Benno Schulenberg
0ed1695fd4 build: fix miscompilation for --enable-{tiny,color,nanorc}
This should have been part of commit 096e3627 from a month ago.
2020-07-16 12:47:43 +02:00
Benno Schulenberg
60d31d2ea6 tweaks: avoid a warning about an unused variable in the tiny version 2020-07-16 12:41:01 +02:00
Benno Schulenberg
b744eec1a9 tweaks: remove an incorrect mention of umask() from a comment
Since commit f8366cd5, umask() is no longer used.
2020-07-15 10:52:49 +02:00
Benno Schulenberg
a6f64212ae tweaks: rename a function, to not shadow a variable, and elide parameter 2020-07-15 10:52:49 +02:00
Benno Schulenberg
a6cee410ef tweaks: normalize the indentation after the previous change 2020-07-15 10:52:49 +02:00
Benno Schulenberg
f7682730bd files: make a backup only when requested, not an unrequested failsafe one
After thinking about it, I don't like it that nano makes an unrequested
failsafe backup: in the vast, vast majority of cases it is a waste both
of time and of disk wear.  If the user is worried about data loss, they
can use --backup.  The fsync() after writing out the buffer (added in
commit a84cdaaa) already reduces the chances on data loss somewhat.
2020-07-15 10:50:36 +02:00
Benno Schulenberg
5f90e067f1 tweaks: rename a parameter and a variable, to be more meaningful 2020-07-14 17:31:47 +02:00
Benno Schulenberg
b0f563980d tweaks: elide an unneeded call of strlen(), and copy NUL byte with string 2020-07-14 17:22:08 +02:00
Benno Schulenberg
258e7c6e65 oops -- restore an accidentally changed file 2020-07-14 15:22:22 +02:00
Benno Schulenberg
65321f9234 files: do not make a failsafe backup when in restricted mode
When in restricted mode, nano should not write to any other file
than to the ones mentioned on the command line.
2020-07-14 15:19:50 +02:00
Benno Schulenberg
bde8858a3a tweaks: rename a variable, to avoid overrepetition of 'backup'
Also, reshuffle three calls of fclose().
2020-07-14 13:52:34 +02:00
Benno Schulenberg
a2b7fc1c81 tweaks: slightly improve a comment and the ordering of some lines 2020-07-14 13:00:34 +02:00
Benno Schulenberg
69e6ccf641 tweaks: reshuffle a fragment of code, to elide a 'goto' 2020-07-14 13:00:34 +02:00
Michalis Kokologiannakis
14717d7449 tweaks: adjust some indentation after the previous change
Signed-off-by: Michalis Kokologiannakis <michalis@mpi-sws.org>
2020-07-14 12:59:30 +02:00
Michalis Kokologiannakis
ed76a045ae tweaks: move the backup code to a separate function
This change moves the code responsible for backup creation to a new,
separate function, backup_file().  This function returns a boolean
indicating whether saving the buffer should proceed or not.

Signed-off-by: Michalis Kokologiannakis <michalis@mpi-sws.org>
2020-07-14 12:12:26 +02:00
Benno Schulenberg
62ffc221aa tweaks: rename a function, and move it to before the one that calls it 2020-07-11 19:43:37 +02:00
Benno Schulenberg
ec8fd9f365 tweaks: reshuffle some code, to avoid needlessly calling a function 2020-07-11 19:11:00 +02:00
Benno Schulenberg
d3a8488b0e tweaks: use a better symbol than 'ERR' to signify a valid hex digit 2020-07-11 18:58:12 +02:00
Benno Schulenberg
b3d6c27502 tweaks: improve a comment, rename a function, and elide a parameter
Checking the current menu instead of the current subwindow works fine.
2020-07-11 18:36:52 +02:00
Benno Schulenberg
2e4d78a714 tweaks: fold translation of all modified keypad keystrokes together
The escape-sequence codes for the different keypad keys are simply
the relevant ASCII code plus 0x40, so they are easy to translate.

Also, do not accept keypad keys with multiple modifiers (Shift+Alt,
Shift+Ctrl, Alt+Ctrl, Shift+Alt+Ctrl) -- report "Unknown sequence"
for those.
2020-07-11 12:16:18 +02:00
Benno Schulenberg
476c838753 bindings: allow typing digits on the numeric keypad by holding Shift
Until now, on an xterm, Shift plus any keypad key would say
"Unknown sequence", which is not useful.  On other terminal
emulators (urxvt, Pantheon, LXTerminal), Shift plus a keypad
key already produces the relevant digit or symbol, so this
change harmonizes the behavior of the different emulators.

However, on a Linux console, Shift plus a keypad key moves
the cursor and selects the text that is passed over.  And
holding Alt while pressing a keypad key does nothing at all.
2020-07-11 11:49:41 +02:00
Benno Schulenberg
ecb4dac494 bindings: stop <Alt+operator> on the keypad from entering spurious letter
For the operator keys on the numeric keypad (/, *, -, and +),
make both the Alt and the Ctrl modifier a no-op.

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

Bug existed since version 2.9.3, commit e734488c.
2020-07-11 11:46:43 +02:00
Benno Schulenberg
95df7dbc8e tweaks: correct some comments, as VT100 and such have smaller keypads
The DEC VTnnn terminals only have period, comma, and minus on the
numeric keypad, not slash nor star nor plus nor Insert nor Delete.
2020-07-11 11:44:23 +02:00
Michalis Kokologiannakis
a84cdaaa50 files: improve the backup procedure to ensure no data is lost
The file-saving procedure that nano followed was not crash-safe
under ext4 (and perhaps other filesystems) when editing existing
files.  Specifically, modifying an existing file could lead to data
loss, since a modified file is not replaced atomically on disk.
Using "-B" did not ensure crash-safety either since the backup might
not have persisted on disk when the writeout of the file started.

In addition, if I/O pressure filled up the remaining disk space
after an existing file is truncated during save, nano would not
be able to finish saving the file, which would remain truncated.

This change addresses these issues by making nano do the following:

1) Make a temporary backup of the file being written so that there
is no time window such that (a) an existing file is truncated, and
(b) the buffer corresponding to said file has not been flushed to
disk.  Such time windows are dangerous because, under certain
circumstances, they can lead to data loss on some filesystems.

The backup is made by copying the original file, and a second
attempt to HOME is made in case that first copy fails.

2) Use fsync() so that, when the save finishes, it is certain
that the file has been successfully written to disk.

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

Signed-off-by: Michalis Kokologiannakis <michalis@mpi-sws.org>
2020-07-09 16:28:21 +02:00
Benno Schulenberg
97a993d401 verbatim: turn bracketed-paste mode off while waiting for input
This allows pasting six hexadecimal digits after typing M-V
in order to enter a specific Unicode character.

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

Bug existed since version 4.8, since bracketed pastes
were introduced in commit f705a967.
2020-07-08 16:24:53 +02:00
Benno Schulenberg
1542cbf942 bindings: add mistakenly removed M-J (Full Justify) back to the main menu
This fixes https://savannah.gnu.org/bugs/?58729.

Bug existed since commit ee03c4b8 from six weeks ago.
2020-07-08 15:46:50 +02:00
Benno Schulenberg
727abceb0f tweaks: adjust comments and indentation after the previous change 2020-07-06 16:59:35 +02:00
Benno Schulenberg
5899181a31 verbatim: show an error message when an invalid Unicode code is entered
The codes from (for example) U+D800 to U+DFFF are invalid.  If any
such invalid code is entered at the Unicode Input prompt, nano should
not act as if the code was accepted and inserted into the buffer, and
should certainly not mark the buffer as Modified.

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

Bug existed since version 4.9, commit b3faf353.
2020-07-06 16:47:23 +02:00
Benno Schulenberg
a2fdf6c486 tweaks: remove an unneeded cursor movement, and rename a variable
There is no need to place the cursor up front, as the drawing of
each name includes the coordinates where the name must be drawn.

Also, trim two comments and reshuffle a free().
2020-07-05 19:29:05 +02:00
Benno Schulenberg
29d493a986 tweaks: move an initialization function to before the one that calls it
Also, frob two comments in that function,
and delete three unneeded blank lines.
2020-07-05 19:01:31 +02:00
Benno Schulenberg
940a17268b speller: take into account that statting a file can fail [coverity] 2020-07-05 17:21:56 +02:00
Benno Schulenberg
ee78f2348b rcfile: rename bindable function 'curpos' to 'location'
It is better that the bindable function is named the same as the
tag in the help lines, and that it is not an ugly abbreviation.
2020-07-05 11:05:45 +02:00
Benno Schulenberg
2261377309 docs: complete the renaming of 'tempfile' to 'saveonexit'
This should have been part of commit d4ee6a2b from two months ago.
2020-07-05 10:53:57 +02:00
Benno Schulenberg
cb1675dac7 tweaks: rename two functions and a variable, and improve two comments 2020-07-04 17:43:16 +02:00
Benno Schulenberg
808d0894f1 tweaks: condense a comment, and reshuffle a few lines 2020-07-04 17:25:32 +02:00
Benno Schulenberg
07c1ac9035 tweaks: delete two functions that are never executed
Those two operations are performed directly in do_browser().
2020-07-04 17:14:52 +02:00
Benno Schulenberg
2b9c0c5724 tweaks: rename a variable, and reduce the scope of two others 2020-07-04 15:12:04 +02:00
Benno Schulenberg
abfde53945 tweaks: drop an unneeded assignment, and reshuffle a few lines
And reset the 'lastmessage' variable to a more fitting value.
2020-07-04 09:36:17 +02:00
Benno Schulenberg
f21508f071 tweaks: improve some comments, and reshuffle an assignment 2020-07-03 19:10:48 +02:00
Benno Schulenberg
2c228796a8 docs: improve some descriptions concerning the file browser 2020-07-03 18:45:09 +02:00
Benno Schulenberg
a84653dc19 feedback: show the cursor position also at startup in an empty buffer
When using --constantshow and --nohelp and opening a new buffer,
the cursor location should be shown on the status bar right away.

Bug existed since commit 2e688640 from a few hours ago.
2020-07-03 13:03:44 +02:00
Benno Schulenberg
1388af2bdc tweaks: elide a wrapper function, by checking a precondition earlier 2020-07-03 12:41:40 +02:00
Benno Schulenberg
2e6886406c tweaks: elide an unneeded global variable
The constant cursor display must be suppressed whenever a message
was printed to the status bar.  That is: whenever 'lastmessage' is
something other than 'VACUUM'.
2020-07-03 12:41:40 +02:00
Benno Schulenberg
80ff5e76d6 help: pair the items in the two bottom lines better in the tiny version
This fixes https://savannah.gnu.org/bugs/?58693.

Bug existed since commit 9b8930cc from ten days ago.
2020-07-03 11:28:41 +02:00
Benno Schulenberg
1a2d0c1770 scrolling: add a function and a key binding to center the cursor line
By default, this function is bound to ^L, to make that keystroke do
something actually useful.  To not lose the Refresh function that this
keystroke had, the centering function additionally does a full redraw
and refresh of the screen.
2020-07-02 11:11:44 +02:00
Benno Schulenberg
eb413a99f2 tweaks: do not use the string "stat()" in any of the comments 2020-06-30 10:56:37 +02:00
Benno Schulenberg
fcb9e58b2d history: take into account that statting a file can fail too 2020-06-30 10:53:28 +02:00
Benno Schulenberg
675a8e4899 history: take into account that closing a file can fail 2020-06-29 13:47:20 +02:00
Benno Schulenberg
3344571227 tweaks: reshuffle some conditions, to straighten the logic 2020-06-29 12:39:46 +02:00
Benno Schulenberg
f9b1306adf tweaks: normalize the indentation after the previous change 2020-06-29 12:35:17 +02:00
Benno Schulenberg
722467cb6b tweaks: add four early returns for read/write errors of history files
Also rewrap a comment and rename a variable.
2020-06-29 12:23:59 +02:00
Benno Schulenberg
b3b3d04552 tweaks: rename a variable, to better fit related ones
Since commit c16e79b6 from nearly three years ago, the string "histfile"
does not occur in other variables any more, so it is fine to use it.
2020-06-29 12:04:15 +02:00
Benno Schulenberg
b9e3e4edb8 history: don't send error messages to the screen; store them in the queue 2020-06-29 11:56:36 +02:00
Benno Schulenberg
2d204bcbfd rcfile: restore terminal settings when exiting upon excessive unbindings
This fixes https://savannah.gnu.org/bugs/?58671.

Bug existed since commit 24cdf78a from two weeks ago.
2020-06-29 11:25:57 +02:00
Benno Schulenberg
3e609ee4c7 rcfile: complain when an essential key binding is missing
This fixes https://savannah.gnu.org/bugs/?58670.

Bug existed since commit 009fb2fa from two days ago.
2020-06-29 11:09:12 +02:00
Benno Schulenberg
13327203e0 build: use a more dependable method for detecting a build from git
The Haiku recipe seems to detect a .git directory somewhere, even though
they are building from a tarball.  So, check instead for the presence of
nano's release script, which ought to be present only in a git checkout,
not in a released tarball.
2020-06-28 15:21:04 +02:00
Benno Schulenberg
da0ac58ecc docs: document the new -O/--bookstyle and 'set bookstyle' options 2020-06-27 11:12:21 +02:00
Benno Schulenberg
712f68c697 options: add -O/--bookstyle to make leading whitespace mean new paragraph
Before version 2.9.8, nano would consider any line that started with
leading whitespace as the beginning of a new paragraph, and would thus
be unable to justify an indented piece of text (unless autoindent was
switched on).  I thought that this was too limiting and changed the
way nano detects and parses paragraphs.  It works fine in texts where
paragraphs occupy multiple lines, but breaks down for paragraphs of
a single line: nano merges those with adjoining lines.

Now, when -O or --bookstyle or 'set bookstyle' is used, nano will again
consider a line that begins with whitespace as the start of a paragraph
-- when 'autoindent' is OFF.

This addresses https://savannah.gnu.org/bugs/?57402.
Indirectly-reported-by: Sébastien Desreux <seb@h-k.fr>
Also-reported-by: Bill Kendrick <nbs@sonic.net>
2020-06-27 11:12:21 +02:00
Benno Schulenberg
331bd7662e tweaks: delete a now-unused function 2020-06-27 10:23:03 +02:00
Benno Schulenberg
009fb2fae6 tweaks: make three hard-bindings of special keys more efficiently
Instead of calling a function that tries to find the relevant operation,
just add three hidden hard-bindings at the end of the shortcuts list.

They are hidden because we don't want them to show up in the help text,
because we don't know what to call them (as a Cancel and Suspend key
don't exist on normal keyboards) or naming the key would be confusing
(Sh-Ins is grabbed by the desktop manager and doesn't reach nano).
2020-06-27 10:20:45 +02:00
Benno Schulenberg
7fa6e95ce1 tweaks: avoid a function call when a simple boolean will do 2020-06-26 19:44:19 +02:00
Benno Schulenberg
8bce70e038 tweaks: rename a variable, to better describe what it holds 2020-06-26 19:27:28 +02:00
Benno Schulenberg
b55153524a tweask: adjust the indentation after the previous change
Also improve a comment.
2020-06-26 19:18:05 +02:00
Benno Schulenberg
a9ce488cc5 tweaks: drop a superfluous check for a non-zero length
The get_history_completion() function is called in just one place,
and gets called only when the length parameter is larger than zero.

Also, improve a few comments.
2020-06-26 19:07:47 +02:00
Benno Schulenberg
8061a981b1 tweaks: correct two spelling mistakes [codespell] 2020-06-26 11:27:07 +02:00
Benno Schulenberg
e64c950896 tweaks: close opened files when something goes wrong [coverity] 2020-06-26 10:24:52 +02:00
Benno Schulenberg
69b12d907e tweaks: avoid unneeded calls of free() by reallocating the full name 2020-06-26 09:57:38 +02:00
Benno Schulenberg
c0c4a1b2b5 tweaks: plug a leak, by always freeing the full filename [valgrind] 2020-06-26 09:47:38 +02:00
Benno Schulenberg
18659f3485 build: fix the Makefile after two header files were renamed
Reported-by: Kamil Dudka <kdudka@redhat.com>
2020-06-25 21:11:26 +02:00
Benno Schulenberg
94f49e208f tabbing: beep at the first listing, and when there are zero possibilities
A successful single completion is silent, but when there are zero
or multiple possibilities, nano beeps.
2020-06-25 10:26:01 +02:00
Benno Schulenberg
3f63982593 tweaks: rewrap a few lines in old news items, for more balanced lines 2020-06-25 10:09:13 +02:00
Benno Schulenberg
7f77cad1b4 tweaks: condense the code a little further, by grouping things better 2020-06-25 10:03:56 +02:00
Benno Schulenberg
e7511abd86 tweaks: avoid checking a variable three times for each pass in the loop 2020-06-25 09:57:41 +02:00
Benno Schulenberg
b1b89f01b7 docs: mention that M-X toggle is special, because available in most menus 2020-06-24 09:30:08 +02:00
Benno Schulenberg
24740815f6 files: make better use of the last row when there are many completions
Put the "(more)" not in the first column of the last row but in the
last column.
2020-06-23 08:28:47 +02:00
Benno Schulenberg
c7356c2d85 files: show possible tab completions near the bottom of the edit window
Especially when it are just a handful of possible completions, it is
much nicer to have them listed close to the prompt bar where the eyes
of the user are.

This fulfills https://savannah.gnu.org/bugs/?58620.
2020-06-23 08:28:47 +02:00
Benno Schulenberg
91ba76e1e0 tweaks: normalize the indentation after the previous change
Also, improve five comments.
2020-06-23 08:28:47 +02:00
Benno Schulenberg
3dcabd6d03 tweaks: make an early return for zero matches, and rename a variable 2020-06-23 08:28:47 +02:00
Benno Schulenberg
0f843b007a tweaks: avoid an unnecessary refresh for zero or just one completion 2020-06-23 08:28:47 +02:00
Benno Schulenberg
ff11ab6b66 files: list possible completions after just one <Tab> instead of two
This gives quicker feedback, and spares the user unnecessary beeps
and typing.  Also, now a beep after a <Tab> means just one thing:
there are NO completions.

This fulfills https://savannah.gnu.org/bugs/?58627.
2020-06-23 08:28:47 +02:00
Benno Schulenberg
096e36279f build: fix compilation for --enable-tiny --enable-color --enable-nanorc 2020-06-22 14:03:48 +02:00
Benno Schulenberg
5eb3b8feb5 tweaks: add a helpful message for when pkg.m4 is missing during a build 2020-06-22 14:03:32 +02:00
Benno Schulenberg
f601eeda57 build: fix compilation when configured with --disable-color 2020-06-22 12:49:04 +02:00
Benno Schulenberg
2430c5b230 build: allow compilation to succeed on curses without italic support
The OpenBSD system that I have access to still uses ncurses-5.7,
and support for A_ITALIC appeared in version 6.0.
2020-06-22 11:19:05 +02:00
Benno Schulenberg
9b8930cc13 tweaks: adjust the conditional help-item pairing for absence of speller
The Spell Checker is no longer among the first twelve items of the
main menu, so the conditional placing of the Go To Line item should
no longer depend on it.
2020-06-22 09:09:05 +02:00
Benno Schulenberg
0f0b620c65 build: fix compilation when configured with --disable-speller
Move two functions that are used by the formatter too
to between the proper #ifdef.

Problem existed since commit 8089f5ad from a month ago.
2020-06-22 08:42:49 +02:00
Benno Schulenberg
a7aab18dfe colors: move purple one step away from magenta, and use a darker mauve 2020-06-21 19:21:07 +02:00
Benno Schulenberg
a9e171de52 tweaks: update three translator hints, add two, and frob three strings 2020-06-21 14:10:37 +02:00
Andreas K. Foerster
ad2490c3fc syntax: ada: new file -- coloring rules for Ada 2012 files
Signed-off-by: Andreas K. Foerster <akf@akfoerster.de>
2020-06-21 09:33:14 +02:00
Benno Schulenberg
380589d95d tweaks: reshuffle and trim a comment, and remove unneeded pair of braces 2020-06-21 09:20:44 +02:00
Benno Schulenberg
bb496bf456 tweaks: rename two variables, to be shorter and without abbreviations 2020-06-21 09:12:59 +02:00
Benno Schulenberg
b086d0bad0 tweaks: elide another parameter, relevant in just three menus
The parameter was referenced in just one place.  So, simply check for
the three relevant menus (and unrestricted mode) and be done with it.

This also has the pleasant effect that the menu name is now the first
parameter of do_prompt(), thus clearly indicating what prompt it is,
instead of having an opaque TRUE or FALSE value at the beginning.
2020-06-20 17:19:23 +02:00
Benno Schulenberg
a13b0bc854 files: disallow tabbing when in restricted mode
Tabbing can list all files in the given directory, but restricted mode
is supposed to prevent the user from any access to the filesystem...

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

Bug existed (in this form) since version 1.3.4, commit f7b5d930.
2020-06-20 14:55:28 +02:00
Benno Schulenberg
bbdbf4586f build: make ./configure report which global nanorc file will be used
This addresses https://savannah.gnu.org/bugs/?57061.
Requested-by: Robert Johnson <aloha@blastpuppy.com>
2020-06-20 14:02:34 +02:00
Benno Schulenberg
af5010c96f syntax: default: colorize embedded control codes 2020-06-20 13:54:48 +02:00
Benno Schulenberg
90f6342fd1 tweaks: rename two header files, to be distinct and not an abbreviation 2020-06-20 12:09:31 +02:00
Pedro Victor de Brito Cordeiro
84b187f627 tweaks: make parameter names in prototypes match those in the definitions
Also, remove three prototypes of functions that no longer exist.

Signed-off-by: Pedro Victor de Brito Cordeiro <pedrocga1.opensource@gmail.com>
2020-06-20 11:25:09 +02:00
Benno Schulenberg
499b926b74 tweaks: elide a parameter that is relevant for only one menu (Goto Dir)
Instead of burdening seven other calls of do_prompt() with a useless
parameter, just check for MGOTODIR in the appropriate place.  It also
saves having to pass the parameter down through three more functions.
2020-06-19 10:55:28 +02:00
Benno Schulenberg
61dda8ff62 tweaks: rename a variable, to make more sense 2020-06-19 10:12:49 +02:00
Benno Schulenberg
6ce4e3ede8 feedback: do not list "." and ".." as possible <Tab><Tab> completions
The single dot serves no purpose, as the user is already there.  And
the double dot is reached more easily by typing a second dot first.

And anyway, . and .. are not shown when the user does not type a dot
first, so why show them when the user types a single dot followed by
<Tab><Tab>?  Most likely the user wants to see actual dot files, so
just show those.

This fixes https://savannah.gnu.org/bugs/?58619.
2020-06-19 10:06:33 +02:00
Benno Schulenberg
287718cf8b tweaks: rename two parameters, to be more fitting 2020-06-18 19:12:11 +02:00
Benno Schulenberg
78f54523d9 tweaks: elide a variable and be more direct, and rename another 2020-06-18 19:02:02 +02:00
Benno Schulenberg
9faa95450b tweaks: rename two functions, and rename and reshuffle a parameter
Also, drop an unneeded nulling: the function copy_of() already
NUL-terminates the copied string.
2020-06-18 17:24:18 +02:00
Benno Schulenberg
26d7a7494e tweaks: improve several comments, and rewrap two lines 2020-06-18 17:10:05 +02:00
Benno Schulenberg
d8249917c3 bindings: allow toggling the help lines at several prompts and in browser
Now the help lines can be toggled not only while editing, but also at
the Read (^R), Write (^O), Execute (^T), Search (^W), Replace (M-R),
Goto (^/), and Yesno prompts, and also in the file browser and when
searching for a file name.  The help lines cannot be toggled in the
help viewer, nor when searching in a help text, nor in the linter,
as these three things force the help lines to be on.

Furthermore, the 'nohelp' function can be rebound in all relevant
menus (default binding: M-X).

This fulfills https://savannah.gnu.org/bugs/?58471.
2020-06-18 15:36:10 +02:00
Benno Schulenberg
054cafa138 docs: mention the nine new color names, and "bold" plus "italic" 2020-06-18 15:31:06 +02:00
Benno Schulenberg
bafcc19b7a tweaks: rename a symbol, from a phrase to a noun 2020-06-18 15:31:06 +02:00
Benno Schulenberg
61c94c2f81 rcfile: report the first bad color element, not a later one that is okay
This fixes https://savannah.gnu.org/bugs/?58605.

Bug existed since commit c275c515 from several days ago.
2020-06-18 15:31:06 +02:00
Benno Schulenberg
69a90dd7af tweaks: elide two redundant calls of strchr() 2020-06-18 15:31:06 +02:00
Benno Schulenberg
fae2eeadce rcfile: introduce the modifier 'italic', for slanted text
The modifier has to come before the foreground color name, separated
by a comma, and after 'bold,' (when present).  This has no effect on
terminals that are incapable of cursive text, like the Linux console.

This fulfills https://savannah.gnu.org/bugs/?56525.
2020-06-18 15:31:06 +02:00
Benno Schulenberg
3ff524821c tweaks: move a copyright notice to a better place, and improve it
The username_tab_completion() function taken from busybox-0.46 was
just a stub, it contained basically nothing.  Chris himself wrote
the function in November 2000 (commit be77c611), and rewrote it in
January 2001 (commit 2c2c5f21).

The version of username_tab_completion() in that latter commit looks
somewhat like the version of Vladimir N. Oleynik <dzo@simtreas.ru>
(busybox commit 4e338757).  That commit comes three days after Chris'
commit, but Vladimir's original email is from a week earlier:
http://lists.busybox.net/pipermail/busybox/2001-January/035687.html.
So... it is quite possible that Rocco saw that email and suggested
to Chris to rewrite username_tab_completion() using getpwent().

Anyway, the version that was taken from busybox-0.46 was just four
lines and thus not worthy of copyright.  The two other functions
that were copied were heavily modified in 2000, so it's better to
add that year in the copyright notice.  It is fine to tweak the
notice: it just says that the original authors must be attributed,
not that the exact text must remain unchanged.
2020-06-18 12:50:24 +02:00
Benno Schulenberg
290b250141 tweaks: elide an unneeded variable, as there is nothing beyond '*place' 2020-06-18 12:12:43 +02:00
Benno Schulenberg
b61d97eb9a tweaks: elide a variable, and shortcircuit a return
Instead of first trying to match things, and then discarding these
matches when the cursor is not at the end of the offered fragment
('buf'), simply don't bother to do any matching in that case.
2020-06-18 12:12:33 +02:00
Benno Schulenberg
0bced0a5e9 tweaks: condense and improve some comments 2020-06-18 11:44:25 +02:00
Benno Schulenberg
23c62c5032 tweaks: drop two unneeded assignments
The variable is set to zero at its declaration, and the second function
is called only when the first is either not called or found nothing --
thus '*num_matches' will still be zero.
2020-06-18 11:20:25 +02:00
Benno Schulenberg
2770ec81e2 build: make a deeper clone of gnulib (when building from git)
This increases the chances that the wanted hash will be present in
the checkout when we haven't changed the hash for a few months.

Reported-by: Félix Piédallu <felix@piedallu.me>
2020-06-17 12:25:23 +02:00
Benno Schulenberg
c35c5af5d8 syntax: nanorc: colorize the new named colors too, from "mint" to "mauve" 2020-06-17 11:29:05 +02:00
Benno Schulenberg
f6e7b7fbc5 rcfile: introduce nine new named colors, from "pink" to "latte"
Names give a rough idea of what the color will look like, whereas
numerical indexes would not do this at all.

Nine extra colors seems enough.  If there were more, no one would be
able to say for sure which is which when two similar colors are used
several rows apart.

This partially fulfills https://savannah.gnu.org/bugs/?56445.
2020-06-17 11:18:22 +02:00
Benno Schulenberg
96a5aa9e90 syntax: nanorc: colorize 'bright' anyway, so existing syntaxes look okay
After a year or so, when people have had time to convert their syntaxes
to use 'bold' and/or 'light' instead of 'bright', we can drop this
colorizing, and still later stop recognizing 'bright' altogether.
2020-06-16 17:33:49 +02:00
Benno Schulenberg
e998c35c53 syntax: sql: rename the file to match the name of the syntax 2020-06-16 14:44:57 +02:00
Benno Schulenberg
4d7e7e28fd tweaks: drop obsolete 'nano.spec' from .gitignore file, and reshuffle 2020-06-15 19:11:45 +02:00
Marco Diego Aurélio Mesquita
648eac936e files: make the M-F (New Buffer) toggle non-persistent
Having the M-F toggle non-persistent, makes the behavior of ^R
predictable.  This allows string binds that load a file to work
correctly independently of when M-F was last pressed.

The -F/--multibuffer command-line option and "set multibuffer"
in a nanorc file determine the default behavior of ^R.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2020-06-15 16:05:31 +02:00
Benno Schulenberg
26fb83c61f docs: use 'bold' and 'light' instead of 'bright' in the sample nanorc 2020-06-15 15:30:52 +02:00
Benno Schulenberg
2fd9974e0e syntax: nanorc: stop colorizing 'bright', even though it's still accepted
The name 'bright' does not fit its effect (often bolding the typeface),
so better discourage its use.

Furthermore, colorize 'bold' and 'light' also for interface colors.
2020-06-15 15:15:06 +02:00
Benno Schulenberg
7ff82aa5e2 rcfile: add bindable function 'execute', for access to "Execute Command"
(This should have been added three weeks ago when ^T was rebound.)
2020-06-15 14:27:49 +02:00
Benno Schulenberg
fd28e5f36c build: fix compilation when configured with --enable-tiny 2020-06-15 12:38:16 +02:00
Benno Schulenberg
7f40eeab0a tweaks: call the spotlighting routines only for the relevant line
Otherwise the affected piece of text gets drawn and spotlighted as
many times as there are rows in the edit window.
2020-06-15 09:45:01 +02:00
Benno Schulenberg
d67faa2bb5 tweaks: remove a superfluous global variable
There were no calls of statusbar() or statusline() before curses mode
was entered.  But since the previous commit curses mode is entered
even earlier, so...
2020-06-14 13:09:23 +02:00
Benno Schulenberg
24cdf78a93 startup: enter curses mode before reading the nanorc files
This way the COLORS variable will be set when the nanorc files specify
interface colors, so that "light" will work for them.
2020-06-14 12:57:46 +02:00
Benno Schulenberg
d01dbbb284 rcfile: do not complain when "bright" is used with a background color
A background color *can* be bright (in the sense of lighter, shinier).
It's just that the background cannot be bold.  Only the typeface used
on the foreground can be bold (if the terminal supports it).  So, let
"bright", when used with a background color, simply mean "light".
2020-06-14 12:05:18 +02:00
Benno Schulenberg
c275c5158e rcfile: introduce the modifier "bold", for specifying bolding separately
This makes it possible to avoid the misnamed prefix "bright".  It is
misnamed because (on current terminal emulators, when the brightening
of bold is switched off) it just makes the typeface bold, not the color
brighter.  The prefix "light" will now only make the color brigther,
and the modifier "bold" will just make the typeface bold (on terminal
emulators, when the brightening of bold is switched off).

On a Linux console, which is not capable of bolding the typeface,
"bold" will brighten the color.

This fully fulfills https://savannah.gnu.org/bugs/?58503.
2020-06-14 11:54:18 +02:00
Benno Schulenberg
adf7f33ea8 rcfile: allow specifying a bright background color (with prefix "light")
If the terminal is capable of more than eight colors, specifying
indexes 8 to 15 works fine for getting a light background color.
2020-06-14 11:51:00 +02:00
Benno Schulenberg
4d10f583e4 rcfile: accept prefix "light" to make a color brighter without bolding it
The prefix "bright" will continue to make the color brighter AND/OR
make the typeface bold (depending on how the terminal is configured
and on its capabilities), but the prefix "light" will just make the
color brighter (if the terminal can do that).

The prefix "bright" continues to do the same as what it did before,
to not change the appearance of user-defined syntaxes.  And having
an option to change the meaning of "bright"... would be confusing.

This partially fulfills https://savannah.gnu.org/bugs/?58503.
2020-06-14 11:45:45 +02:00
Benno Schulenberg
926bc6751e startup: check stdout instead of stdin when probing for a Linux console
This way we don't have to probe twice, and the result is accurate also
when nano is reading data from standard input.  Standard output should
always be connected to a terminal, as nano is not meant to operate
without a screen.
2020-06-14 10:52:42 +02:00
Benno Schulenberg
1c8c02f63b tweaks: move a function, to be in the order in which they are called
In addition, rename two variables and adjust the type of one of them.
2020-06-13 17:16:33 +02:00
Benno Schulenberg
43a1756783 tweaks: call init_pair() just once for each pair number 2020-06-13 14:17:45 +02:00
Benno Schulenberg
34528db096 tweaks: remove unneeded variables after the previous change 2020-06-13 14:17:45 +02:00
Benno Schulenberg
c79b52da1d tweaks: do the conversion of -1 to a specific color just once
Do the conversion (when needed) when the syntax is loaded,
not for each buffer switch.
2020-06-13 14:17:45 +02:00
Benno Schulenberg
454dc6e1ec tweaks: elide two ifs for the most likely case, when defaults are allowed 2020-06-13 14:17:45 +02:00
Benno Schulenberg
23460bc6a8 tweaks: rename a variable, for more contrast with the function name 2020-06-13 14:17:45 +02:00
Benno Schulenberg
ba2807c6f7 tweaks: call use_default_colors() just once for each run 2020-06-13 14:17:45 +02:00
Benno Schulenberg
3899a09dea tweaks: rename a variable, improve a comment, and reshuffle a few things 2020-06-11 19:23:37 +02:00
Benno Schulenberg
b535714671 tweaks: reshuffle a statement, to have major initialization in nano.c 2020-06-11 16:48:52 +02:00
Benno Schulenberg
8535b3db4c tweaks: rename a variable, to not refer to a row as a "line" 2020-06-11 16:45:47 +02:00
Benno Schulenberg
77bce9f1c4 tweaks: remove a redundant cursor movement, remove a redundant condition
Each listing of a name is preceeded by a call to wmove(), so there
is no need for an initial wmove().  And after writing "more" on the
bottom row of the edit window, the loop is terminated, so there is
no need to check that this is the first item on the bottom row.
2020-06-11 16:29:38 +02:00
Benno Schulenberg
a2b85e0c12 indicator: recompute the extra rows also when justifying and resizing
And when the margin changes (when line numbers are switched on or off,
or when the buffer grows or shrinks), and when a piece of text from a
different buffer with a different margin is pasted.

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

Bug existed since commit 9a9f36fc from yesterday.
2020-06-07 12:16:15 +02:00
Benno Schulenberg
786d2221e1 indicator: recompute the extra rows also for cut/paste/split/join
This fixes https://savannah.gnu.org/bugs/?58511.

Bug existed since commit 9a9f36fc from yesterday.
2020-06-07 11:05:14 +02:00
Benno Schulenberg
9a9f36fca7 indicator: rework how the "scrollbar" is computed when softwrapping
Instead of storing for each line the ordinal number of the first chunk
in that line, simply store the number of extra chunks in the line.

It now takes some more computation to actually draw the scrollbar, but
it saves a lot of computation when just inserting or deleting characters
(when using --softwrap and causing a change in chunk count).

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

Bug existed since commit 6bccedb3 from two days ago.
2020-06-06 19:21:23 +02:00
Benno Schulenberg
00d4a06cc7 tweaks: group the exiting routines together, and condense the comments 2020-06-05 19:10:36 +02:00
Benno Schulenberg
2aec478ea6 tweaks: elide an unneeded parameter, and rename the other 2020-06-05 17:23:52 +02:00
Benno Schulenberg
ae7f5ebdeb tweaks: move a function to before the one that calls it 2020-06-05 17:14:38 +02:00
Benno Schulenberg
bea5e85f3e tweaks: make an error message more accurate and reduce it to its essence
There is no need to be explicit about not having saved the buffer --
it is implied in the "Too many".  And anyway, no one is ever going to
see this message -- who will have a hundred thousand .save files?
Trimming this message makes the tiny version smaller.

Also, rewrap a neighbouring line.
2020-06-05 12:19:42 +02:00
Benno Schulenberg
32ee39e44a docs: document the --indicator (-q) and 'set indicator' options 2020-06-04 18:52:28 +02:00
Benno Schulenberg
8e7b869cd9 options: add --indicator and -q for switching on the scroll-bar thing
By default, the position indicator is off.  It can be turned on
by passing -q or --indicator on the command line, or by adding
'set indicator' in your nanorc file.
2020-06-04 18:52:28 +02:00
Marco Diego Aurélio Mesquita
6bccedb319 display: support the position indicator also when --softwrap is used
A new member ('chunk_nr') is added to each 'linestruct', to store
the serial number of the first chunk of that line, so that, when
softwrap is on, the scroll-bar thing can be computed relative to
chunks instead of relative to actual lines.

To guarantee that 'chunk_nr' is correctly synced, the buffer is
renumbered whenever the number of chunks in a line changes, and
also when softwrap is toggled on, and when buffers are switched.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2020-06-04 18:52:28 +02:00
Benno Schulenberg
b33a62af8c new feature: a position-plus-portion indicator on the righthand side
This displays a scrollbar-like thing on the right edge of the screen,
giving a rough indication where in the buffer the text that is being
shown in the viewport is located, and how large/small a portion of
the buffer this text is.

(Support for softwrapping, and an option to turn the indicator on,
will arrive in subsequent commits.)

This fulfills https://savannah.gnu.org/bugs/?57956.

Original-patch-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2020-06-04 18:52:28 +02:00
Benno Schulenberg
d729edaeda bindings: make ^L (Refresh) work at all the prompts too
(Unfortunately, this means that ^L cannot be used for the
Linter in the "Execute Command" menu.)

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

Bug existed since around version 2.1.0.
2020-06-04 09:10:48 +02:00
Benno Schulenberg
bc92e28b30 tweaks: elide an unused parameter, and rename the other and a variable
Also, regroup a few lines.
2020-06-03 18:45:14 +02:00
Benno Schulenberg
c5b0e1958a feedback: beep also at a prompt when receiving an unknown escape sequence
Nano would beep (and report "Unknown sequence") only when in the main
edit window, in the help viewer, or in the file browser.  But the same
keystroke at a prompt would be enigmatically silent.

Also, in the file browser, nano would leave the cursor at the end of
the "Unknown sequence" message when --showcursor was used.

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

Bug existed (in this form) since around version 2.7.4,
and in a worse form since around version 2.3.5.
2020-06-03 17:15:51 +02:00
Benno Schulenberg
da43cc0959 display: reposition the cursor after an error message also in a help text
A help text is contained in a normal buffer (since quite a while now),
so cursor placement should work like in a regular edit window.

Also, remove an unneeded switching on of the cursor -- it is already on
as nano is waiting for keyboard input.

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

Bug existed since version 3.2, commit 10d9742c, since --showcursor
shows the cursor also in the help viewer.
2020-06-03 10:38:08 +02:00
Benno Schulenberg
506f617d5b tweaks: remove an unneeded call of wnoutrefresh()
On NetBSD, nano requires ncurses nowadays.  With ncurses, cursor
placement works fine without the extra call of wnoutrefresh().
2020-06-03 10:14:50 +02:00
Benno Schulenberg
e81e18dd14 tweaks: recalculate the multiline info just once when doing "Replace All" 2020-06-02 19:14:36 +02:00
Benno Schulenberg
569d00564b replacing: recalculate the multiline coloring info when needed
If a replacement changed the matching of a multiline coloring regex,
then wipe the existing multiline data and recalculate it for the whole
buffer.

There is no need to redraw the current line (let alone the whole window)
directly after a replacement, because if there is a next occurrence, the
edit window will be redrawn then in order to spotlight that occurrence;
and if there is no other occurrence, the edit window will be redrawn in
the main loop because there has been at least one replacement.

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

Bug existed (in this form) since version 2.7.5.  Before that,
the miscoloring could happen even without scrolling.
2020-06-02 18:52:40 +02:00
Benno Schulenberg
881106c487 tweaks: drop two unneeded wnoutrefresh() calls in the spotlight routines
The call will be made at the end of edit_refresh() or in the main loop.
2020-06-01 20:28:07 +02:00
Benno Schulenberg
2a44cb2ed8 tweaks: rename a function, to leave the old names behind
What the function does has changed, so better change the name too.
2020-06-01 09:43:08 +02:00
Benno Schulenberg
19a124e806 display: avoid an additional redrawing when redrawing the screen
When resizing the screen or toggling the help lines or refreshing
the screen with ^L, what used to be total_refresh() would first call
what used to be total_redraw(), to tell ncurses to redraw whatever
had been on the screen so far, before proceeding to fully redraw the
content of the title bar and the edit window and the bottom bars.
That was duplicate work.

Thus, rename total_redraw() to total_refresh(), so that ^L in the
edit window, help viewer, and file browser will redraw the screen
just once.  This also preserves whatever was on the status bar
(when --quickblank isn't used).

Rename the old total_refresh() to draw_all_subwindows() and call
this routine when resizing the screen or toggling the help lines
or returning from the credits crawl.
2020-06-01 09:40:09 +02:00
Benno Schulenberg
d9106abfda rcfile: rename 'extcmd' to 'execute', to be more readable and fitting
Also, improve its description in the documentation.
2020-05-31 12:04:58 +02:00
Benno Schulenberg
bc0ea5ea71 help: describe what has been added to the "Execute Command" menu 2020-05-30 19:21:44 +02:00
Benno Schulenberg
ee03c4b857 bindings: remove the Full-Justify function from the Search menu
It was out of place there and found a new home in the Execute menu.
2020-05-30 18:58:41 +02:00
Benno Schulenberg
6d7ff17901 help: put the two toggles first in the "Execute Command" menu
This makes that the M-F toggle stays roughly in the same place when
toggling between "Read File" and "Execute Command", and groups the
six special commands together.
2020-05-30 18:57:04 +02:00
Benno Schulenberg
7bad92c50b bindings: add ^Z (Suspend) to the "Execute Command" menu
This makes suspension more discoverable, and allows the user to rebind
^Z in the main menu without losing the ability to suspend nano.

This drops the ^X (Flip Execute) toggle from the menu -- keeping it
would make an ugly uneven number and would reduce the space for each
menu item too much (clipping "Full Justify" and "Cut Till End") --
but it is still present as a blind toggle.
2020-05-30 18:56:58 +02:00
Benno Schulenberg
d3954901a9 bindings: make ^T invoke the "Execute Command" menu, and ^T^T the Speller
Make the "Execute Command" menu accessible also with a single keystroke
(^T), not just with a double one (^R^X).  This is useful, because no one
will suspect that "Execute Command" can be found behind "Read File".

To not disturb muscle memory too much for people who are used to ^T
invoking the Spell Checker, a second ^T will invoke it.
2020-05-30 18:56:55 +02:00
Benno Schulenberg
cd594b85f4 general: make five tools accessible through the "Execute Command" menu
Instead of creating a special Tools menu, add the five functions that
affect the whole buffer to the "Execute Command" menu.  There is room
for these five functions there, and they kind of fit in because three
of them (Speller, Linter, and Formatter) actually invoke an external
command, and Full Justify could have been implemented externally, and
the destructive Cut Till End ought to have required a double keystroke
since the beginning.
2020-05-30 18:56:51 +02:00
Benno Schulenberg
933dd567de tweaks: separate a symbol from its definition by two spaces
It's a little clearer, and new ones were like that already.
2020-05-29 18:45:14 +02:00
Benno Schulenberg
248d392c4d tweaks: rename a symbol, and actually use it where it is needed 2020-05-29 17:19:38 +02:00
Benno Schulenberg
e1f80b9707 tweaks: move a function to a more logical place
Initialization should come first.
2020-05-29 17:12:45 +02:00
Benno Schulenberg
6b4e7d0f78 tweaks: reshuffle a declaration and six calls of free(), to avoid a leak
If the user chose to skip making a backup,
'backupname' would not be freed.
2020-05-29 13:57:38 +02:00
Benno Schulenberg
4b4a8be58b files: before prompting, show also the reason why the backup failed
Also, do not prompt when there is no space left on the device,
because then trying to save the actual file would likely lead
to truncating it, resulting in an empty file.
2020-05-29 11:57:33 +02:00
Benno Schulenberg
512b0fd32d files: take into account that also closing a backup file can fail
Only when fclose() is called, does the data get flushed out to disk,
and maybe only then the system realizes that there is no space left on
the device, as Chris noted in: https://savannah.gnu.org/bugs/?24000.
2020-05-29 11:40:27 +02:00
Benno Schulenberg
586d22109b files: show a warning when writing a backup fails, before prompting
Make the behavior similar to that of the other failure cases.

Also, plug a tiny memory leak.
2020-05-29 11:22:57 +02:00
Benno Schulenberg
47953bd6ac files: also when creating a backup fails, ask the user whether to proceed
When asking this question when deleting fails or writing fails,
it should be asked too when creating fails.  Otherwise the user
is blocked from saving the file -- until she realizes that maybe
toggling off backups would help.
2020-05-29 10:58:11 +02:00
Benno Schulenberg
11d3b01050 files: give a more precise warning when deleting an existing backup fails
This addresses https://savannah.gnu.org/bugs/?58410.
2020-05-29 10:48:01 +02:00
Benno Schulenberg
eddd8963e7 files: ask the user whether to proceed every time a backup fails
If the user answered "No" or "Cancel" the first time, they should
be allowed to answer "Yes" the next time -- possibly after fixing
the necessary permissions in another terminal.

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

Bug existed since version 2.3.0, commit 3d411188.
2020-05-29 10:23:54 +02:00
Benno Schulenberg
160f07baba tweaks: simplify an error message, by mentioning just the main point
Also, correct a comment.
2020-05-28 19:30:09 +02:00
Benno Schulenberg
822d764d27 files: ignore errors when calling futimens() on a backup file
Access control lists can permit read and write access to a file
but not permit to manipulate any attributes of the file.  So it
is quite possible for futimens() to fail, just like chown() and
chmod() can fail, but this should be no cause for alarm: as long
as writing the backup file worked, then writing the file itself
will probably work too.
2020-05-28 17:19:45 +02:00
Benno Schulenberg
6d00e75dc2 tweaks: rename a function, to be more correct 2020-05-28 16:59:50 +02:00
Benno Schulenberg
90772ad05b backup: do not understand ^C as "Yes" when asking whether to continue
This fixes https://savannah.gnu.org/bugs/?58443.

Bug existed since version 2.3.0, commit 3d411188.
2020-05-28 14:58:05 +02:00
Benno Schulenberg
756b95748b tweaks: rename a struct element, to be shorter and preciser
And anyway, there are too many occurrences of 'current'.
2020-05-28 14:38:48 +02:00
Benno Schulenberg
8d31ad8a70 files: ignore errors when calling chmod() on a backup file
First, it is very unlikely that chmod() would fail as the user just
created the file herself.  Second, even if chmod() would fail, this
is not a problem, because we have created the file with read+write
permissions for the owner only, so the file cannot accidentally be
left accessible to unintended others.

But most of all, such a failure should not stop nano from trying to
write the backup file.  Only when the actual *writing* fails, should
we bother the user with a prompt.
2020-05-28 14:35:42 +02:00
Ryan Westlund
3480518a5c syntax: go: highlight the chan keyword, and the special +build comment
This fixes https://savannah.gnu.org/bugs/?58424
Reported-by: Ryan Westlund <rlwestlund@gmail.com>

Signed-off-by: Ryan Westlund <rlwestlund@gmail.com>
2020-05-26 16:50:31 +02:00
Benno Schulenberg
b48dfde3b2 files: remove two superfluous calls for shielding temp files from others
If there are still systems where mkstemp() creates world-readable
temporary files, then please holler.  On current BSDs and on GNU,
I've verified that mkstemp() creates files with 0600 permissions.
2020-05-26 13:40:11 +02:00
Benno Schulenberg
f8366cd5c9 tweaks: remove two calls of umask() by specifying permissions directly 2020-05-26 12:36:18 +02:00
Benno Schulenberg
423105e371 tweaks: improve some comments and whitespace, and reshuffle a few lines
Also, silence a compiler warning.
2020-05-25 19:49:17 +02:00
Benno Schulenberg
5a7cdacf46 startup: allow presetting case-sensitive search also in the tiny version
If nanorc-file support is re-enabled (--enable-tiny --enable-nanorc),
then it ought to be possible to set case sensitivity at startup.
2020-05-25 19:08:00 +02:00
Benno Schulenberg
d909291b0c tweaks: rename one of the flag symbols, to be clearer
I kept understanding 'BACKUP_FILE' as a noun instead of as an imperative.
2020-05-25 18:52:09 +02:00
Benno Schulenberg
b30522463a files: do not append but truncate when allowing insecure backups
When deleting an existing backup file failed, we do not want to
append to this file, but want instead to overwrite it (when the
user has put 'set allow_insecure_backup' in their nanorc file).

Also, when using O_EXCL (in the normal, secure case), O_APPEND
is pointless, because the file will be created and thus empty.

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

Bug existed since version 2.2.5, commit 461519cc.
2020-05-25 12:22:15 +02:00
Benno Schulenberg
5449d1e6a5 files: ignore errors when calling chown() on a backup file
A normal user can change the group of a file (if the user is a member
of that group), but cannot change the owner of that file.  So, when a
user edits a file that belongs to a different user, the call of fchown()
will fail.  But there is no harm in that.  Also when the user is root,
there is no harm in fchown() failing -- it will simply mean that the
backup file will remain owned by root and will not be writable by the
intended owner (when root has the normal umask of 0022).

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

Bug existed since version 2.2.5, commit 86be3af7.
2020-05-24 16:08:05 +02:00
Benno Schulenberg
d7743b05f0 tweaks: correct a comment, and drop a redundant (because nested) #ifdef
Also, drop an unneeded case-insensivity when comparing two strings,
as all commands in a nanorc file have to be in lower case.
2020-05-24 12:30:40 +02:00
Benno Schulenberg
8089f5ad54 build: do not let --disable-speller exclude also the formatter code
In the past, when Speller and Linter and Formatter were all bound
to ^T (later ones taking priority), it was easier to exclude also
the formatter code when --disable-speller was used.  But since the
formatter was reintroduced (in commit 34170611) and bound to its
own keystroke (M-F), this is no longer the case.
2020-05-24 12:08:50 +02:00
Benno Schulenberg
2579b105da tweaks: slightly improve the grouping of shortcuts in some help texts 2020-05-24 11:54:02 +02:00
Benno Schulenberg
09a004cad9 tweaks: order three menu names in the documentation slightly better 2020-05-24 11:24:49 +02:00
Benno Schulenberg
3162e73540 docs: copy the 4.9.3 news item from the release branch 2020-05-24 09:01:53 +02:00
Benno Schulenberg
2c5045bfce feedback: skip wiping the prompt bar when the shortcut printed a message
When, at a prompt, the user chose a function shortcut instead of typing
an answer, and this function printed some message to the status bar,
then we do not want to wipe this message.  Also: the message overwrote
and cleared the prompt bar, so there is no need to wipe the latter.

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

Bug existed since version 4.0, since justifying started giving feedback
(or rather since version 4.1, since M-J no longer crashed).
2020-05-22 12:12:36 +02:00
Benno Schulenberg
53c5ace8c3 tweaks: rename a symbol, away from a double abbreviation 2020-05-22 10:04:33 +02:00
Benno Schulenberg
e0d00bc750 tweaks: avoid a compiler warning 2020-05-21 10:47:04 +02:00
Benno Schulenberg
b72f3b10ba prompt: at Yes-No, do not treat a screen resize as an invalid keystroke
Commit 12cf1c99 added a beep() for every invalid keystroke at the
Yes-No prompt, but overlooked that KEY_WINCH is not invalid.

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

Bug existed since version 4.8, commit 12cf1c99.
2020-05-21 09:50:13 +02:00
Benno Schulenberg
c9482bcd2b display: do not try to draw content when there is no open buffer yet
Commit b63c90bf avoided creating an empty buffer before asking the
yes-no question when encountering a lock file at startup, but the
SIGWINCH code still expected to have an open buffer whose contents
to show.

This fix also has the pleasant effect that, when resizing the screen
at the lock-file yes-no prompt, the title bar doesn't suddenly appear.

This fixes https://savannah.gnu.org/bugs/?58414.
Reported-by: Liu Hao <lh_mouse@126.com>

Bug existed since version 4.9, commit b63c90bf.
2020-05-21 09:24:02 +02:00
Benno Schulenberg
747ce3b5da tweaks: don't bother statting the lock file before unlinking it
If unlinking would fail because the parent directory is unwritable,
then a check in has_valid_path() would have prevented do_lockfile()
from being called at all.
2020-05-20 16:56:32 +02:00
Benno Schulenberg
10800ee410 locking: prevent a symlink attack by not opening an existing lock file
If in between the unlink() in delete_lockfile() and the fopen() in
write_lockfile() some other process creates a symlink in the place
of the lock file, then the fopen() could unexpectedly overwite a
root-owned file (when the user is root).

This basically reverts the previous commit, b4299f4f, but makes the
code a bit conciser.
2020-05-20 16:22:15 +02:00
Benno Schulenberg
b4299f4f4e tweaks: don't bother using the exclusive flag when creating a lock file
One microsecond earlier, the lock file has been deleted (if it existed),
so, if between our unlink() and our open() some other process managed to
recreate the lock file... well, we want to delete it *again*.  So, just
overwrite and truncate the lock file (if it exists).

When the lock file did NOT exist (a few microseconds earlier, when
checking in do_lockfile(), before calling write_lockfile()), then
the user expects the lock file to be written, so: just write it.

That between the check and the actual writing of the lock file there
is a small window of opportunity for other processes to write this
lock file is unfortunate, but it is not a reason to bother the user
with an error message when it happens.
2020-05-19 17:07:31 +02:00
Benno Schulenberg
c45df589fa locking: ignore the insecure-backup flag when creating a lock file
One microsecond before a lock file is created an existing lock file
has been deleted, and if that deletion failed, writing the lock file
is aborted.  So why should writing the lock file not be aborted when
the lock file cannot be exclusively created one microsecond later?
This makes no sense.  So... always include the O_EXCL flag, also
when the INSECURE_BACKUP flag is set.

(And anyway: lock files are not an essential part of editing, they
are just a small service to the user, AND they have nothing to do
with backups, so a backup flag should not influence them.)
2020-05-19 14:56:37 +02:00
Benno Schulenberg
44fd299921 tweaks: add a symbol, in order to condense three function calls 2020-05-17 19:11:54 +02:00
Benno Schulenberg
40a0463250 tweaks: reshuffle an assignment, for conciseness, and rename a variable 2020-05-17 11:34:22 +02:00
Benno Schulenberg
187843d2da tweaks: exclude a bit of bracketed-paste code from the tiny version
The tiny version does not support bracketed pastes.
2020-05-14 18:47:50 +02:00
Benno Schulenberg
0f2dd8456f usage: unabbreviate option arguments where possible
And make it clearer what kind of argument is expected:
digits, characters, or a program name.
2020-05-14 17:27:15 +02:00
Benno Schulenberg
821fbf713d tweaks: reshuffle a bit of code, to elide an #ifndef 2020-05-14 11:44:21 +02:00
Benno Schulenberg
ebc2364742 tweaks: move a fragment of code to the one branch that needs it
When two lines are joined, 'refresh_needed' is already set to TRUE,
so only when a midline character is deleted the check for a changed
number of chunks is needed.
2020-05-14 11:43:30 +02:00
Benno Schulenberg
15fadd700a tweaks: rename a function, to be more precise, and reshuffle it 2020-05-13 12:43:22 +02:00
Benno Schulenberg
78bfc9223a tweaks: add a condition, so that two ifs can be elided
Now all functions that are relevant only to softwrapping
get called only when softwrapping is on.

This also allows to elide an intermediate function call.
2020-05-13 12:32:57 +02:00
Benno Schulenberg
e8e9b8ad82 tweaks: move an 'if', to not call leftedge_for() when not softwrapping 2020-05-13 12:01:55 +02:00
Benno Schulenberg
964771afc3 tweaks: reshuffle a condition, for symmetry 2020-05-13 11:11:24 +02:00
Benno Schulenberg
fe94999c1c tweaks: don't bother overwriting a CR -- decreasing the length is enough
The string of bytes get properly terminated by encode_data(); there is
no need to do that earlier.
2020-05-13 10:31:39 +02:00
Benno Schulenberg
56bf29409b tweaks: correct a comment, and avoid third repetition of some conditions 2020-05-12 20:53:08 +02:00
Benno Schulenberg
fcbf85887b files: never report a file as being of mixed format
A file is always in either Unix or DOS or Mac format, and should
by default be saved again in that same format.

Any lone CRs or LFs after the first line should not change the
format that was deduced from that very first line.
2020-05-12 18:55:31 +02:00
Benno Schulenberg
ac0f2c9485 files: do not let a stray CR in a DOS file trigger Mac format
Only when a CR is seen before any LF, and the CR is not followed
by a LF, should this CR be interpreted as a line separator.  And
only then the file should be reported as being in Mac format --
as long as --noconvert is not used.

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

Bug existed since at least version 2.0.6.
2020-05-12 17:25:04 +02:00
Benno Schulenberg
0a1817e893 tweaks: exclude an unneeded fragment of code from the tiny version 2020-05-12 11:09:23 +02:00
Benno Schulenberg
b18f1265ff tweaks: reshuffle a condition, to make a little more sense 2020-05-11 19:40:17 +02:00
Benno Schulenberg
2dd97a0352 tweaks: rename two variables, and reduce the scope of a third 2020-05-11 16:59:39 +02:00
Benno Schulenberg
ef4b0edd4e tweaks: rename a symbol, to better suit its purpose, and reduce its scope 2020-05-11 16:44:16 +02:00
Benno Schulenberg
b47d111a3d tweaks: don't use a symbol for other purposes 2020-05-11 16:18:03 +02:00
Benno Schulenberg
d80ecf0209 tweaks: trim some oververbose comments -- they overshadow the code
The text was harder to understand than the code itself.
2020-05-11 15:58:08 +02:00
Benno Schulenberg
ff4973458c tweaks: adjust the file format indicator in a quicker way 2020-05-11 15:32:41 +02:00
Benno Schulenberg
f9ff902bbc tweaks: drop two redundant conditions, and improve three comments 2020-05-08 11:06:43 +02:00
Benno Schulenberg
95c966c3fc tweaks: do the saving of histories in a single place
Also, when finish() is called when the user presses Cancel upon
encountering a lock file, there is no need to save any history
files because nothing has changed.
2020-05-08 11:01:37 +02:00
Benno Schulenberg
982e226c3f tweaks: elide three parameters, as they are the same for both calls 2020-05-08 10:40:03 +02:00
Benno Schulenberg
42ca89039a tweaks: improve three comments, drop one, and unwrap a line 2020-05-08 10:21:02 +02:00
Benno Schulenberg
07b48024d1 tweaks: condense a comment, and reshuffle some conditions 2020-05-07 13:34:07 +02:00
Benno Schulenberg
1c4dd79b9b files: trigger the Easter egg only when "zzy" is typed at the prompt
When the user mentions the file "zzy" on the command line,
the magic spell "Xyzzy" does not actually get typed, so the
Easter egg should then not be triggered.
2020-05-07 13:28:41 +02:00
Benno Schulenberg
56fc8f6d30 tweaks: improve a comment, reshuffle a scroll command, elide a variable
Also, drop an unneeded keyboard check: the next check is just a few
microseconds away.
2020-05-06 17:29:20 +02:00
Benno Schulenberg
ad1331527e color: when syntax coloring is toggled back on, calculate multiline data
This will not catch all cases, but at least it will precalculate the
data when syntax coloring was toggled off (M-Y) while in one buffer
and then toggled back on after having switched to a new buffer.
2020-05-01 14:08:55 +02:00
Benno Schulenberg
1bbf07b27e color: avoid allocating emptiness when there are no multiline regexes
When a file is saved under a different name, and as a result the
applicable syntax changes, and the old syntax had multiline regexes
and the new syntax doesn't, then the call of precalc_multicolorinfo()
in write_file() should not result in nano setting up a multicache of
zero bytes for each line in the buffer.

(Problem was found by locally letting nano crash when zero bytes are
allocated, and then happening to rename a file.py to a file.sh.)
2020-05-01 13:59:56 +02:00
Benno Schulenberg
b9deb883fa tweaks: shorten the name of a symbol, to match its bindable function 2020-05-01 13:25:15 +02:00
Benno Schulenberg
9c4ebed3ff tweaks: remove an unneeded element from the openfilestruct 2020-05-01 12:38:02 +02:00
Benno Schulenberg
e64e54d57f tweaks: condense a bit of code, by reusing an existing variable 2020-05-01 12:37:50 +02:00
Benno Schulenberg
d4ee6a2b53 options: rename --tempfile to --saveonexit, to be far clearer
A long option should describe what it does, not vaguely hint at it.

Also, in several places of nano's code we deal with actual temp files,
and then having a flag called TEMP_FILE that doesn't have anything to
do with temp files is somewhat confusing.
2020-04-30 19:12:54 +02:00
Benno Schulenberg
af062af490 docs: mention that doing a full-buffer operation wipes away all anchors 2020-04-30 18:58:17 +02:00
Benno Schulenberg
4bdd6013b0 anchor: do not let piping and spelling transfer an anchor to the top
Just let all anchors disappear when doing an external spell check or
formatting or piping the buffer through an external command, because
leaving just a single anchor on the top line is useless.

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

Bug existed since commit 732cf887 from one month ago.  That code
causes an anchor to persist at the point where lines are removed.
2020-04-30 16:51:22 +02:00
Benno Schulenberg
11f099e1da anchor: during full justification preserve anchors as during single ones
When a single paragraph is justified, any anchor on any of its lines
gets moved to its first line.  Let a full justification do the same
for each of the paragraphs.

This fixes https://savannah.gnu.org/bugs/?58272 in a better way.
2020-04-30 16:07:31 +02:00
Benno Schulenberg
703cebaaac anchor: do not let a full justification transfer an anchor to the top
This fixes https://savannah.gnu.org/bugs/?58272.

Bug existed since commit 732cf887 from one month ago.  That code
causes an anchor to persist at the point where lines are removed.
2020-04-29 19:34:48 +02:00
Benno Schulenberg
4710b94cfb tweaks: move a function to before the one that calls it 2020-04-29 12:22:02 +02:00
Benno Schulenberg
5ca2fd887a startup: initialize colors only when the terminal is capable of colors
This avoids trying to show colors on a vt100, for example.
2020-04-29 12:07:31 +02:00
Benno Schulenberg
d1e1438ca0 tweaks: delete some unneeded code, and rename the function accordingly
When set_colorpairs() is called, no files have been loaded yet, so
no syntaxes will have been loaded yet either.  Thus it is pointless
to run through the list of available syntaxes.
2020-04-28 16:49:45 +02:00
Benno Schulenberg
382ec84248 tweaks: rename a function, to match with the boolean that guards it 2020-04-28 16:38:27 +02:00
Benno Schulenberg
bc4240dda5 tweaks: rename a function, to better describe what it does
Its major function is to find an applicable syntax, if there is any.
And if the syntax hasn't been used before, to prime its color pairs.

Also, reshuffle a line to be able to elide an #ifdef.
2020-04-28 16:34:45 +02:00
Benno Schulenberg
b97da1dfe4 files: reinitialize the palette only when the syntax actually changed 2020-04-28 15:30:00 +02:00
Benno Schulenberg
e62a6964f7 syntax: sql: condense some regexes, and reduce their number 2020-04-26 19:32:44 +02:00
Benno Schulenberg
fd70c25d21 menus: remove unneeded words and shortenings from key labels
In "Cut Text" and "Paste Text" the word "Text" is superfluous.  (It
could even be called slightly misleading, because by default ^K will
cut the current line, whether or not it contains text.)

The "Get Help" is of course inherited from Pico, but to me it has
always sounded a bit as if it would go search help on the internet.

Instead of "Spelling" I would have preferred "Spellcheck", but that
gets a bit too cramped on an 80-column terminal.

For ^C I've chosen "Location" because I tend to understand "Position"
as a verb, especially when seen next to "Go To Line" (even when having
two items with the same meaning next to each other doesn't make sense).

"Mark Text" has simply always been wrong.  It doesn't mark anything,
but just *sets* the mark (or unsets it, but that normally happens
automatically, no need to mention that in the label).

The "Cut Till End" and "Full Justify" get shown only on very wide
terminals, and at such widths there is enough room for each label
to write out those two labels in full.
2020-04-21 19:14:28 +02:00
Benno Schulenberg
227467adb9 syntaxes: remove some superfluous outer parentheses from regexes
Also, standardize some comments, condense a few regexes, add some
word-edge anchors, and remove some superfluous backslashes.
2020-04-21 12:49:29 +02:00
Benno Schulenberg
afce41c754 syntaxes: move the rules for Fortran and Povray files down to extra/
Fortran and POV-Ray files are not found on any regular install of a
Unixy system nor in common software packages.  People who want these
syntaxes will have to make a little effort to enable them.
2020-04-21 12:11:44 +02:00
Ryan Westlund
36e22c99a1 syntax: haskell: new file -- coloring rules for Haskell programs
Adapted from the original coloring rules by Alex Taber found at:
  https://github.com/scopatz/nanorc/blob/master/haskell.nanorc

Signed-off-by: Ryan Westlund <rlwestlund@gmail.com>
2020-04-21 11:56:24 +02:00
Benno Schulenberg
dd25d807df syntaxes: remove some stuff that has been commented out for a long time 2020-04-20 19:22:39 +02:00
Benno Schulenberg
fea5d7c612 syntaxes: uniformize the initial comment 2020-04-20 19:21:56 +02:00
Benno Schulenberg
c859fd40b6 syntax: markdown: do not colorize text between two bold words as italic
Also, do not colorize the text between two stricken-through words,
do not colorize text immediately after an indented piece of code,
but do give color to a double trailing space.

Signed-off-by: Ryan Westlund <rlwestlund@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2020-04-20 13:42:00 +02:00
Benno Schulenberg
890e12fc79 docs: note Marco as the original author of the bookmarking code 2020-04-16 11:05:14 +02:00
Benno Schulenberg
ab1a5c7abb tweaks: rename two parameters, away from abbreviations 2020-04-15 17:50:59 +02:00
Benno Schulenberg
079a679431 tweaks: rename two functions, to better indicate what they do 2020-04-15 17:20:03 +02:00
Benno Schulenberg
56d1214187 syntax: move distro-specific files down to a subdirectory, syntax/extra/ 2020-04-14 19:05:41 +02:00
Benno Schulenberg
fb53ad9c3a syntax: markdown: new file -- coloring rules for Markdown files
First-draft-by: Ryan Westlund <rlwestlund@gmail.com>
2020-04-14 16:15:49 +02:00
Benno Schulenberg
5755ecdbfc options: let --afterends affect also the deleting of words (Ctrl+Delete)
It makes more sense that <Ctrl+Delete> deletes the same thing as what
<Shift+Ctrl+Right> would select.

Suggested-by: Liu Hao <lh_mouse@126.com>
2020-04-14 12:14:49 +02:00
Benno Schulenberg
bcaa1ef7f2 docs: explain how anchors work, and document their bindable functions 2020-04-13 12:20:36 +02:00
Benno Schulenberg
9bb9a747e2 feedback: indicate an anchor with a "+" in the line-number margin 2020-04-13 11:48:36 +02:00
Benno Schulenberg
e86180119e tweaks: implement the anchor routines in a different way 2020-04-13 11:35:40 +02:00
Benno Schulenberg
40053593a8 general: rename "bookmark" to "anchor", to sound less permanent 2020-04-13 11:25:29 +02:00
Benno Schulenberg
732cf88786 text: retain a bookmark when two lines are joined or something is cut
Also, do not copy the bookmark into the cutbuffer, so it will not get
pasted elsewhere.
2020-04-13 11:10:23 +02:00
Marco Diego Aurélio Mesquita
9fb0beca1d bindings: hard-bind the bookmark functions to M-Ins and M-PgUp/M-PgDn
Bind the toggling of a bookmark to <Alt+Insert>, and the jumping to the
previous and next bookmark to <Alt+PageUp> and <Alt+PageDown>, so that
these functions are available by default.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2020-04-13 10:51:40 +02:00
Marco Diego Aurélio Mesquita
f091c34bac new feature: bindable functions for toggling and jumping to "bookmarks"
With the 'bookmark' function, the user can place a bookmark on any
line in the buffer.  Multiple lines can be bookmarked in this way.
With 'prevbookmark' and 'nextbookmark', the user can then easily
return to the bookmarked lines.  The search for a bookmark wraps
around, as if start and end of buffer are connected.

[However, in this implementation, when a bookmarked line is deleted,
the bookmark is deleted too.  This is undesirable.  Also, when such
a deleted line is pasted elsewhere, the bookmark reappears with it,
and when pasted multiple times, the bookmark will be there as many
times.  This is thoroughly undesirable.  These behaviors will be
changed in a later commit.]

A bookmark is not yet visible in any way.

This fulfills https://savannah.gnu.org/bugs/?57577.
Requested-by: Ken Tyler <kent@werple.net.au>

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2020-04-13 10:51:40 +02:00
Benno Schulenberg
fd9f6e4619 syntax: mgp: drop the almost-empty MagicPoint file and syntax
It colored any word after a % sign.  But a good syntax would color
only the valid commands, and also the ones after a comma.
2020-04-12 10:40:29 +02:00
Benno Schulenberg
4f9bebddec syntax: email: rename file and syntax, away from the mistaken 'mutt'
Also, colorize lines that are multiply quoted, and email addresses,
and URLs.
2020-04-10 13:01:57 +02:00
Benno Schulenberg
edf2d8d68f docs: mention that the dedicated cursor-moving keys are not rebindable 2020-04-10 12:25:02 +02:00
Benno Schulenberg
654d694e39 tweaks: simplify the counting of characters in a section
The line after the given section is always NULL (or when it is not,
it is intended to be NULL), so always subtract 1 at the end.
2020-04-09 12:58:41 +02:00
Benno Schulenberg
19a6120dc8 tweaks: rename a function, to be more general and clearer 2020-04-09 12:27:07 +02:00
Benno Schulenberg
f4a33b868a tweaks: delete the now-unused partitioning and unpartitioning routines 2020-04-09 12:12:04 +02:00
Benno Schulenberg
cd3db5fcc4 cutting: change the implementation of cutting to not use partitioning
This has the pleasing effect of not changing the linestruct of the
succeeding line when a line is cut.

This addresses https://savannah.gnu.org/bugs/?56226.
2020-04-09 11:45:10 +02:00
Benno Schulenberg
ae5a4ecee2 cutting: overhaul the pasting routine, to not make use of partitioning
This has the pleasing effect of not changing the linestructs of the
current line nor of the line after it (if any).
2020-04-09 11:29:44 +02:00
Benno Schulenberg
fd4a5fc473 files: write out a marked region without partitioning the buffer
Use the same mechanism as when copying a marked region: temporarily
clipping the buffer.
2020-04-09 11:07:05 +02:00
Benno Schulenberg
66e64dd2d2 docs: in the sample nanorc file, refer instead of duplicating
Instead of duplicating information, just refer to 'man nanorc'.

Also reshuffle a paragraph, and add a suggestion to just select
the syntax files that will actually get used.
2020-04-09 10:27:39 +02:00
Benno Schulenberg
a0119b83ca tweaks: add two comments, and improve another 2020-04-08 11:25:02 +02:00
Benno Schulenberg
dba7a8a70a copying: do not forget to update the screen when M-6 is pressed
This fixes https://savannah.gnu.org/bugs/?58140.

Bug existed since commit f52b6cf1 from one week ago.
2020-04-08 11:04:35 +02:00
Benno Schulenberg
5c3a22dbd6 tweaks: rename a function, to be more precise, and reshuffle some things 2020-04-07 19:19:26 +02:00
Benno Schulenberg
b70510f4be docs: copy the 4.9.2 news item from the release branch 2020-04-07 14:35:42 +02:00
Benno Schulenberg
2d4bacf61d docs: stop mentioning that --wordchars overrides --wordbounds
Since the previous commit, it no longer does.  Instead, the two
interfere, and the user probably wants to use just one of them.
2020-04-06 19:07:02 +02:00
Benno Schulenberg
547de4a7bb counting: count words correctly also when --wordchars is used
It should give the same result as 'wc -w' as long as the content
of 'wordchars' does not affect the counting.

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

Bug existed since version 2.6.2, since the --wordchars option was
introduced in commit 6f12992c.
2020-04-06 11:17:43 +02:00
Benno Schulenberg
845a5973c9 counting: count words and characters without partitioning the file 2020-04-05 17:29:54 +02:00
Benno Schulenberg
6e5195f650 tweaks: invert a condition, to have two clauses in a more logical order
First the clause for the intro text and the normal lines, and then the
clause for the continuation lines (that are narrower and indented).

Also, avoid blanking the status bar when initializing the subwindows
anyway, and avoid an unneeded resfreshing call -- the bottombars()
function will take care of that.
2020-04-03 17:19:15 +02:00
Benno Schulenberg
f3624b1b87 build: fix compilation when configured with --enable-tiny 2020-04-03 17:12:28 +02:00
Benno Schulenberg
1a2c9044d7 display: blank the status bar for a copy operation, like for cut & paste
This way an earlier "Copied nothing" or other message cannot confuse
the user.
2020-04-03 16:34:27 +02:00
Benno Schulenberg
9a67d7958f undo: choose the proper x positions to place the cursor and rejoin lines
Normally, when undoing an <Enter> that created automatic indentation,
the created whitespace should be skipped when rejoining the two lines.
In other words: take the data starting from tail_x in the second line.
But when the <Enter> occurred at the end of leading whitespace, then
that whitespace has disappeared from the original line and it should
be copied back in from the second line.  That is: from x is zero.

This fixes https://savannah.gnu.org/bugs/?58108.
Reported-by: Liu Hao <lh_mouse@126.com>

Bug existed since version 4.9, commit 1961c052.
2020-04-03 11:21:24 +02:00
Benno Schulenberg
23f73cb8b3 tweaks: exit from the writing loop as soon as the last line is reached
Avoid having to decrement the count in order to offset the increment
at the end of the loop.

Also, declare a variable on a separate line, and rename it.
2020-04-01 16:05:45 +02:00
Benno Schulenberg
9f6962f3f1 tweaks: condense a comment, and express a condition in a different way 2020-04-01 15:54:08 +02:00
Benno Schulenberg
958e3ec201 feedback: show a message also when trying to copy an empty region 2020-03-31 19:44:32 +02:00
Benno Schulenberg
ce9cfdaa45 tweaks: normalize the indentation after the previous change
Also improve a comment.
2020-03-31 19:44:32 +02:00
Benno Schulenberg
56a111afa3 tweaks: fold two blocks into each other, to elide three overlapping cases 2020-03-31 19:42:22 +02:00
Benno Schulenberg
38bbdf8fc3 tweaks: change a helping variable, to make two blocks still more similar 2020-03-31 19:27:07 +02:00
Benno Schulenberg
a0e523cd4b tweaks: add a helping variable, to slightly condense the code
And to prepare for folding two blocks together.
2020-03-31 19:21:38 +02:00
Benno Schulenberg
7660849b8f tweaks: invert a condition, to see the similarity between the two modes
The two modes being: the normal full-line cutting, and --cutfromcursor.
2020-03-31 19:17:17 +02:00
Benno Schulenberg
4b814698bd copying: with --nonewlines, don't add a final newline to the cutbuffer
This fixes https://savannah.gnu.org/bugs/?58086.

Bug existed since commit f52b6cf1 from yesterday.
2020-03-31 19:12:46 +02:00
Benno Schulenberg
96046f1e82 copying: when using M-6, copy the final line in the buffer just once
When using --nonewlines and the cursor has arrived at the end of the
final line, each press of M-6 would add another copy of that line to
the cutbuffer.  That is clearly not the right behavior.

Also, give feedback when a press of M-6 does not actually copy anything.

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

The bug was old -- it existed since before version 2.2.0.
2020-03-31 17:59:21 +02:00
Benno Schulenberg
387be713c8 docs: copy the 4.9.1 news item from the release branch 2020-03-31 14:09:08 +02:00
Benno Schulenberg
d9943120ed tweaks: move two functions, to have them in a more logical order
The logical order being: cut, copy, paste.
2020-03-30 19:20:18 +02:00
Benno Schulenberg
a1907d77f8 tweaks: add a helping variable, in order to unwrap three lines
Also, move an administrative thing to after the actual operations.
2020-03-30 19:13:50 +02:00
Benno Schulenberg
f25a3f8a36 tweaks: elide three functions that are called just once
The function that they were called from has shrunk a lot,
so there is now room to write their content out in full.
2020-03-30 19:05:57 +02:00
Benno Schulenberg
9f1c3c8513 memory: plug a leak, by freeing the cutbuffer after a bracketed paste
Also, remove an unneeded assignment -- the 'cutbottom' variable is
needed only when consecutives cuts (^K) or copies (M-6) are made.
2020-03-30 16:55:38 +02:00
Benno Schulenberg
d1521c584d tweaks: elide a now-unused parameter -- it is always FALSE 2020-03-30 16:55:30 +02:00
Benno Schulenberg
f52b6cf19f copying: change the implementation, away from cutting plus copying back
First cutting the text to be copied (before copying it back into the
buffer) had unwanted side effects: it moved the cursor, and changed
the linestructs of the current line and the line where the mark was.

[This takes thirty more lines, but the idea is to later get rid of
the partitioning routines entirely.]
2020-03-30 16:55:17 +02:00
Benno Schulenberg
59040169ed tweaks: get rid of a bunch of annoying casts, and thus condense the code 2020-03-29 20:17:32 +02:00
Benno Schulenberg
8f6559828d files: make filtering of the entire buffer into a new buffer work again
This fixes https://savannah.gnu.org/bugs/?58076.

Bug existed since version 4.9, commit 477a9b33.
2020-03-29 18:04:36 +02:00
Benno Schulenberg
619962ee18 undo: when undoing a line cut, place the cursor back where it was
This fixes https://savannah.gnu.org/bugs/?58074.

Bug existed since version 4.9, commit ac612545.
2020-03-29 14:25:15 +02:00
Benno Schulenberg
7ebe44ac25 tweaks: rename a symbol, to be more accurate, and reshuffle two lines 2020-03-29 14:24:16 +02:00
Benno Schulenberg
0cc2104257 tweaks: elide a parameter, by calling the relevant function beforehand
This means that in most cases mark_is_before_cursor() is called twice:
once before get_region() is called, and once by get_region() itself.
This small duplication of effort is acceptable: the affected functions
are not time critical, and it makes the code shorter.
2020-03-29 13:22:17 +02:00
Benno Schulenberg
9a6158cd94 input: stop recognizing the raw escape sequences for F13 to F16
It is very unlikely that anyone uses those keystrokes: 1) no keyboard
has such keys; 2) the default bindings for these keys were removed a
year and a half ago, and no one complained; 3) for several years nano
did not recognize the modern xterm escape sequences for F13 to F16,
and no one ssh'ing from a new machine to an old machine complained.

The only people who might be affected by this removal are Konsole users:
a Konsole claims to be an xterm, but sends its own peculiar "Esc O 2 X"
sequences for F13 to F16.  Using the data from terminfo, ncurses will
not recognize those sequences, and will pass them untranslated to nano.
When nano now stops recognizing them too...  Well, let's see if there
are any Konsole users that use F13 to F16.
2020-03-29 12:04:37 +02:00
Benno Schulenberg
7d3aad403d options: make -S the short synonym of --softwrap
The form -$ is still accepted, but is deprecated.
2020-03-27 17:02:55 +01:00
Benno Schulenberg
aa70f3d95e options: stop recognizing the obsolete --morespace and --smooth
They have been no-ops for a year.

Also remove their documentation entries.

(The nanorc options still remain -- to be removed next year.)
2020-03-27 16:54:09 +01:00
Benno Schulenberg
ec457dc33a tweaks: rename a variable, for shortness and contrast 2020-03-27 15:29:48 +01:00
Benno Schulenberg
31b978ca3e docs: reduce the TODO file to a reference to the bug tracker on Savannah
All those items that were marked as DONE are not actually TO-DO items.

Also, most of those things are mentioned in the IMPROVEMENTS file too.
So, add the few that were missing there, and condense/rewrap some.
2020-03-26 19:27:46 +01:00
Benno Schulenberg
9a4586557b build: stop distributing a nano.spec file
We do not provide an RPM package.  And distros like Fedora, Mageia,
and Suse have their own spec files -- they don't need ours.  And in
case anyone would like to create their own RPM package from nano,
they can look at the spec files of those distros.
2020-03-26 17:08:36 +01:00
Benno Schulenberg
02c48dc8a4 tweaks: delete another pointless ChangeLog 2020-03-26 13:17:41 +01:00
Benno Schulenberg
384c9aaad3 tweaks: delete a ChangeLog that is no longer updated and is incomplete
It is incomplete at the top, in the middle, and at the bottom.

Also, the Makefile from gettext automatically includes this ChangeLog
in a release tarball when the ChangeLog exists.  This is an unneeded
burden on the tarball, as I don't think any distro installs this file
in nano's doc directory.  And if any does, I don't think they should:
it is not helpful for using nano.

If anyone would like to know more about the history of a PO file,
since we now have git, they can do something like:

        git log -p po/<LANGUAGECODE>.po |
        grep -e Revision-Date -e Last-Translator |
        grep -A1 "^\+.PO" | less
2020-03-26 13:17:21 +01:00
Benno Schulenberg
0c249de9e5 tweaks: for each version, mention the changes to the PO files last
Also, rewrap some lines, and  normalize how function names are listed,
back until version 0.9.9.
2020-03-26 12:18:22 +01:00
Benno Schulenberg
abf4658ab9 tweaks: uniformize some old translator credits
And add two of the earliest that were missing.
2020-03-25 19:37:09 +01:00
Benno Schulenberg
ba25d0df1d tweaks: fix twenty typos, in old Changelogs and in some comments
They were found by a run of 'codespell' at https://fossies.org/.

Reported-by: Jens Schleusener <Jens.Schleusener@fossies.org>
2020-03-25 16:57:43 +01:00
123 changed files with 43060 additions and 39457 deletions

11
.gitignore vendored
View File

@@ -13,6 +13,9 @@ core
.gdb_history
.gdbinit
/src/nano
/src/revision.h
/ABOUT-NLS
/INSTALL
/aclocal.m4
@@ -35,7 +38,7 @@ core
/mkinstalldirs
/stamp-h1
# gettext m4 files.
# Gettext m4 files:
/m4/codeset.m4
/m4/extern-inline.m4
/m4/fcntl-o.m4
@@ -69,13 +72,9 @@ core
/m4/wint_t.m4
/m4/xsize.m4
# gnulib entries
# Gnulib stuff:
/gnulib/
/lib/
/m4/.gitignore
/m4/gnulib-cache.m4
/snippet/
/nano.spec
/src/nano
/src/revision.h

View File

@@ -69,6 +69,7 @@ Rishabh Dave <rishabhddave@gmail.com>
Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
* Filtering text through an external command.
* Placing anchors (bookmarks) and jumping to them.
Brand Huntsman <alpha@qzx.com>
* The delayed parsing of syntax files.

638
ChangeLog
View File

@@ -1,3 +1,616 @@
Changes between v5.2 and v5.3:
------------------------------
Arturo Borrero González (1):
syntax: nftables: include author and license lines
Benno Schulenberg (92):
browser: make M-W/M-Q functional right after startup, if there is history
browser: sort names that differ only in case with uppercase first
browser: wipe the status bar before searching again with M-W or M-Q
build: abort the update script if a PO file contains a control character
build: avoid two compiler warnings when gnulib has been ripped out
build: do not accept --enable-libmagic when not having color support
build: do not let Slang translate escape sequences to key codes
build: exclude bunches of raw escape sequences from the tiny version
build: exclude --emptyline, --jumpyscrolling, and --noread from tiny nano
build: exclude excessive version information from the tiny version
build: exclude option --tabsize (-T) from the tiny version
build: exclude reading a file from standard input from the tiny version
build: exclude the three --help column headers from the tiny version
build: include some raw sequences for the graphical Debian installer
build: stop using an obsolete macro, and use 'void' for signal handlers
build: to verify wide curses, probe for a function that cannot be a macro
bump version numbers and add a news item for the 5.3 release
chars: reduce searching time with roughly 85 percent for plain ASCII
display: do not unnecessarily wipe the status bar
display: do not wipe the status bar when the terminal has just one row
display: force the cursor to reappear after a message (when using Slang)
display: force the cursor to reappear in a better way (when using Slang)
display: skip a special-case refresh when a message was written
docs: add a link to the website also to the info manual
docs: add the customary (1) after the name of command-line programs
docs: condense the descriptions of cutting and pasting
docs: explain the purpose of -! / --magic / 'set magic'
docs: explain the 'set scrollercolor' option, for coloring the indicator
docs: explain what the options --stateflags (-%) and 'set stateflags' do
docs: improve two wordings in the sample nanorc
docs: mention that syntax definitions are available in /usr/share/nano/
feedback: don't give a hint for <Bsp>, and not after an Alt+key was used
feedback: in the tiny version, let M-H show the helpful hint too
feedback: make an "Unbound key" message disappear on the next keystroke
feedback: show a helpful message for ^G even when there is no help
feedback: show helpful message for the first ^H at the top of the file
gnulib: update to its current upstream state
help: do not leave the cursor on the status bar after a search
help: do not show "^G Help" in the tiny version when there is no help
help: ensure the help lines are always drawn, also when using Slang
help: in the tiny version, show Prev/Next Word before Backward/Forward
help: nicely pair menu items also when built with just --disable-help
new feature: option --stateflags to show some states in top-right corner
options: add -? as a synonym of -h (--help), but leave it undocumented
options: move --stateflags (-%) and --magic (-!) to the end of the list
options: require --magic or 'set magic' to enable the use of libmagic
rcfile: add 'set scrollercolor', for changing the color of the indicator
suspension: do not enter an invalid byte upon resume (when using Slang)
suspension: properly resume from an external SIGSTOP
suspension: resume properly from an external SIGSTOP (when using Slang)
suspension: switch off flow control at the right moment (for Slang)
syntaxes: add author and license lines to four of the files
syntax: nanorc: stop coloring 'morespace' and 'smooth' as valid
syntax: nanorc: stop coloring 'nopauses' and 'nowrap' as valid
syntax: nanorc: stop coloring 'quiet' and 'backwards' and 'finalnewline'
syntax: po: do not leave the occasional tab with a red background color
syntax: po: highlight embedded control codes that shouldn't be there
syntax: sh: recognize some shell scripts by their Emacs modeline
tweaks: add a hint for translators
tweaks: add some comments to the C syntax, and sort some keywords
tweaks: adjust some whitespace in the docs, and improve a comment
tweaks: avoid a compiler warning when compiling with more than -O1
tweaks: condense a bit of code
tweaks: condense a bit of code after the previous change
tweaks: drop the unneeded saving and restoring of a global variable
tweaks: dummy commit, to add some info about the previous one
tweaks: elide a one-line function, after reducing it to a single call
tweaks: fold one function into another, to elide an unneeded return value
tweaks: harmonize the spelling of a compound word, and rewrap a section
tweaks: harmonize the style of error messages and warnings in ./configure
tweaks: make two of the changes that 'autoupdate' suggests
tweaks: move three functions, to before the ones that call them
tweaks: move two more functions, to before the ones that call them
tweaks: move two more functions, to before the one that calls them
tweaks: normalize the indentation after the previous change
tweaks: remove an inconsistent newline from the end of an error message
tweaks: remove an unused element from 'funcstruct', saving 8 more bytes
tweaks: remove mistaken escape sequences for function keys on xterm
tweaks: remove two stray comments and two lines that were commented out
tweaks: rename another variable, away from being misnamed
tweaks: rename four variables, reshuffle them, and correct one type
tweaks: rename two elements of history struct, away from abbreviations
tweaks: rename two variables, to be more distinct
tweaks: replace two more occurrences of 'AC_TRY_RUN' with 'AC_RUN_IFELSE'
tweaks: reshuffle a condition, to elide a blank string
tweaks: reshuffle some lines after the previous change
tweaks: reshuffle some lines and adjust indentation after previous change
tweaks: reshuffle two lines and a function name, for a consistent order
tweaks: rewrap nine more old NEWS items, for balanced line lengths
tweaks: rewrap three NEWS items, for more balanced line lengths
tweaks: stop 'autoupdate' from failing with "end of file in string"
version: remove URL and email address from the --version output
Hussam al-Homsi (5):
syntax: c: colorize also one-character constants, and the null directive
syntax: c: colorize also the keywords that start with an underscore
syntax: c: colorize also the 'restrict' keyword, and the #line directive
tweaks: reorder a member of 'funcstruct', to save 8 bytes of padding
tweaks: stop casting the return of malloc() and friends
Ryan Westlund (1):
syntax: markdown: add author and license line
Changes between v5.1 and v5.2:
------------------------------
Benno Schulenberg (30):
build: stop distributing the README.GIT file
build: stop mentioning Slang in two ./configure messages
bump version numbers and add a news item for the 5.2 release
display: restore the ability to resize the screen while searching
docs: add a cross-reference from 'findbracket' to 'set matchbrackets'
docs: adjust description of ^T in cheatsheet, and mention M-Bsp
docs: mention in the FAQ how to change the escape sequences of urxvt
docs: reshuffle the section about the file browser to a better place
gnulib: back away from a commit that causes trouble when using clang
gnulib: update to its current upstream state
history: do not interpret a failing stat() as an error
input: allow also a Meta keystroke to abort a Search command
input: dawdle after an ESC also when --rawsequences is used
input: discard any multibyte character when <Alt> is being held
input: do not enter invalid bytes when holding down both Alt keys
input: hold on to a shift-selected region when an unbound key is struck
rcfile: make sure that "bright"/"light" are prefixes, not separate words
replacing: do not try to wipe nonexistent multidata, to avoid crashing
search: poll the input stream directly, not nano's own keystroke buffer
search: retain the current answer when something is toggled
tweaks: adjust a comment, and reshuffle the setting of a boolean
tweaks: condense two declarations
tweaks: condense two fragments of code, for compactness
tweaks: elide an unneeded variable
tweaks: improve three comments and an indentation
tweaks: move the keyboard-checking code to the end of the search loop
tweaks: remove a variable and two functions that have become redundant
tweaks: rename a variable, to not seem to refer to the scrollbar
tweaks: reshuffle four declarations, and rename two variables
verbatim: reserve enough space for the result also in non-UTF-8 locales
Changes between v5.0 and v5.1:
------------------------------
Benno Schulenberg (55):
anchor: in a UTF-8 locale, show an anchor as a diamond, for visibility
anchor: show an anchor also when the line is horizontally scrolled
bindings: make <Alt+Backspace> delete a word backwards, like in Bash
build: fix compilation for --enable-tiny --enable-nanorc --enable-color
build: fix compilation when configured with --enable-tiny
build: stop distributing the two old Changelogs
bump version numbers and add a news item for the 5.1 release
display: show the cursor position also right after the screen is resized
docs: fix a closing tag in the FAQ [tidy]
docs: mention that anchors are visible when line numbers are shown
feedback: add the reason to the error message when forking fails
feedback: use three dots to indicate processing, like everywhere else
feedback: when creating a pipe fails, report also the reason
files: do not try writing to the status bar while not in curses mode
formatter: force the mark off, to not crash by accessing empty cutbuffer
gnulib: update to its current upstream state
help: list again the keystroke for toggling the help lines (M-X)
input: understand M-Bsp also when terminfo does not match the terminal
moving: make <Ctrl+Up> go to the top when above the cursor all is blank
rcfile: allow to bind M-[ (even though it is an escape-sequence starter)
softwrap: initialize the 'extrarows' value for the magic line correctly
speller: give proper feedback when the user tries to check emptiness
speller: give startup feedback (relevant when running on a Linux console)
speller: re-enter curses mode before trying to report an error
syntax: css: differentiate pseudo-classes (now cyan) from comments (blue)
syntax: default: colorize also "GNU nano 5.x"
tweaks: adjust the indentation after the previous change
tweaks: adjust the indentation after the previous change
tweaks: avoid a maybe-uninitialized-variable warning from gcc
tweaks: elide an unneeded variable, by transforming the key code directly
tweaks: elide two variables that are no longer needed, and update comment
tweaks: exclude old and mistaken "Esc O" sequences from the tiny version
tweaks: make a few more direct returns, and reshuffle another bit of code
tweaks: make a misplaced call of statusline() more obvious by crashing
tweaks: normalize the indentation after the previous change
tweaks: normalize the indentation, and regroup two lines
tweaks: optimize for byte-range characters, and shorten some comments
tweaks: parse the escape-sequence bytes without copying them first
tweaks: pass first byte of sequence directly to the decoding function
tweaks: print error message directly instead of passing it to the caller
tweaks: read keycodes from the keystroke buffer without copying them
tweaks: remove an unneeded beep, and reshuffle the lines for compactness
tweaks: reshuffle a few lines, to condense the code, and improve comment
tweaks: reshuffle four lines, for esthetics
tweaks: reshuffle some fragments, to make the next change easier
tweaks: reshuffle the zeroing of a counter, to allow some direct returns
tweaks: simplify two functions, as they now return always NULL
tweaks: split a function into two, one for "Esc O" and one for "Esc ["
tweaks: stop using a 'switch' when there are just three possibilities
verbatim: discard entire keystroke when it's not valid for Unicode Input
verbatim: do not report "Invalid code" when a Unicode character is typed
verbatim: do not report "Invalid code" when the terminal is resized
verbatim: insert the full code sequence when <Alt+Backspace> is pressed
verbatim: pause a little after an ESC, to not miss a succeeding code
verbatim: report and ignore an invalid keystroke for Unicode input
Michalis Kokologiannakis (2):
build: avoid compilation warnings by using memcpy() instead of strncpy()
files: ignore only EPERM when fchmod() or fchown() fails
Changes between v4.9 and v5.0:
------------------------------
Andreas K. Foerster (1):
syntax: ada: new file -- coloring rules for Ada 2012 files
Benno Schulenberg (374):
anchor: do not let a full justification transfer an anchor to the top
anchor: do not let piping and spelling transfer an anchor to the top
anchor: during full justification preserve anchors as during single ones
backup: do not understand ^C as "Yes" when asking whether to continue
backup: when rereading the original file fails, ask the user what to do
bindings: add mistakenly removed M-J (Full Justify) back to the main menu
bindings: add ^Z (Suspend) to the "Execute Command" menu
bindings: allow toggling the help lines at several prompts and in browser
bindings: allow typing digits on the numeric keypad by holding Shift
bindings: make ^L (Refresh) work at all the prompts too
bindings: make ^T invoke the "Execute Command" menu, and ^T^T the Speller
bindings: remove the Full-Justify function from the Search menu
bindings: stop <Alt+operator> on the keypad from entering spurious letter
bindings: stop supporting <Esc> <Esc> <numeric slash> without NumLock
build: allow compilation to succeed on curses without italic support
build: do not let --disable-speller exclude also the formatter code
build: fix compilation for --enable-tiny --enable-color --enable-nanorc
build: fix compilation when configured with --disable-color
build: fix compilation when configured with --disable-speller
build: fix compilation when configured with --enable-tiny
build: fix compilation when configured with --enable-tiny
build: fix miscompilation for --enable-{tiny,color,nanorc}
build: fix the Makefile after two header files were renamed
build: make a deeper clone of gnulib (when building from git)
build: make ./configure report which global nanorc file will be used
build: replace the non-standard backslash escape "\e" with "\x1B"
build: stop distributing a nano.spec file
build: use a more dependable method for detecting a build from git
bump version numbers and add a news item for the 5.0 release
color: avoid allocating emptiness when there are no multiline regexes
color: when syntax coloring is toggled back on, calculate multiline data
colors: move purple one step away from magenta, and use a darker mauve
copying: change the implementation, away from cutting plus copying back
copying: do not forget to update the screen when M-6 is pressed
copying: when using M-6, copy the final line in the buffer just once
copying: with --nonewlines, don't add a final newline to the cutbuffer
counting: count words and characters without partitioning the file
counting: count words correctly also when --wordchars is used
cutting: change the implementation of cutting to not use partitioning
cutting: overhaul the pasting routine, to not make use of partitioning
display: avoid an additional redrawing when redrawing the screen
display: blank the status bar for a copy operation, like for cut & paste
display: do not try to draw content when there is no open buffer yet
display: reposition the cursor after an error message also in a help text
docs: complete the renaming of 'tempfile' to 'saveonexit'
docs: copy the 4.9.1 news item from the release branch
docs: copy the 4.9.2 news item from the release branch
docs: copy the 4.9.3 news item from the release branch
docs: document the --indicator (-q) and 'set indicator' options
docs: document the new -O/--bookstyle and 'set bookstyle' options
docs: explain how anchors work, and document their bindable functions
docs: improve some descriptions concerning the file browser
docs: in the sample nanorc file, refer instead of duplicating
docs: mention that doing a full-buffer operation wipes away all anchors
docs: mention that M-X toggle is special, because available in most menus
docs: mention that the dedicated cursor-moving keys are not rebindable
docs: mention the nine new color names, and "bold" plus "italic"
docs: note Marco as the original author of the bookmarking code
docs: reduce the TODO file to a reference to the bug tracker on Savannah
docs: stop mentioning that --wordchars overrides --wordbounds
docs: use 'bold' and 'light' instead of 'bright' in the sample nanorc
feedback: beep also at a prompt when receiving an unknown escape sequence
feedback: do not list "." and ".." as possible <Tab><Tab> completions
feedback: indicate an anchor with a "+" in the line-number margin
feedback: show a message also when trying to copy an empty region
feedback: show the cursor position also at startup in an empty buffer
feedback: skip wiping the prompt bar when the shortcut printed a message
files: also when creating a backup fails, ask the user whether to proceed
files: ask the user whether to proceed every time a backup fails
files: before prompting, show also the reason why the backup failed
files: disallow tabbing when in restricted mode
files: do not append but truncate when allowing insecure backups
files: do not let a stray CR in a DOS file trigger Mac format
files: do not make a failsafe backup when in restricted mode
files: give a more precise warning when deleting an existing backup fails
files: ignore errors when calling chmod() on a backup file
files: ignore errors when calling chown() on a backup file
files: ignore errors when calling futimens() on a backup file
files: list possible completions after just one <Tab> instead of two
files: make a backup only when requested, not an unrequested failsafe one
files: make better use of the last row when there are many completions
files: make filtering of the entire buffer into a new buffer work again
files: never report a file as being of mixed format
files: reinitialize the palette only when the syntax actually changed
files: remove two superfluous calls for shielding temp files from others
files: show a warning when writing a backup fails, before prompting
files: show possible tab completions near the bottom of the edit window
files: take into account that also closing a backup file can fail
files: trigger the Easter egg only when "zzy" is typed at the prompt
files: warn the root user when all the write bits are missing
files: write out a marked region without partitioning the buffer
general: make five tools accessible through the "Execute Command" menu
general: rename "bookmark" to "anchor", to sound less permanent
gnulib: update to its current upstream state
help: describe what has been added to the "Execute Command" menu
help: pair the items in the two bottom lines better in the tiny version
help: put the two toggles first in the "Execute Command" menu
history: don't send error messages to the screen; store them in the queue
history: take into account that closing a file can fail
history: take into account that statting a file can fail too
indicator: recompute the extra rows also for cut/paste/split/join
indicator: recompute the extra rows also when justifying and resizing
indicator: rework how the "scrollbar" is computed when softwrapping
input: interpret an escape sequence only when it starts with "[" or "O"
input: reset the counters when a three-digit sequence is not completed
input: stop recognizing the raw escape sequences for F13 to F16
locking: ignore the insecure-backup flag when creating a lock file
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 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
options: let --afterends affect also the deleting of words (Ctrl+Delete)
options: make -S the short synonym of --softwrap
options: rename --tempfile to --saveonexit, to be far clearer
options: stop recognizing the obsolete --morespace and --smooth
prompt: at Yes-No, do not treat a screen resize as an invalid keystroke
rcfile: accept prefix "light" to make a color brighter without bolding it
rcfile: add bindable function 'execute', for access to "Execute Command"
rcfile: allow specifying a bright background color (with prefix "light")
rcfile: complain when an essential key binding is missing
rcfile: do not complain when "bright" is used with a background color
rcfile: introduce nine new named colors, from "pink" to "latte"
rcfile: introduce the modifier "bold", for specifying bolding separately
rcfile: introduce the modifier 'italic', for slanted text
rcfile: rename bindable function 'curpos' to 'location'
rcfile: rename 'extcmd' to 'execute', to be more readable and fitting
rcfile: report the first bad color element, not a later one that is okay
rcfile: restore terminal settings when exiting upon excessive unbindings
replacing: recalculate the multiline coloring info when needed
scrolling: add a function and a key binding to center the cursor line
speller: take into account that statting a file can fail [coverity]
startup: allow presetting case-sensitive search also in the tiny version
startup: check stdout instead of stdin when probing for a Linux console
startup: enter curses mode before reading the nanorc files
startup: initialize colors only when the terminal is capable of colors
syntax: css: color multiline comments correctly
syntax: default: colorize embedded control codes
syntax: email: rename file and syntax, away from the mistaken 'mutt'
syntax: markdown: do not colorize text between two bold words as italic
syntax: markdown: new file -- coloring rules for Markdown files
syntax: mgp: drop the almost-empty MagicPoint file and syntax
syntax: move distro-specific files down to a subdirectory, syntax/extra/
syntax: nanorc: colorize 'bright' anyway, so existing syntaxes look okay
syntax: nanorc: colorize the new named colors too, from "mint" to "mauve"
syntax: nanorc: stop colorizing 'bright', even though it's still accepted
syntax: sql: condense some regexes, and reduce their number
syntax: sql: rename the file to match the name of the syntax
syntaxes: move the rules for Fortran and Povray files down to extra/
syntaxes: remove some stuff that has been commented out for a long time
syntaxes: remove some superfluous outer parentheses from regexes
syntaxes: remove unneeded backslash escapes before quotes
syntaxes: uniformize the initial comment
tabbing: beep at the first listing, and when there are zero possibilities
tabbing: properly terminate the answer when the sole match is a folder
text: retain a bookmark when two lines are joined or something is cut
tweaks: add a condition, so that two ifs can be elided
tweaks: add a helpful message for when pkg.m4 is missing during a build
tweaks: add a helping variable, in order to unwrap three lines
tweaks: add a helping variable, to slightly condense the code
tweaks: add a symbol, in order to condense three function calls
tweaks: add four early returns for read/write errors of history files
tweaks: add four more translator hints
tweaks: add two comments, and improve another
tweaks: adjust comments and indentation after the previous change
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
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
tweaks: avoid a warning about an unused variable in the tiny version
tweaks: avoid checking a variable three times for each pass in the loop
tweaks: avoid unneeded calls of free() by reallocating the full name
tweaks: call init_pair() just once for each pair number
tweaks: call the spotlighting routines only for the relevant line
tweaks: call use_default_colors() just once for each run
tweaks: cascade the ifs properly: without increasing the indentation
tweaks: change a helping variable, to make two blocks still more similar
tweaks: change a 'switch' to 'if', to elide a dummy 'return'
tweaks: close opened files when something goes wrong [coverity]
tweaks: condense a bit of code, by reusing an existing variable
tweaks: condense a comment, and express a condition in a different way
tweaks: condense a comment, and reshuffle a few lines
tweaks: condense a comment, and reshuffle some conditions
tweaks: condense and improve some comments
tweaks: condense some cases to a single line, for more clarity
tweaks: condense the code a little further, by grouping things better
tweaks: correct a comment, and avoid third repetition of some conditions
tweaks: correct a comment, and drop a redundant (because nested) #ifdef
tweaks: correct some comments, as VT100 and such have smaller keypads
tweaks: correct two spelling mistakes [codespell]
tweaks: delete a ChangeLog that is no longer updated and is incomplete
tweaks: delete another pointless ChangeLog
tweaks: delete a now-unused function
tweaks: delete some unneeded code, and rename the function accordingly
tweaks: delete the now-unused partitioning and unpartitioning routines
tweaks: delete two functions that are never executed
tweaks: do not use 'switch' when there are just two possibilities
tweaks: do not use the string "stat()" in any of the comments
tweaks: don't bother overwriting a CR -- decreasing the length is enough
tweaks: don't bother statting the lock file before unlinking it
tweaks: don't bother using the exclusive flag when creating a lock file
tweaks: don't check for escape sequences that start with a lowercase "o"
tweaks: don't use a symbol for other purposes
tweaks: do the conversion of -1 to a specific color just once
tweaks: do the saving of histories in a single place
tweaks: drop an unneeded assignment, and reshuffle a few lines
tweaks: drop a superfluous check for a non-zero length
tweaks: drop obsolete 'nano.spec' from .gitignore file, and reshuffle
tweaks: drop two redundant conditions, and improve three comments
tweaks: drop two unneeded assignments
tweaks: drop two unneeded wnoutrefresh() calls in the spotlight routines
tweaks: elide a function that is called just once
tweaks: elide a function that is too sparse
tweaks: elide another parameter, relevant in just three menus
tweaks: elide a now-unused parameter -- it is always FALSE
tweaks: elide an unneeded call of strlen(), and copy NUL byte with string
tweaks: elide an unneeded global variable
tweaks: elide an unneeded parameter, and rename the other
tweaks: elide an unneeded variable, as there is nothing beyond '*place'
tweaks: elide an unused parameter, and rename the other and a variable
tweaks: elide a parameter, by calling the relevant function beforehand
tweaks: elide a parameter that is relevant for only one menu (Goto Dir)
tweaks: elide a redundant intermediate function
tweaks: elide a variable and be more direct, and rename another
tweaks: elide a variable, and shortcircuit a return
tweaks: elide a variable, by returning the result directly
tweaks: elide a wrapper function, by checking a precondition earlier
tweaks: elide three functions that are called just once
tweaks: elide three parameters, as they are the same for both calls
tweaks: elide two ifs for the most likely case, when defaults are allowed
tweaks: elide two redundant calls of strchr()
tweaks: exclude a bit of bracketed-paste code from the tiny version
tweaks: exclude an unneeded fragment of code from the tiny version
tweaks: exit from the writing loop as soon as the last line is reached
tweaks: fix twenty typos, in old Changelogs and in some comments
tweaks: fold translation of all modified keypad keystrokes together
tweaks: fold two blocks into each other, to elide three overlapping cases
tweaks: for each version, mention the changes to the PO files last
tweaks: get rid of a bunch of annoying casts, and thus condense the code
tweaks: group the exiting routines together, and condense the comments
tweaks: handle the double escapes directly, instead of going round again
tweaks: handle two similar things in the same way
tweaks: implement the anchor routines in a different way
tweaks: improve a comment, rename a function, and elide a parameter
tweaks: improve a comment, reshuffle a scroll command, elide a variable
tweaks: improve four comments
tweaks: improve several comments, and rewrap two lines
tweaks: improve some comments, and reshuffle an assignment
tweaks: improve some comments and whitespace, and reshuffle a few lines
tweaks: improve three comments, drop one, and unwrap a line
tweaks: improve two comments, and reshuffle some lines for conciseness
tweaks: invert a condition, to have two clauses in a more logical order
tweaks: invert a condition, to see the similarity between the two modes
tweaks: make an early return for zero matches, and rename a variable
tweaks: make an error message more accurate and reduce it to its essence
tweaks: make three hard-bindings of special keys more efficiently
tweaks: move a copyright notice to a better place, and improve it
tweaks: move a fragment of code to the one branch that needs it
tweaks: move a function to a more logical place
tweaks: move a function to before the one that calls it
tweaks: move a function to before the one that calls it
tweaks: move a function, to be in the order in which they are called
tweaks: move a function to the file where it is used the most
tweaks: move an 'if', to not call leftedge_for() when not softwrapping
tweaks: move an initialization function to before the one that calls it
tweaks: move two functions, to have them in a more logical order
tweaks: normalize the indentation after the previous change
tweaks: normalize the indentation after the previous change
tweaks: normalize the indentation after the previous change
tweaks: normalize the indentation after the previous change
tweaks: normalize the indentation after the previous change
tweaks: order three menu names in the documentation slightly better
tweaks: plug a leak, by always freeing the full filename [valgrind]
tweaks: rake a common statement to the end of the case
tweaks: recalculate the multiline info just once when doing "Replace All"
tweaks: reduce the indentation after the previous change
tweaks: remove an incorrect mention of umask() from a comment
tweaks: remove an unneeded call of wnoutrefresh()
tweaks: remove an unneeded cursor movement, and rename a variable
tweaks: remove an unneeded element from the openfilestruct
tweaks: remove a redundant cursor movement, remove a redundant condition
tweaks: remove a superfluous check on the length of the key buffer
tweaks: remove a superfluous global variable
tweaks: remove some superfluous conditions
tweaks: remove three unneeded while loops from two input routines
tweaks: remove two calls of umask() by specifying permissions directly
tweaks: remove two redundant conditions, and make a more direct return
tweaks: remove two superfluous assignments
tweaks: remove unneeded variables after the previous change
tweaks: rename a function, and move it to before the one that calls it
tweaks: rename a function, and move it to before the one that calls it
tweaks: rename a function, to be more correct
tweaks: rename a function, to be more general and clearer
tweaks: rename a function, to be more precise, and reshuffle it
tweaks: rename a function, to be more precise, and reshuffle some things
tweaks: rename a function, to better describe what it does
tweaks: rename a function, to leave the old names behind
tweaks: rename a function, to match with the boolean that guards it
tweaks: rename a function, to not shadow a variable, and elide parameter
tweaks: rename a parameter and a variable, to be more meaningful
tweaks: rename a struct element, to be shorter and preciser
tweaks: rename a symbol, and actually use it where it is needed
tweaks: rename a symbol, away from a double abbreviation
tweaks: rename a symbol, from a phrase to a noun
tweaks: rename a symbol, to be more accurate, and reshuffle two lines
tweaks: rename a symbol, to better suit its purpose, and reduce its scope
tweaks: rename a variable, and condense a comment
tweaks: rename a variable, and normalize the indentation
tweaks: rename a variable, and reduce the scope of two others
tweaks: rename a variable, for more contrast with the function name
tweaks: rename a variable, for shortness and contrast
tweaks: rename a variable, improve a comment, and reshuffle a few things
tweaks: rename a variable, to avoid overrepetition of 'backup'
tweaks: rename a variable, to better describe what it holds
tweaks: rename a variable, to better fit related ones
tweaks: rename a variable, to make more sense
tweaks: rename a variable, to not refer to a row as a "line"
tweaks: rename one of the flag symbols, to be clearer
tweaks: rename two functions and a variable, and improve two comments
tweaks: rename two functions, and rename and reshuffle a parameter
tweaks: rename two functions, to better indicate what they do
tweaks: rename two header files, to be distinct and not an abbreviation
tweaks: rename two labels, for brevity
tweaks: rename two parameters, away from abbreviations
tweaks: rename two parameters, away from an abbreviation
tweaks: rename two parameters, to be more fitting
tweaks: rename two variables, and reduce the scope of a third
tweaks: rename two variables, away from abbreviations
tweaks: rename two variables, to avoid a repetitive prefix
tweaks: rename two variables, to be shorter and without abbreviations
tweaks: reshuffle a bit of code, to elide an #ifndef
tweaks: reshuffle a condition, for symmetry
tweaks: reshuffle a condition, to avoid a repetition of code
tweaks: reshuffle a condition, to make a little more sense
tweaks: reshuffle a declaration and six calls of free(), to avoid a leak
tweaks: reshuffle a few lines, and remove a few unneeded comments
tweaks: reshuffle a few lines, for conciseness
tweaks: reshuffle a few lines, to elide an 'if' from the most common path
tweaks: reshuffle a fragment of code, to elide a 'goto'
tweaks: reshuffle an assignment, for conciseness, and rename a variable
tweaks: reshuffle and trim a comment, and remove unneeded pair of braces
tweaks: reshuffle a statement, to have major initialization in nano.c
tweaks: reshuffle some code, to avoid needlessly calling a function
tweaks: reshuffle some conditions, to straighten the logic
tweaks: reshuffle some lines, for esthetics
tweaks: reshuffle some lines, to better separate the three cases
tweaks: rewrap a few lines in old news items, for more balanced lines
tweaks: separate a symbol from its definition by two spaces
tweaks: shorten an error message, to be appropriate in all situations
tweaks: shorten the name of a symbol, to match its bindable function
tweaks: simplify an error message, by mentioning just the main point
tweaks: simplify the counting of characters in a section
tweaks: skip the conversion to multibyte for plain ASCII codes
tweaks: slightly improve a comment and the ordering of some lines
tweaks: slightly improve the grouping of shortcuts in some help texts
tweaks: three escapes is the same as either zero escapes or one escape
tweaks: trim an ASCII case, as the function is called only for UTF-8
tweaks: trim some oververbose comments -- they overshadow the code
tweaks: uniformize some old translator credits
tweaks: update a translator hint, and add another
tweaks: update three translator hints, add two, and frob three strings
tweaks: use a better symbol than 'ERR' to signify a valid hex digit
tweaks: use knowledge of Unicode to skip the general multibyte conversion
tweaks: use three switches instead of cascading ifs, for brevity
undo: choose the proper x positions to place the cursor and rejoin lines
undo: when undoing a line cut, place the cursor back where it was
usage: unabbreviate option arguments where possible
verbatim: show an error message when an invalid Unicode code is entered
verbatim: turn bracketed-paste mode off while waiting for input
Marco Diego Aurélio Mesquita (4):
bindings: hard-bind the bookmark functions to M-Ins and M-PgUp/M-PgDn
display: support the position indicator also when --softwrap is used
files: make the M-F (New Buffer) toggle non-persistent
new feature: bindable functions for toggling and jumping to "bookmarks"
Michalis Kokologiannakis (3):
files: improve the backup procedure to ensure no data is lost
tweaks: adjust some indentation after the previous change
tweaks: move the backup code to a separate function
Pedro Victor de Brito Cordeiro (1):
tweaks: make parameter names in prototypes match those in the definitions
Ryan Westlund (2):
syntax: go: highlight the chan keyword, and the special +build comment
syntax: haskell: new file -- coloring rules for Haskell programs
Changes between v4.8 and v4.9:
------------------------------
@@ -249,7 +862,7 @@ Benno Schulenberg (166):
docs: improve the description of which rc-files are read during startup
docs: mention in the FAQ that auto-indentation is suppressed when pasting
docs: mention that -D/--boldtext gets overridden by some nanorc options
docs: put the three new behaviors in a bulletted list, to catch the eye
docs: put the three new behaviors in a bulleted list, to catch the eye
docs: stop saying that 'set fill' enables hard-wrapping -- it does not
docs: use more generally available arrows in the cheatsheet
feedback: ask a clearer question when a valid lock file is encountered
@@ -374,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
@@ -636,7 +1249,7 @@ Benno Schulenberg (60):
tweaks: sort two keywords strictly alphabetically
tweaks: speed up determining the width of plain ASCII characters
tweaks: speed up the counting of the menu entries to be shown
tweaks: use a more effecient way to skip storing an empty file name
tweaks: use a more efficient way to skip storing an empty file name
tweaks: use an early return when there is no tilde
tweaks: use 'void' in prototypes of parameterless functions [coverity]
usage: mark the -J/--guidestripe option plus argument as translatable
@@ -838,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
@@ -858,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
@@ -1064,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
@@ -1402,7 +2015,7 @@ Benno Schulenberg (87):
tweaks: remove a check that was made redundant by the previous commit
tweaks: remove a now-unused parameter from four functions
tweaks: remove an unneeded check for NULL, and rename a parameter
tweaks: remove a stray file that was accidentally comitted
tweaks: remove a stray file that was accidentally committed
tweaks: remove some old debugging code
tweaks: rename a bunch of variables, to make it clearer what they contain
tweaks: rename a flag, to match the name of the option
@@ -1917,7 +2530,7 @@ Benno Schulenberg (65):
undo: when redoing, don't try to find a line number that might not exist
Brand Huntsman (1):
color: remove unneeded bright comparision to prevent duplicate pairs
color: remove unneeded bright comparison to prevent duplicate pairs
David Lawrence Ramsey (3):
docs: mention that errorcolor does have default colors
@@ -2141,7 +2754,7 @@ Benno Schulenberg (103):
docs: mention that macros work correctly only on terminal emulators
docs: remove another remark about indenting lacking undo capability
docs: update references to the nanorc files for the XDG changes
files: avoid an abortion when excuting a command in a new buffer
files: avoid an abortion when executing a command in a new buffer
gnulib: update to its current upstream state
help: don't fall back to other syntaxes if there is no nanohelp one
history: after loading the lists, mark them as unchanged
@@ -2237,7 +2850,7 @@ Brand Huntsman (3):
David Lawrence Ramsey (18):
build: add history.c to the list of files with translatable strings
display: don't cut off zero-width characters at the end of a chunk
docs: decribe the bindable functions 'recordmacro' and 'runmacro'
docs: describe the bindable functions 'recordmacro' and 'runmacro'
docs: document the more everyday names of three bindable functions
docs: remove man page reference to indent/unindent lacking undo/redo
files: don't change file format when inserting into an existing buffer
@@ -3688,3 +4301,8 @@ Mike Scalora (3):
Rishabh Dave (2):
browser: keep the same file selected when the directory contents change
browser: move all openings and closings of a directory to the same function
======================================================================
For older changes, see in https://ftp.gnu.org/gnu/nano/nano-5.0.tar.xz
======================================================================

View File

@@ -3007,7 +3007,7 @@ GNU nano 1.3.5 - 2004.11.22
- Don't change the file format when we insert another file into
the current one. (DLR)
do_insertfile()
- Simplify by reusing variables whereever possible, and add a
- Simplify by reusing variables wherever possible, and add a
parameter execute to indicate whether or not to be in "Execute
Command" mode. (DLR)
- Rework so that goto is no longer needed, using do_writeout()
@@ -5035,7 +5035,7 @@ GNU nano 1.1.99pre2 - 2003.02.03
- Fix the mouse code to work with lines longer than COLS and
with the proper positioning, including special characters.
(David Benbennick)
do_preserve_msg():
do_preserve_msg()
- Unsplit error message into a single fprintf call. (Jordi)
main()
- Call load_file with arg 0 for insert, as we aren't really
@@ -5143,7 +5143,7 @@ GNU nano 1.1.99pre1 - 2003.01.17
- Added --enable-all option to compile in all the extra stuff
we'd normally need extra flags for.
- color.c:
update_color():
update_color()
- Remove an unneeded edit_refresh() call after do_colorinit().
(David Benbennick)
- cut.c:
@@ -5778,7 +5778,7 @@ GNU nano 1.1.10 - 2002.07.25
Also, pass current_x_find to strstrwrapper() so we know whether
we're at the beginning of a string or not (see changes to
strstrwrapper() below), and reset it between lines. (DLR)
do_gotoline():
do_gotoline()
- Make sure placewewant is zero after we go to a line. (David
Benbennick)
do_gotopos()
@@ -6036,7 +6036,7 @@ GNU nano 1.1.8 - 2002.03.30
- Catalan and Spanish translation updates. (Jordi)
- Typo. (DLR)
- po/fr.po:
- French translation updates (Jean-Philippe Guérard).
- French translation updates. (Jean-Philippe Guérard)
- po/gl.po:
- Galician translation updates. (Jacobo Tarrio)
- po/uk.po, po/ru.po:
@@ -6156,10 +6156,9 @@ GNU nano 1.1.7 - 2002.03.05
- po/it.po:
- Italian translation updates. (Marco Colombo)
- po/cs.po:
- Partial Czech translation updates. (Vaclav Haisman)
- Partial Czech translation updates. (Václav Haisman)
- po/hu.po:
- Hungarian translation updates, or to be precise, rewrite.
(Gergely Nagy)
- Hungarian translation updates, or to be precise, rewrite. (Gergely Nagy)
- po/uk.po, po/ru.po:
- Russian and Ukrainian translation updates. (Sergey A. Ribalchenko)
- po/da.po:
@@ -6268,7 +6267,7 @@ nano-1.1.6 - 2002.01.25
- po/nn.po:
- Norwegian nynorsk translation updates. (Kjetil Torgrim Homme)
- po/nb.po:
- New Norwegian bokmål translation. (Stig E Sandoe <stig@ii.uib.no>)
- New Norwegian bokmål translation, by Stig E Sandoe <stig@ii.uib.no>.
- po/da.po:
- Danish translation update. (Keld Simonsen)
@@ -6380,8 +6379,10 @@ nano-1.1.4 - 2001.12.11
do_wrap()
- Many fixes. (David Lawrence Ramsey)
do_spell()
- Dont prompt for replace if we don't change the word in
- Don't prompt for replace if we don't change the word in
question. (Rocco Corsi)
- m4/gettext.m4:
- diff against mutt 1.2.5's gettext.m4.
- po/de.po:
- German translation updates. (Karl Eichwalder)
- po/ru.po:
@@ -6394,8 +6395,6 @@ nano-1.1.4 - 2001.12.11
- Spanish translation updates. (Jordi)
- po/fr.po:
- French translation updates. (Michel Robitaille)
- m4/gettext.m4:
- diff against mutt 1.2.5's gettext.m4.
nano-1.1.3 - 2001.10.26
- General
@@ -6770,7 +6769,7 @@ nano-1.1.0 - 2001.07.15
- po/es.po, po/ca.po:
- Updated. (Jordi)
- po/gl.po:
- Galician translation by Jacobo Tarrío.
- New Galician translation, by Jacobo Tarrío <jtarrio@trasno.net>.
- po/uk.po, po/ru.po:
- New Ukrainian and Russian translations by Sergey A. Ribalchenko
<fisher@obu.ck.ua>, thanks!
@@ -6779,9 +6778,9 @@ nano-1.1.0 - 2001.07.15
- po/it.po
- Updated Italian translation by Marco Colombo.
- po/no.po:
- New Norwegian translation by Eivind Kjørstad <ekj@vestdata.no>.
- New Norwegian translation, by Eivind Kjørstad <ekj@vestdata.no>.
- po/sv.po:
- New Swedish translation by Christian Rose <menthos@menthos.com>.
- New Swedish translation, by Christian Rose <menthos@menthos.com>.
nano 1.0.1 - 2001.04.06
- General:
@@ -6825,15 +6824,15 @@ nano-1.0.0 - 2001.03.22
the "new" C++ reserved word, even though there is likely no way
nano will EVER be compilable with a C++ compiler. (suggested by
Rocco Corsi).
- ca.po, es.po:
- Final tweaks for Nano 1.0.
- cs.po:
- Czech translation from Vaclav Haisman.
- nano.info:
- Added dir entry. (Albert Chin)
- winio.c:
statusq()
- Added NANO_BACK_KEY and NANO_FORWARD_KEY cases for left and right.
- ca.po, es.po:
- Final tweaks for Nano 1.0.
- cs.po:
- New Czech translation, by Václav Haisman <V.Haisman@sh.cvut.cz>.
1.0-test prerelease - 2001.03.17
- nano.c:
@@ -6847,7 +6846,7 @@ nano-1.0.0 - 2001.03.22
edit update. Fixes bug #57.
- search.c:
print_replaced()
- s/occurence/occurrence typos. (Jordi)
- Fix typos in "occurrence". (Jordi)
search_init()
- If using Pico mode and regex and same answer is entered, use
last_search string instead of answer. Fixes bug #56.
@@ -6888,13 +6887,13 @@ nano-0.9.99pre3 - 2001.02.19
- fi.po:
- Translation updates by Pauli Virtanen.
- hu.po:
- Hungarian translation by Horvath Szabolcs.
- New Hungarian translation, by Horvath Szabolcs <horvaths@penguinpowered.com>.
- id.po:
- Translation updates by Tedi Heriyanto.
- es.po:
- Translation updates and grammatical/typo fixes. (Jordi)
- ca.po:
- Catalan translation by Jordi Mallach :)
- Catalan translation by Jordi Mallach. :)
- Miquel Vidal <miquel@sindominio.net> went over it and corrected
many typos and completed bits that remained untranslated by error.
@@ -6998,7 +6997,6 @@ General
repeated string defs and globals.
do_justify()
- Small fix for totsize calculation. (Rob)
- fi.po:
- Update by Pauli Virtanen.
@@ -7395,7 +7393,7 @@ nano 0.9.18 - 2000.09.18
- es.po:
- Translated new strings and minor updates. (Jordi)
- de.po
- Revised translations by <floki@bigfoot.com>.
- Revised translations by Florian König.
nano-0.9.17 - 2000.09.04
- General
@@ -7426,7 +7424,7 @@ nano-0.9.17 - 2000.09.04
do_toggle()
- Added checks for no help and no wrap mode, and print opposite
enable/disable message.
do_suspend(), do_cont():
do_suspend(), do_cont()
- New functions, handle suspend signal in a Pico-like manner and
work with Meta-Z.
- winio.c:
@@ -7447,7 +7445,7 @@ nano-0.9.17 - 2000.09.04
search_abort()
- Now calls edit_refresh_clearok when MARK_ISSET to handle screen
ugliness bug (reported by Ken Tyler).
findnextstr():
findnextstr()
- Added reset for placewewant. (Ben Roberts)
- Fixed check for string that only occurs on the same line failing
(bug discovered by Ken Tyler).
@@ -7532,10 +7530,10 @@ nano-0.9.14 - 2000.07.27
- Changed check for filename to filename[0]. Added some code,
overall fixes bug #30 =-)
- nano.c:
do_justify() & do_wrap():
do_justify(), do_wrap()
- totsize-related fixes. (Rob)
- de.po
- Revised translations by floki@bigfoot.com
- Revised translations by Florian König.
nano-0.9.13 - 2000.07.23
- Implemented Pico's -k mode. New flag CUT_TO_END, option (-k, --cut),
@@ -7548,32 +7546,32 @@ nano-0.9.13 - 2000.07.23
- Don't edit_refresh() if the bottom of the file is in the edit
buffer. (Adam)
- nano.c:
main():
main()
- TABSIZE now set before first call to edit_refresh. (Bill Soudan)
- Different ^C kill code (patch by Christian Weisgerber).
die():
die()
- More intelligent emergency-save filename selection. (Rob)
do_spell():
do_spell()
- Changed exit semantics a bit so that aspell wouldn't get
all screwy (bug discovered by Joshua Jensen).
- files.c:
read_file():
read_file()
- Added init of buf variable, hopefully this will stop the
"bleeding" of text seen with mutt and using i18n.
write_file():
write_file()
- Added code to check to see if using -l and the file is not
in fact a link. This should fix the behavior where a file
that does not have write permission but could be removed and
rewritten is saved without error. Please test this feature
and give feedback.
- search.c:
search_init():
search_init()
- Added " (to replace)" statement to end of search string if
we are doing a replace. Manually converted all the translations
from '%s' to '%s%s' to ensure they still work with the new code.
Also put in the translation for " (replace)" in the .po's. Hope
I didn't step on your toes doing this Jordi. (Chris)
do_search(), do_replace():
do_search(), do_replace()
- Removed call to search_abort()/replace_abort() before call to
the opposite function.
- Fixed bug #28.
@@ -7612,52 +7610,47 @@ nano-0.9.12 - 2000.07.07
- Corrected FIXME in do_enter with explanation. (Rob)
- Fixed FIXME in do_justify, resulted in creation of
fix_editbot [also fixed in do_enter] (winio.c). (Rob)
help_init():
help_init()
- Moved newline out of if statement. (Rocco Corsi)
do_char():
do_char()
- Magic Line related code in do_char. (Rob)
do_backspace(), do_delete():
do_backspace(), do_delete()
- Added magic line code here too.
- de.po:
- Revised translations by floki@bigfoot.com.
- fi.po:
- Finnish translation by pauli.virtanen@saunalahti.fi.
- utils.c:
- Added new_magicline()
- winio.c:
- Added stdlib.h to includes, found by OpenBSD gcc.
- lots of new commenting around display functions
do_yesno(), nanogetstr():
do_yesno(), nanogetstr()
- Removed now unnecessary raw/cbreak combos.
- Removed gettext calls from "Y(es)", "N(o)", "A(ll)" and "^C", till
we decide if those keybindings should be translated. (Jordi)
clear_bottomwin():
clear_bottomwin()
- Removed wrefresh(edit) call.
edit_update_top():
edit_update_top()
- Fixed a bug that caused nano to not update when
current->next == NULL (e.g. paging down to the very bottom of
ABOUT NLS wouldn't work).
fix_editbot:
fix_editbot()
- Added (should rebuild editbot from a valid edittop). (Rob)
edit_add:
edit_add()
- removal of redundant call to mvwaddnstr.
- de.po:
- Revised translations by Florian König.
- fi.po:
- New Finnish translation, by Pauli Virtanen <pauli.virtanen@saunalahti.fi>.
nano-0.9.11 - 2000.06.20
- New flag "-T" or "--tabsize" to specify how to display tab widths.
Affects main() in nano.c, strlenpt(), xpt() and actual_x() (et al) in
winio.c, and nano.h. Many hardcoded "8"s have been changed to the
TABSIZE int. Added changes to nano.1 and nano.1.html.
- id.po:
- Indonesian translation by Tedi Heriyanto.
- es.po:
- Updated translation. (Jordi Mallach)
- winio.c
- Rewrite of display functions to correct the display problems
we had been seeing. Affects: add_marked_sameline, edit_add,
and many others. (Rob Siemborski)
- totsize fixes. (Rob Siemborski)
total_refresh():
total_refresh()
- Cut display_main_list call, as this function is only supposed to
refresh what's already on the screen, not go through the process
of adding the text again.
@@ -7669,12 +7662,12 @@ nano-0.9.11 - 2000.06.20
Changed all calls to editwinrows - 1 in nano.c and move.c.
- Removed all functions that were split into other files.
Affects LOTS of funcs.
do_enter():
do_enter()
- Added reset of placewewant to end.
do_insertfile():
do_insertfile()
- Fix display problem when using Ctrl-R to load a file
into the buffer. (Rob Siemborski)
handle_sigwinch():
handle_sigwinch()
- Added titlebar(), edit_refresh() and display_main_list() calls
because a resize wasn't picking up on possible different width
correctly.
@@ -7689,17 +7682,21 @@ nano-0.9.11 - 2000.06.20
- search.c:
- Contains all our searching and related functions, (do_search(),
findnextstr(), do_replace(), do_gotoline()).
- id.po:
- New Indonesian translation, by Tedi Heriyanto <tedi_h@gmx.net>.
- es.po:
- Updated translation. (Jordi Mallach)
nano-0.9.10 - 2000.06.04
- es.po:
- Translation updates. (Jordi)
- AUTHORS, nano.1.html, TODO, README:
- Documentation and email address updates. (Jordi)
- nano.c:
main():
main()
- Moved Adam's termio code down to after getopt() and before initscr()
to stop people losing their SIGINT character when using args that
exit nano before it runs (--version, --help, etc).
- es.po:
- Translation updates. (Jordi)
nano-0.9.9 - 2000.05.31
- Makefile.am:
@@ -7708,8 +7705,6 @@ nano-0.9.9 - 2000.05.31
- Spelling fixes. (Jordi Mallach)
- Removed CFLAGS changes for gcc, reduces portability according to
some, and it certainly doesn't seem to decrease exe size.
- es.po:
- Spanish translation updates. (Jordi Mallach)
- POTFILES.in:
- Added global.c file, was screwing up translations (i.e. they
weren't getting done).
@@ -7747,6 +7742,8 @@ nano-0.9.9 - 2000.05.31
- winio.c:
total_refresh():
- Completely rewrote function, not quite so brain-damaged now.
- es.po:
- Spanish translation updates. (Jordi Mallach)
nano-0.9.8 - 2000.05.18
- nano.c:
@@ -7768,7 +7765,7 @@ nano-0.9.8 - 2000.05.18
should now only be called once, at the bottom of the main()
loop.
- global.c:
shortcut_init():
shortcut_init():
- Removed suspend sc_init call and suspend message because suspend
is no longer needed in the shortcut list to work properly.
@@ -7787,7 +7784,6 @@ nano-0.9.7 - 2000.05.14
display update (bug discovered by Ken Tyler).
nano-0.9.6 - 2000.05.08
- New Italian translation (it.po), by Daniele Medri.
- nano.c:
page_up(), page_down():
- Added reset of placewewant to 0, as it should be.
@@ -7806,6 +7802,12 @@ nano-0.9.6 - 2000.05.08
- Removed yucky code that didn't work, this function now just
computes edittop and editbot and calls edit_refresh() to do the
rest, which removes a lot of duplicate code...
- it.po:
- New Italian translation, by Daniele Medri <madrid@linux.it>.
- fr.po:
- New French translation, by Pierre Tane <tanep@bigfoot.com>.
- de.po:
- New German translation, by Florian König <floki@bigfoot.com>.
nano-0.9.5 - 2000.05.01
- Removed bytes from file struct because it was computationally wasteful.
@@ -7831,25 +7833,23 @@ nano-0.9.5 - 2000.05.01
- Removed inefficient call to edit_refresh() after every keystroke.
It is now up each function to leave the screen in a good state.
- winio.c:
do_cursorpos()
do_cursorpos():
- Rewritten to not use bytes from filestruct by an incremental sum.
update_line(), reset_cursor():
- Optimized calls to xplustabs() through a single variable.
- update_line() now takes a new arg, an index into the string
for where to update the line from. Needed for new update
code.
for where to update the line from. Needed for new update code.
- configure.in:
- Better checks for slang, allows argument to --with-slang.
(Albert Chin-A-Young)
- Removed -Iintl from CFLAGS in gcc check.
- Makefile.am:
- Addition of -Iintl for gettext (Albert Chin-A-Young)
- Addition of -Iintl for gettext. (Albert Chin-A-Young)
nano-0.9.4 - 2000.04.25
- Fixed calls to no_help and changed them to the more consistent
ISSET(NO_HELP). Fixed return val of no_help to be what it should (2,
not 1. Code to temporarily disable NO_HELP when in the
help system. (Adam Rogoyski)
- Fixed calls to no_help and changed them to the more consistent ISSET(NO_HELP).
Fixed return val of no_help to be what it should (2, not 1). Code to
temporarily disable NO_HELP when in the help system. (Adam Rogoyski)
- cut.c:
do_marked_cut(), do_cut(), do_uncut():
- Commented out unnecessary bits when NANO_SMALL is being used.
@@ -7985,23 +7985,26 @@ nano-0.8.8 - 2000.03.12
support i18n.
- nano.c:
includes: Added sys/param.h and limits.h. (Adam Rogoyski).
statics: Changed some things that were not necessarily static
(Adam Rogoyski).
nrealloc(): New function, similar to nmalloc(). Changed calls from
statics: Changed some things that were not necessarily static.
(Adam Rogoyski)
nrealloc():
New function, similar to nmalloc(). Changed calls from
realloc() to nrealloc. (Adam Rogoyski)
empty_line(), no_spaces(), justify_format(), do_justify():
New functions for justify function. (Adam Rogoyski)
- winio.c:
blank_edit(): Added wrefresh call to edit so that screen updates (like
on ^L) actually work.
xplustabs(), xpt(), strlenpt(): Fixed off-by-one buglets. (Adam Rogoyski)
blank_edit():
Added wrefresh call to edit so that screen updates (like on ^L)
actually work.
xplustabs(), xpt(), strlenpt():
Fixed off-by-one buglets. (Adam Rogoyski)
nano-0.8.7 - 2000.03.01
- main.c:
do_wrap(): Better fix for segfaults, and fix for lines being wrapped
to a single character on one line when no good place to
break the line exists, and for wrapping lines longer than
COLS.
do_wrap():
Better fix for segfaults, and fix for lines being wrapped
to a single character on one line when no good place to break
the line exists, and for wrapping lines longer than COLS.
- nano.1.html:
Html version of man page, now included in dist. For
the benefit of nano packages in Linux distributions.
@@ -8024,7 +8027,8 @@ nano-0.8.6 - 2000.02.24
nano-0.8.5 - 2000.02.18
- nano.c:
main(): Finally fixed tilde being input on page up/down keys in
main():
Finally fixed tilde being input on page up/down keys in
certain terminal types. Fix was input 26->91->5[34] check
for 126, if so make the kbinput PAGE UP/DOWN, else unget
the keystroke and continue. Added #include <ioctl.h> for
@@ -8038,7 +8042,7 @@ nano-0.8.5 - 2000.02.18
edit_refresh() is now unmanageably complex, and must be
revamped.
check_statblank():
Added check for constupdate, makes things less choppy
Added check for constupdate, makes things less choppy.
(Adam Rogoyski)
nano-0.8.4 - 2000.02.11
@@ -8049,7 +8053,8 @@ nano-0.8.4 - 2000.02.11
Removed redundant NANO_CONTROL_H from backspace shortcut,
added char 127 which should have been there.
- nano.c:
main(): Fix for loops looping until MAIN_LEN, added -1 to stop
main():
Fix for loops looping until MAIN_LEN, added -1 to stop
segfaults. (Adam Rogoyski)
- Makefile.am: Added all source filenames. (Adam Rogoyski)
- nano.1: Fixed mail addressed and added mailing list address.
@@ -8057,13 +8062,15 @@ nano-0.8.4 - 2000.02.11
nano-0.8.3 - 2000.02.08
- New Pico mode (-p, --pico), toggles (more) compatibility with the
Pico messages displayed in the shortcut list. Note that there are still
small differences in this mode.
- nano.h: New shortcut struct format, for the benefit of i18n and
Pico messages displayed in the shortcut list. Note that there are
still small differences in this mode.
- nano.h:
New shortcut struct format, for the benefit of i18n and
our help menu. Removed shortcut message macros, they are
now all in shortcut_init in global.c.
- nano.c:
do_wrap(): Removed resetting of current_x when we are in fact
do_wrap():
Removed resetting of current_x when we are in fact
wrapping to the next line, fixes a bug in -i mode.
do_enter():
Rewrote the autoindent mode code to be a lot less pretty,
@@ -8116,7 +8123,8 @@ nano-0.8.1 - 2000.01.28
global variable fill, affects check_wrap(), do_wrap(), main(), usage(),
global.c and proto.h.
- nano.c:
write_file(): Added (incredibly) necessary check for EPERM when
write_file():
Added (incredibly) necessary check for EPERM when
link() fails. This allows us to actually save
files via rename() on filesystems that don't
support hard links (AIEEEEEE).
@@ -8136,7 +8144,7 @@ nano-0.8.0 - 2000.01.25
- View flag (-v, --view) implemented. Global variable view_mode, affects
main loop of nano.c and new_file(). (Chris)
- nano.c:
split checks for TERMIOS_H and TERMIO_H up so we
Split checks for TERMIOS_H and TERMIO_H up so we
can (theoretically) include them both, which is good.
handle_sigwinch():
Added check for ncurses.h. (Andy Kahn)
@@ -8254,7 +8262,6 @@ nano 0.7.6 - 2000.01.15
than one huge buffer, and replaced the strcat at the end
with an index variable. Added call to read_bytes().
do_next_word(): New function, binding is Ctrl-Space (0). (Chris)
- winio.c:
bottombars(): Fixed non-expanding shortcut keys at bottom of screen.
(formula is extra space needed = COLS / 6 - 13).

View File

@@ -330,7 +330,7 @@ GNU nano 2.5.2 - 2016.02.12
2016-02-09 Benno Schulenberg <bensberg@justemail.net>
* src/files.c (stat_with_alloc, open_buffer, write_file): Check the
result of a stat() to avoid referencing unitialized data. Original
result of a stat() to avoid referencing uninitialized data. Original
patch was by Kamil Dudka.
* doc/man/{nano.1,rnano.1,nanorc.5}: Adjust version for release.
@@ -661,7 +661,7 @@ GNU nano 2.5.0 - 2015.12.05
This addresses Debian bug #805288.
2015-12-01 Benno Schulenberg <bensberg@justemail.net>
* src/files.c (do_insertfile): Mark the buffer as mofified only when
* src/files.c (do_insertfile): Mark the buffer as modified only when
actually something was inserted. This fixes Savannah bug #45409.
* src/files.c (do_insertfile): Rename two variables for clarity.
* src/text.c (redo_cut): Delete two redundant assignments.
@@ -1305,7 +1305,7 @@ GNU nano 2.4.2 - 2015.07.05
* src/text.c (do_alt_speller, do_linter, do_formatter): Distinguish
a failure to launch the linter from receiving zero parsable lines;
add a new function to glue together the invocation-error string.
* src/global.c (shortcut_init): In the Help Viewer and File Browswer,
* src/global.c (shortcut_init): In the Help Viewer and File Browser,
bind the unbound Home and End keys to goto_top and goto_bottom, to
mimic the behaviour of these keys in file viewers and web browsers.
Also show ^Y and ^V in the WhereisFile menu instead of M-\ and M-/,
@@ -2005,7 +2005,7 @@ GNU nano 2.3.4 - 2014.06.02
2014-06-02 Chris Allegretta <chrisa@asty.org>
* doc/syntax/default.nanorc: Can't do trailing spaces in the
default syntax or it will hilight the spaces as you type them
default syntax or it will highlight the spaces as you type them
into a new file, which for non-programming is infuriating.
2014-05-29 Mark Majeres <mark@engine12.com>
@@ -3455,7 +3455,7 @@ GNU nano 2.1.8 - 2009.02.07
multi-line regexes but this may not be enough to increase performance.
* Add interruptability to search functions. New functions enable_nodelay and
disable_nodelay and changes to the routines to handle checking for pending
searches. Fixes Savannah bug #24946: Need interrrupt for search.
searches. Fixes Savannah bug #24946: Need interrupt for search.
2009-01-19 Chris Allegretta <chrisa@asty.org>
* Change function definitions to shorts instead of (void *)s. New mapping function
@@ -3494,7 +3494,7 @@ GNU nano 2.1.6 - 2008.10.03
* ocaml.nanorc: Sample OCaml syntax highlighting file.
2008-09-30 Dave Geering <dgeering@toshiba-tap.com>
* objc.nanorc: Sample Objective-C syntax hightlighting file.
* objc.nanorc: Sample Objective-C syntax highlighting file.
2008-09-30 Chris Allegretta <chrisa@asty.org>
* configure.ac: Change extra, multibuffer, color and rcfile configure options
@@ -3648,7 +3648,7 @@ GNU nano 2.1.1 - 2008.04.01
* gentoo.nanorc: Gentoo syntax highlighting config.
2008-03-17 Benno Schulenberg <bensberg@justemail.net>
* global.c: Fix incorrect first line jump messsage, fix
* global.c: Fix incorrect first line jump message, fix
more comments to assist translators.
* winio.c: Fix shortcut labels not being translated.

View File

@@ -1,6 +1,16 @@
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.
- Toggling help lines (M-X) and Refresh (^L) work nearly everywhere.
- Colors can be modified with the attributes "bold," and/or "italic,".
- Nine new color names: from pink and purple to orange and latte.
Since 4.0:
- Pasting from outside into nano suppresses auto-indentation.
- Such an external paste can be undone with a single M-U.
@@ -28,7 +38,7 @@ Since 2.9.0:
- Option 'set afterends' for making Ctrl+Right stop at word ends.
- A crash handler that saves changed buffers in case of a crash.
- Addition of the color name "normal", meaning the default color.
- A key can be bound to a string -- any mix of text and commands.
- A key can be bound to a string -- any mix of text and control codes.
- Error messages are shown by default in bright white on red.
- <Tab> and <Shift+Tab> can be used to indent/unindent a marked region.
- Can snip trailing whitespace while typing, with 'set trimblanks'.
@@ -92,25 +102,19 @@ Since 2.3.0:
- The option 'positionlog' for saving/restoring the cursor position.
- The ability to read and write vim-style lock files.
Visible changes since 2.0
-------------------------
* Editor Features
- The ability to rebind (reassign) keys using the nanorc.
Since 2.0.0:
- The ability to rebind keys, via a nanorc file.
- The ability to read standard input like a pager ("nano -").
- Color syntax highlighting can be set by the first line of a file.
- The ability to silence nanorc error messages (-q).
- Undo/redo operations (-u).
- Undo/redo operations (M-U/M-E, enabled with -u).
- Soft wrapping of text (-$).
* File Handling
- Better handling of backup files: if nano can't write a backup file,
it won't try to write the original file afterward.
- Emergency savefiles retain ownerships and permissions when possible.
- Performance improvements in color syntax highlighting.
Visible changes since 1.2
-------------------------
* Editor Features
Since 1.2.0:
- Support for UTF-8.
- Moving to a specified line and column of a file, instead of just a
line (+LINE,COLUMN).
@@ -119,7 +123,7 @@ Visible changes since 1.2
- Insertion of spaces instead of a tab when Tab is pressed (-E).
- The long option for -K is now --rebindkeypad.
- Regular expression searching can now be toggled when nano is built
with --enable-tiny, so -R now means something else (see below).
with --enable-tiny, so -R now means something else (see next item).
- Restricted mode that provides more security than -o (-R).
- Blanking of the statusbar after 1 keystroke instead of 25 (-U).
- Word searches can optionally skip over punctuation (-W).
@@ -127,70 +131,58 @@ Visible changes since 1.2
- Many more options are supported in the nanorc.
- Improvements to color syntax highlighting support: case insensitive
matching, the ability to include color syntaxes in separate files,
the ability to specify background colors without foreground colors,
etc.
the ability to specify background colors without foreground colors...
- Insertion of single-byte characters via Esc Esc <000-255>.
- Insertion of all characters via "Verbatim Input" mode.
- Insertion of any character via Meta-V, "Verbatim Input".
- Workaround for the "NumLock glitch".
- Meta-W now repeats the last search. Wrapping is now toggled via
Meta-L.
- Meta-W now repeats the last search. Wrapping is toggled via Meta-L.
- Replacing and spell checking only selected text.
- Indenting lines with one keystroke.
- Copying text into the cutbuffer without cutting it.
- Scrolling the text up and down single lines without moving the
cursor.
- Scrolling the text up and down single lines without moving the cursor.
- PageUp and PageDown work more smoothly when using -S.
- Scrolling the help text up and down single lines.
- Cutting all text from the current position to the end of the file
with one keystroke.
- Justifying the entire file with one keystroke.
with one keystroke (Meta-T).
- Justifying the entire file with one keystroke (Meta-J).
- Justifying without removing spaces from the ends of lines.
- Unjustifying after justifying and immediately resizing.
- Going to the first or last line of the current paragraph.
- Going to the first or last line of the file without having to go to
the "Search" prompt.
- Searching for filenames in the file browser.
- Displaying spaces and tabs differently to make it easier to tell
them apart.
- Many more functions available at the statusbar prompt: moving to the
next or previous word, searching for matching brackets, "Verbatim
Input" mode, etc.
- The glibc 2.2.3 crashes involving extended regular expressions are
no longer worked around, as they can break anything using extended
regular expressions, and glibc 2.2.3 is old. You should upgrade to
at least glibc 2.2.4.
* File Handling
- Spaces and tabs are shown differently to make it easier to tell them apart.
- Many more functions are available at the prompt: moving to the next or
previous word, searching for matching brackets, "Verbatim Input"...
- "To Line" (^W^T) and "Read from Command" (^R^X) return to their parent
menu when their keystroke is entered again (^W^T^T and ^R^X^X).
- Automatic adding of newlines to the ends of files without them can
now be disabled (-L).
- Converting from and to DOS/Mac file format is now toggled only at
the "Write File" prompt, via Meta-D and Meta-M, and the default file
format to save in is now set depending on what format the file was
originally in. -D now makes nano use bold text instead of reverse
video text, and Meta-D at the edit window now does a
word/line/character count. -O now makes the unused second line of
the screen part of the edit window, and Meta-O at the edit window
now toggles this behavior.
- Converting from and to DOS/Mac file format is now toggled only at the
"Write File" prompt, via Meta-D and Meta-M, and the default file format
to save in is now set depending on what format the file was originally
in. -D now makes nano use bold text instead of reverse video text,
and Meta-D at the edit window now does a word/line/character count.
-O now makes the unused second line of the screen part of the edit
window, and Meta-O now toggles this behavior while editing.
- Converting files that contain a mix of DOS and Mac format lines.
- Automatic switching on of -N with binary files has been removed, as
it causes problems with UTF-8 support.
Visible changes since 1.0
-------------------------
* Editor Features
- Complete Pico compatibility (--pico has been removed, and -p means
something else, see below).
- nanorc support (see nanorc.sample included in sources).
Since 1.0
- Complete Pico compatibility (option --pico has been removed,
and -p now means something else, see below).
- Support for nanorc files.
- Smooth scrolling (-S).
- Support for searching for matching braces, brackets, etc.
- Jumping to the matching brace, bracket, etc.
- Help for all editor features.
- Color syntax highlighting support.
- Quote string support, useful for mail agents, etc. (-Q).
- Insertion of output of external commands.
- Optional enabling of XON and XOFF control characters (-p).
- Tons of bugfixes/enhancements for already existing features.
* File Handling
- Option -o (--operatingdir) implements a chroot of sorts.
- Mouse support (-m) also allows clicking on shortcuts.
- Option -r allows a negative argument.
- Overwriting and appending or prepending to files.
- Writing marked text to separate files.
- Multiple file buffers (-F).
@@ -199,4 +191,12 @@ Visible changes since 1.0
- Creation of backup files (-B).
- Search/replace history (-H).
See the nano manual for detailed information on each feature.
Available in 1.0:
- Spell checking (^T).
- Justification (^J) and unjustification (^U).
- Internationalization (more translations are welcome).
- Help texts (^G).
- Resizing in X.
- On PageUp/Down, the cursor is put on the first screen line (like Pico).
- Tab completion at the prompt (for filenames and ~user).
- Cut-to-end-of-line option (-k).

View File

@@ -6,7 +6,12 @@ if USE_COLOR
SUBDIRS += syntax
endif
EXTRA_DIST = ChangeLog.1999-2006 ChangeLog.2007-2015 \
IMPROVEMENTS README.GIT nano.spec
EXTRA_DIST = IMPROVEMENTS
ACLOCAL_AMFLAGS = -I m4
showinfo:
@ echo
@ echo " The global nanorc file is: @sysconfdir@/nanorc"
@ echo " Syntaxes get installed in: @PKGDATADIR@/"
@ echo

324
NEWS
View File

@@ -1,3 +1,84 @@
2020.10.07 - GNU nano 5.3 "Revolution!"
• Option 'set stateflags' makes nano show the state of auto-indenting,
the mark, hard-wrapping, macro recording, and soft-wrapping in the
title bar. The flags take the place of "Modified", and a modified
buffer is instead indicated by an asterisk (*) after its name.
• Nano no longer by default tries using libmagic to determine the type
of a file (when neither filename nor first line gave a clue), because
in most cases it is a waste of time. It requires using the option
--magic or -! or 'set magic' to make nano try libmagic.
• The color of the indicator can be changed with 'set scrollercolor'.
2020.08.24 - GNU nano 5.2 "Ranrapalca"
• Making certain replacements after a large paste does not crash.
• Hitting a toggle at the Search prompt does not clear the answer.
• Using --positionlog does not complain at the first start.
• A macro containing a Search command will not sometimes fail.
2020.08.12 - GNU nano 5.1 "Cantabria"
• M-Bsp (Alt+Backspace) deletes a word backwards, like in Bash.
• M-[ has become bindable. (Be careful, though: as it is the
starting combination of many escape sequences, avoid gluing
it together with other keystrokes, like in a macro.)
• With --indicator and --softwrap, the first keystroke in an
empty buffer does not crash.
• Invoking the formatter while text is marked does not crash.
• In UTF-8 locales, an anchor is shown as a diamond.
2020.07.29 - GNU nano 5.0 "Among the fields of barley"
• With --indicator (or -q or 'set indicator') nano will show a kind
of scrollbar on the righthand side of the screen to indicate where
in the buffer the viewport is located and how much it covers.
• With <Alt+Insert> any line can be "tagged" with an anchor, and
<Alt+PageUp> and <Alt+PageDown> will jump to the nearest anchor.
When using line numbers, an anchor is shown as "+" in the margin.
• The Execute Command prompt is now directly accessible from the
main menu (with ^T, replacing the Spell Checker). The Linter,
Formatter, Spell Checker, Full Justification, Suspension, and
Cut-Till-End functions are available in this menu too.
• On terminals that support at least 256 colors, nine new color
names are available: pink, purple, mauve, lagoon, mint, lime,
peach, orange, and latte. These do not have lighter versions.
• For the color names red, green, blue, yellow, cyan, magenta,
white, and black, the prefix 'light' gives a brighter color.
Prefix 'bright' is deprecated, as it means both bold AND light.
• All color names can be preceded with "bold," and/or "italic,"
(in that order) to get a bold and/or italic typeface.
• With --bookstyle (or -O or 'set bookstyle') nano considers any
line that begins with whitespace as the start of a paragraph.
• Refreshing the screen with ^L now works in every menu.
• In the main menu, ^L also centers the line with the cursor.
• Toggling the help lines with M-X now works in all menus except
in the help viewer and the linter.
• At a filename prompt, the first <Tab> lists the possibilities,
and these are listed near the bottom instead of near the top.
• Bindable function 'curpos' has been renamed to 'location'.
• Long option --tempfile has been renamed to --saveonexit.
• Short option -S is now a synonym of --softwrap.
• The New Buffer toggle (M-F) has become non-persistent. Options
--multibuffer and 'set multibuffer' still make it default to on.
• Backup files will retain their group ownership (when possible).
• Data is synced to disk before "... lines written" is shown.
• The raw escape sequences for F13 to F16 are no longer recognized.
• Distro-specific syntaxes, and syntaxes of less common languages,
have been moved down to subdirectory syntax/extra/. The affected
distros and others may wish to move wanted syntaxes one level up.
• Syntaxes for Markdown, Haskell, and Ada were added.
2020.05.23 - GNU nano 4.9.3 "Almendras"
• One more bug introduced in version 4.9 is fixed: a crash when
the terminal screen is resized while at a lock-file prompt.
2020.04.07 - GNU nano 4.9.2 "Mali Lošinj"
• Another bug introduced in version 4.9 is fixed: a likely crash
after undoing an <Enter> at the end of leading whitespace.
2020.03.31 - GNU nano 4.9.1 "Sapperdeflap"
• Two bugs introduced in version 4.9 are fixed: the cursor
getting misplaced when undoing line cuts, and filtering
of the whole buffer to a new buffer not working.
2020.03.24 - GNU nano 4.9 "die fetten Jahre sind vorbei"
• When justifying a selection, the new paragraph and the
succeeding one get the appropriate first-line indent.
@@ -459,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,
@@ -701,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
@@ -854,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!
@@ -1035,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,
@@ -1257,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
@@ -1349,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
@@ -1562,9 +1641,9 @@
some compatibility issues with older ncurses libraries
have also been fixed. All in all, a lot to see.
2001.01.31 - Nano 0.9.99pre2 is released. Not surprisingly, all that is
new is bugfixes, bugfixes, bugfixes. There were a few
cleanups in unneeded global variables and duplicate
2001.01.31 - Nano 0.9.99pre2 is released. Not surprisingly, all that
is new is bugfixes, bugfixes, bugfixes. There were a
few cleanups in unneeded global variables and duplicate
functions, but most is just fixing. Specifically, there
is now a preliminary (read: needs testing) fix for
resizing the editor in any mode other than normal edit
@@ -1608,9 +1687,9 @@
main reason for this release is the less-than-optimal
fix for the security issue in nano with following
symbolic links. Hopefully this will fix the problem
permanently. The --nofollow option also works again for
those who are real security nuts. There are also some
display and search fixes, and the --disable-spell
permanently. The --nofollow option also works again
for those who are real security nuts. There are also
some display and search fixes, and the --disable-spell
function was renamed to --disable-speller to be in line
with nano and Pico's "speller" term.
@@ -1631,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.
@@ -1734,12 +1813,11 @@
(id).
2000.06.06 - Nano 0.9.10 is primarily a bugfix for the loss of SIGINT
when using "run and terminate" flags (for example,
--help). There are also some minor documentation
updates. This version of nano is the most stable in
quite some time, and is likely to be the most stable for
awhile. Users are encouraged to upgrade to this
version.
when using "run and terminate" flags (for example, --help).
There are also some minor documentation updates. This
version of nano is the most stable in quite some time,
and is likely to be the most stable for awhile. Users
are encouraged to upgrade to this version.
2000.05.31 - Nano 0.9.9 introduces much better working i18n support,
more portability, and a ton of bugfixes. While nano is
@@ -1754,10 +1832,10 @@
are also the obligatory display fixes and speedups.
Have fun with it.
2000.05.14 - Nano 0.9.7 (the Mother's Day release) continues in the long
line of display fixes, and also fixes the broken symlink
behavior (i.e. symlinks weren't being followed by
default). Hopefully all major bugs can be worked out
2000.05.14 - Nano 0.9.7 (the Mother's Day release) continues in the
long line of display fixes, and also fixes the broken
symlink behavior (i.e. symlinks weren't being followed
by default). Hopefully all major bugs can be worked out
soon and we can have a 1.0 release before the end of the
year, but who knows.
@@ -1768,15 +1846,14 @@
most stable versions of nano to date, but this one may
not be too bad =-)
2000.05.01 - Nano 0.9.5 attempts to speed up the display of text
to be at least somewhat reasonable. Much code profiling
has been done to reduce the ridiculous number of
redundant display updates. This will probably expose a
lot of bugs that can then be fixed, so this release is
probably not for the faint of heart. For anyone
curious, I would call nano 0.9.2 the most stable version
recently, so use that if you're not particularly
concerned with being on the bleeding edge.
2000.05.01 - Nano 0.9.5 attempts to speed up the display of text to be
at least somewhat reasonable. Much code profiling has been
done to reduce the ridiculous number of redundant display
updates. This will probably expose a lot of bugs that can
then be fixed, so this release is probably not for the faint
of heart. For anyone curious, I would call nano 0.9.2 the
most stable version recently, so use that if you're not
particularly concerned with being on the bleeding edge.
2000.04.25 - Nano 0.9.4 fixes some problems in 0.9.3 with the last
line code and related segfaults. It now also has much
@@ -1854,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! =)
@@ -1881,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
@@ -1907,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.

77
TODO
View File

@@ -1,78 +1,5 @@
A list of desired features
--------------------------
* Allow color syntaxes to apply to more than just color, so that we can
e.g. specify a different alternate spell checker depending on which
file type we have open.
For a list of open bugs and requested features see:
* Add support for right-to-left text (RTL).
https://savannah.gnu.org/bugs/?group=nano
* Allow setting bookmarks (saved positions, not to be confused with the
mark set via Ctrl-^) at various lines and/or columns in the buffer,
and allow movement between them with a single keystroke?
See https://savannah.gnu.org/bugs/?57577.
For version 4.8:
- Detect when text is being pasted, so that we can handle it faster. [DONE]
For version 4.0:
- Make undo/redo work also for justifying. [DONE]
For version 2.9:
- Allow piping (marked) text to an external command and replacing it with
the command's output. That is: implement filtering. [DONE]
- Allow to record and replay a macro: a stored series of keystrokes. [DONE]
- Make undo/redo work also for indenting. [DONE]
For version 2.8:
- Allow text searches in the help viewer. [DONE]
For version 2.4:
- Handle window resizes better. After we've resized, we should stay
wherever we were before we resized, as Pico does. [DONE]
- Allow even better file-type detection, e.g. through libmagic. [DONE]
- Compatibility with vim status files to let other editors know we're
in a file. [DONE]
For version 2.2:
- Rebindable keys? [DONE]
- Undo/Redo keys (M-U and M-E)? [DONE]
- Fix problems with color syntaxes highlighting lines too aggressively. [DONE]
- Allow nano to work like a pager (reading from stdin). [DONE]
- Select a color syntax based on more than just the filename extension. [DONE]
- Allow soft wrapping as well as hard wrapping? [DONE]
For version 2.0:
- UTF-8 support. [DONE]
- Support for paragraph searches. [DONE]
- Support for justifying the entire file at once. [DONE]
- Support for filename searches in the file browser. [DONE]
- A keystroke to implement "Add next sequence as raw", like vi's ^V. [DONE]
- Spell check selected text only. [DONE]
- Make "To Line" (^W^T) and "Read from Command" (^R^X) return to their parent
menu when their keystroke is entered again (^W^T^T and ^R^X^X). [DONE]
For version 1.2:
- Single-line scroll up/down? [DONE]
- Color syntax highlighting? [DONE]
- Support for a .nanorc file. [DONE]
- Backup making (filename~)? [DONE]
- Search/replace string history. [DONE]
- Implement Pico's -j and -g flags. [DONE]
- Make mouse support (-m) work with clicking on the shortcuts. [DONE]
- Implement -o (--operatingdir, a chroot of sorts). [DONE]
- Allow -r to take a negative argument. [DONE]
For version 1.0:
- Implement Spelling. [DONE]
- Implement Help. [DONE]
- Internationalization [In progress, translators welcome!]
- Allow nano to be resized in X. [DONE]
- On PageUp/Down, put the cursor on the first screen line (like Pico). [DONE]
- Implement justify function. [DONE]
- Cut to end of line. [DONE]
- Built-in speller command. [DONE]
- Better status-bar interaction (scrolling, tab completion). [DONE]
- Unjustify command (^U after ^J). [DONE]
- Username completion (~user). [DONE]

View File

@@ -2,7 +2,7 @@
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="360979fd6fb84567e0ffc6839b0431fc00d6362f"
gnulib_hash="6160ee8e4d2b88d934c3c4c8c5930a75b835723f"
modules="
futimens
@@ -30,7 +30,7 @@ modules="
# Make sure the local gnulib git repo is up-to-date.
if [ ! -d "gnulib" ]; then
git clone --depth=123 ${gnulib_url}
git clone --depth=1111 ${gnulib_url}
fi
cd gnulib >/dev/null || exit 1
curr_hash=$(git log -1 --format=%H)

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], [4.9], [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
@@ -59,7 +59,7 @@ AC_DEFINE_DIR([PKGDATADIR], [pkgdatadir], [Where data are placed to.])
dnl Whether this is a git repository.
AC_MSG_CHECKING([whether building from git])
if test -d .git ; then
if test -f roll-a-release.sh ; then
AC_MSG_RESULT([yes])
from_git=yes
else
@@ -73,13 +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. ***])
*** 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
@@ -91,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
@@ -111,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
@@ -119,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
@@ -134,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
@@ -159,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
@@ -167,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
@@ -201,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]))
@@ -284,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
@@ -527,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
@@ -566,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
@@ -582,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
@@ -596,7 +611,7 @@ if eval "test x$CURSES_LIB_NAME = x"; then
*** from libncursesw5-dev (Debian), ncurses-devel (Fedora), or similar.
*** (Or install ncurses from https://ftp.gnu.org/gnu/ncurses/.)])
else
AC_MSG_RESULT([Using $CURSES_LIB_NAME as the curses library])
AC_MSG_RESULT([ The curses library to be used is: $CURSES_LIB_NAME])
fi
AC_CHECK_LIB([$CURSES_LIB_NAME], [use_default_colors],
@@ -609,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)
@@ -627,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
@@ -665,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
@@ -683,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.
@@ -720,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])
@@ -738,7 +752,8 @@ m4/Makefile
po/Makefile.in
src/Makefile
syntax/Makefile
nano.spec
])
AC_OUTPUT
make showinfo

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,12 +41,12 @@
<h3><a href="#4">4. Running</a></h3>
<blockquote><p>
<a href="#4.1">4.1. How do I open a file with a name beginning with '+' from the command line?</a><br>
<a href="#4.2">4.2. Ack! My Backspace/Delete/Enter/Meta/double bucky key doesn't seem to work! What can I do?</a><br>
<a href="#4.2">4.2. How can I make Ctrl+Shift+Left/Right select words on urxvt?</a><br>
<a href="#4.3">4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</a><br>
<a href="#4.4">4.4. With what keystroke can I paste text from the clipboard into nano?</a><br>
<a href="#4.5">4.5. How do I select text for or paste text from the clipboard when nano's mouse support is turned on?</a><br>
<a href="#4.6">4.6. When I paste text into a document, each line gets indented further than the last. Why? And how can I stop this?</a><br>
<a href="#4.7">4.7. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?<a><br>
<a href="#4.7">4.7. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?</a><br>
<a href="#4.8">4.8. I've compiled nano with color support, but I don't see any color when I run it!</a><br>
<a href="#4.9">4.9. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
</p></blockquote>
@@ -89,7 +89,7 @@
<h3><a name="1.3"></a>1.3. Why the name change from TIP?</h3>
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program &quot;establishes a full duplex terminal connection to a remote host&quot;, and was included with many older Unix systems (and newer ones like Solaris). The conflict was not noticed at first because there is no 'tip' utility included with most GNU/Linux distributions (where nano was developed).</p></blockquote>
<h3><a name="1.4"></a>1.4. What is the current version of nano?</h3>
<blockquote><p>The current version of nano <i>should</i> be <b>4.9</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<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 4.9" "March 2020"
.TH NANO 1 "version 5.3" "October 2020"
.SH NAME
nano \- Nano's ANOther editor, inspired by Pico
@@ -155,10 +155,9 @@ hard-wrapping occurs or when text is justified.
.BR \-N ", " \-\-noconvert
Disable automatic conversion of files from DOS/Mac format.
.TP
.BR \-O ", " \-\-morespace
Obsolete and ignored option, since the line below the title bar is included
into the editing space by default. If you prefer to keep this line blank,
use \fB\-e\fR or \fB\-\-emptyline\fR.
.BR \-O ", " \-\-bookstyle
When justifying, treat any line that starts with whitespace as the
beginning of a paragraph (unless auto-indenting is on).
.TP
.BR \-P ", " \-\-positionlog
For the 200 most recent files, log the last position of the cursor,
@@ -166,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.
@@ -180,14 +179,15 @@ different name if it already has one; and don't make backup files.
Restricted mode can also be activated by invoking \fBnano\fP
with any name beginning with 'r' (e.g. "rnano").
.TP
.BR \-S ", " \-\-smooth
Obsolete and ignored option, since smooth scrolling has become the default.
If you prefer the chunk-by-chunk scrolling behavior,
use \fB\-j\fR or \fB\-\-jumpyscrolling\fR.
.BR \-S ", " \-\-softwrap
Display over multiple screen rows lines that exceed the screen's width.
(You can make this soft-wrapping occur at whitespace instead of rudely at
the screen's edge, by using also \fB\-\-atblanks\fR.)
(The old short option, \fB\-$\fR, is deprecated.)
.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
@@ -203,8 +203,8 @@ characters as part of a word.
.TP
.BR "\-X ""\fIcharacters\fB""" ", " "\-\-wordchars=""" \fIcharacters """
Specify which other characters (besides the normal alphanumeric ones)
should be considered as part of a word. This overrides option
\fB\-W\fR (\fB\-\-wordbounds\fR).
should be considered as part of a word. When using this option, you
probably want to omit \fB\-W\fR (\fB\-\-wordbounds\fR).
.TP
.BR \-Y\ \fIname ", " \-\-syntax= \fIname
Specify the name of the syntax highlighting to use from among the ones
@@ -261,6 +261,7 @@ position to the end of the line, instead of cutting the entire line.
.TP
.BR \-l ", " \-\-linenumbers
Display line numbers to the left of the text area.
(Any line with an anchor additionally gets a mark in the margin.)
.TP
.BR \-m ", " \-\-mouse
Enable mouse support, if available for your system. When enabled, mouse
@@ -284,19 +285,25 @@ similar to a chroot.
Preserve the XON and XOFF sequences (\fB^Q\fR and \fB^S\fR) so they
will be caught by the terminal.
.TP
.BR \-q ", " \-\-indicator
Display a "scrollbar" on the righthand side of the edit window.
It shows the position of the viewport in the buffer
and how much of the buffer is covered by the viewport.
.TP
.BR \-r\ \fInumber ", " \-\-fill= \fInumber
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 ", " \-\-tempfile
.BR \-t ", " \-\-saveonexit
Save a changed buffer without prompting (when exiting with \fB^X\fR).
(The old form of the long option, \fB\-\-tempfile\fR, is deprecated.)
.TP
.BR \-u ", " \-\-unix
Save a file by default in Unix format. This overrides nano's
@@ -312,25 +319,27 @@ 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.
.TP
.BR \-y ", " \-\-afterends
Make Ctrl+Right stop at word ends instead of beginnings.
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 \-$ ", " \-\-softwrap
Display lines that exceed the screen's width over multiple screen lines.
(You can make this soft-wrapping occur at whitespace instead of rudely at
the screen's edge, by using also \fB\-\-atblanks\fR.)
Since
\&'$' normally refers to a variable in the Unix shell, you should specify
this option last when using other options (e.g.\& 'nano \-wS$') or pass it
separately (e.g.\& 'nano \-wS \-$').
.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
@@ -339,6 +348,10 @@ hard-wrapping of long lines, \fBM\-S\fR toggles soft-wrapping,
\fBM\-N\fR toggles line numbers, \fBM\-M\fR toggles the mouse,
\fBM\-I\fR auto-indentation, and \fBM\-X\fR the help lines.
See at the end of the \fB^G\fR help text for a complete list.
.sp
The \fBM\-X\fR toggle is special: it works in all menus except
the help viewer and the linter. All other toggles work in
the main menu only.
.SH FILES
When \fB\-\-rcfile\fR is given, \fBnano\fR will read just the specified file
@@ -349,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 4.9
@set UPDATED March 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 4.9
@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 4.9.
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 4.9.
* 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
@@ -97,16 +97,16 @@ as is reasonable while offering a superset of Pico's functionality.
Pico differ.
Starting with version 4.0, @command{nano} no longer hard-wraps an overlong
line by default. It further uses smooth scrolling by default, and by
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
@@ -240,10 +240,9 @@ hard-wrapping occurs or when text is justified.
Disable automatic conversion of files from DOS/Mac format.
@item -O
@itemx --morespace
Obsolete and ignored option, since the line below the title bar is included
into the editing space by default. If you prefer to keep this line blank,
use @option{-e} or @option{--emptyline}.
@itemx --bookstyle
When justifying, treat any line that starts with whitespace as the
beginning of a paragraph (unless auto-indenting is on).
@item -P
@itemx --positionlog
@@ -253,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.
@@ -269,10 +268,11 @@ Restricted mode can also be activated by invoking @command{nano} with
any name beginning with @code{r} (e.g.@: @command{rnano}).
@item -S
@itemx --smooth
Obsolete and ignored option, since smooth scrolling has become the default.
If you prefer the chunk-by-chunk scrolling behavior,
use @option{-j} or @option{--jumpyscrolling}.
@itemx --softwrap
Display over multiple screen rows lines that exceed the screen's width.
(You can make this soft-wrapping occur at whitespace instead of rudely at
the screen's edge, by using also @code{--atblanks}.)
(The old short option, @code{-$}, is deprecated.)
@item -T @var{number}
@itemx --tabsize=@var{number}
@@ -297,8 +297,8 @@ characters as parts of words.
@item -X "@var{characters}"
@itemx --wordchars="@var{characters}"
Specify which other characters (besides the normal alphanumeric ones)
should be considered as parts of words. This overrides option
@option{-W} (@option{--wordbounds}).
should be considered as parts of words. When using this option, you
probably want to omit @option{-W} (@option{--wordbounds}).
@item -Y @var{name}
@itemx --syntax=@var{name}
@@ -370,6 +370,7 @@ position to the end of the line, instead of cutting the entire line.
@item -l
@itemx --linenumbers
Display line numbers to the left of the text area.
(Any line with an anchor additionally gets a mark in the margin.)
@item -m
@itemx --mouse
@@ -397,6 +398,12 @@ similar to a chroot.
Preserve the @kbd{^Q} (XON) and @kbd{^S} (XOFF) sequences so data being
sent to the editor can be stopped and started.
@item -q
@itemx --indicator
Display a "scrollbar" on the righthand side of the edit window.
It shows the position of the viewport in the buffer
and how much of the buffer is covered by the viewport.
@item -r @var{number}
@itemx --fill=@var{number}
Set the target width for justifying and automatic hard-wrapping at this
@@ -416,10 +423,11 @@ corrector, which requires either @command{hunspell} or GNU @command{spell}
to be installed.
@item -t
@itemx --tempfile
Don't ask whether to save a modified buffer when exiting with @kbd{^X}, but
assume yes. This option is useful when @command{nano} is used as the
composer of a mailer program.
@itemx --saveonexit
Save a changed buffer without prompting (when exiting with @kbd{^X}).
This can be handy when @command{nano} is used as the composer of an
email program.
(The old form of the long option, @code{--tempfile}, is deprecated.)
@item -u
@item --unix
@@ -453,22 +461,26 @@ disabled to display the help-system navigation keys.
@item -y
@itemx --afterends
Make Ctrl+Right stop at word ends instead of beginnings.
Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
@item -z
@itemx --suspendable
Enable the ability to suspend @command{nano} using the system's suspend
keystroke (usually @kbd{^Z}).
@item -$
@itemx --softwrap
Display lines that exceed the screen's width over multiple screen lines.
(You can make this soft-wrapping occur at whitespace instead of rudely at
the screen's edge, by using also @code{--atblanks}.)
Since
@code{$} normally refers to a variable in the Unix shell, you should specify
this option last when using other options (e.g.@: @code{nano -wS$}) or pass it
separately (e.g.@: @code{nano -wS -$}).
@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
@@ -484,6 +496,7 @@ separately (e.g.@: @code{nano -wS -$}).
* Screen Layout::
* Search and Replace::
* Using the Mouse::
* Anchors::
* Limitations::
@end menu
@@ -538,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
@@ -565,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
@@ -618,6 +630,22 @@ Shift key during those actions.
The mouse will work in the X Window System, and on the console when gpm
is running.
@node Anchors
@section Anchors
With @kbd{M-Ins} you can place an anchor (a kind of temporary bookmark)
at the current line. With @kbd{M-PgUp} and @kbd{M-PgDn} you can jump
to an anchor in the backward/forward direction. This jumping wraps
around at the top and bottom.
When a line with an anchor is removed, the line where the cursor ends up
inherits the anchor. After performing an operation on the entire buffer
(like formatting it, piping it through a command, or doing an external
spell check on it), any anchors that were present are gone. And when
you close the buffer, all its anchors simply disappear; they are not saved.
Anchors are visualized in the margin when line numbers are activated.
@node Limitations
@section Limitations
@@ -635,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
@@ -673,7 +720,7 @@ The following global toggles are available:
@kbd{Meta-P} toggles the displaying of whitespace (@pxref{Whitespace}).
@item Soft Wrapping
@kbd{Meta-S} toggles the @option{-$} (@option{--softwrap}) command-line option.
@kbd{Meta-S} toggles the @option{-S} (@option{--softwrap}) command-line option.
@item Expert/No Help
@kbd{Meta-X} toggles the @option{-x} (@option{--nohelp}) command-line option.
@@ -730,7 +777,7 @@ The supported settings in a nanorc file are:
@table @code
@item set afterends
Make Ctrl+Right stop at word ends instead of beginnings.
Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
@item set allow_insecure_backup
When backing up files, allow the backup to succeed even if its
@@ -762,12 +809,16 @@ function tags, line numbers, and selected text. This is overridden by
setting the options @code{titlecolor}, @code{statuscolor}, @code{keycolor},
@code{functioncolor}, @code{numbercolor}, and/or @code{selectedcolor}.
@item set bookstyle
When justifying, treat any line that starts with whitespace as the
beginning of a paragraph (unless auto-indenting is on).
@item set brackets "@var{characters}"
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.
@@ -785,7 +836,7 @@ Use cut-from-cursor-to-end-of-line by default, instead of cutting the whole line
@item set emptyline
Do not use the line below the title bar, leaving it entirely blank.
@item set errorcolor @var{fgcolor},@var{bgcolor}
@item set errorcolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
Use this color combination for the status bar when an error message is displayed.
The default value is @t{brightwhite,red}.
@xref{@code{set functioncolor}} for valid color names.
@@ -798,15 +849,26 @@ point to vary along with the width of the screen if the screen is resized.
The default value is @t{-8}.
@anchor{@code{set functioncolor}}
@item set functioncolor @var{fgcolor},@var{bgcolor}
@item set functioncolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
Use this color combination for the concise function descriptions
in the two help lines at the bottom of the screen.
Valid names for foreground and background color are:
@code{white}, @code{black}, @code{blue}, @code{green},
@code{red}, @code{cyan}, @code{yellow}, @code{magenta}, and @code{normal}
Valid names for the foreground and background colors are:
@code{red}, @code{green}, @code{blue},
@code{magenta}, @code{yellow}, @code{cyan},
@code{white}, and @code{black}.
Each of these eight names may be prefixed with the word
@code{light} to get a brighter version of that color.
On terminal emulators that can do at least 256 colors,
other valid (but unprefixable) color names are:
@code{pink}, @code{purple}, @code{mauve},
@code{lagoon}, @code{mint}, @code{lime},
@code{peach}, @code{orange}, @code{latte}, and @code{normal}
--- where @code{normal} means the default foreground or background color.
The name of the foreground color may be prefixed with @code{bright}.
And either @var{fgcolor} or ,@var{bgcolor} may be left out.
Either @var{fgcolor} or ,@var{bgcolor} may be left out,
and the pair may be preceded by @code{bold} and/or @code{italic}
(separated by commas) to get a bold and/or slanting typeface,
if your terminal can do those.
@item set guidestripe @var{number}
Draw a vertical stripe at the given column, to help judge the width of the
@@ -819,22 +881,30 @@ executed commands, so they can be easily reused in later sessions.
@item set jumpyscrolling
Scroll the buffer contents per half-screen instead of per line.
@item set keycolor @var{fgcolor},@var{bgcolor}
@item set keycolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
Use this color combination for the shortcut key combos
in the two help lines at the bottom of the screen.
@xref{@code{set functioncolor}} for valid color names.
@item set linenumbers
Display line numbers to the left of the text area.
(Any line with an anchor additionally gets a mark in the margin.)
@item set locking
Enable vim-style lock-files for when editing files.
@item set magic
When neither the file's name nor its first line give a clue,
try using libmagic to determine the applicable syntax.
(Calling libmagic can be relatively time consuming.
It is therefore not done by default.)
@anchor{@code{set matchbrackets}}
@item set matchbrackets "@var{characters}"
Set the opening and closing brackets that can be found by bracket
Specify the opening and closing brackets that can be found by bracket
searches. This may not include blank characters. The opening set must
come before the closing set, and the two sets must be in the same order.
The default value is @t{"(<[@{)>]@}"}.
The default value is "@t{(<[@{)>]@}}".
@item set morespace
Deprecated option since it has become the default setting.
@@ -864,7 +934,7 @@ Obsolete option. Ignored.
Deprecated option since it has become the default setting.
When needed, use @code{unset breaklonglines} instead.
@item set numbercolor @var{fgcolor},@var{bgcolor}
@item set numbercolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
Use this color combination for line numbers.
@xref{@code{set functioncolor}} for valid color names.
@@ -881,12 +951,17 @@ The cursor position is remembered for the 200 most-recently edited files.
@item set preserve
Preserve the XON and XOFF keys (@kbd{^Q} and @kbd{^S}).
@item set indicator
Display a "scrollbar" on the righthand side of the edit window.
It shows the position of the viewport in the buffer
and how much of the buffer is covered by the viewport.
@item set punct "@var{characters}"
Set the characters treated as closing punctuation when justifying
paragraphs. This may not include blank characters. Only the
specified closing punctuation, optionally followed by closing brackets
(see @code{set brackets}), can end sentences.
The default value is @t{"!.?"}.
The default value is "@t{!.?}".
@item set quickblank
Do quick status-bar blanking: status-bar messages will disappear after 1
@@ -894,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.
@@ -914,7 +989,17 @@ system either Backspace acts like Delete or Delete acts like Backspace.
Do regular-expression searches by default.
Regular expressions in @command{nano} are of the extended type (ERE).
@item set selectedcolor @var{fgcolor},@var{bgcolor}
@item set saveonexit
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.
@@ -943,11 +1028,19 @@ the screen's edge, by using also @code{set atblanks}.)
Use the given program to do spell checking and correcting.
@xref{@option{--speller}} for details.
@item set statuscolor @var{fgcolor},@var{bgcolor}
@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.
@item set stripecolor @var{fgcolor},@var{bgcolor}
@item set stripecolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
Use this color combination for the vertical guiding stripe.
@xref{@code{set functioncolor}} for valid color names.
@@ -961,10 +1054,7 @@ greater than 0. The default value is @t{8}.
@item set tabstospaces
Convert typed tabs to spaces.
@item set tempfile
Save automatically on exit, don't prompt.
@item set titlecolor @var{fgcolor},@var{bgcolor}
@item set titlecolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
Use this color combination for the title bar.
@xref{@code{set functioncolor}} for valid color names.
@@ -994,8 +1084,8 @@ characters as part of a word.
@item set wordchars "@var{characters}"
Specify which other characters (besides the normal alphanumeric ones)
should be considered as parts of words. This overrides the option
@code{wordbounds}.
should be considered as parts of words. When using this option, you
probably want to unset @code{wordbounds}.
@item set zap
Let an unmodified @key{Backspace} or @key{Delete} erase the marked region
@@ -1013,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.
@@ -1080,32 +1173,40 @@ 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
Python that want to see only spaces for indentation.
This overrides the setting of the @code{tabstospaces} option.
@item color @var{fgcolor},@var{bgcolor} "@var{regex}" @dots{}
@item color [bold,][italic,]@var{fgcolor},@var{bgcolor} "@var{regex}" @dots{}
Paint all pieces of text that match the extended regular expression "regex"
with the given foreground and background colors, at least one of which must
be specified. Valid color names are:
@code{white}, @code{black}, @code{blue}, @code{green},
@code{red}, @code{cyan}, @code{yellow}, @code{magenta}, and @code{normal}
@code{red}, @code{green}, @code{blue},
@code{magenta}, @code{yellow}, @code{cyan},
@code{white}, and @code{black}.
Each of these eight names may be prefixed with the word
@code{light} to get a brighter version of that color.
On terminal emulators that can do at least 256 colors,
other valid (but unprefixable) color names are:
@code{pink}, @code{purple}, @code{mauve},
@code{lagoon}, @code{mint}, @code{lime},
@code{peach}, @code{orange}, @code{latte}, and @code{normal}
--- where @code{normal} means the default foreground or background color.
You may use the prefix @code{bright} for the foreground color to get a
stronger highlight.
If your terminal supports transparency, not specifying a "bgcolor"
tells @command{nano} to attempt to use a transparent background.
The color pair may be preceded by @code{bold} and/or @code{italic}
(separated by commas) to get a bold and/or slanting typeface,
if your terminal can do those.
All coloring commands are applied in the order in which they are specified,
which means that later commands can recolor stuff that was colored earlier.
@item icolor @var{fgcolor},@var{bgcolor} "@var{regex}" @dots{}
@item icolor [bold,][italic,]@var{fgcolor},@var{bgcolor} "@var{regex}" @dots{}
Same as above, except that the matching is case insensitive.
@item color @var{fgcolor},@var{bgcolor} start="@var{fromrx}" end="@var{torx}"
@item color [bold,][italic,]@var{fgcolor},@var{bgcolor} start="@var{fromrx}" end="@var{torx}"
Paint all pieces of text whose start matches extended regular expression
"fromrx" and whose end matches extended regular expression "torx" with
the given foreground and background colors, at least one of
@@ -1113,7 +1214,7 @@ which must be specified. This means that, after an initial instance of
"fromrx", all text until the first instance of "torx" will be colored.
This allows syntax highlighting to span multiple lines.
@item icolor @var{fgcolor},@var{bgcolor} start="@var{fromrx}" end="@var{torx}"
@item icolor [bold,][italic,]@var{fgcolor},@var{bgcolor} start="@var{fromrx}" end="@var{torx}"
Same as above, except that the matching is case insensitive.
@item include "@var{syntaxfile}"
@@ -1189,7 +1290,9 @@ with Shift.)
Rebinding @code{^M} (Enter) or @code{^I} (Tab) is probably not a good idea.
Rebinding @code{^[} (Esc) is not possible, because its keycode
is the starter byte of escape sequences and Meta keystrokes.
is the starter byte of Meta keystrokes and escape sequences.
Rebinding any of the dedicated cursor-moving keys (the arrows, Home, End,
PageUp and PageDown) is not possible.
On some terminals it's not possible to rebind @code{^H} (unless @code{--raw}
is used) because its keycode is identical to that of the Backspace key.
@@ -1205,7 +1308,7 @@ Invokes the help viewer.
Cancels the current command.
@item exit
Exits from the program (or from the help viewer or the file browser).
Exits from the program (or from the help viewer or file browser).
@item writeout
Writes the current buffer to disk, asking for a name.
@@ -1265,12 +1368,18 @@ Cuts all text from the cursor position till the end of the buffer.
Sets the mark at the current position, to start selecting text.
Or, when it is set, unsets the mark.
@item curpos
Shows the current cursor position: the line, column, and character positions.
@item location
Reports the current position of the cursor in the buffer:
the line, column, and character positions.
(The old name of this function, 'curpos', is deprecated.)
@item wordcount
Counts the number of words, lines and characters in the current buffer.
@item execute
Prompts for a program to execute. The program's output will be inserted
into the current buffer (or into a new buffer when @kbd{M-F} is toggled).
@item speller
Invokes a spell-checking program, either the default @command{hunspell}
or GNU @command{spell}, or the one defined by @option{--speller} or
@@ -1325,6 +1434,9 @@ while keeping the cursor in the same text position, if possible.
Scrolls the viewport down one row (meaning that the text slides up)
while keeping the cursor in the same text position, if possible.
@item center
Scrolls the line with the cursor to the middle of the screen.
@item prevword
Moves the cursor to the beginning of the previous word.
@@ -1367,8 +1479,18 @@ Goes to a specific line (and column if specified). Negative numbers count
from the end of the file (and end of the line).
@item findbracket
Moves the cursor to the bracket (brace, parenthesis, etc.) that matches
(pairs) with the one under the cursor.
Moves the cursor to the bracket (or brace or parenthesis, etc.) that matches
(pairs) with the one under the cursor. @xref{@code{set matchbrackets}}.
@item anchor
Places an anchor at the current line, or removes it when already present.
(An anchor is visible when line numbers are activated.)
@item prevanchor
Goes to the first anchor before the current line.
@item nextanchor
Goes to the first anchor after the current line.
@item prevbuf
Switches to editing/viewing the previous buffer when multiple buffers are open.
@@ -1465,24 +1587,27 @@ When writing a file, creates a backup of the current file.
@item discardbuffer
When about to write a file, discard the current buffer without saving.
(This function is bound by default only when option @option{--tempfile}
(This function is bound by default only when option @option{--saveonexit}
is in effect.)
@item browser
Starts the file browser, allowing to select a file from a list.
Starts the file browser (in the Read File and Write Out menus),
allowing to select a file from a list.
@item gotodir
Goes to a directory to be specified, allowing to browse anywhere
in the filesystem.
@item firstfile
Goes to the first file when using the file browser (reading or writing files).
Goes to the first file in the list when using the file browser.
@item lastfile
Goes to the last file when using the file browser (reading or writing files).
Goes to the last file in the list when using the file browser.
@item nohelp
Toggles the presence of the two-line list of key bindings at the bottom of the screen.
(This toggle is special: it is available in all menus except the help viewer
and the linter. All further toggles are available in the main menu only.)
@item constantshow
Toggles the constant display of the current line, column, and character positions.
@@ -1535,6 +1660,9 @@ Valid names for @code{menu} are:
@item main
The main editor window where text is entered and edited.
@item help
The help-viewer menu.
@item search
The search menu (AKA whereis).
@@ -1556,20 +1684,9 @@ The 'write file' menu.
@item insert
The 'insert file' menu.
@item extcmd
The menu for inserting output from an external command, reached from the insert menu.
@item help
The help-viewer menu.
@item spell
The menu of the integrated spell checker where the user can edit a misspelled word.
@item linter
The linter menu.
@item browser
The file browser, for choosing a file to read from or write to.
The 'file browser' menu, for selecting a file to be opened or
inserted or written to.
@item whereisfile
The 'search for a file' menu in the file browser.
@@ -1577,6 +1694,18 @@ The 'search for a file' menu in the file browser.
@item gotodir
The 'go to directory' menu in the file browser.
@item execute
The menu for inserting the output from an external command,
or for filtering the buffer (or the marked region) through
an external command, or for executing one of several tools.
(The old form of this menu name, 'extcmd', is deprecated.)
@item spell
The menu of the integrated spell checker where the user can edit a misspelled word.
@item linter
The linter menu, which allows jumping through the linting messages.
@item all
A special name that encompasses all menus. For @code{bind} it means
all menus where the specified @code{function} exists; for @code{unbind}
@@ -1585,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 4.9" "March 2020"
.TH NANORC 5 "version 5.3" "October 2020"
.SH NAME
nanorc \- GNU nano's configuration file
@@ -65,10 +65,9 @@ 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 stop at word ends instead of beginnings.
Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
.TP
.B set allow_insecure_backup
When backing up files, allow the backup to succeed even if its permissions
@@ -100,11 +99,15 @@ function tags, line numbers, and selected text. This can be overridden by
setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, \fBkeycolor\fP,
\fBfunctioncolor\fP, \fBnumbercolor\fP, and \fBselectedcolor\fP.
.TP
.B set bookstyle
When justifying, treat any line that starts with whitespace as the
beginning of a paragraph (unless auto-indenting is on).
.TP
.BI "set brackets """ characters """
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.
@@ -122,7 +125,7 @@ Use cut-from-cursor-to-end-of-line by default, instead of cutting the whole line
.B set emptyline
Do not use the line below the title bar, leaving it entirely blank.
.TP
.B set errorcolor \fIfgcolor\fR,\fIbgcolor\fR
.B set errorcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for the status bar when an error message is displayed.
The default value is \fBbrightwhite,red\fR.
See \fBset titlecolor\fR for valid color names.
@@ -134,7 +137,7 @@ 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 \fB\-8\fR.
.TP
.B set functioncolor \fIfgcolor\fR,\fIbgcolor\fR
.B set functioncolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for the function descriptions
in the two help lines at the bottom of the screen.
See \fBset titlecolor\fR for more details.
@@ -147,22 +150,34 @@ text. (The color of the stripe can be changed with \fBset stripecolor\fR.)
Save the last hundred search strings and replacement strings and
executed commands, so they can be easily reused in later sessions.
.TP
.B set indicator
Display a "scrollbar" on the righthand side of the edit window.
It shows the position of the viewport in the buffer
and how much of the buffer is covered by the viewport.
.TP
.B set jumpyscrolling
Scroll the buffer contents per half-screen instead of per line.
.TP
.B set keycolor \fIfgcolor\fR,\fIbgcolor\fR
.B set keycolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for the shortcut key combos
in the two help lines at the bottom of the screen.
See \fBset titlecolor\fR for more details.
.TP
.B set linenumbers
Display line numbers to the left of the text area.
(Any line with an anchor additionally gets a mark in the margin.)
.TP
.B set locking
Enable vim-style lock-files for when editing files.
.TP
.B set magic
When neither the file's name nor its first line give a clue,
try using libmagic to determine the applicable syntax.
(Calling libmagic can be relatively time consuming.
It is therefore not done by default.)
.TP
.BI "set matchbrackets """ characters """
Set the opening and closing brackets that can be found by bracket
Specify the opening and closing brackets that can be found by bracket
searches. This may not include blank characters. The opening set must
come before the closing set, and the two sets must be in the same order.
The default value is "\fB(<[{)>]}\fP".
@@ -198,7 +213,7 @@ Obsolete option. Ignored.
Deprecated option since it has become the default setting.
When needed, use \fBunset breaklonglines\fR instead.
.TP
.B set numbercolor \fIfgcolor\fR,\fIbgcolor\fR
.B set numbercolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for line numbers.
See \fBset titlecolor\fR for more details.
.TP
@@ -247,7 +262,17 @@ system either Backspace acts like Delete or Delete acts like Backspace.
Do regular-expression searches by default.
Regular expressions in \fBnano\fR are of the extended type (ERE).
.TP
.B set selectedcolor \fIfgcolor\fR,\fIbgcolor\fR
.B set saveonexit
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.
.TP
@@ -273,13 +298,21 @@ 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 statuscolor \fIfgcolor\fR,\fIbgcolor\fR
.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.
See \fBset titlecolor\fR for more details.
.TP
.B set stripecolor \fIfgcolor\fR,\fIbgcolor\fR
.B set stripecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for the vertical guiding stripe.
See \fBset titlecolor\fR for more details.
.TP
@@ -293,17 +326,22 @@ greater than 0. The default value is \fB8\fR.
.B set tabstospaces
Convert typed tabs to spaces.
.TP
.B set tempfile
Save automatically on exit, don't prompt.
.TP
.B set titlecolor \fIfgcolor\fR,\fIbgcolor\fR
.B set titlecolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Specify the color combination to use for the title bar.
Valid names for the foreground and background colors are:
.BR white ", " black ", " blue ", " green ", " red ", "
.BR cyan ", " yellow ", " magenta ", and " normal
.BR red ", " green ", " blue ", " magenta ", " yellow ", " cyan ", "
.BR white ", and " black .
Each of these eight names may be prefixed with the word \fBlight\fR
to get a brighter version of that color.
On terminal emulators that can do at least 256 colors,
other valid (but unprefixable) color names are:
.BR pink ", " purple ", " mauve ", " lagoon ", " mint ", "
.BR lime ", " peach ", " orange ", " latte ", and " normal
-- where \fBnormal\fR means the default foreground or background color.
The name of the foreground color may be prefixed with \fBbright\fR.
And either "\fIfgcolor\fR" or ",\fIbgcolor\fR" may be left out.
Either "\fIfgcolor\fR" or "\fB,\fIbgcolor\fR" may be left out,
and the pair may be preceded by \fBbold\fR and/or \fBitalic\fR
(separated by commas) to get a bold and/or slanting typeface,
if your terminal can do those.
.TP
.B set trimblanks
Remove trailing whitespace from wrapped lines when automatic
@@ -330,8 +368,8 @@ characters as parts of words.
.TP
.BI "set wordchars """ characters """
Specify which other characters (besides the normal alphanumeric ones)
should be considered as parts of words. This overrides the option
\fBwordbounds\fR.
should be considered as parts of words. When using this option, you
probably want to unset \fBwordbounds\fR.
.TP
.B set zap
Let an unmodified Backspace or Delete erase the marked region
@@ -367,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
@@ -417,24 +455,30 @@ Make the <Tab> key produce the given \fIstring\fR. Useful for languages like
Python that want to see only spaces for indentation.
This overrides the setting of the \fBtabstospaces\fR option.
.TP
.BI "color " fgcolor , bgcolor " """ regex """ " \fR...
.BI "color \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " """ regex """ " \fR...
Paint all pieces of text that match the extended regular expression
\fIregex\fP with the given foreground and background colors, at least
one of which must be specified. Valid color names are:
.BR white ", " black ", " blue ", " green ", " red ", "
.BR cyan ", " yellow ", " magenta ", and " normal
.BR red ", " green ", " blue ", " magenta ", " yellow ", " cyan ", "
.BR white ", and " black .
Each of these eight names may be prefixed with the word \fBlight\fR
to get a brighter version of that color.
On terminal emulators that can do at least 256 colors,
other valid (but unprefixable) color names are:
.BR pink ", " purple ", " mauve ", " lagoon ", " mint ", "
.BR lime ", " peach ", " orange ", " latte ", and " normal
-- where \fBnormal\fR means the default foreground or background color.
You may use the prefix \fBbright\fR for the foreground color to get a
stronger highlight. If your terminal supports transparency, not specifying
a \fIbgcolor\fP tells \fBnano\fP to attempt to use a transparent background.
The color pair may be preceded by \fBbold\fR and/or \fBitalic\fR
(separated by commas) to get a bold and/or slanting typeface,
if your terminal can do those.
.sp
All coloring commands are applied in the order in which they are specified,
which means that later commands can recolor stuff that was colored earlier.
.TP
.BI "icolor " fgcolor , bgcolor " """ regex """ " \fR...
.BI "icolor \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " """ regex """ " \fR...
Same as above, except that the matching is case insensitive.
.TP
.BI "color " fgcolor , bgcolor " start=""" fromrx """ end=""" torx """
.BI "color \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " start=""" fromrx """ end=""" torx """
Paint all pieces of text whose start matches extended regular expression
\fIfromrx\fP and whose end matches extended regular expression \fItorx\fP
with the given foreground and background colors,
@@ -443,7 +487,7 @@ initial instance of \fIfromrx\fP, all text until the first instance of
\fItorx\fP will be colored. This allows syntax highlighting to span
multiple lines.
.TP
.BI "icolor " fgcolor , bgcolor " start=""" fromrx """ end=""" torx """
.BI "icolor \fR[\fBbold,\fR][\fBitalic,\fR]" fgcolor , bgcolor " start=""" fromrx """ end=""" torx """
Same as above, except that the matching is case insensitive.
.TP
.BI "include """ syntaxfile """
@@ -504,14 +548,15 @@ 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 escape sequences and Meta keystrokes.
is the starter byte of Meta keystrokes and escape sequences.
Rebinding any of the dedicated cursor-moving keys (the arrows, Home, End,
PageUp and PageDown) is not possible.
On some terminals it's not possible to rebind \fB^H\fR (unless \fB\-\-raw\fR
is used) because its keycode is identical to that of the Backspace key.
@@ -526,7 +571,7 @@ Invokes the help viewer.
Cancels the current command.
.TP
.B exit
Exits from the program (or from the help viewer or the file browser).
Exits from the program (or from the help viewer or file browser).
.TP
.B writeout
Writes the current buffer to disk, asking for a name.
@@ -586,15 +631,21 @@ Cuts all text from the cursor position till the end of the buffer.
Sets the mark at the current position, to start selecting text.
Or, when it is set, unsets the mark.
.TP
.B curpos
Shows the current cursor position: the line, column, and character positions.
.B location
Reports the current position of the cursor in the buffer:
the line, column, and character positions.
(The old name of this function, 'curpos', is deprecated.)
.TP
.B wordcount
Counts the number of words, lines and characters in the current buffer.
.TP
.B execute
Prompts for a program to execute. The program's output will be inserted
into the current buffer (or into a new buffer when \fBM-F\fR is toggled).
.TP
.B speller
Invokes a spell-checking program, either the default \fBhunspell\fR or GNU
\fBspell\fR, or the one defined by \fB\-\-speller\fR or \fBset speller\fR.
Invokes a spell-checking program, either the default \fBhunspell\fR(1) or GNU
\fBspell\fR(1), or the one defined by \fB\-\-speller\fR or \fBset speller\fR.
.TP
.B formatter
Invokes a full-buffer-processing program (if the active syntax defines one).
@@ -645,6 +696,9 @@ while keeping the cursor in the same text position, if possible.
Scrolls the viewport down one row (meaning that the text slides up)
while keeping the cursor in the same text position, if possible.
.TP
.B center
Scrolls the line with the cursor to the middle of the screen.
.TP
.B prevword
Moves the cursor to the beginning of the previous word.
.TP
@@ -687,8 +741,18 @@ Goes to a specific line (and column if specified). Negative numbers count
from the end of the file (and end of the line).
.TP
.B findbracket
Moves the cursor to the bracket (brace, parenthesis, etc.) that matches
(pairs) with the one under the cursor.
Moves the cursor to the bracket (or brace or parenthesis, etc.) that matches
(pairs) with the one under the cursor. See \fBset matchbrackets\fR.
.TP
.B anchor
Places an anchor at the current line, or removes it when already present.
(An anchor is visible when line numbers are activated.)
.TP
.B prevanchor
Goes to the first anchor before the current line.
.TP
.B nextanchor
Goes to the first anchor after the current line.
.TP
.B prevbuf
Switches to editing/viewing the previous buffer when multiple buffers are open.
@@ -785,24 +849,27 @@ When writing a file, creates a backup of the current file.
.TP
.B discardbuffer
When about to write a file, discard the current buffer without saving.
(This function is bound by default only when option \fB\-\-tempfile\fR
(This function is bound by default only when option \fB\-\-saveonexit\fR
is in effect.)
.TP
.B browser
Starts the file browser, allowing to select a file from a list.
Starts the file browser (in the Read File and Write Out menus),
allowing to select a file from a list.
.TP
.B gotodir
Goes to a directory to be specified, allowing to browse anywhere
in the filesystem.
.TP
.B firstfile
Goes to the first file when using the file browser (reading or writing files).
Goes to the first file in the list when using the file browser.
.TP
.B lastfile
Goes to the last file when using the file browser (reading or writing files).
Goes to the last file in the list when using the file browser.
.TP
.B nohelp
Toggles the presence of the two-line list of key bindings at the bottom of the screen.
(This toggle is special: it is available in all menus except the help viewer
and the linter. All further toggles are available in the main menu only.)
.TP
.B constantshow
Toggles the constant display of the current line, column, and character positions.
@@ -853,6 +920,9 @@ Valid \fImenu\fP sections are:
.B main
The main editor window where text is entered and edited.
.TP
.B help
The help-viewer menu.
.TP
.B search
The search menu (AKA whereis).
.TP
@@ -874,20 +944,9 @@ The 'write file' menu.
.B insert
The 'insert file' menu.
.TP
.B extcmd
The menu for inserting output from an external command, reached from the insert menu.
.TP
.B help
The help-viewer menu.
.TP
.B spell
The menu of the integrated spell checker where the user can edit a misspelled word.
.TP
.B linter
The linter menu.
.TP
.B browser
The file browser for inserting or writing a file.
The 'file browser' menu, for selecting a file to be opened or
inserted or written to.
.TP
.B whereisfile
The 'search for a file' menu in the file browser.
@@ -895,6 +954,18 @@ The 'search for a file' menu in the file browser.
.B gotodir
The 'go to directory' menu in the file browser.
.TP
.B execute
The menu for inserting the output from an external command,
or for filtering the buffer (or the marked region) through
an external command, or for executing one of several tools.
(The old form of this menu name, 'extcmd', is deprecated.)
.TP
.B spell
The menu of the integrated spell checker where the user can edit a misspelled word.
.TP
.B linter
The linter menu, which allows jumping through the linting messages.
.TP
.B all
A special name that encompasses all menus.
For \fBbind\fR it means all menus where the specified \fIfunction\fR exists;
@@ -908,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 4.9" "March 2020"
.TH RNANO 1 "version 5.3" "October 2020"
.SH NAME
rnano \- a restricted nano

View File

@@ -1,15 +1,15 @@
## Sample initialization file for GNU nano.
##
## Characters that are special in a shell should not be escaped here.
## Inside string parameters, quotes should not be escaped -- the last
## double quote on the line will be seen as the closing quote.
##
## For the options that take parameters, the default value is shown.
## Other options are unset by default. To make sure that an option
## is disabled, you can use "unset <option>".
##
## Characters that are special in a shell should not be escaped here.
## Inside string parameters, quotes should not be escaped -- the last
## double quote on the line will be seen as the closing quote.
## Make the 'nextword' function (Ctrl+Right) stop at word ends
## instead of at beginnings.
## Make 'nextword' (Ctrl+Right) and 'chopwordright' (Ctrl+Delete)
## stop at word ends instead of at beginnings.
# set afterends
## When soft line wrapping is enabled, make it wrap lines at blanks
@@ -30,6 +30,9 @@
## Use bold text instead of reverse video text.
# set boldtext
## Treat any line with leading whitespace as the beginning of a paragraph.
# set bookstyle
## The characters treated as closing brackets when justifying paragraphs.
## This may not include any blank characters. Only closing punctuation,
## optionally followed by these closing brackets, can end sentences.
@@ -59,10 +62,13 @@
## Remember the used search/replace strings for the next session.
# set historylog
## Display a "scrollbar" on the righthand side of the edit window.
# set indicator
## Scroll the buffer contents per half-screen instead of per line.
# set jumpyscrolling
## Display line numbers to the left of the text.
## Display line numbers to the left (and any anchors in the margin).
# set linenumbers
## Enable vim-style lock-files. This is just to let a vim user know you
@@ -70,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.
@@ -130,6 +139,10 @@
## Regular expressions are of the extended type (ERE).
# set regexp
## Save a changed buffer automatically on exit; don't prompt.
# set saveonexit
## (The old form of this option, 'set tempfile', is deprecated.)
## Put the cursor on the highlighted item in the file browser, and show
## the cursor in the help viewer; useful for people who use a braille
## display and people with poor vision.
@@ -149,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.)
@@ -159,9 +176,6 @@
## Convert typed tabs to spaces.
# set tabstospaces
## Save automatically on exit; don't prompt.
# set tempfile
## Snip whitespace at the end of lines when justifying or hard-wrapping.
# set trimblanks
@@ -191,56 +205,42 @@
## Paint the interface elements of nano. These are examples;
## by default there are no colors, except for errorcolor.
# set titlecolor brightwhite,blue
# set statuscolor brightwhite,green
# set errorcolor brightwhite,red
# set selectedcolor brightwhite,magenta
# set titlecolor bold,lightwhite,blue
# set statuscolor bold,lightwhite,green
# 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 brightwhite,magenta
# set statuscolor brightwhite,magenta
# set errorcolor brightwhite,red
# set selectedcolor brightwhite,cyan
# 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 brightmagenta
# set keycolor lightmagenta
# set functioncolor magenta
## Setup of syntax coloring.
##
## syntax "name" ["filename regex" ...]
##
## color|icolor foreground,background "regex" ["regex"...]
## [...]
##
## 'color' will do case-sensitive matches, while 'icolor' will do
## case-insensitive matches.
##
## All color commands are applied in the order in which they are specified,
## meaning that later commands can recolor stuff that was colored earlier.
##
## Valid color names for foreground and background are: white, black, normal,
## red, blue, green, yellow, magenta, cyan. For foreground colors, you may
## use the prefix "bright" to get a stronger highlight.
##
## All regexes (regular expressions) are of the extended type (ERE).
##
## If the coloring rule should span multiple lines, use the following format:
##
## color fg,bg start="regex" end="regex"
##
## If you wish, you may put your syntax definitions in separate files.
## You can make use of such files as follows:
##
## include "/path/to/syntax_file.nanorc"
## === 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:
# include "@PKGDATADIR@/html.nanorc"
# include "@PKGDATADIR@/python.nanorc"
# include "@PKGDATADIR@/sh.nanorc"
## In @PKGDATADIR@/extra/ you can find some syntaxes that are
## 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':
@@ -250,8 +250,8 @@
# extendsyntax makefile tabgives " "
## Key bindings.
## See nanorc(5) (section REBINDING KEYS) for more details on this.
## === Key bindings ===
## For all details, see 'man nanorc', section REBINDING KEYS.
## The <Ctrl+Delete> keystroke deletes the word to the right of the cursor.
## On some terminals the <Ctrl+Backspace> keystroke produces ^H, which is
@@ -280,7 +280,7 @@
#bind ^X cut all
#bind ^C copy main
#bind ^V paste all
#bind ^P curpos main
#bind ^P location main
#bind ^A mark main
#unbind ^K main
#unbind ^U all

View File

@@ -1,29 +0,0 @@
2002-08-21 gettextize <bug-gnu-gettext@gnu.org>
* gettext.m4: Upgrade to gettext-0.11.5.
* ulonglong.m4: New file, from gettext-0.11.5.
* iconv.m4: Upgrade to gettext-0.11.5.
* intdiv0.m4: New file, from gettext-0.11.5.
* inttypes.m4: New file, from gettext-0.11.5.
* inttypes_h.m4: New file, from gettext-0.11.5.
* inttypes-pri.m4: New file, from gettext-0.11.5.
* lcmessage.m4: Upgrade to gettext-0.11.5.
* lib-link.m4: Upgrade to gettext-0.11.5.
* stdint_h.m4: New file, from gettext-0.11.5.
* uintmax_t.m4: New file, from gettext-0.11.5.
* Makefile.am (EXTRA_DIST): Add the new files.
2002-06-03 gettextize <bug-gnu-gettext@gnu.org>
* codeset.m4: Upgrade to gettext-0.11.2.
* gettext.m4: Upgrade to gettext-0.11.2.
* glibc21.m4: Upgrade to gettext-0.11.2.
* iconv.m4: Upgrade to gettext-0.11.2.
* isc-posix.m4: New file, from gettext-0.11.2.
* lcmessage.m4: Upgrade to gettext-0.11.2.
* lib-ld.m4: New file, from gettext-0.11.2.
* lib-link.m4: New file, from gettext-0.11.2.
* lib-prefix.m4: New file, from gettext-0.11.2.
* progtest.m4: Upgrade to gettext-0.11.2.
* Makefile.am (EXTRA_DIST): Add the new files.

View File

@@ -1,52 +0,0 @@
%define name @PACKAGE@
%define version @VERSION@
%define release 1
Name : %{name}
Version : %{version}
Release : %{release}
Summary : a user-friendly editor, a Pico clone with enhancements
License : GPLv3+
Group : Applications/Editors
URL : https://nano-editor.org/
Source : https://nano-editor.org/dist/latest/%{name}-%{version}.tar.gz
BuildRoot : %{_tmppath}/%{name}-%{version}-root
BuildRequires : autoconf, automake, gettext-devel, ncurses-devel, texinfo
Requires(post) : info
Requires(preun) : info
%description
GNU nano is a small and friendly text editor. It aims to emulate the
Pico text editor while also offering several enhancements.
%prep
%setup -q
%build
%configure
make
%install
make DESTDIR="%{buildroot}" install
#ln -s nano %{buildroot}/%{_bindir}/pico
rm -f %{buildroot}/%{_infodir}/dir
%post
/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir || :
%preun
if [ $1 = 0 ] ; then
/sbin/install-info --delete %{_infodir}/%{name}.info %{_infodir}/dir || :
fi
%files
%defattr(-,root,root)
%doc AUTHORS COPYING ChangeLog INSTALL NEWS README THANKS TODO doc/faq.html doc/sample.nanorc
%{_bindir}/*
%{_docdir}/nano/*
%{_mandir}/man*/*
%{_infodir}/nano.info*
%{_datadir}/locale/*/LC_MESSAGES/nano.mo
%{_datadir}/nano/*

View File

@@ -1,998 +0,0 @@
2014-05-28 Benno Schulenberg <bensberg@justemail.net>
* de.po, eo.po, nl.po: Updates for German, Dutch, and Esperanto.
2014-05-27 Benno Schulenberg <bensberg@justemail.net>
* de.po, nl.po, ru.po: Updates for Russian, Dutch, and German.
2014-05-25 Benno Schulenberg <bensberg@justemail.net>
* it.po, uk.po: Updates from the TP for Ukrainian and Italian.
2014-05-22 Benno Schulenberg <bensberg@justemail.net>
* de.po, uk.po: Updates from the TP for German and Ukrainian.
2014-05-16 Benno Schulenberg <bensberg@justemail.net>
* eo.po, fi.po, fr.po, nl.po, vi.po: Updates from the TP for
Vietnamese, Finnish, Dutch, French, and Esperanto.
2014-05-13 Benno Schulenberg <bensberg@justemail.net>
* nano.pot, *.po: Regenerated the POT file and refreshed the PO's.
2014-03-22 Benno Schulenberg <bensberg@justemail.net>
* nano.pot: Regenerated the POT file.
* cs.po, es.po, it.po, nb.po, sr.po, zh_TW: Updates from the TP
for Czech, Spanish, Italian, Norwegian, Serbian, and Chinese.
* LINGUAS: Removed rw (Kinyarwanda) -- it was just fragments.
2007-12-09 Jordi Mallach <jordi@gnu.org>
* LINGUAS: Add zh_CN.
* es.po, fr.po, it.po, nb.po, nl.po, pt_BR.po: New pull from the TP,
to fetch the now corrected latest pt_BR file.
2007-12-08 Jordi Mallach <jordi@gnu.org>
* zh_CN.po: New Simplified Chinese translation by
LI Daobing <lidaobing@gmail.com>.
* fr.po, ga.po, ms.po, nl.po, nn.po, vi.po: Translation updates taken
from the Translation Project.
* Refreshed the rest of the files from the latest TP archive.
2007-09-18 Jordi Mallach <jordi@gnu.org>
* po/ru.po: Updated Russian translation by Sergey A. Ribalchenko.
2007-08-11 David Lawrence Ramsey <pooka109@gmail.com>
* po/update.pl: Relicense to the GNU GPL version 3 or later.
2007-07-31 David Lawrence Ramsey <pooka109@gmail.com>
* po/update.pl: Update copyright notice to account for
modifications.
2007-01-29 David Lawrence Ramsey <pooka109@cox.net>
* ru.po: Updated Russian translation by Dimitriy Ryazantcev.
* ru.po: Fix incorrect "Project-Id-Version" entry and misplaced
space.
2007-01-13 David Lawrence Ramsey <pooka109@cox.net>
* es.po: Fix misplaced space.
* eu.po: Fix typos and misplaced space.
* fr.po: Fix misplaced space.
* gl.po: Fix typos and misplaced space.
* nb.po: Fix typos and more misplaced space.
2007-01-06 David Lawrence Ramsey <pooka109@cox.net>
* nb.po: Fix misplaced space.
2006-12-06 David Lawrence Ramsey <pooka109@cox.net>
* hu.po: Removed unneeded duplicate plural forms again.
* ms.po: Fix incorrect "Project-Id-Version" entry.
2006-12-06 Jordi Mallach <jordi@gnu.org>
* hu.po: Updated Hungarian translation by Gabor Kelemen.
* ms.po: Updated Malay translation by
Sharuzzaman Ahmat Raslan.
2006-11-20 David Lawrence Ramsey <pooka109@cox.net>
* tr.po: Removed unneeded blank plural forms, as gettext 0.15
generates errors upon encountering them.
2006-10-25 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by Jean-Philippe Guérard.
* nb.po: Updated Norwegian bokmål translation by
Geir Helland.
2006-10-16 Jordi Mallach <jordi@gnu.org>
* gl.po: Updated Galician translation by
Francisco Javier Tsao Santín.
2006-10-16 Jordi Mallach <jordi@gnu.org>
* eu.po: Updated Basque translation by Mikel Olasagasti.
2006-10-10 Jordi Mallach <jordi@gnu.org>
* gl.po: Updated Galician translation by
Francisco Javier Tsao Santín.
2006-10-02 Jordi Mallach <jordi@gnu.org>
* pt_BR.po: Refetch the current nano 1.9.99pre0 pt_BR file from
the TP, as the latest file offered is apparently for 1.3.11pre1.
2006-10-02 David Lawrence Ramsey <pooka109@cox.net>
* pt_BR.po: Restore previous version of pt_BR, as it was for
nano 1.9.99pre0, and the current version is for 1.3.11pre1.
2006-09-27 Jordi Mallach <jordi@gnu.org>
* pt_BR.po: Updated Brazilian Portuguese translation by
Joao Victor Duarte Martins.
2006-09-10 David Lawrence Ramsey <pooka109@cox.net>
* hu.po: Removed unneeded duplicate plural forms again.
2006-09-10 Jordi Mallach <jordi@gnu.org>
* hu.po: Updated Hungarian translation by Gabor Kelemen.
2006-09-02 Jordi Mallach <jordi@gnu.org>
* pt_BR.po: Updated Brazilian Portuguese translation by
Joao Victor Duarte Martins.
2006-09-01 Benno Schulenberg <bensberg@justemail.net>
* ChangeLog: Fix incorrect years in two entries.
2006-08-31 David Lawrence Ramsey <pooka109@cox.net>
* bg.po: Fix misplaced space.
2006-08-31 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* de.po: Updated German translation by Michael Piefel.
* es.po: Updated Spanish translation by
Ricardo Javier Cardenes Medina.
2006-08-28 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by Jean-Philippe Guérard.
2006-08-25 Jordi Mallach <jordi@gnu.org>
* bg.po: Updated Bulgarian translation by Anton Zinoviev.
* ca.po: Updated Catalan translation.
* ga.po: Updated Irish translation by Kevin Patrick Scannell.
* it.po: Updated Italian translation by Marco Colombo.
* nl.po: Updated Dutch translation by Benno Schulenberg.
* sv.po: Updated Swedish translation by Daniel Nylander.
2006-08-15 David Lawrence Ramsey <pooka109@cox.net>
* hu.po: Removed unneeded duplicate plural forms, as gettext
0.15 generates errors upon encountering them.
* id.po: Removed unneeded duplicate plural forms, as gettext
0.15 generates errors upon encountering them.
2006-06-20 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* fr.po: Updated French translation by Jean-Philippe Guérard.
* hu.po: Updated Hungarian translation by Gabor Kelemen.
* nl.po: Updated Dutch translation by Benno Schulenberg.
2006-06-20 David Lawrence Ramsey <pooka109@cox.net>
* fr.po: Fix incorrect "Project-Id-Version" entry.
* hu.po: Fix incorrect "Project-Id-Version" entry.
* it.po: Fix incorrect "Project-Id-Version" entry.
2006-06-19 Jordi Mallach <jordi@gnu.org>
* bg.po: Updated Bulgarian translation by Anton Zinoviev.
* ga.po: Updated Irish translation by Kevin Patrick Scannell.
2006-06-17 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* de.po: Updated German translation by Michael Piefel.
* fr.po: Updated French translation by Jean-Philippe Guérard.
* hu.po: Updated Hungarian translation by Gabor Kelemen.
* it.po: Updated Italian translation by Marco Colombo.
* nl.po: Updated Dutch translation by Benno Schulenberg.
2006-06-12 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by Jean-Philippe Guérard.
* hu.po: Updated Hungarian translation by Gabor Kelemen.
2006-06-09 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* ga.po: Updated Irish translation by Kevin Patrick Scannell.
* it.po: Updated Italian translation by Marco Colombo.
* nl.po: Updated Dutch translation by Benno Schulenberg.
2006-05-17 Jordi Mallach <jordi@gnu.org>
* LINGUAS: Added "ga".
* ga.po: New Irish translation by
Kevin Patrick Scannell <scannell@SLU.EDU>.
2006-05-10 Jordi Mallach <jordi@gnu.org>
* nl.po: Updated Dutch translation by Benno Schulenberg.
2006-03-15 Jordi Mallach <jordi@gnu.org>
* sv.po: Updated Swedish translation by Daniel Nylander.
2006-03-06 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Vietnamese translation by
Phan Vinh Thinh.
2005-12-21 Jordi Mallach <jordi@gnu.org>
* bg.po: Updated Bulgarian translation by Anton Zinoviev.
* ca.po: Updated Catalan translation.
* fr.po: Updated French translation by Jean-Philippe Guérard.
* ms.po: Updated Malay translation by Sharuzzaman Ahmat Raslan.
* zh_TW: Updated Traditional Chinese translation by
Wei-Lun Chao.
2005-12-13 Jordi Mallach <jordi@gnu.org>
* it.po: Updated Italian translation by Marco Colombo.
* de.po: Updated German translation by Michael Piefel.
* nl.po: Updated Dutch translation by Benno Schulenberg.
2005-11-08 David Lawrence Ramsey <pooka109@cox.net>
* POTFILES.in: Add prompt.c.
2005-11-05 David Lawrence Ramsey <pooka109@cox.net>
* POTFILES.in: Add browser.c.
2005-11-01 David Lawrence Ramsey <pooka109@cox.net>
* POTFILES.in: Add help.c.
2005-10-23 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* eu.po: Updated Basque translation by Mikel Olasagasti.
* fr.po: Updated French translation by Jean-Philippe Guérard.
* it.po: Updated Italian translation by Marco Colombo.
* ms.po: Updated Malay translation by Sharuzzaman Ahmat Raslan.
* nl.po: Updated Dutch translation by Benno Schulenberg.
* zh_TW: Updated Traditional Chinese translation by
Wei-Lun Chao.
2005-08-22 Jordi Mallach <jordi@gnu.org>
* bg.po: New Bulgarian translation by
Yavor Doganov <yavor@doganov.org>.
* LINGUAS: Added "bg".
2005-08-16 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
2005-08-16 Jordi Mallach <jordi@gnu.org>
* nl.po: Updated Dutch translation by
Benno Schulenberg and Reinout van Schouwen.
2005-07-24 David Lawrence Ramsey <pooka109@cox.net>
* POTFILES.in: Add text.c.
2005-07-19 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by
Sharuzzaman Ahmat Raslan.
2005-07-18 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by
Jean-Philippe Guérard.
2005-07-07 Jordi Mallach <jordi@gnu.org>
* it.po: Updated Italian translation by Marco Colombo.
* ca.po: Updated Catalan translation.
2005-06-28 David Lawrence Ramsey <pooka109@cox.net>
* POTFILES.in: Remove source files that contain no translatable
strings.
2005-06-19 David Lawrence Ramsey <pooka109@cox.net>
* pt_BR.po: Typo fix.
2005-06-15 Jordi Mallach <jordi@gnu.org>
* de.po: Typo fix by Jens Seidel.
2005-05-23 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by
Jean-Philippe Guérard.
2005-04-27 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by
Sharuzzaman Ahmat Raslan.
2005-04-22 Jordi Mallach <jordi@gnu.org>
* nb.po: Updated Norwegian bokmål translation by
Geir Helland.
2005-04-20 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by
Sharuzzaman Ahmat Raslan.
* ro.po: Updated Romanian translation by Laurentiu Buzdugan.
* zh_TW.po: Updated Traditional Chinese translation by
CHAO Wei-Lun.
2005-04-18 Jordi Mallach <jordi@gnu.org>
* vi.po: Updated Vietnamese translation by Phan Vinh Thinh.
2005-04-18 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* it.po: Updated Italian translation by Marco Colombo.
* ro.po: Updated Romanian translation by Laurentiu Buzdugan.
2005-04-14 Jordi Mallach <jordi@gnu.org>
* es.po: Updated Spanish translation by
Ricardo Javier Cárdenes Medina.
2005-04-13 Jordi Mallach <jordi@gnu.org>
* vi.po: New Vietnamese translation by Phan Vinh Thinh.
* LINGUAS: Added "vi".
2005-04-09 Jordi Mallach <jordi@gnu.org>
* zh_TW.po: Added Plural-Forms header and fix format specification
typos.
2005-04-08 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* it.po: Updated Italian translation by Marco Colombo.
* zh_TW.po: Updated Traditional Chinese translation by
CHAO Wei-Lun.
2005-04-06 Jordi Mallach <jordi@gnu.org>
* rw.po: New Kinyarwanda translation by Steve Murphy.
* LINGUAS: Added "rw".
2005-04-05 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by
Jean-Philippe Guérard.
* ro.po: Updated Romanian translation by
Laurentiu Buzdugan.
2005-03-11 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by
Sharuzzaman Ahmat Raslan.
2005-01-17 Jordi Mallach <jordi@gnu.org>
* pt_BR.po: Updated Brazilian Portuguese translation by
Joao Victor Duarte Martins.
2004-12-15 Jordi Mallach <jordi@gnu.org>
* it.po: Updated Italian translation by Marco Colombo.
2004-12-15 Jordi Mallach <jordi@gnu.org>
* sv.po: Updated Swedish translation by Christian Rose.
2004-12-13 Jordi Mallach <jordi@gnu.org>
* sv.po: Updated Swedish translation by Christian Rose.
2004-12-07 Jordi Mallach <jordi@gnu.org>
* it.po: Updated Italian translation by
Marco Colombo.
* ro.po: Updated Romanian translation by
Laurentiu Buzdugan.
2004-12-01 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* nb: Updated Norwegian bokmål translation by
Geir Helland.
* fr.po: Updated French translation by
Jean-Philippe Guérard.
2004-11-18 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by
Jean-Philippe Guérard.
2004-11-18 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by
Sharuzzaman Ahmat Raslan.
2004-10-07 Jordi Mallach <jordi@gnu.org>
* eu.po: Updated Basque translation by
Mikel Olasagasti.
2004-08-31 Jordi Mallach <jordi@gnu.org>
* es.po: Updated Spanish translation by
Ricardo Javier Cárdenes Medina.
2004-08-31 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated Catalan translation by
Jean-Philippe Guérard.
2004-08-27 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* de.po: Updated German translation by Michael Piefel.
2004-06-01 Jordi Mallach <jordi@gnu.org>
* zh_TW.po: Added Traditional Chinese translation by
CHAO Wei-Lun <chaoweilun@pcmail.com.tw>.
* LINGUAS: Added "zh_TW".
2004-02-24 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by Sharuzzaman Ahmat Raslan.
2003-11-25 Jordi Mallach <jordi@gnu.org>
* ro.po: Updated Romanian translation by Laurentiu Buzdugan.
2003-11-06 Jordi Mallach <jordi@gnu.org>
* sr.po: Added Serbian translation by Danilo Segan <dsegan@gmx.net>.
* LINGUAS: Added "sr" (Serbian), and alphabetize.
* ChangeLog: Recoded as UTF-8.
2003-10-30 Jordi Mallach <jordi@gnu.org>
* fi.po: Patch from Martin-Eric Racine <q-funk@pp.fishpool.fi>
to accept "Yy" and "Nn" as well as the Finnish letters in Yes/No
prompts.
2003-10-18 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
2003-09-12 Jordi Mallach <jordi@gnu.org>
* POTFILES.in: Updated path to sources.
2003-09-01 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by Jean-Philippe Guérard.
2003-08-17 Jordi Mallach <jordi@gnu.org>
* tr.po: Updated Turkish translation by A. Murat EREN.
2003-08-05 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
2003-06-11 Jordi Mallach <jordi@gnu.org>
* nb.po: Updated Norwegian bokmål translation by Geir Helland.
2003-06-10 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by Jean-Philippe Guérard.
2003-06-02 Jordi Mallach <jordi@gnu.org>
* de.po: Updated German translation by Michael Piefel.
2003-05-06 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by Sharuzzaman Ahmat Raslan.
2003-04-24 Jordi Mallach <jordi@gnu.org>
* ro.po: New Romanian translation by Laurentiu Buzdugan.
* id.po: Updated Indonesian translation by Tedi Heriyanto.
* LINGUAS: Added "ro" (Romanian).
2003-04-12 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by Sharuzzaman Ahmat Raslan.
2003-04-04 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by Jean-Philippe Guérard.
2003-03-17 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by Sharuzzaman Ahmat Raslan.
2003-03-10 Jordi Mallach <jordi@gnu.org>
* da.po: Updated Danish translation by Keld Simonsen.
2003-03-06 Jordi Mallach <jordi@gnu.org>
* ms.po: Updated Malay translation by Sharuzzaman Ahmat Raslan.
* id.po: Updated Indonesian translation by Tedi Heriyanto.
2003-02-23 Jordi Mallach <jordi@gnu.org>
* nl.po: Updated Dutch translation by Guus Sliepen.
2003-02-19 Jordi Mallach <jordi@gnu.org>
* fi.po: Updated Finnish translation by Kalle Olavi Niemitalo.
* es.po: Updated Spanish translation by Ricardo Javier Cárdenes
Medina.
2003-02-17 Jordi Mallach <jordi@gnu.org>
* de.po: Updated German translation by Michael Piefel.
* ru.po: Updated Russian translation by Sergey A. Ribalchenko.
* uk.po: Updated Ukrainian translation by Sergey A. Ribalchenko.
2003-02-16 Jordi Mallach <jordi@gnu.org>
* gl.po: Updated Galician translation by Jacobo Tarrío.
* fr.po: Updated French translation by Jean-Philippe Guérard.
2003-02-15 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated French translation by Jean-Philippe Guérard.
* nl.po: Updated Dutch translation by Guus Sliepen.
* sv.po: Updated Swedish translation by Christian Rose.
* ca.po: Updated Catalan translation.
2003-02-13 Jordi Mallach <jordi@gnu.org>
* ru.po: Updated Russian translation from Sergey A. Ribalchenko.
2003-02-10 Jordi Mallach <jordi@gnu.org>
* Makevars (XGETTEXT_OPTIONS): Added --keyword=P_:1,2.
* update.pl: likewise.
* fi.po: Added Plural-Forms: header.
2003-02-10 Jordi Mallach <jordi@gnu.org>
* fi.po: Updated Finnish translation by Kalle Kivimaa and
Kalle Olavi Niemitalo.
2003-02-08 Chris Allegretta <chrisa@asty.org>
* it.po: Fix broken format string in translation.
2003-02-08 Jordi Mallach <jordi@gnu.org>
* it.po: Updated Italian translation by Marco Colombo.
* gl.po: Updated Galician translation by Jacobo Tarrío.
* es.po: Updated Spanish translation by Ricardo Javier Cárdenes
Medina.
2003-02-06 Jordi Mallach <jordi@gnu.org>
* pl.po: Updated Polish translation by Wojciech Kotwica.
* sv.po: Updated Swedish translation by Christian Rose.
2003-02-04 Jordi Mallach <jordi@gnu.org>
* ca.po: Updated Catalan translation.
* fr.po: Updated French translation by Jean-Philippe Guérard.
* uk.po: Updated Ukrainian translation by Sergey A. Ribalchenko.
* de.po: Updated German translation by Michael Piefel.
2003-01-27 Jordi Mallach <jordi@gnu.org>
* es.po: Updated translation by Ricardo Javier Cárdenes Medina.
2002-01-26 Jordi Mallach <jordi@gnu.org>
* pl.po: Updated translation by Wojciech Kotwica.
2002-01-25 Jordi Mallach <jordi@gnu.org>
* gl.po: Updated translation by Jacobo Tarrío.
2002-01-22 Jordi Mallach <jordi@gnu.org>
* de.po: Updated translation by Michael Piefel.
2003-01-21 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated translation by Jean-Philippe Guérard.
* ms.po: Updated translation by Sharuzzaman Ahmat Raslan.
* uk.po: Updated translation by Sergey A. Ribalchenko.
2003-01-18 Jordi Mallach <jordi@gnu.org>
* fr.po: Updated translation by Jean-Philippe Guérard.
* sv.po: Updated translation by Christian Rose.
* nl.po: Updated translation by Guus Sliepen.
* ca.po: Updated translation.
2003-01-15 Jordi Mallach <jordi@gnu.org>
* Makefile.in.in: Removed, generated by autopoint.
* Rules-quot: Likewise.
* boldquot.sed: Likewise.
* en@boldquot.header: Likewise.
* en@quot.header: Likewise.
* insert-header.sin: Likewise.
* quot.sed: Likewise.
* remove-potcdate.sin: Likewise.
2003-01-15 Jordi Mallach <jordi@gnu.org>
* LINGUAS: New file, exported values from configure.ac's ALL_LINGUAS.
* it.po: Updated translation by Marco Colombo.
* eu.po: New Basque translation by Peio Ziarsolo.
2002-12-14 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
* tr.po: New Turkish translation by Doruk Fisek.
2002-11-10 Jordi Mallach <jordi@sindominio.net>
* uk.po: Updated translation by Sergey A. Ribalchenko.
* da.po: Updated translation by Keld Simonsen.
2002-11-05 Jordi Mallach <jordi@sindominio.net>
* ms.po: Updated translation by Sharuzzaman Ahmat Raslan.
2002-11-03 Jordi Mallach <jordi@sindominio.net>
* sv.po: Updated translation by Christian Rose.
* pl.po: Updated translation by Wojciech Kotwica.
2002-10-29 Jordi Mallach <jordi@sindominio.net>
* id.po: Updated translation by Tedi Heriyanto.
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-10-27 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-10-26 Jordi Mallach <jordi@sindominio.net>
* es.po: Updated translation by Ricardo Javier Cárdenes Medina.
2002-10-26 Jordi Mallach <jordi@sindominio.net>
* gl.po: Updated translation by Jacobo Tarrío.
* sv.po: Updated translation by Christian Rose.
* de.po: Updated translation by Michael Piefel.
* fr.po: Updated translation by Jean-Philippe Guérard.
* ca.po: Updated translation.
2002-10-17 Jordi Mallach <jordi@sindominio.net>
* de.po: Updated translation by Michel Piefel.
2002-10-14 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-10-13 Jordi Mallach <jordi@sindominio.net>
* es.po: Updated translation by Ricardo Javier Cárdenes Medina.
2002-10-08 Jordi Mallach <jordi@sindominio.net>
* id.po: Updated translation by Tedi Heriyanto.
* ms.po: Updated translation by Sharuzzaman Ahmat Raslan.
2002-10-07 Jordi Mallach <jordi@sindominio.net>
* de.po: Updated translation by Michel Piefel.
2002-10-07 Jordi Mallach <jordi@sindominio.net>
* ca.po: Updated translation.
2002-10-07 Jordi Mallach <jordi@sindominio.net>
* sv.po: Updated translation by Christian Rose.
* gl.po: Updated translation by Jacobo Tarrío.
* pl.po: Updated translation by Wojciech Kotwica.
2002-09-08 Jordi Mallach <jordi@sindominio.net>
* ms.po: Updated translation by Sharuzzaman Ahmat Raslan.
2002-09-08 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
* da.po: Updated translation by Keld Simonsen.
2002-08-19 Jordi Mallach <jordi@sindominio.net>
* de.po: Updated translation by Michael Piefel.
* ms.po: Updated translation by Sharuzzaman Ahmat Raslan.
2002-07-31 Jordi Mallach <jordi@sindominio.net>
* gl.po: Updated translation by Jacobo Tarrío.
2002-07-31 Jordi Mallach <jordi@sindominio.net>
* es.po: Updated translation by Ricardo Javier Cárdenes Medina.
2002-07-31 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-07-30 Jordi Mallach <jordi@sindominio.net>
* pl.po: Updated translation by Wojciech Kotwica.
* sv.po: Upadted translation by Christian Rose.
2002-07-29 Jordi Mallach <jordi@sindominio.net>
* ca.po: Updated translation.
2002-07-29 Jordi Mallach <jordi@sindominio.net>
* sv.po: Updated translation by Christian Rose.
2002-07-27 Jordi Mallach <jordi@sindominio.net>
* pt_BR.po: New Brazilian Portuguese translation by
Claudio Neves.
2002-07-25 Jordi Mallach <jordi@sindominio.net>
* id.po: Updated translation by Tedi Heriyanto.
2002-07-09 Jordi Mallach <jordi@sindominio.net>
* de.po: Updated translation by Michael Piefel.
2002-07-07 Jordi Mallach <jordi@sindominio.net>
* da.po: Updated translation by Keld Simonsen.
2002-07-03 Jordi Mallach <jordi@sindominio.net>
* ms.po: New Bahasa Melayu translation by
Sharuzzaman Ahmat Raslan.
2002-06-03 gettextize <bug-gnu-gettext@gnu.org>
* Makefile.in.in: Upgrade to gettext-0.11.2.
* Rules-quot: New file, from gettext-0.11.2.
* boldquot.sed: New file, from gettext-0.11.2.
* en@boldquot.header: New file, from gettext-0.11.2.
* en@quot.header: New file, from gettext-0.11.2.
* insert-header.sin: New file, from gettext-0.11.2.
* quot.sed: New file, from gettext-0.11.2.
* remove-potcdate.sin: New file, from gettext-0.11.2.
2002-05-13 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
* de.po: Updated translation by Michael Piefel.
2002-05-13 Jordi Mallach <jordi@sindominio.net>
* it.po: Updated translation by Marco Colombo.
* gl.po: Updated translation by Jacobo Tarrío.
* ca.po: Updated translation.
* es.po: Updated translation.
2002-05-13 Jordi Mallach <jordi@sindominio.net>
* sv.po: Updated translation by Christian Rose.
2002-05-05 Jordi Mallach <jordi@sindominio.net>
* sv.po: Updated translation by Christian Rose.
2002-04-25 Jordi Mallach <jordi@sindominio.net>
* id.po: Updated translation by Tedi Heriyanto.
2002-04-19 Jordi Mallach <jordi@sindominio.net>
* ru.po: Updated translation by Sergey A. Ribalchenko.
* uk.po: Updated translation by Sergey A. Ribalchenko.
2002-04-13 Jordi Mallach <jordi@sindominio.net>
* it.po: Updated translation by Marco Colombo.
2002-04-13 Jordi Mallach <jordi@sindominio.net>
* nl.po: Updated translation by Guus Sliepen.
2002-04-10 Jordi Mallach <jordi@sindominio.net>
* sv.po: Updated translation by Christian Rose.
2002-04-05 Jordi Mallach <jordi@sindominio.net>
* gl.po: Updated translation by Jacobo Tarrio.
* de.po: Updated translation by Michael Piefel.
* fr.po: Updated translation by Jean-Philippe Guérard.
* ca.po: Updated.
* es.po: Updated.
2002-03-29 Jordi Mallach <jordi@sindominio.net>
* da.po: Updated translation by Keld Simonsen.
2002-03-27 Jordi Mallach <jordi@sindominio.net>
* it.po: Updated translation by Marco Colombo.
2002-03-25 Jordi Mallach <jordi@sindominio.net>
* id.po: Updated translation by Tedi Heriyanto.
2002-03-17 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-03-15 Jordi Mallach <jordi@sindominio.net>
* pl.po: Updated translation by Wojciech Kotwica.
2002-03-14 Jordi Mallach <jordi@sindominio.net>
* uk.po, ru.po: Updated translations by Sergey A.
Ribalchenko.
2002-03-12 Jordi Mallach <jordi@sindominio.net>
* ca.po: Updated to current CVS.
* es.po: Updated to current CVS.
* gl.po: Updated translation to current CVS by Jacobo Tarrio.
2002-03-12 Jordi Mallach <jordi@sindominio.net>
* gl.po: Updated translation by Jacobo Tarrio.
2002-03-11 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-03-09 Jordi Mallach <jordi@sindominio.net>
* id.po: Updated translation by Tedi Heriyanto.
* ca.po: Updated.
* es.po: Updated.
2002-03-07 Jordi Mallach <jordi@sindominio.net>
* sv.po: Updated translation by Christian Rose.
* de.po: Updated translation by Michael Piefel.
2002-03-05 Jordi Mallach <jordi@sindominio.net>
* pl.po: Updated translation by Wojciech Kotwica.
2002-02-20 Jordi Mallach <jordi@sindominio.net>
* nl.po: Updated translation by Guus Sliepen.
2002-02-15 Jordi Mallach <jordi@sindominio.net>
* nb.po: Updated translation by Stig E Sandoe.
2002-02-15 Jordi Mallach <jordi@sindominio.net>
* nb.po: Updated translation by Stig E Sandoe.
2002-02-14 Jordi Mallach <jordi@sindominio.net>
* da.po: Updated translation by Keld Simonsen.
2002-02-10 Jordi Mallach <jordi@sindominio.net>
* hu.po: Updated translation by Gergely Nagy.
2002-02-07 Jordi Mallach <jordi@sindominio.net>
* uk.po, ru.po: Updated translations by Sergey A.
Ribalchenko.
2002-02-06 Jordi Mallach <jordi@sindominio.net>
* hu.po: Updated translation by Gergely Nagy.
2002-02-06 Jordi Mallach <jordi@sindominio.net>
* cs.po: Incomplete update by Václav Haisman.
2002-01-27 Jordi Mallach <jordi@sindominio.net>
* it.po: Updated translation by Marco Colombo.
2002-01-26 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
* nn.po: Updated translation by Kjetil Torgrim Homme.
* de.po: Updated translation by Michael Piefel.
2002-01-25 Jordi Mallach <jordi@sindominio.net>
* sv.po: Updated translation by Christian Rose.
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-01-25 Jordi Mallach <jordi@sindominio.net>
* ca.po: Updated.
* es.po: Updated.
2002-01-23 Jordi Mallach <jordi@sindominio.net>
* ca.po: Updated.
* es.po: Updated.
2002-01-19 gettextize <bug-gnu-utils@gnu.org>
* Makefile.in.in: Upgrade to gettext-0.10.40.
* cat-id-tbl.c: Remove file.
* stamp-cat-id: Remove file.
2002-01-19 Jordi Mallach <jordi@sindominio.net>
* ca.po: Updated.
* es.po: Updated.
2002-01-19 Jordi Mallach <jordi@sindominio.net>
* da.po: Updated translation by Keld Simonsen.
2002-01-17 Jordi Mallach <jordi@sindominio.net>
* no.po: Removed, replaced by nn.po.
* nn.po: Updated translation by Kjetil Torgrim Homme.
* nb.po: New Norwegian bokmål translation by Stig E Sandoe.
2002-01-12 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-01-10 Jordi Mallach <jordi@sindominio.net>
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-01-08 Jordi Mallach <jordi@sindominio.net>
* ru.po, uk.po: Updated translations by Sergey A.
Ribalchenko.
* fr.po: Updated translation by Jean-Philippe Guérard.
2002-01-07 Jordi Mallach <jordi@sindominio.net>
* de.po: Updated translation by Michael Piefel.
2002-01-07 Jordi Mallach <jordi@sindominio.net>
* sv.po: Updated translation by Christian Rose.
2002-01-07 Jordi Mallach <jordi@sindominio.net>
* ca.po: Updated.
* es.po: Updated.

1970
po/bg.po

File diff suppressed because it is too large Load Diff

1981
po/ca.po

File diff suppressed because it is too large Load Diff

2023
po/cs.po

File diff suppressed because it is too large Load Diff

1741
po/da.po

File diff suppressed because it is too large Load Diff

2000
po/de.po

File diff suppressed because it is too large Load Diff

1969
po/eo.po

File diff suppressed because it is too large Load Diff

1981
po/es.po

File diff suppressed because it is too large Load Diff

1970
po/eu.po

File diff suppressed because it is too large Load Diff

1864
po/fi.po

File diff suppressed because it is too large Load Diff

1740
po/fr.po

File diff suppressed because it is too large Load Diff

1989
po/ga.po

File diff suppressed because it is too large Load Diff

1984
po/gl.po

File diff suppressed because it is too large Load Diff

2143
po/hr.po

File diff suppressed because it is too large Load Diff

1764
po/hu.po

File diff suppressed because it is too large Load Diff

1997
po/id.po

File diff suppressed because it is too large Load Diff

1744
po/it.po

File diff suppressed because it is too large Load Diff

1744
po/ja.po

File diff suppressed because it is too large Load Diff

1807
po/ko.po

File diff suppressed because it is too large Load Diff

2011
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1753
po/nb.po

File diff suppressed because it is too large Load Diff

1971
po/nl.po

File diff suppressed because it is too large Load Diff

1980
po/nn.po

File diff suppressed because it is too large Load Diff

1971
po/pl.po

File diff suppressed because it is too large Load Diff

1978
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1976
po/ro.po

File diff suppressed because it is too large Load Diff

1981
po/ru.po

File diff suppressed because it is too large Load Diff

1972
po/sl.po

File diff suppressed because it is too large Load Diff

2028
po/sr.po

File diff suppressed because it is too large Load Diff

1834
po/sv.po

File diff suppressed because it is too large Load Diff

1972
po/tr.po

File diff suppressed because it is too large Load Diff

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

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

View File

@@ -21,7 +21,10 @@ revision.h: FORCE
FORCE:
bin_PROGRAMS = nano
nano_SOURCES = browser.c \
nano_SOURCES = \
definitions.h \
prototypes.h \
browser.c \
chars.c \
color.c \
cut.c \
@@ -31,9 +34,7 @@ nano_SOURCES = browser.c \
history.c \
move.c \
nano.c \
nano.h \
prompt.c \
proto.h \
rcfile.c \
search.c \
text.c \

View File

@@ -19,7 +19,7 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#ifdef ENABLE_BROWSER
@@ -39,352 +39,6 @@ static size_t longest = 0;
static size_t selected = 0;
/* The currently selected filename in the list; zero-based. */
/* Our main file browser function. path is the tilde-expanded path we
* start browsing from. */
char *do_browser(char *path)
{
char *retval = NULL;
int kbinput;
char *present_name = NULL;
/* The name of the currently selected file, or of the directory we
* were in before backing up to "..". */
size_t old_selected;
/* The number of the selected file before the current selected file. */
functionptrtype func;
/* The function of the key the user typed in. */
DIR *dir;
/* The directory whose contents we are showing. */
read_directory_contents:
/* We come here when we refresh or select a new directory. */
path = free_and_assign(path, get_full_path(path));
if (path != NULL)
dir = opendir(path);
if (path == NULL || dir == NULL) {
statusline(ALERT, _("Cannot open directory: %s"), strerror(errno));
/* If we don't have a file list yet, there is nothing to show. */
if (filelist == NULL) {
napms(1200);
lastmessage = HUSH;
free(path);
free(present_name);
return NULL;
}
path = mallocstrcpy(path, present_path);
present_name = mallocstrcpy(present_name, filelist[selected]);
}
if (dir != NULL) {
/* Get the file list, and set longest and width in the process. */
read_the_list(path, dir);
closedir(dir);
dir = NULL;
}
/* If given, reselect the present_name and then discard it. */
if (present_name != NULL) {
browser_select_dirname(present_name);
free(present_name);
present_name = NULL;
/* Otherwise, select the first file or directory in the list. */
} else
selected = 0;
old_selected = (size_t)-1;
present_path = mallocstrcpy(present_path, path);
titlebar(path);
while (TRUE) {
lastmessage = HUSH;
bottombars(MBROWSER);
/* Display (or redisplay) the file list if the list itself or
* the selected file has changed. */
if (old_selected != selected || ISSET(SHOW_CURSOR))
browser_refresh();
old_selected = selected;
kbinput = get_kbinput(edit, ISSET(SHOW_CURSOR));
#ifdef ENABLE_MOUSE
if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y;
/* We can click on the edit window to select a filename. */
if (get_mouseinput(&mouse_y, &mouse_x, TRUE) == 0 &&
wmouse_trafo(edit, &mouse_y, &mouse_x, FALSE)) {
/* longest is the width of each column. There
* are two spaces between each column. */
selected = selected - selected % (editwinrows * width) +
(mouse_y * width) + (mouse_x / (longest + 2));
/* If they clicked beyond the end of a row,
* select the last filename in that row. */
if (mouse_x > width * (longest + 2))
selected--;
/* If we're beyond the list, select the last filename. */
if (selected > filelist_len - 1)
selected = filelist_len - 1;
/* If we selected the same filename as last time, fake a
* press of the Enter key so that the file is read in. */
if (old_selected == selected)
kbinput = KEY_ENTER;
}
if (kbinput == KEY_MOUSE)
continue;
}
#endif /* ENABLE_MOUSE */
#ifndef NANO_TINY
if (bracketed_paste || kbinput == BRACKETED_PASTE_MARKER) {
beep();
continue;
}
#endif
func = interpret(&kbinput);
if (func == total_refresh) {
total_redraw();
#ifndef NANO_TINY
/* Simulate a window resize to force a directory reread. */
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
} else if (func == do_search_forward) {
do_filesearch(FORWARD);
} else if (func == do_search_backward) {
do_filesearch(BACKWARD);
} else if (func == do_findprevious) {
do_fileresearch(BACKWARD);
} else if (func == do_findnext) {
do_fileresearch(FORWARD);
} else if (func == do_left) {
if (selected > 0)
selected--;
} else if (func == do_right) {
if (selected < filelist_len - 1)
selected++;
} else if (func == to_prev_word) {
selected -= (selected % width);
} else if (func == to_next_word) {
selected += width - 1 - (selected % width);
if (selected >= filelist_len)
selected = filelist_len - 1;
} else if (func == do_up) {
if (selected >= width)
selected -= width;
} else if (func == do_down) {
if (selected + width <= filelist_len - 1)
selected += width;
} else if (func == to_prev_block) {
selected = ((selected / (editwinrows * width)) *
editwinrows * width) + selected % width;
} else if (func == to_next_block) {
selected = ((selected / (editwinrows * width)) *
editwinrows * width) + selected % width +
editwinrows * width - width;
if (selected >= filelist_len)
selected = (filelist_len / width) * width + selected % width;
if (selected >= filelist_len)
selected -= width;
} else if (func == do_page_up) {
if (selected < width)
selected = 0;
else if (selected < editwinrows * width)
selected = selected % width;
else
selected -= editwinrows * width;
} else if (func == do_page_down) {
if (selected + width >= filelist_len - 1)
selected = filelist_len - 1;
else if (selected + editwinrows * width >= filelist_len)
selected = (selected + editwinrows * width - filelist_len) %
width + filelist_len - width;
else
selected += editwinrows * width;
} else if (func == to_first_file) {
selected = 0;
} else if (func == to_last_file) {
selected = filelist_len - 1;
} else if (func == goto_dir) {
/* Ask for the directory to go to. */
if (do_prompt(TRUE, FALSE, MGOTODIR, "", NULL,
/* TRANSLATORS: This is a prompt. */
browser_refresh, _("Go To Directory")) < 0) {
statusbar(_("Cancelled"));
continue;
}
path = free_and_assign(path, real_dir_from_tilde(answer));
/* If the given path is relative, join it with the current path. */
if (*path != '/') {
path = charealloc(path, strlen(present_path) +
strlen(answer) + 1);
sprintf(path, "%s%s", present_path, answer);
}
#ifdef ENABLE_OPERATINGDIR
if (outside_of_confinement(path, FALSE)) {
/* TRANSLATORS: This refers to the confining effect of the
* option --operatingdir, not of --restricted. */
statusline(ALERT, _("Can't go outside of %s"), operating_dir);
path = mallocstrcpy(path, present_path);
continue;
}
#endif
/* Snip any trailing slashes, so the name can be compared. */
while (strlen(path) > 1 && path[strlen(path) - 1] == '/')
path[strlen(path) - 1] = '\0';
/* In case the specified directory cannot be entered, select it
* (if it is in the current list) so it will be highlighted. */
for (size_t j = 0; j < filelist_len; j++)
if (strcmp(filelist[j], path) == 0)
selected = j;
/* Try opening and reading the specified directory. */
goto read_directory_contents;
} else if (func == do_enter) {
struct stat st;
/* It isn't possible to move up from the root directory. */
if (strcmp(filelist[selected], "/..") == 0) {
statusline(ALERT, _("Can't move up a directory"));
continue;
}
#ifdef ENABLE_OPERATINGDIR
/* Note: The selected file can be outside the operating
* directory if it's ".." or if it's a symlink to a
* directory outside the operating directory. */
if (outside_of_confinement(filelist[selected], FALSE)) {
statusline(ALERT, _("Can't go outside of %s"), operating_dir);
continue;
}
#endif
/* If for some reason the file is inaccessible, complain. */
if (stat(filelist[selected], &st) == -1) {
statusline(ALERT, _("Error reading %s: %s"),
filelist[selected], strerror(errno));
continue;
}
/* If it isn't a directory, a file was selected -- we're done. */
if (!S_ISDIR(st.st_mode)) {
retval = copy_of(filelist[selected]);
break;
}
/* If we are moving up one level, remember where we came from, so
* this directory can be highlighted and easily reentered. */
if (strcmp(tail(filelist[selected]), "..") == 0)
present_name = strip_last_component(filelist[selected]);
/* Try opening and reading the selected directory. */
path = mallocstrcpy(path, filelist[selected]);
goto read_directory_contents;
#ifdef ENABLE_NANORC
} else if (func == (functionptrtype)implant) {
implant(first_sc_for(MBROWSER, func)->expansion);
#endif
#ifndef NANO_TINY
} else if (kbinput == KEY_WINCH) {
; /* Nothing to do. */
#endif
} else if (func == do_exit) {
break;
} else
unbound_key(kbinput);
#ifndef NANO_TINY
/* If the window resized, refresh the file list. */
if (kbinput == KEY_WINCH) {
/* Remember the selected file, to be able to reselect it. */
present_name = copy_of(filelist[selected]);
/* Reread the contents of the current directory. */
goto read_directory_contents;
}
#endif
}
titlebar(NULL);
edit_refresh();
free(path);
free_chararray(filelist, filelist_len);
filelist = NULL;
filelist_len = 0;
return retval;
}
/* The file browser front end. We check to see if inpath has a
* directory in it. If it does, we start do_browser() from there.
* Otherwise, we start do_browser() from the current directory. */
char *do_browse_from(const char *inpath)
{
struct stat st;
char *path;
/* This holds the tilde-expanded version of inpath. */
path = real_dir_from_tilde(inpath);
/* Perhaps path is a directory. If so, we'll pass it to
* do_browser(). Or perhaps path is a directory / a file. If so,
* we'll try stripping off the last path element and passing it to
* do_browser(). Or perhaps path doesn't have a directory portion
* at all. If so, we'll just pass the current directory to
* do_browser(). */
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
path = free_and_assign(path, strip_last_component(path));
if (stat(path, &st) == -1 || !S_ISDIR(st.st_mode)) {
char *currentdir = charalloc(PATH_MAX + 1);
free(path);
path = getcwd(currentdir, PATH_MAX + 1);
if (path == NULL) {
free(currentdir);
statusline(MILD, _("The working directory has disappeared"));
beep();
napms(1200);
return NULL;
}
}
}
#ifdef ENABLE_OPERATINGDIR
/* If the resulting path isn't in the operating directory, use
* the operating directory instead. */
if (outside_of_confinement(path, FALSE))
path = mallocstrcpy(path, operating_dir);
#endif
return do_browser(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
@@ -424,7 +78,7 @@ void read_the_list(const char *path, DIR *dir)
filelist_len = i;
filelist = (char **)nmalloc(filelist_len * sizeof(char *));
filelist = nmalloc(filelist_len * sizeof(char *));
i = 0;
@@ -433,7 +87,7 @@ void read_the_list(const char *path, DIR *dir)
if (strcmp(nextdir->d_name, ".") == 0)
continue;
filelist[i] = charalloc(path_len + strlen(nextdir->d_name) + 1);
filelist[i] = nmalloc(path_len + strlen(nextdir->d_name) + 1);
sprintf(filelist[i], "%s%s", path, nextdir->d_name);
i++;
@@ -453,8 +107,31 @@ void read_the_list(const char *path, DIR *dir)
width = (COLS + 2) / (longest + 2);
}
/* Set width to the number of files that we can display per screen row,
* if necessary, and display the list of files. */
/* 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;
@@ -467,11 +144,8 @@ void browser_refresh(void)
titlebar(present_path);
blank_edit();
wmove(edit, 0, 0);
for (size_t index = selected - selected % (editwinrows * width);
index < filelist_len && row < editwinrows; index++) {
struct stat st;
const char *thename = tail(filelist[index]);
/* The filename we display, minus the path. */
size_t namelen = breadth(thename);
@@ -488,6 +162,7 @@ void browser_refresh(void)
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. */
@@ -503,20 +178,18 @@ void browser_refresh(void)
mvwaddstr(edit, row, col, "...");
mvwaddstr(edit, row, dots ? col + 3 : col, disp);
free(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], &st) == -1 || S_ISLNK(st.st_mode)) {
if (stat(filelist[index], &st) == -1 || !S_ISDIR(st.st_mode))
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(st.st_mode)) {
} 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)"));
@@ -524,18 +197,18 @@ void browser_refresh(void)
} else
info = copy_of(_("(dir)"));
} else {
off_t result = st.st_size;
off_t result = state.st_size;
char modifier;
info = charalloc(infomaxlen + 1);
info = nmalloc(infomaxlen + 1);
/* Massage the file size into a human-readable form. */
if (st.st_size < (1 << 10))
if (state.st_size < (1 << 10))
modifier = ' '; /* bytes */
else if (st.st_size < (1 << 20)) {
else if (state.st_size < (1 << 20)) {
result >>= 10;
modifier = 'K'; /* kilobytes */
} else if (st.st_size < (1 << 30)) {
} else if (state.st_size < (1 << 30)) {
result >>= 20;
modifier = 'M'; /* megabytes */
} else {
@@ -565,13 +238,13 @@ void browser_refresh(void)
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 isn't going to fit on the current row,
* move to the next row. */
/* If the next entry will not fit on this row, move to next row. */
if (col > COLS - longest) {
row++;
col = 0;
@@ -587,69 +260,6 @@ void browser_refresh(void)
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(FALSE, FALSE, 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)
@@ -709,49 +319,66 @@ void findfile(const char *needle, bool forwards)
selected = looking_at;
}
/* Search for a filename. If forwards is TRUE, search forward in the list;
* otherwise, search backward.*/
void do_filesearch(bool forwards)
/* 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)
{
/* If the user cancelled or jumped to first or last file, don't search. */
if (filesearch_init(forwards) != 0)
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 answer is now "", copy last_search into answer. */
if (*answer == '\0')
answer = mallocstrcpy(answer, last_search);
else
/* If the user typed an answer, remember it. */
if (*answer != '\0') {
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);
findfile(last_search, forwards);
}
/* Search again without prompting for the last given search string,
* either forwards or backwards. */
void do_fileresearch(bool forwards)
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
else {
wipe_statusbar();
findfile(last_search, forwards);
}
/* Select the first file in the list. */
void to_first_file(void)
{
selected = 0;
}
/* Select the last file in the list. */
void to_last_file(void)
{
selected = filelist_len - 1;
}
}
/* Strip one element from the end of path, and return the stripped path.
@@ -767,4 +394,344 @@ char *strip_last_component(const char *path)
return copy;
}
/* Allow the user to browse through the directories in the filesystem,
* starting at the given path. */
char *browse(char *path)
{
char *present_name = NULL;
/* The name of the currently selected file, or of the directory we
* were in before backing up to "..". */
size_t old_selected;
/* The number of the selected file before the current selected file. */
DIR *dir;
/* The directory whose contents we are showing. */
char *chosen = NULL;
/* The name of the file that the user picked, or NULL if none. */
read_directory_contents:
/* We come here when the user refreshes or selects a new directory. */
path = free_and_assign(path, get_full_path(path));
if (path != NULL)
dir = opendir(path);
if (path == NULL || dir == NULL) {
statusline(ALERT, _("Cannot open directory: %s"), strerror(errno));
/* If we don't have a file list yet, there is nothing to show. */
if (filelist == NULL) {
lastmessage = VACUUM;
free(present_name);
free(path);
napms(1200);
return NULL;
}
path = mallocstrcpy(path, present_path);
present_name = mallocstrcpy(present_name, filelist[selected]);
}
if (dir != NULL) {
/* Get the file list, and set longest and width in the process. */
read_the_list(path, dir);
closedir(dir);
dir = NULL;
}
/* If given, reselect the present_name and then discard it. */
if (present_name != NULL) {
browser_select_dirname(present_name);
free(present_name);
present_name = NULL;
/* Otherwise, select the first file or directory in the list. */
} else
selected = 0;
old_selected = (size_t)-1;
present_path = mallocstrcpy(present_path, path);
titlebar(path);
while (TRUE) {
functionptrtype func;
int kbinput;
lastmessage = VACUUM;
bottombars(MBROWSER);
/* Display (or redisplay) the file list if the list itself or
* the selected file has changed. */
if (old_selected != selected || ISSET(SHOW_CURSOR))
browser_refresh();
old_selected = selected;
kbinput = get_kbinput(edit, ISSET(SHOW_CURSOR));
#ifdef ENABLE_MOUSE
if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y;
/* We can click on the edit window to select a filename. */
if (get_mouseinput(&mouse_y, &mouse_x, TRUE) == 0 &&
wmouse_trafo(edit, &mouse_y, &mouse_x, FALSE)) {
/* longest is the width of each column. There
* are two spaces between each column. */
selected = selected - selected % (editwinrows * width) +
(mouse_y * width) + (mouse_x / (longest + 2));
/* If they clicked beyond the end of a row,
* select the last filename in that row. */
if (mouse_x > width * (longest + 2))
selected--;
/* If we're beyond the list, select the last filename. */
if (selected > filelist_len - 1)
selected = filelist_len - 1;
/* If we selected the same filename as last time, fake a
* press of the Enter key so that the file is read in. */
if (old_selected == selected)
kbinput = KEY_ENTER;
}
if (kbinput == KEY_MOUSE)
continue;
}
#endif /* ENABLE_MOUSE */
#ifndef NANO_TINY
if (bracketed_paste || kbinput == BRACKETED_PASTE_MARKER) {
beep();
continue;
}
#endif
func = interpret(&kbinput);
if (func == full_refresh) {
full_refresh();
#ifndef NANO_TINY
/* Simulate a window resize to force a directory reread. */
kbinput = KEY_WINCH;
#endif
} else if (func == do_help) {
do_help();
#ifndef NANO_TINY
/* The window dimensions might have changed, so act as if. */
kbinput = KEY_WINCH;
#endif
#ifndef NANO_TINY
} else if (func == do_toggle_void) {
TOGGLE(NO_HELP);
window_init();
kbinput = KEY_WINCH;
#endif
} else if (func == do_search_backward) {
search_filename(BACKWARD);
} else if (func == do_search_forward) {
search_filename(FORWARD);
} else if (func == do_findprevious) {
research_filename(BACKWARD);
} else if (func == do_findnext) {
research_filename(FORWARD);
} else if (func == do_left) {
if (selected > 0)
selected--;
} else if (func == do_right) {
if (selected < filelist_len - 1)
selected++;
} else if (func == to_prev_word) {
selected -= (selected % width);
} else if (func == to_next_word) {
selected += width - 1 - (selected % width);
if (selected >= filelist_len)
selected = filelist_len - 1;
} else if (func == do_up) {
if (selected >= width)
selected -= width;
} else if (func == do_down) {
if (selected + width <= filelist_len - 1)
selected += width;
} else if (func == to_prev_block) {
selected = ((selected / (editwinrows * width)) *
editwinrows * width) + selected % width;
} else if (func == to_next_block) {
selected = ((selected / (editwinrows * width)) *
editwinrows * width) + selected % width +
editwinrows * width - width;
if (selected >= filelist_len)
selected = (filelist_len / width) * width + selected % width;
if (selected >= filelist_len)
selected -= width;
} else if (func == do_page_up) {
if (selected < width)
selected = 0;
else if (selected < editwinrows * width)
selected = selected % width;
else
selected -= editwinrows * width;
} else if (func == do_page_down) {
if (selected + width >= filelist_len - 1)
selected = filelist_len - 1;
else if (selected + editwinrows * width >= filelist_len)
selected = (selected + editwinrows * width - filelist_len) %
width + filelist_len - width;
else
selected += editwinrows * width;
} else if (func == to_first_file) {
selected = 0;
} else if (func == to_last_file) {
selected = filelist_len - 1;
} else if (func == goto_dir) {
/* Ask for the directory to go to. */
if (do_prompt(MGOTODIR, "", NULL,
/* TRANSLATORS: This is a prompt. */
browser_refresh, _("Go To Directory")) < 0) {
statusbar(_("Cancelled"));
continue;
}
path = free_and_assign(path, real_dir_from_tilde(answer));
/* If the given path is relative, join it with the current path. */
if (*path != '/') {
path = nrealloc(path, strlen(present_path) +
strlen(answer) + 1);
sprintf(path, "%s%s", present_path, answer);
}
#ifdef ENABLE_OPERATINGDIR
if (outside_of_confinement(path, FALSE)) {
/* TRANSLATORS: This refers to the confining effect of the
* option --operatingdir, not of --restricted. */
statusline(ALERT, _("Can't go outside of %s"), operating_dir);
path = mallocstrcpy(path, present_path);
continue;
}
#endif
/* Snip any trailing slashes, so the name can be compared. */
while (strlen(path) > 1 && path[strlen(path) - 1] == '/')
path[strlen(path) - 1] = '\0';
/* In case the specified directory cannot be entered, select it
* (if it is in the current list) so it will be highlighted. */
for (size_t j = 0; j < filelist_len; j++)
if (strcmp(filelist[j], path) == 0)
selected = j;
/* Try opening and reading the specified directory. */
goto read_directory_contents;
} else if (func == do_enter) {
struct stat st;
/* It isn't possible to move up from the root directory. */
if (strcmp(filelist[selected], "/..") == 0) {
statusline(ALERT, _("Can't move up a directory"));
continue;
}
#ifdef ENABLE_OPERATINGDIR
/* Note: The selected file can be outside the operating
* directory if it's ".." or if it's a symlink to a
* directory outside the operating directory. */
if (outside_of_confinement(filelist[selected], FALSE)) {
statusline(ALERT, _("Can't go outside of %s"), operating_dir);
continue;
}
#endif
/* If for some reason the file is inaccessible, complain. */
if (stat(filelist[selected], &st) == -1) {
statusline(ALERT, _("Error reading %s: %s"),
filelist[selected], strerror(errno));
continue;
}
/* If it isn't a directory, a file was selected -- we're done. */
if (!S_ISDIR(st.st_mode)) {
chosen = copy_of(filelist[selected]);
break;
}
/* If we are moving up one level, remember where we came from, so
* this directory can be highlighted and easily reentered. */
if (strcmp(tail(filelist[selected]), "..") == 0)
present_name = strip_last_component(filelist[selected]);
/* Try opening and reading the selected directory. */
path = mallocstrcpy(path, filelist[selected]);
goto read_directory_contents;
#ifdef ENABLE_NANORC
} else if (func == (functionptrtype)implant) {
implant(first_sc_for(MBROWSER, func)->expansion);
#endif
#ifndef NANO_TINY
} else if (kbinput == KEY_WINCH) {
; /* Nothing to do. */
#endif
} else if (func == do_exit) {
break;
} else
unbound_key(kbinput);
#ifndef NANO_TINY
/* If the window resized, refresh the file list. */
if (kbinput == KEY_WINCH) {
/* Remember the selected file, to be able to reselect it. */
present_name = copy_of(filelist[selected]);
/* Reread the contents of the current directory. */
goto read_directory_contents;
}
#endif
}
titlebar(NULL);
edit_refresh();
free(path);
free_chararray(filelist, filelist_len);
filelist = NULL;
filelist_len = 0;
return chosen;
}
/* Prepare to start browsing. If the given path has a directory part,
* start browsing in that directory, otherwise in the current directory. */
char *browse_in(const char *inpath)
{
char *path = real_dir_from_tilde(inpath);
struct stat fileinfo;
/* If path is not a directory, try to strip a filename from it; if then
* still not a directory, use the current working directory instead. */
if (stat(path, &fileinfo) == -1 || !S_ISDIR(fileinfo.st_mode)) {
path = free_and_assign(path, strip_last_component(path));
if (stat(path, &fileinfo) == -1 || !S_ISDIR(fileinfo.st_mode)) {
char *currentdir = nmalloc(PATH_MAX + 1);
path = free_and_assign(path, getcwd(currentdir, PATH_MAX + 1));
if (path == NULL) {
statusline(MILD, _("The working directory has disappeared"));
free(currentdir);
beep();
napms(1200);
return NULL;
}
}
}
#ifdef ENABLE_OPERATINGDIR
/* If the resulting path isn't in the operating directory, use
* the operating directory instead. */
if (outside_of_confinement(path, FALSE))
path = mallocstrcpy(path, operating_dir);
#endif
return browse(path);
}
#endif /* ENABLE_BROWSER */

View File

@@ -19,7 +19,7 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#include <ctype.h>
#include <string.h>
@@ -131,15 +131,17 @@ bool is_word_char(const char *c, bool allow_punct)
if (is_alnum_char(c))
return TRUE;
if (allow_punct && is_punct_char(c))
return TRUE;
if (word_chars != NULL && *word_chars != '\0') {
char symbol[MAXCHARLEN + 1];
int symlen = collect_char(c, symbol);
symbol[symlen] = '\0';
return (strstr(word_chars, symbol) != NULL);
}
return (allow_punct && is_punct_char(c));
} else
return FALSE;
}
/* Return the visible representation of control character c. */
@@ -194,34 +196,25 @@ int mbwidth(const char *c)
} else
return 1;
}
#endif
/* Convert the Unicode value in code to a multibyte character, if possible.
/* Convert the given Unicode value to a multibyte character, if possible.
* If the conversion succeeds, return the (dynamically allocated) multibyte
* character and its length. Otherwise, return an undefined (dynamically
* allocated) multibyte character and a length of zero. */
* 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);
#ifdef ENABLE_UTF8
if (use_utf8) {
*length = wctomb(mb_char, (wchar_t)code);
*length = wctomb(mb_char, (wchar_t)code);
/* Reject invalid Unicode characters. */
if (*length < 0 || !is_valid_unicode((wchar_t)code)) {
IGNORE_CALL_RESULT(wctomb(NULL, 0));
*length = 0;
}
} else
#endif
{
*mb_char = (char)code;
*length = 1;
/* Reject invalid Unicode characters. */
if (*length < 0 || !is_valid_unicode((wchar_t)code)) {
IGNORE_CALL_RESULT(wctomb(NULL, 0));
*length = 0;
}
return mb_char;
}
#endif /* ENABLE_UTF8 */
/* Return the length (in bytes) of the character located at *pointer. */
int char_length(const char *pointer)
@@ -381,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

@@ -19,7 +19,7 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#ifdef ENABLE_COLOR
@@ -38,41 +38,15 @@
#define A_BANDAID A_NORMAL
#endif
/* Assign pair numbers for the colors in the given syntax, giving identical
* color pairs the same number. */
void set_syntax_colorpairs(syntaxtype *sntx)
static bool defaults_allowed = FALSE;
/* Whether ncurses accepts -1 to mean "default color". */
/* Initialize the color pairs for nano's interface. */
void set_interface_colorpairs(void)
{
int new_number = NUMBER_OF_ELEMENTS + 1;
colortype *ink;
for (ink = sntx->color; ink != NULL; ink = ink->next) {
const colortype *beforenow = sntx->color;
while (beforenow != ink && (beforenow->fg != ink->fg ||
beforenow->bg != ink->bg))
beforenow = beforenow->next;
if (beforenow != ink)
ink->pairnum = beforenow->pairnum;
else
ink->pairnum = new_number++;
ink->attributes |= COLOR_PAIR(ink->pairnum) | A_BANDAID;
}
}
/* Initialize the colors for nano's interface, and assign pair numbers
* for the colors in each loaded syntax. */
void set_colorpairs(void)
{
bool using_defaults = FALSE;
/* Tell ncurses to enable colors. */
start_color();
#ifdef HAVE_USE_DEFAULT_COLORS
/* Allow using the default colors, if available. */
using_defaults = (use_default_colors() != ERR);
/* Ask ncurses to allow -1 to mean "default color". */
defaults_allowed = (use_default_colors() == OK);
#endif
/* Initialize the color pairs for nano's interface elements. */
@@ -80,15 +54,17 @@ void set_colorpairs(void)
colortype *combo = color_combo[index];
if (combo != NULL) {
if (combo->fg == USE_THE_DEFAULT && !using_defaults)
combo->fg = COLOR_WHITE;
if (combo->bg == USE_THE_DEFAULT && !using_defaults)
combo->bg = COLOR_BLACK;
if (!defaults_allowed) {
if (combo->fg == THE_DEFAULT)
combo->fg = COLOR_WHITE;
if (combo->bg == THE_DEFAULT)
combo->bg = COLOR_BLACK;
}
init_pair(index + 1, combo->fg, combo->bg);
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;
@@ -102,42 +78,45 @@ void set_colorpairs(void)
free(color_combo[index]);
}
/* For each loaded syntax, assign pair numbers to color combinations. */
for (syntaxtype *sntx = syntaxes; sntx != NULL; sntx = sntx->next)
if (sntx->filename == NULL)
set_syntax_colorpairs(sntx);
}
/* Initialize the color information. */
void color_init(void)
/* Assign a pair number to each of the foreground/background color combinations
* in the given syntax, giving identical combinations the same number. */
void set_syntax_colorpairs(syntaxtype *sntx)
{
const colortype *ink;
bool using_defaults = FALSE;
short foreground, background;
short number = NUMBER_OF_ELEMENTS;
colortype *older;
/* If the terminal is not capable of colors, forget it. */
if (!has_colors())
return;
for (colortype *ink = sntx->color; ink != NULL; ink = ink->next) {
if (!defaults_allowed) {
if (ink->fg == THE_DEFAULT)
ink->fg = COLOR_WHITE;
if (ink->bg == THE_DEFAULT)
ink->bg = COLOR_BLACK;
}
#ifdef HAVE_USE_DEFAULT_COLORS
/* Allow using the default colors, if available. */
using_defaults = (use_default_colors() != ERR);
#endif
older = sntx->color;
/* For each coloring expression, initialize the color pair. */
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
foreground = ink->fg;
background = ink->bg;
while (older != ink && (older->fg != ink->fg || older->bg != ink->bg))
older = older->next;
if (foreground == USE_THE_DEFAULT && !using_defaults)
foreground = COLOR_WHITE;
ink->pairnum = (older != ink) ? older->pairnum : ++number;
if (background == USE_THE_DEFAULT && !using_defaults)
background = COLOR_BLACK;
init_pair(ink->pairnum, foreground, background);
ink->attributes |= COLOR_PAIR(ink->pairnum) | A_BANDAID;
}
}
/* Initialize the color pairs for the current syntax. */
void prepare_palette(void)
{
short number = NUMBER_OF_ELEMENTS;
/* For each unique pair number, tell ncurses the combination of colors. */
for (colortype *ink = openfile->syntax->color; ink != NULL; ink = ink->next)
if (ink->pairnum > number) {
init_pair(ink->pairnum, ink->fg, ink->bg);
number = ink->pairnum;
}
have_palette = TRUE;
}
@@ -163,8 +142,9 @@ bool found_in_list(regexlisttype *head, const char *shibboleth)
return FALSE;
}
/* Update the color information based on the current filename and content. */
void color_update(void)
/* Find a syntax that applies to the current buffer, based upon filename
* or buffer content, and load and prime this syntax when needed. */
void find_and_prime_applicable_syntax(void)
{
syntaxtype *sntx = NULL;
@@ -209,8 +189,8 @@ void color_update(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;
@@ -258,13 +238,12 @@ void color_update(void)
}
openfile->syntax = sntx;
openfile->colorstrings = (sntx == NULL ? NULL : sntx->color);
}
/* 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;
@@ -286,7 +265,7 @@ void check_the_multis(linestruct *line)
if (line->multidata == NULL)
set_up_multicache(line);
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
for (ink = openfile->syntax->color; ink != NULL; ink = ink->next) {
/* If it's not a multiline regex, skip. */
if (ink->end == NULL)
continue;
@@ -325,14 +304,15 @@ void precalc_multicolorinfo(void)
regmatch_t startmatch, endmatch;
linestruct *line, *tailline;
if (openfile->colorstrings == NULL || ISSET(NO_COLOR_SYNTAX))
if (openfile->syntax == NULL || openfile->syntax->nmultis == 0 ||
openfile->filetop->multidata || ISSET(NO_SYNTAX))
return;
/* For each line, allocate cache space for the multiline-regex info. */
for (line = openfile->filetop; line != NULL; line = line->next)
set_up_multicache(line);
for (ink = openfile->colorstrings; ink != NULL; ink = ink->next) {
for (ink = openfile->syntax->color; ink != NULL; ink = ink->next) {
/* If this is not a multi-line regex, skip it. */
if (ink->end == NULL)
continue;

568
src/cut.c
View File

@@ -20,17 +20,13 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#include <string.h>
/* Delete the character under the cursor. */
void do_deletion(undo_type action)
{
#ifndef NANO_TINY
size_t old_amount = 0;
#endif
openfile->placewewant = xplustabs();
/* When in the middle of a line, delete the current character. */
@@ -38,6 +34,8 @@ void do_deletion(undo_type action)
int charlen = char_length(openfile->current->data + openfile->current_x);
size_t line_len = strlen(openfile->current->data + openfile->current_x);
#ifndef NANO_TINY
size_t old_amount = openfile->current->extrarows;
/* If the type of action changed or the cursor moved to a different
* line, create a new undo item, otherwise update the existing item. */
if (action != openfile->last_action ||
@@ -45,15 +43,20 @@ void do_deletion(undo_type action)
add_undo(action, NULL);
else
update_undo(action);
if (ISSET(SOFTWRAP))
old_amount = number_of_chunks_in(openfile->current);
#endif
/* Move the remainder of the line "in", over the current character. */
memmove(&openfile->current->data[openfile->current_x],
&openfile->current->data[openfile->current_x + charlen],
line_len - charlen + 1);
#ifndef NANO_TINY
/* When softwrapping, recompute the number of chunks in the line,
* and schedule a refresh if the number changed. */
if (ISSET(SOFTWRAP)) {
openfile->current->extrarows = extra_chunks_in(openfile->current);
if (openfile->current->extrarows != old_amount)
refresh_needed = TRUE;
}
/* Adjust the mark if it is after the cursor on the current line. */
if (openfile->mark == openfile->current &&
openfile->mark_x > openfile->current_x)
@@ -65,7 +68,7 @@ void do_deletion(undo_type action)
/* If there is a magic line, and we're before it: don't eat it. */
if (joining == openfile->filebot && openfile->current_x != 0 &&
!ISSET(NO_NEWLINES)) {
!ISSET(NO_NEWLINES)) {
#ifndef NANO_TINY
if (action == BACK)
add_undo(BACK, NULL);
@@ -75,23 +78,28 @@ void do_deletion(undo_type action)
#ifndef NANO_TINY
add_undo(action, NULL);
#endif
/* Add the contents of the next line to those of the current one. */
openfile->current->data = charealloc(openfile->current->data,
strlen(openfile->current->data) + strlen(joining->data) + 1);
strcat(openfile->current->data, joining->data);
#ifndef NANO_TINY
/* Adjust the mark if it was on the line that was "eaten". */
/* Adjust the mark if it is on the line that will be "eaten". */
if (openfile->mark == joining) {
openfile->mark = openfile->current;
openfile->mark_x += openfile->current_x;
}
#endif
unlink_node(joining);
renumber_from(openfile->current);
/* Two lines were joined, so we need to refresh the screen. */
openfile->current->has_anchor |= joining->has_anchor;
#endif
/* Add the content of the next line to that of the current one. */
openfile->current->data = nrealloc(openfile->current->data,
strlen(openfile->current->data) + strlen(joining->data) + 1);
strcat(openfile->current->data, joining->data);
unlink_node(joining);
#ifndef NANO_TINY
if (ISSET(SOFTWRAP))
openfile->current->extrarows = extra_chunks_in(openfile->current);
#endif
/* Two lines were joined, so do a renumbering and refresh the screen. */
renumber_from(openfile->current);
refresh_needed = TRUE;
} else
/* We're at the end-of-file: nothing to do. */
@@ -101,14 +109,7 @@ void do_deletion(undo_type action)
openfile->totsize--;
#ifndef NANO_TINY
openfile->current_undo->newsize = openfile->totsize;
/* If the number of screen rows that a softwrapped line occupies
* has changed, we need a full refresh. */
if (ISSET(SOFTWRAP) && refresh_needed == FALSE &&
number_of_chunks_in(openfile->current) != old_amount)
refresh_needed = TRUE;
#endif
set_modified();
}
@@ -191,7 +192,7 @@ void chop_word(bool forward)
openfile->current_x = strlen(openfile->current->data);
}
} else {
do_next_word(FALSE, ISSET(WORD_BOUNDS));
do_next_word(ISSET(AFTER_ENDS), ISSET(WORD_BOUNDS));
if (openfile->current != is_current &&
is_current->data[is_current_x] != '\0') {
openfile->current = is_current;
@@ -209,7 +210,7 @@ void chop_word(bool forward)
/* Now kill the marked region and a word is gone. */
add_undo(CUT, NULL);
do_snip(FALSE, TRUE, FALSE, FALSE);
do_snip(TRUE, FALSE, FALSE);
update_undo(CUT);
/* Discard the cut word and restore the cutbuffer. */
@@ -236,81 +237,109 @@ void chop_next_word(void)
}
#endif /* !NANO_TINY */
/* Move all text between (top, top_x) and (bot, bot_x) from the current buffer
* into the cutbuffer. */
/* Excise the text between the given two points and add it to the cutbuffer. */
void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_x)
{
linestruct *taken, *last;
bool edittop_inside = (openfile->edittop->lineno >= top->lineno &&
openfile->edittop->lineno <= bot->lineno);
#ifndef NANO_TINY
bool mark_inside = (openfile->mark &&
openfile->mark->lineno >= top->lineno &&
openfile->mark->lineno <= bot->lineno &&
(openfile->mark != top || openfile->mark_x >= top_x) &&
(openfile->mark != bot || openfile->mark_x <= bot_x));
bool same_line = (openfile->mark == top);
bool post_marked = (openfile->mark && (openfile->mark->lineno > top->lineno ||
(same_line && openfile->mark_x > top_x)));
bool was_anchored = top->has_anchor;
if (top == bot && top_x == bot_x)
return;
if (top != bot)
for (linestruct *line = top->next; line != bot->next; line = line->next)
was_anchored |= line->has_anchor;
#endif
/* Reduce the buffer to cover just the text that needs to be extracted. */
partition_buffer(top, top_x, bot, bot_x);
if (top == bot) {
taken = make_new_node(NULL);
taken->data = measured_copy(top->data + top_x, bot_x - top_x);
memmove(top->data + top_x, top->data + bot_x,
strlen(top->data + bot_x) + 1);
last = taken;
} else if (top_x == 0 && bot_x == 0) {
taken = top;
last = make_new_node(NULL);
last->data = copy_of("");
/* Subtract the number of characters in that text from the file size. */
openfile->totsize -= get_totsize(top, bot);
last->prev = bot->prev;
bot->prev->next = last;
last->next = NULL;
bot->prev = top->prev;
if (top->prev)
top->prev->next = bot;
else
openfile->filetop = bot;
openfile->current = bot;
} else {
taken = make_new_node(NULL);
taken->data = copy_of(top->data + top_x);
taken->next = top->next;
top->next->prev = taken;
top->next = bot->next;
if (bot->next)
bot->next->prev = top;
top->data = nrealloc(top->data, top_x + strlen(bot->data + bot_x) + 1);
strcpy(top->data + top_x, bot->data + bot_x);
last = bot;
last->data[bot_x] = '\0';
last->next = NULL;
openfile->current = top;
}
/* Subtract the size of the excised text from the buffer size. */
openfile->totsize -= number_of_characters_in(taken, last);
/* If the cutbuffer is currently empty, just move all the text directly
* into it; otherwise, append the text to what is already there. */
if (cutbuffer == NULL) {
cutbuffer = openfile->filetop;
cutbottom = openfile->filebot;
cutbuffer = taken;
cutbottom = last;
} else {
/* Tack the data of the first line of the text onto the data of
* the last line in the given buffer. */
cutbottom->data = charealloc(cutbottom->data,
strlen(cutbottom->data) +
strlen(openfile->filetop->data) + 1);
strcat(cutbottom->data, openfile->filetop->data);
cutbottom->data = nrealloc(cutbottom->data,
strlen(cutbottom->data) + strlen(taken->data) + 1);
strcat(cutbottom->data, taken->data);
/* Attach the second line of the text (if any) to the last line
* of the buffer, then remove the now superfluous first line. */
cutbottom->next = openfile->filetop->next;
delete_node(openfile->filetop);
cutbottom->next = taken->next;
delete_node(taken);
/* If there is a second line, make the reverse attachment too and
* update the buffer pointer to point at the end of the text. */
if (cutbottom->next != NULL) {
cutbottom->next->prev = cutbottom;
cutbottom = openfile->filebot;
cutbottom = last;
}
}
/* Since the text has now been saved, remove it from the file buffer. */
openfile->filetop = make_new_node(NULL);
openfile->filetop->data = copy_of("");
openfile->filebot = openfile->filetop;
/* Set the cursor at the point where the text was removed. */
openfile->current = openfile->filetop;
openfile->current_x = top_x;
#ifndef NANO_TINY
/* If the mark was inside the partition, put it where the cursor now is. */
if (mark_inside) {
openfile->mark = openfile->current;
openfile->mark_x = openfile->current_x;
} else if (same_line)
/* Update the pointer to this partially cut line. */
openfile->mark = openfile->current;
#endif
/* Glue the texts before and after the extraction together. */
unpartition_buffer();
#ifndef NANO_TINY
openfile->current->has_anchor = was_anchored;
if (ISSET(SOFTWRAP))
openfile->current->extrarows = extra_chunks_in(openfile->current);
if (post_marked || same_line)
openfile->mark = openfile->current;
if (post_marked)
openfile->mark_x = openfile->current_x;
#endif
if (openfile->filebot == bot)
openfile->filebot = openfile->current;
renumber_from(openfile->current);
/* If the top of the edit window was inside the old partition, put
* it in range of current. */
/* When the beginning of the viewport was inside the excision, adjust. */
if (edittop_inside) {
adjust_viewport(STATIONARY);
refresh_needed = TRUE;
@@ -325,59 +354,80 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
* at the current cursor position. */
void ingraft_buffer(linestruct *topline)
{
size_t current_x_save = openfile->current_x;
/* Remember whether the current line is at the top of the edit window. */
bool edittop_inside = (openfile->edittop == openfile->current);
linestruct *line = openfile->current;
size_t length = strlen(line->data);
size_t extralen = strlen(topline->data);
size_t xpos = openfile->current_x;
char *tailtext = copy_of(line->data + xpos);
#ifndef NANO_TINY
/* Remember whether mark and cursor are on the same line, and their order. */
bool right_side_up = (openfile->mark && mark_is_before_cursor());
bool same_line = (openfile->mark == openfile->current);
bool mark_follows = (openfile->mark == line && !mark_is_before_cursor());
#endif
linestruct *botline = topline;
/* Partition the buffer so that it contains no text, then delete it.*/
partition_buffer(openfile->current, openfile->current_x,
openfile->current, openfile->current_x);
delete_node(openfile->filetop);
while (botline->next != NULL)
botline = botline->next;
/* Replace the current buffer with the passed buffer. */
openfile->filetop = topline;
openfile->filebot = topline;
while (openfile->filebot->next != NULL)
openfile->filebot = openfile->filebot->next;
/* Add the size of the text to be grafted to the buffer size. */
openfile->totsize += number_of_characters_in(topline, botline);
/* Put the cursor at the end of the pasted text. */
openfile->current = openfile->filebot;
openfile->current_x = strlen(openfile->filebot->data);
if (topline != botline)
length = xpos;
/* When the pasted stuff contains no newline, adjust the cursor's
* x coordinate for the text that is before the pasted stuff. */
if (openfile->filetop == openfile->filebot)
openfile->current_x += current_x_save;
if (extralen > 0) {
/* Insert the text of topline at the current cursor position. */
line->data = nrealloc(line->data, length + extralen + 1);
memmove(line->data + xpos + extralen, line->data + xpos, length - xpos + 1);
strncpy(line->data + xpos, topline->data, extralen);
}
if (topline != botline) {
#ifndef NANO_TINY
/* First compute the softwrapped chunks for each line in the graft. */
compute_the_extra_rows_per_line_from(topline);
#endif
/* When inserting at end-of-buffer, update the relevant pointer. */
if (line->next == NULL)
openfile->filebot = botline;
line->data[xpos + extralen] = '\0';
/* Hook the grafted lines in after the current one. */
botline->next = openfile->current->next;
if (botline->next)
botline->next->prev = botline;
openfile->current->next = topline->next;
topline->next->prev = openfile->current;
/* Add the text after the cursor position at the end of botline. */
length = strlen(botline->data);
extralen = strlen(tailtext);
botline->data = nrealloc(botline->data, length + extralen + 1);
strcpy(botline->data + length, tailtext);
/* Put the cursor at the end of the grafted text. */
openfile->current = botline;
openfile->current_x = length;
} else
openfile->current_x += extralen;
#ifndef NANO_TINY
/* When needed, refresh the mark's pointer and compensate the mark's
* x coordinate for the change in the current line. */
if (same_line) {
if (!right_side_up) {
openfile->mark = openfile->filebot;
openfile->mark_x += openfile->current_x - current_x_save;
} else
openfile->mark = openfile->filetop;
/* When needed, update the mark's pointer and position. */
if (mark_follows && topline != botline) {
openfile->mark = botline;
openfile->mark_x += length - xpos;
} else if (mark_follows)
openfile->mark_x += extralen;
if (ISSET(SOFTWRAP)) {
line->extrarows = extra_chunks_in(line);
openfile->current->extrarows = extra_chunks_in(openfile->current);
}
#endif
/* Add the number of characters in the copied text to the file size. */
openfile->totsize += get_totsize(openfile->filetop, openfile->filebot);
delete_node(topline);
free(tailtext);
/* If we pasted onto the first line of the edit window, the corresponding
* record has been freed, so... point at the start of the copied text. */
if (edittop_inside)
openfile->edittop = openfile->filetop;
/* Weld the pasted text into the surrounding content of the buffer. */
unpartition_buffer();
renumber_from(topline);
renumber_from(line);
/* If the text doesn't end with a newline, and it should, add one. */
if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0')
@@ -392,143 +442,74 @@ void copy_from_buffer(linestruct *somebuffer)
ingraft_buffer(the_copy);
}
/* Move the whole current line from the current buffer to the cutbuffer. */
void cut_line(void)
{
/* When not on the last line of the buffer, move the text from the
* head of this line to the head of the next line into the cutbuffer;
* otherwise, move all of the text of this line into the cutbuffer. */
if (openfile->current != openfile->filebot)
extract_segment(openfile->current, 0, openfile->current->next, 0);
else
extract_segment(openfile->current, 0,
openfile->current, strlen(openfile->current->data));
openfile->placewewant = 0;
}
#ifndef NANO_TINY
/* Move all text from the cursor position until the end of this line into
* the cutbuffer. But when already at the end of a line, then move this
* "newline" to the cutbuffer. */
void cut_to_eol(void)
{
size_t data_len = strlen(openfile->current->data);
/* When not at the end of a line, move the rest of this line into
* the cutbuffer. Otherwise, when not at the end of the buffer,
* move the line separation into the cutbuffer. */
if (openfile->current_x < data_len)
extract_segment(openfile->current, openfile->current_x,
openfile->current, data_len);
else if (openfile->current != openfile->filebot) {
extract_segment(openfile->current, openfile->current_x,
openfile->current->next, 0);
openfile->placewewant = xplustabs();
}
}
/* Move all marked text from the current buffer into the cutbuffer. */
void cut_marked(bool *right_side_up)
void cut_marked_region(void)
{
linestruct *top, *bot;
size_t top_x, bot_x;
get_region((const linestruct **)&top, &top_x,
(const linestruct **)&bot, &bot_x, right_side_up);
get_region(&top, &top_x, &bot, &bot_x);
extract_segment(top, top_x, bot, bot_x);
openfile->placewewant = xplustabs();
}
#endif
/* Move all text from the cursor position to end-of-file into the cutbuffer. */
void cut_to_eof(void)
{
extract_segment(openfile->current, openfile->current_x,
openfile->filebot, strlen(openfile->filebot->data));
}
#endif /* !NANO_TINY */
/* Move text from the current buffer into the cutbuffer. If
* copying is TRUE, copy the text back into the buffer afterward.
/* Move text from the current buffer into the cutbuffer.
* If until_eof is TRUE, move all text from the current cursor
* position to the end of the file into the cutbuffer. If append
* is TRUE (when zapping), always append the cut to the cutbuffer. */
void do_snip(bool copying, bool marked, bool until_eof, bool append)
void do_snip(bool marked, bool until_eof, bool append)
{
linestruct *line = openfile->current;
#ifndef NANO_TINY
linestruct *was_bottom = NULL;
/* The current end of the cutbuffer, before we add text to it. */
size_t botlen = 0;
/* The length of the string at the current end of the cutbuffer,
* before we add text to it. */
bool using_magicline = !ISSET(NO_NEWLINES);
/* Whether an automatic newline should be added at end-of-buffer. */
bool right_side_up = TRUE;
/* There *is* no region, *or* it is marked forward. */
keep_cutbuffer &= (openfile->last_action != COPY);
#endif
static bool precedent = FALSE;
/* Whether the previous operation was a copying operation. */
/* If cuts were not continuous, or when cutting a region, clear the slate. */
if ((!keep_cutbuffer || marked || until_eof || copying != precedent) &&
!append) {
if ((marked || until_eof || !keep_cutbuffer) && !append) {
free_lines(cutbuffer);
cutbuffer = NULL;
}
/* After a line operation, future ones should add to the cutbuffer. */
keep_cutbuffer = !marked && !until_eof;
precedent = copying;
#ifndef NANO_TINY
if (copying) {
/* If the cutbuffer isn't empty, remember where it currently ends. */
if (cutbuffer != NULL) {
was_bottom = cutbottom;
botlen = strlen(cutbottom->data);
}
/* Don't add a magic line when moving text to the cutbuffer. */
SET(NO_NEWLINES);
}
/* Now move the relevant piece of text into the cutbuffer. */
if (until_eof)
cut_to_eof();
extract_segment(openfile->current, openfile->current_x,
openfile->filebot, strlen(openfile->filebot->data));
else if (openfile->mark) {
cut_marked(&right_side_up);
cut_marked_region();
openfile->mark = NULL;
} else if (ISSET(CUT_FROM_CURSOR))
cut_to_eol();
else
#endif
cut_line();
#ifndef NANO_TINY
if (copying) {
/* Copy the text that was put into the cutbuffer back into the current
* file buffer, so that in the end nothing has been deleted. */
if (cutbuffer != NULL) {
if (was_bottom != NULL) {
was_bottom->data += botlen;
copy_from_buffer(was_bottom);
was_bottom->data -= botlen;
} else
copy_from_buffer(cutbuffer);
/* If the copied region was marked forward, put the new desired
* x position at its end; otherwise, leave it at its beginning. */
if (right_side_up)
openfile->placewewant = xplustabs();
} else if (ISSET(CUT_FROM_CURSOR)) {
/* When not at the end of a line, move the rest of this line into
* the cutbuffer. Otherwise, when not at the end of the buffer,
* move just the "line separator" into the cutbuffer. */
if (openfile->current_x < strlen(openfile->current->data))
extract_segment(line, openfile->current_x, line, strlen(line->data));
else if (openfile->current != openfile->filebot) {
extract_segment(line, openfile->current_x, line->next, 0);
openfile->placewewant = xplustabs();
}
/* Restore the magic-line behavior now that we're done fiddling. */
if (using_magicline)
UNSET(NO_NEWLINES);
} else
#endif
set_modified();
{
/* When not at end-of-buffer, move one full line into the cutbuffer;
* otherwise, move all text until end-of-line into the cutbuffer. */
if (openfile->current != openfile->filebot)
extract_segment(line, 0, line->next, 0);
else
extract_segment(line, 0, line, strlen(line->data));
openfile->placewewant = 0;
}
/* After a line operation, future ones should add to the cutbuffer. */
keep_cutbuffer = !marked && !until_eof;
set_modified();
refresh_needed = TRUE;
}
@@ -546,47 +527,22 @@ void cut_text(void)
add_undo(CUT, NULL);
}
do_snip(FALSE, openfile->mark != NULL, FALSE, FALSE);
do_snip(openfile->mark != NULL, FALSE, FALSE);
update_undo(CUT);
#else
if (is_cuttable(FALSE))
do_snip(FALSE, FALSE, FALSE, FALSE);
do_snip(FALSE, FALSE, FALSE);
#endif
wipe_statusbar();
}
#ifndef NANO_TINY
/* Move text from the current buffer into the cutbuffer, and copy it
* back into the buffer afterward. If the mark is set or the cursor
* was moved, blow away previous contents of the cutbuffer. */
void copy_text(void)
{
bool mark_is_set = (openfile->mark != NULL);
/* Remember the current viewport and cursor position. */
ssize_t is_edittop_lineno = openfile->edittop->lineno;
size_t is_firstcolumn = openfile->firstcolumn;
ssize_t is_current_lineno = openfile->current->lineno;
size_t is_current_x = openfile->current_x;
do_snip(TRUE, mark_is_set, FALSE, FALSE);
/* If the mark was set, restore the viewport and cursor position. */
if (mark_is_set) {
openfile->edittop = line_from_number(is_edittop_lineno);
openfile->firstcolumn = is_firstcolumn;
openfile->current = line_from_number(is_current_lineno);
openfile->current_x = is_current_x;
} else
focusing = FALSE;
openfile->last_action = OTHER;
}
/* Cut from the current cursor position to the end of the file. */
void cut_till_eof(void)
{
ran_a_tool = TRUE;
if (openfile->current->data[openfile->current_x] == '\0' &&
(openfile->current->next == NULL ||
(!ISSET(NO_NEWLINES) && openfile->current_x > 0 &&
@@ -596,7 +552,7 @@ void cut_till_eof(void)
}
add_undo(CUT_TO_EOF, NULL);
do_snip(FALSE, FALSE, TRUE, FALSE);
do_snip(FALSE, TRUE, FALSE);
update_undo(CUT_TO_EOF);
wipe_statusbar();
}
@@ -618,13 +574,123 @@ void zap_text(void)
/* Use the cutbuffer from the ZAP undo item, so the cut can be undone. */
cutbuffer = openfile->current_undo->cutbuffer;
do_snip(FALSE, openfile->mark != NULL, FALSE, TRUE);
do_snip(openfile->mark != NULL, FALSE, TRUE);
update_undo(ZAP);
wipe_statusbar();
cutbuffer = was_cutbuffer;
}
/* Make a copy of the marked region, putting it in the cutbuffer. */
void copy_marked_region(void)
{
linestruct *topline, *botline, *afterline;
char *was_datastart, saved_byte;
size_t top_x, bot_x;
get_region(&topline, &top_x, &botline, &bot_x);
openfile->last_action = OTHER;
keep_cutbuffer = FALSE;
openfile->mark = NULL;
refresh_needed = TRUE;
if (topline == botline && top_x == bot_x) {
statusbar(_("Copied nothing"));
return;
}
/* Make the area that was marked look like a separate buffer. */
afterline = botline->next;
botline->next = NULL;
saved_byte = botline->data[bot_x];
botline->data[bot_x] = '\0';
was_datastart = topline->data;
topline->data += top_x;
cutbuffer = copy_buffer(topline);
/* Restore the proper state of the buffer. */
topline->data = was_datastart;
botline->data[bot_x] = saved_byte;
botline->next = afterline;
}
/* Copy text from the current buffer into the cutbuffer. The text is either
* the marked region, the whole line, the text from cursor to end-of-line,
* just the line break, or nothing, depending on mode and cursor position. */
void copy_text(void)
{
bool at_eol = (openfile->current->data[openfile->current_x] == '\0');
bool sans_newline = (ISSET(NO_NEWLINES) && openfile->current->next == NULL);
size_t from_x = (ISSET(CUT_FROM_CURSOR)) ? openfile->current_x : 0;
linestruct *was_current = openfile->current;
linestruct *addition;
if (openfile->mark || openfile->last_action != COPY || !keep_cutbuffer) {
free_lines(cutbuffer);
cutbuffer = NULL;
}
wipe_statusbar();
if (openfile->mark) {
copy_marked_region();
return;
}
/* When at the very end of the buffer, there is nothing to do. */
if (openfile->current->next == NULL && at_eol && (ISSET(CUT_FROM_CURSOR) ||
openfile->current_x == 0 || cutbuffer)) {
statusbar(_("Copied nothing"));
return;
}
addition = make_new_node(NULL);
addition->data = copy_of(openfile->current->data + from_x);
if (ISSET(CUT_FROM_CURSOR))
sans_newline = !at_eol;
/* Create the cutbuffer OR add to it, depending on the mode, the position
* of the cursor, and whether or not the cutbuffer is currently empty. */
if (cutbuffer == NULL && sans_newline) {
cutbuffer = addition;
cutbottom = addition;
} else if (cutbuffer == NULL) {
cutbuffer = addition;
cutbottom = make_new_node(cutbuffer);
cutbottom->data = copy_of("");
cutbuffer->next = cutbottom;
} else if (sans_newline) {
addition->prev = cutbottom->prev;
addition->prev->next = addition;
delete_node(cutbottom);
cutbottom = addition;
} else if (ISSET(CUT_FROM_CURSOR)) {
addition->prev = cutbottom;
cutbottom->next = addition;
cutbottom = addition;
} else {
addition->prev = cutbottom->prev;
addition->prev->next = addition;
addition->next = cutbottom;
cutbottom->prev = addition;
}
/* When needed and possible, move the cursor to the next line. */
if ((!ISSET(CUT_FROM_CURSOR) || at_eol) && openfile->current->next) {
openfile->current = openfile->current->next;
openfile->current_x = 0;
} else
openfile->current_x = strlen(openfile->current->data);
edit_redraw(was_current, FLOWING);
openfile->last_action = COPY;
keep_cutbuffer = TRUE;
}
#endif /* !NANO_TINY */
/* Copy text from the cutbuffer into the current buffer. */

View File

@@ -1,5 +1,5 @@
/**************************************************************************
* nano.h -- This file is part of GNU nano. *
* definitions.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017 Benno Schulenberg *
@@ -25,16 +25,16 @@
#ifdef NEED_XOPEN_SOURCE_EXTENDED
#ifndef _XOPEN_SOURCE_EXTENDED
#define _XOPEN_SOURCE_EXTENDED 1
#define _XOPEN_SOURCE_EXTENDED 1
#endif
#endif
#ifdef __TANDEM
/* Tandem NonStop Kernel support. */
#include <floss.h>
#define NANO_ROOT_UID 65535
#define ROOT_UID 65535
#else
#define NANO_ROOT_UID 0
#define ROOT_UID 0
#endif
#ifdef HAVE_LIMITS_H
@@ -46,30 +46,26 @@
#endif
/* Suppress warnings for __attribute__((warn_unused_result)). */
#define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0)
#define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0)
/* Macros for flags, indexing each bit in a small array. */
#define FLAGS(flag) flags[((flag) / (sizeof(unsigned) * 8))]
#define FLAGMASK(flag) ((unsigned)1 << ((flag) % (sizeof(unsigned) * 8)))
#define SET(flag) FLAGS(flag) |= FLAGMASK(flag)
#define UNSET(flag) FLAGS(flag) &= ~FLAGMASK(flag)
#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)
#define FLAGS(flag) flags[((flag) / (sizeof(unsigned) * 8))]
#define FLAGMASK(flag) ((unsigned)1 << ((flag) % (sizeof(unsigned) * 8)))
#define SET(flag) FLAGS(flag) |= FLAGMASK(flag)
#define UNSET(flag) FLAGS(flag) &= ~FLAGMASK(flag)
#define ISSET(flag) ((FLAGS(flag) & FLAGMASK(flag)) != 0)
#define TOGGLE(flag) FLAGS(flag) ^= FLAGMASK(flag)
/* In UTF-8 a character is at most six bytes long. */
#ifdef ENABLE_UTF8
#define MAXCHARLEN 6
#define MAXCHARLEN 6
#else
#define MAXCHARLEN 1
#define MAXCHARLEN 1
#endif
/* Set a default value for PATH_MAX if there isn't one. */
#ifndef PATH_MAX
#define PATH_MAX 4096
#define PATH_MAX 4096
#endif
#ifdef USE_SLANG
@@ -77,8 +73,8 @@
#include <slcurses.h>
/* Slang curses emulation brain damage, part 3: Slang doesn't define the
* curses equivalents of the Insert or Delete keys. */
#define KEY_DC SL_KEY_DELETE
#define KEY_IC SL_KEY_IC
#define KEY_DC SL_KEY_DELETE
#define KEY_IC SL_KEY_IC
/* Ncurses support. */
#elif defined(HAVE_NCURSESW_NCURSES_H)
#include <ncursesw/ncurses.h>
@@ -90,7 +86,7 @@
#endif /* CURSES_H */
#if defined(NCURSES_VERSION_MAJOR) && (NCURSES_VERSION_MAJOR < 6)
#define USING_OLD_NCURSES yes
#define USING_OLD_NCURSES yes
#endif
#ifdef ENABLE_NLS
@@ -98,14 +94,14 @@
#ifdef HAVE_LIBINTL_H
#include <libintl.h>
#endif
#define _(string) gettext(string)
#define P_(singular, plural, number) ngettext(singular, plural, number)
#define _(string) gettext(string)
#define P_(singular, plural, number) ngettext(singular, plural, number)
#else
#define _(string) (string)
#define P_(singular, plural, number) (number == 1 ? singular : plural)
#define _(string) (string)
#define P_(singular, plural, number) (number == 1 ? singular : plural)
#endif
#define gettext_noop(string) (string)
#define N_(string) gettext_noop(string)
#define gettext_noop(string) (string)
#define N_(string) gettext_noop(string)
/* Mark a string that will be sent to gettext() later. */
#include <dirent.h>
@@ -121,22 +117,22 @@
#endif
#if defined(ENABLE_WRAPPING) || defined(ENABLE_JUSTIFY)
#define ENABLED_WRAPORJUSTIFY 1
#define ENABLED_WRAPORJUSTIFY 1
#endif
#define BACKWARD FALSE
#define FORWARD TRUE
#define BACKWARD FALSE
#define FORWARD TRUE
#define BLIND FALSE
#define VISIBLE TRUE
#define BLIND FALSE
#define VISIBLE TRUE
#define JUSTFIND 0
#define REPLACING 1
#define INREGION 2
#define JUSTFIND 0
#define REPLACING 1
#define INREGION 2
#ifdef ENABLE_COLOR
#define USE_THE_DEFAULT -1
#define BAD_COLOR -2
#define THE_DEFAULT -1
#define BAD_COLOR -2
#endif
#define STANDARD_INPUT 0
@@ -147,7 +143,7 @@ typedef enum {
} format_type;
typedef enum {
HUSH, NOTICE, MILD, ALERT
VACUUM, HUSH, NOTICE, MILD, ALERT
} message_type;
typedef enum {
@@ -172,7 +168,8 @@ typedef enum {
#ifdef ENABLE_COMMENT
COMMENT, UNCOMMENT, PREFLIGHT,
#endif
ZAP, CUT, CUT_TO_EOF, PASTE, INSERT, COUPLE_BEGIN, COUPLE_END, OTHER
ZAP, CUT, CUT_TO_EOF, COPY, PASTE, INSERT,
COUPLE_BEGIN, COUPLE_END, OTHER
} undo_type;
/* Structure types. */
@@ -283,6 +280,10 @@ typedef struct linestruct {
/* The text of this line. */
ssize_t lineno;
/* The number of this line. */
#ifndef NANO_TINY
ssize_t extrarows;
/* The extra rows that this line occupies when softwrapping. */
#endif
struct linestruct *next;
/* Next node. */
struct linestruct *prev;
@@ -291,6 +292,10 @@ typedef struct linestruct {
short *multidata;
/* Array of which multi-line regexes apply to this line. */
#endif
#ifndef NANO_TINY
bool has_anchor;
/* Whether the user has placed an anchor at this line. */
#endif
} linestruct;
#ifndef NANO_TINY
@@ -336,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;
@@ -368,8 +373,8 @@ typedef struct openfilestruct {
/* The file's x position we would like. */
ssize_t current_y;
/* The file's y-coordinate position. */
struct stat *current_stat;
/* The file's current stat information. */
struct stat *statinfo;
/* The file's stat information from when it was opened or last saved. */
#ifdef ENABLE_WRAPPING
linestruct *spillage_line;
/* The line for prepending stuff to during automatic hard-wrapping. */
@@ -382,7 +387,7 @@ typedef struct openfilestruct {
mark_type kind_of_mark;
/* Whether it is a soft (with Shift) or a hard mark. */
format_type fmt;
/* The file's format -- Unix or DOS or Mac or mixed. */
/* The file's format -- Unix or DOS or Mac. */
char *lock_filename;
/* The path of the lockfile, if we created one. */
undostruct *undotop;
@@ -398,9 +403,7 @@ typedef struct openfilestruct {
/* Whether the file has been modified. */
#ifdef ENABLE_COLOR
syntaxtype *syntax;
/* The syntax struct for this file, if any. */
colortype *colorstrings;
/* The file's associated colors. */
/* The syntax that applies to this file, if any. */
#endif
#ifdef ENABLE_MULTIBUFFER
struct openfilestruct *next;
@@ -446,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
@@ -459,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;
@@ -478,6 +479,7 @@ enum
TITLE_BAR = 0,
LINE_NUMBER,
GUIDE_STRIPE,
SCROLL_BAR,
SELECTED_TEXT,
STATUS_BAR,
ERROR_MESSAGE,
@@ -499,7 +501,7 @@ enum
VIEW_MODE,
USE_MOUSE,
USE_REGEXP,
TEMP_FILE,
SAVE_ON_EXIT,
CUT_FROM_CURSOR,
BACKWARDS_SEARCH,
MULTIBUFFER,
@@ -507,9 +509,9 @@ enum
REBIND_DELETE,
RAW_SEQUENCES,
NO_CONVERT,
BACKUP_FILE,
MAKE_BACKUP,
INSECURE_BACKUP,
NO_COLOR_SYNTAX,
NO_SYNTAX,
PRESERVE,
HISTORYLOG,
RESTRICTED,
@@ -535,7 +537,11 @@ enum
LET_THEM_ZAP,
BREAK_LONG_LINES,
JUMPY_SCROLLING,
EMPTY_LINE
EMPTY_LINE,
INDICATOR,
BOOKSTYLE,
STATEFLAGS,
USE_MAGIC
};
/* Flags for the menus in which a given function should be present. */
@@ -546,7 +552,7 @@ enum
#define MGOTOLINE (1<<4)
#define MWRITEFILE (1<<5)
#define MINSERTFILE (1<<6)
#define MEXTCMD (1<<7)
#define MEXECUTE (1<<7)
#define MHELP (1<<8)
#define MSPELL (1<<9)
#define MBROWSER (1<<10)
@@ -557,7 +563,7 @@ enum
#define MFINDINHELP (1<<15)
/* This is an abbreviation for all menus except Help and Browser and YesNo. */
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\
MEXTCMD|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER)
MEXECUTE|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER)
#ifndef NANO_TINY
#define MSOME MMOST|MBROWSER
#else
@@ -569,82 +575,82 @@ enum
#define DEL_CODE 0x7F
/* Codes for "modified" Arrow keys, beyond KEY_MAX of ncurses. */
#define CONTROL_LEFT 0x401
#define CONTROL_RIGHT 0x402
#define CONTROL_UP 0x403
#define CONTROL_DOWN 0x404
#define CONTROL_HOME 0x405
#define CONTROL_END 0x406
#define CONTROL_DELETE 0x40D
#define SHIFT_CONTROL_LEFT 0x411
#define SHIFT_CONTROL_RIGHT 0x412
#define SHIFT_CONTROL_UP 0x413
#define SHIFT_CONTROL_DOWN 0x414
#define SHIFT_CONTROL_HOME 0x415
#define SHIFT_CONTROL_END 0x416
#define CONTROL_SHIFT_DELETE 0x41D
#define ALT_LEFT 0x421
#define ALT_RIGHT 0x422
#define ALT_UP 0x423
#define ALT_DOWN 0x424
#define ALT_DELETE 0x42D
#define SHIFT_ALT_LEFT 0x431
#define SHIFT_ALT_RIGHT 0x432
#define SHIFT_ALT_UP 0x433
#define SHIFT_ALT_DOWN 0x434
#define CONTROL_LEFT 0x401
#define CONTROL_RIGHT 0x402
#define CONTROL_UP 0x403
#define CONTROL_DOWN 0x404
#define CONTROL_HOME 0x405
#define CONTROL_END 0x406
#define CONTROL_DELETE 0x40D
#define SHIFT_CONTROL_LEFT 0x411
#define SHIFT_CONTROL_RIGHT 0x412
#define SHIFT_CONTROL_UP 0x413
#define SHIFT_CONTROL_DOWN 0x414
#define SHIFT_CONTROL_HOME 0x415
#define SHIFT_CONTROL_END 0x416
#define CONTROL_SHIFT_DELETE 0x41D
#define ALT_LEFT 0x421
#define ALT_RIGHT 0x422
#define ALT_UP 0x423
#define ALT_DOWN 0x424
#define ALT_PAGEUP 0x427
#define ALT_PAGEDOWN 0x428
#define ALT_INSERT 0x42C
#define ALT_DELETE 0x42D
#define SHIFT_ALT_LEFT 0x431
#define SHIFT_ALT_RIGHT 0x432
#define SHIFT_ALT_UP 0x433
#define SHIFT_ALT_DOWN 0x434
//#define SHIFT_LEFT 0x451
//#define SHIFT_RIGHT 0x452
#define SHIFT_UP 0x453
#define SHIFT_DOWN 0x454
#define SHIFT_HOME 0x455
#define SHIFT_END 0x456
#define SHIFT_PAGEUP 0x457
#define SHIFT_PAGEDOWN 0x458
#define SHIFT_DELETE 0x45D
#define SHIFT_TAB 0x45F
#define SHIFT_UP 0x453
#define SHIFT_DOWN 0x454
#define SHIFT_HOME 0x455
#define SHIFT_END 0x456
#define SHIFT_PAGEUP 0x457
#define SHIFT_PAGEDOWN 0x458
#define SHIFT_DELETE 0x45D
#define SHIFT_TAB 0x45F
/* A special keycode for when <Tab> is pressed while the mark is on. */
#define INDENT_KEY 0x4F1
#define INDENT_KEY 0x4F1
/* A special keycode to signal the beginning and end of a bracketed paste. */
#define BRACKETED_PASTE_MARKER 0x4FB
#define BRACKETED_PASTE_MARKER 0x4FB
/* A special keycode for when a key produces an unknown escape sequence. */
#define FOREIGN_SEQUENCE 0x4FC
#ifdef USE_SLANG
#ifdef ENABLE_UTF8
#define KEY_BAD 0xFF /* Clipped error code. */
#endif
#define KEY_FLUSH 0x91 /* User-definable control code. */
#define KEY_FLUSH 0xFF /* Clipped error code. */
#else
#define KEY_FLUSH KEY_F0 /* Nonexistent function key. */
#define KEY_FLUSH KEY_F0 /* Nonexistent function key. */
#endif
#ifndef NANO_TINY
/* An imaginary key for when we get a SIGWINCH (window resize). */
#define KEY_WINCH -2
#define KEY_WINCH -2
/* Some extra flags for the undo function. */
#define WAS_BACKSPACE_AT_EOF (1<<1)
#define WAS_WHOLE_LINE (1<<2)
#define INCLUDED_LAST_LINE (1<<3)
#define MARK_WAS_SET (1<<4)
#define WAS_MARKED_BACKWARDS (1<<5)
#define CURSOR_WAS_AT_HEAD (1<<5)
#endif /* !NANO_TINY */
/* The default number of columns from end of line where wrapping occurs. */
#define COLUMNS_FROM_EOL 8
#define COLUMNS_FROM_EOL 8
/* The default width of a tab in spaces. */
#define WIDTH_OF_TAB 8
#define WIDTH_OF_TAB 8
/* The default comment character when a syntax does not specify any. */
#define GENERAL_COMMENT_CHARACTER "#"
#define GENERAL_COMMENT_CHARACTER "#"
/* The maximum number of search/replace history strings saved, not
* counting the blank lines at their ends. */
#define MAX_SEARCH_HISTORY 100
/* The maximum number of bytes buffered at one time. */
#define MAX_BUF_SIZE 128
#define MAX_SEARCH_HISTORY 100
/* The largest size_t number that doesn't have the high bit set. */
#define HIGHEST_POSITIVE ((~(size_t)0) >> 1)
#define HIGHEST_POSITIVE ((~(size_t)0) >> 1)

File diff suppressed because it is too large Load Diff

View File

@@ -19,7 +19,7 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#include <ctype.h>
#include <string.h>
@@ -45,13 +45,14 @@ bool mute_modifiers = FALSE;
bool bracketed_paste = FALSE;
/* Whether text is being pasted into nano from outside. */
bool started_curses = FALSE;
/* Becomes TRUE when curses mode has been entered the first time. */
bool we_are_running = FALSE;
/* Becomes TRUE as soon as all options and files have been read. */
bool more_than_one = FALSE;
/* Whether more than one buffer is or has been open. */
bool ran_a_tool = FALSE;
/* Whether a tool has been run at the Execute-Command prompt. */
bool inhelp = FALSE;
/* Whether we are in the help viewer. */
char *title = NULL;
@@ -69,10 +70,7 @@ bool as_an_at = TRUE;
bool control_C_was_pressed = FALSE;
/* Whether Ctrl+C was pressed (when a keyboard interrupt is enabled). */
bool suppress_cursorpos = FALSE;
/* Should we skip constant position display for current keystroke? */
message_type lastmessage = HUSH;
message_type lastmessage = VACUUM;
/* Messages of type HUSH should not overwrite type MILD nor ALERT. */
linestruct *pletion_line = NULL;
@@ -104,7 +102,8 @@ int shiftleft, shiftright, shiftup, shiftdown;
int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown;
int shiftcontrolhome, shiftcontrolend;
int altleft, altright, altup, altdown;
int altdelete;
int altpageup, altpagedown;
int altinsert, altdelete;
int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown;
#endif
@@ -130,7 +129,11 @@ int editwincols = -1;
/* The number of usable columns in the edit window: COLS - margin. */
int margin = 0;
/* The amount of space reserved at the left for line numbers. */
int thebar = 0;
/* Becomes 1 when a scrollbar is shown. */
#ifndef NANO_TINY
int *bardata = NULL;
/* An array of characters that together depict the scrollbar. */
ssize_t stripe_column = 0;
/* The column at which a vertical bar will be drawn. */
#endif
@@ -270,9 +273,9 @@ size_t light_to_col = 0;
#define BLANKAFTER TRUE /* A blank line after this one. */
#define TOGETHER FALSE
#ifdef ENABLE_MULTIBUFFER
#define CAN_OPEN_OTHER_BUFFER TRUE
#define CAN_OPEN_OTHER_BUFFER TRUE
#else
#define CAN_OPEN_OTHER_BUFFER FALSE
#define CAN_OPEN_OTHER_BUFFER FALSE
#endif
/* Empty functions, for the most part corresponding to toggles. */
@@ -295,6 +298,12 @@ void flip_goto(void)
void to_files(void)
{
}
void to_first_file(void)
{
}
void to_last_file(void)
{
}
void goto_dir(void)
{
}
@@ -448,26 +457,12 @@ void add_to_sclist(int menus, const char *scstring, const int keycode,
const keystruct *first_sc_for(int menu, void (*func)(void))
{
for (keystruct *sc = sclist; sc != NULL; sc = sc->next)
if ((sc->menus & menu) && sc->func == func)
if ((sc->menus & menu) && sc->func == func && sc->keystr[0])
return sc;
return NULL;
}
/* Return the first keycode that is bound to the given function in the
* current menu, if any; otherwise, return the given default value. */
int the_code_for(void (*func)(void), int defaultval)
{
const keystruct *sc = first_sc_for(currmenu, func);
if (sc == NULL)
return defaultval;
meta_key = (0x20 <= sc->keycode && sc->keycode <= 0x7E);
return sc->keycode;
}
/* Return the number of entries that can be shown in the given menu. */
size_t shown_entries_for(int menu)
{
@@ -481,7 +476,7 @@ size_t shown_entries_for(int menu)
item = item->next;
}
/* When --tempfile is not used, widen the grid of the WriteOut menu. */
/* When --saveonexit is not used, widen the grid of the WriteOut menu. */
if (menu == MWRITEFILE && first_sc_for(menu, discard_buffer) == NULL)
count--;
@@ -499,9 +494,11 @@ const keystruct *get_shortcut(int *keycode)
if (meta_key && *keycode < 0x20)
return NULL;
#ifndef NANO_TINY
/* During a paste at a prompt, ignore all command keycodes. */
if (bracketed_paste && *keycode != BRACKETED_PASTE_MARKER)
return NULL;
#endif
for (keystruct *sc = sclist; sc != NULL; sc = sc->next) {
if ((sc->menus & currmenu) && *keycode == sc->keycode)
@@ -628,6 +625,7 @@ void shortcut_init(void)
N_("Scroll up one line without moving the cursor textually");
const char *scrolldown_gist =
N_("Scroll down one line without moving the cursor textually");
const char *center_gist = N_("Center the line where the cursor is");
#endif
#ifdef ENABLE_MULTIBUFFER
const char *prevfile_gist = N_("Switch to the previous file buffer");
@@ -670,6 +668,9 @@ void shortcut_init(void)
#ifndef NANO_TINY
const char *recordmacro_gist = N_("Start/stop recording a macro");
const char *runmacro_gist = N_("Run the last recorded macro");
const char *anchor_gist = N_("Place or remove an anchor at the current line");
const char *prevanchor_gist = N_("Jump backward to the nearest anchor");
const char *nextanchor_gist = N_("Jump forward to the nearest anchor");
#endif
const char *case_gist = N_("Toggle the case sensitivity of the search");
const char *reverse_gist = N_("Reverse the direction of the search");
@@ -684,7 +685,7 @@ void shortcut_init(void)
const char *append_gist = N_("Toggle appending");
const char *prepend_gist = N_("Toggle prepending");
const char *backup_gist = N_("Toggle backing up of the original file");
const char *execute_gist = N_("Execute external command");
const char *execute_gist = N_("Execute a function or an external command");
const char *pipe_gist =
N_("Pipe the current buffer (or marked region) to the command");
const char *convert_gist = N_("Do not convert from DOS/Mac format");
@@ -715,24 +716,23 @@ void shortcut_init(void)
const char *lint_gist = N_("Invoke the linter, if available");
const char *prevlint_gist = N_("Go to previous linter msg");
const char *nextlint_gist = N_("Go to next linter msg");
#ifdef ENABLE_SPELLER
const char *formatter_gist =
N_("Invoke a program to format/arrange/manipulate the buffer");
#endif
#endif
#endif /* ENABLE_HELP */
#ifdef ENABLE_HELP
#define WITHORSANS(help) help
#define WITHORSANS(help) help
#else
#define WITHORSANS(help) ""
#define WITHORSANS(help) ""
#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 eleven strings at most 10 characters. */
N_("Get Help"), WITHORSANS(help_gist), TOGETHER, VIEW);
/* 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);
@@ -747,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);
@@ -769,7 +778,7 @@ void shortcut_init(void)
#ifdef ENABLE_HELP
/* The description ("x") and blank_after (0) are irrelevant,
* because the help viewer does not have a help text. */
add_to_funcs(total_refresh, MHELP, N_("Refresh"), "x", 0, VIEW);
add_to_funcs(full_refresh, MHELP, N_("Refresh"), "x", 0, VIEW);
add_to_funcs(do_exit, MHELP, close_tag, "x", 0, VIEW);
#endif
@@ -779,29 +788,38 @@ 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 Text"), WITHORSANS(cut_gist), TOGETHER, NOVIEW);
N_("Cut"), WITHORSANS(cut_gist), TOGETHER, NOVIEW);
add_to_funcs(paste_text, MMAIN,
N_("Paste Text"), WITHORSANS(paste_gist), BLANKAFTER, NOVIEW);
N_("Paste"), WITHORSANS(paste_gist), BLANKAFTER, NOVIEW);
if (!ISSET(RESTRICTED)) {
#ifndef NANO_TINY
add_to_funcs(do_execute, MMAIN,
N_("Execute"), WITHORSANS(execute_gist), TOGETHER, NOVIEW);
#endif
#ifdef ENABLE_JUSTIFY
add_to_funcs(do_justify_void, MMAIN,
N_("Justify"), WITHORSANS(justify_gist), TOGETHER, NOVIEW);
#endif
#ifdef ENABLE_SPELLER
add_to_funcs(do_spell, MMAIN,
N_("To Spell"), WITHORSANS(spell_gist), BLANKAFTER, NOVIEW);
N_("Justify"), WITHORSANS(justify_gist), BLANKAFTER, NOVIEW);
#endif
}
add_to_funcs(do_cursorpos_void, MMAIN,
/* TRANSLATORS: Try to keep the next thirteen strings at most 12 characters. */
N_("Cur Pos"), WITHORSANS(cursorpos_gist), TOGETHER, VIEW);
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(ENABLE_JUSTIFY) && defined(ENABLE_SPELLER)) || \
(!defined(ENABLE_JUSTIFY) && !defined(ENABLE_SPELLER)))
#if defined(NANO_TINY) || defined(ENABLE_JUSTIFY)
/* Conditionally placing this one here or further on, to keep the
* help items nicely paired in most conditions. */
add_to_funcs(do_gotolinecolumn_void, MMAIN,
@@ -810,26 +828,26 @@ void shortcut_init(void)
#ifndef NANO_TINY
add_to_funcs(do_undo, MMAIN,
/* TRANSLATORS: Try to keep the next ten strings at most 12 characters. */
N_("Undo"), WITHORSANS(undo_gist), TOGETHER, NOVIEW);
add_to_funcs(do_redo, MMAIN,
N_("Redo"), WITHORSANS(redo_gist), BLANKAFTER, NOVIEW);
add_to_funcs(do_mark, MMAIN,
N_("Mark Text"), WITHORSANS(mark_gist), TOGETHER, VIEW);
N_("Set Mark"), WITHORSANS(mark_gist), TOGETHER, VIEW);
add_to_funcs(copy_text, MMAIN,
N_("Copy Text"), WITHORSANS(copy_gist), BLANKAFTER, NOVIEW);
N_("Copy"), WITHORSANS(copy_gist), BLANKAFTER, NOVIEW);
#endif
add_to_funcs(case_sens_void, MWHEREIS|MREPLACE,
N_("Case Sens"), WITHORSANS(case_gist), TOGETHER, VIEW);
add_to_funcs(regexp_void, MWHEREIS|MREPLACE,
N_("Regexp"), WITHORSANS(regexp_gist), TOGETHER, VIEW);
N_("Reg.exp."), WITHORSANS(regexp_gist), TOGETHER, VIEW);
add_to_funcs(backwards_void, MWHEREIS|MREPLACE,
N_("Backwards"), WITHORSANS(reverse_gist), TOGETHER, VIEW);
N_("Backwards"), WITHORSANS(reverse_gist), BLANKAFTER, VIEW);
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);
@@ -840,51 +858,48 @@ 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), TOGETHER, VIEW);
#ifdef ENABLE_JUSTIFY
add_to_funcs(do_full_justify, MWHEREIS,
N_("FullJstify"), WITHORSANS(fulljustify_gist), BLANKAFTER, NOVIEW);
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);
add_to_funcs(total_refresh, MBROWSER,
#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);
#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);
#ifndef NANO_TINY
add_to_funcs(do_findnext, MMAIN|MBROWSER|MHELP,
add_to_funcs(do_findnext, MMAIN|MHELP,
N_("Next"), WITHORSANS(findnext_gist), BLANKAFTER, VIEW);
#else
/* In the tiny version, arrange things a bit differently, so that
* the useful M-W and M-Q are shown in the help lines. */
add_to_funcs(do_findnext, MMAIN|MBROWSER|MHELP,
N_("Next"), WITHORSANS(findnext_gist), TOGETHER, VIEW);
add_to_funcs(do_search_backward, MMAIN|MHELP,
N_("Where Was"), WITHORSANS(wherewas_gist), BLANKAFTER, VIEW);
add_to_funcs(total_refresh, MMAIN,
N_("Refresh"), WITHORSANS(refresh_gist), BLANKAFTER, VIEW);
#endif
add_to_funcs(do_left, MMAIN,
@@ -899,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 eighteen strings at most 12 characters. */
/* 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);
@@ -927,12 +944,14 @@ void shortcut_init(void)
N_("Next Block"), WITHORSANS(nextblock_gist), TOGETHER, VIEW);
#ifdef ENABLE_JUSTIFY
add_to_funcs(to_para_begin, MMAIN|MGOTOLINE,
N_("Beg of Par"), WITHORSANS(parabegin_gist), TOGETHER, VIEW);
/* TRANSLATORS: Try to keep these two strings at most 15 characters. */
N_("Begin of Paragr."), WITHORSANS(parabegin_gist), TOGETHER, VIEW);
add_to_funcs(to_para_end, MMAIN|MGOTOLINE,
N_("End of Par"), WITHORSANS(paraend_gist), BLANKAFTER, VIEW);
N_("End of Paragraph"), WITHORSANS(paraend_gist), BLANKAFTER, VIEW);
#endif
add_to_funcs(do_page_up, MMAIN|MHELP,
/* TRANSLATORS: Try to keep the next six strings at most 12 characters. */
N_("Prev Page"), WITHORSANS(prevpage_gist), TOGETHER, VIEW);
add_to_funcs(do_page_down, MMAIN|MHELP,
N_("Next Page"), WITHORSANS(nextpage_gist), TOGETHER, VIEW);
@@ -949,8 +968,7 @@ void shortcut_init(void)
N_("Next File"), WITHORSANS(nextfile_gist), BLANKAFTER, VIEW);
#endif
#if ((!defined(ENABLE_JUSTIFY) && defined(ENABLE_SPELLER)) || \
(defined(ENABLE_JUSTIFY) && !defined(ENABLE_SPELLER)))
#if !defined(NANO_TINY) && !defined(ENABLE_JUSTIFY)
add_to_funcs(do_gotolinecolumn_void, MMAIN,
N_("Go To Line"), WITHORSANS(gotoline_gist), BLANKAFTER, VIEW);
#endif
@@ -979,12 +997,12 @@ void shortcut_init(void)
add_to_funcs(chop_next_word, MMAIN,
N_("Chop Right"), WITHORSANS(chopwordright_gist), TOGETHER, NOVIEW);
add_to_funcs(cut_till_eof, MMAIN,
N_("CutTillEnd"), WITHORSANS(cuttilleof_gist), BLANKAFTER, NOVIEW);
N_("Cut Till End"), WITHORSANS(cuttilleof_gist), BLANKAFTER, NOVIEW);
#endif
#ifdef ENABLE_JUSTIFY
add_to_funcs(do_full_justify, MMAIN,
N_("FullJstify"), WITHORSANS(fulljustify_gist), TOGETHER, NOVIEW);
N_("Full Justify"), WITHORSANS(fulljustify_gist), TOGETHER, NOVIEW);
#endif
#ifndef NANO_TINY
@@ -995,8 +1013,8 @@ void shortcut_init(void)
add_to_funcs(do_verbatim_input, MMAIN,
N_("Verbatim"), WITHORSANS(verbatim_gist), BLANKAFTER, NOVIEW);
#ifndef NANO_TINY
add_to_funcs(total_refresh, MMAIN,
#ifdef ENABLE_HELP
add_to_funcs(full_refresh, MMAIN,
N_("Refresh"), WITHORSANS(refresh_gist), TOGETHER, VIEW);
#endif
@@ -1017,31 +1035,81 @@ 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);
add_to_funcs(run_macro, MMAIN,
N_("Run Macro"), WITHORSANS(runmacro_gist), BLANKAFTER, VIEW);
add_to_funcs(zap_text, MMAIN,
N_("Zap Text"), WITHORSANS(zap_gist), BLANKAFTER, NOVIEW);
add_to_funcs(put_or_lift_anchor, MMAIN,
N_("Anchor"), WITHORSANS(anchor_gist), TOGETHER, VIEW);
add_to_funcs(to_prev_anchor, MMAIN,
N_("Up to anchor"), WITHORSANS(prevanchor_gist), TOGETHER, VIEW);
add_to_funcs(to_next_anchor, MMAIN,
N_("Down to anchor"), WITHORSANS(nextanchor_gist), BLANKAFTER, VIEW);
add_to_funcs(zap_text, MMAIN,
/* TRANSLATORS: This *deletes* a line or marked region. */
N_("Zap"), WITHORSANS(zap_gist), BLANKAFTER, NOVIEW);
#ifdef ENABLE_COLOR
if (!ISSET(RESTRICTED)) {
add_to_funcs(do_linter, MMAIN,
N_("To Linter"), WITHORSANS(lint_gist), TOGETHER, NOVIEW);
#ifdef ENABLE_SPELLER
add_to_funcs(do_spell, MMAIN,
N_("Spell Check"), WITHORSANS(spell_gist), TOGETHER, NOVIEW);
#endif
#ifdef ENABLE_COLOR
add_to_funcs(do_linter, MMAIN,
N_("Linter"), WITHORSANS(lint_gist), TOGETHER, NOVIEW);
add_to_funcs(do_formatter, MMAIN,
N_("Formatter"), WITHORSANS(formatter_gist), BLANKAFTER, NOVIEW);
#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);
#endif
add_to_funcs(do_savefile, MMAIN,
N_("Save"), WITHORSANS(savefile_gist), BLANKAFTER, NOVIEW);
#ifdef ENABLE_MULTIBUFFER
/* Multiple buffers are only available when not in restricted mode. */
if (!ISSET(RESTRICTED))
add_to_funcs(flip_newbuffer, MINSERTFILE|MEXECUTE,
N_("New Buffer"), WITHORSANS(newbuffer_gist), TOGETHER, NOVIEW);
#endif
#ifndef NANO_TINY
add_to_funcs(flip_pipe, MEXECUTE,
N_("Pipe Text"), WITHORSANS(pipe_gist), BLANKAFTER, NOVIEW);
#endif
#ifdef ENABLE_SPELLER
add_to_funcs(do_spell, MEXECUTE,
N_("Spell Check"), WITHORSANS(spell_gist), TOGETHER, NOVIEW);
#endif
#ifdef ENABLE_COLOR
add_to_funcs(do_linter, MEXECUTE,
N_("Linter"), WITHORSANS(lint_gist), BLANKAFTER, NOVIEW);
#endif
#ifdef ENABLE_JUSTIFY
add_to_funcs(do_full_justify, MEXECUTE,
N_("Full Justify"), WITHORSANS(fulljustify_gist), TOGETHER, NOVIEW);
#endif
#ifdef ENABLE_COLOR
add_to_funcs(do_formatter, MEXECUTE,
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,
@@ -1062,34 +1130,29 @@ void shortcut_init(void)
add_to_funcs(backup_file_void, MWRITEFILE,
N_("Backup File"), WITHORSANS(backup_gist), BLANKAFTER, NOVIEW);
}
#endif /* !NANO_TINY */
#ifdef ENABLE_MULTIBUFFER
/* Multiple buffers are only available when not in restricted mode. */
if (!ISSET(RESTRICTED))
add_to_funcs(flip_newbuffer, MINSERTFILE|MEXTCMD,
N_("New Buffer"), WITHORSANS(newbuffer_gist), TOGETHER, NOVIEW);
#endif
#ifndef NANO_TINY
add_to_funcs(flip_convert, MINSERTFILE,
N_("No Conversion"), WITHORSANS(convert_gist), TOGETHER, NOVIEW);
N_("No Conversion"), WITHORSANS(convert_gist), BLANKAFTER, NOVIEW);
/* Command execution is only available when not in restricted mode. */
if (!ISSET(RESTRICTED) && !ISSET(VIEW_MODE)) {
add_to_funcs(flip_execute, MINSERTFILE,
N_("Execute Command"), WITHORSANS(execute_gist), TOGETHER, NOVIEW);
N_("Execute Command"), WITHORSANS(execute_gist), BLANKAFTER, NOVIEW);
add_to_funcs(flip_pipe, MEXTCMD,
N_("Pipe Text"), WITHORSANS(pipe_gist), TOGETHER, NOVIEW);
add_to_funcs(cut_till_eof, MEXECUTE,
N_("Cut Till End"), WITHORSANS(cuttilleof_gist), BLANKAFTER, NOVIEW);
add_to_funcs(flip_execute, MEXTCMD,
N_("Read File"), WITHORSANS(readfile_gist), TOGETHER, NOVIEW);
add_to_funcs(do_suspend_void, MEXECUTE,
N_("Suspend"), WITHORSANS(suspend_gist), BLANKAFTER, VIEW);
}
#endif
#endif /* !NANO_TINY */
#ifdef ENABLE_BROWSER
/* The file browser is only available when not in restricted mode. */
if (!ISSET(RESTRICTED))
add_to_funcs(to_files, MWRITEFILE|MINSERTFILE,
N_("To Files"), WITHORSANS(tofiles_gist), TOGETHER, VIEW);
/* TRANSLATORS: This invokes the file browser. */
N_("Browse"), WITHORSANS(tofiles_gist), BLANKAFTER, VIEW);
add_to_funcs(do_page_up, MBROWSER,
N_("Prev Page"), WITHORSANS(prevpage_gist), TOGETHER, VIEW);
@@ -1100,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);
@@ -1118,9 +1182,9 @@ void shortcut_init(void)
#ifdef ENABLE_COLOR
add_to_funcs(do_page_up, MLINTER,
/* TRANSLATORS: The next two strings may be up to 37 characters each. */
N_("Prev Lint Msg"), WITHORSANS(prevlint_gist), TOGETHER, VIEW);
N_("Previous Linter message"), WITHORSANS(prevlint_gist), TOGETHER, VIEW);
add_to_funcs(do_page_down, MLINTER,
N_("Next Lint Msg"), WITHORSANS(nextlint_gist), TOGETHER, VIEW);
N_("Next Linter message"), WITHORSANS(nextlint_gist), TOGETHER, VIEW);
#endif
/* Link key combos to functions in certain menus. */
@@ -1147,19 +1211,23 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "M-R", 0, do_replace, 0);
add_to_sclist(MMOST, "^K", 0, cut_text, 0);
add_to_sclist(MMOST, "^U", 0, paste_text, 0);
#ifndef NANO_TINY
add_to_sclist(MMAIN, "^T", 0, do_execute, 0);
#endif
#ifdef ENABLE_JUSTIFY
add_to_sclist(MMAIN, "^J", '\n', do_justify_void, 0);
#endif
#ifdef ENABLE_SPELLER
add_to_sclist(MMAIN, "^T", 0, do_spell, 0);
add_to_sclist(MEXECUTE, "^S", 0, do_spell, 0);
add_to_sclist(MEXECUTE, "^T", 0, do_spell, 0);
#endif
#ifdef ENABLE_COLOR
add_to_sclist(MMAIN, "M-B", 0, do_linter, 0);
#ifdef ENABLE_SPELLER
add_to_sclist(MEXECUTE, "^Y", 0, do_linter, 0);
add_to_sclist(MMAIN, "M-F", 0, do_formatter, 0);
add_to_sclist(MEXECUTE, "^O", 0, do_formatter, 0);
#endif
#endif
add_to_sclist(MMAIN, "^C", 0, do_cursorpos_void, 0);
add_to_sclist(MMAIN, "^C", 0, report_cursor_position, 0);
add_to_sclist(MMAIN, "^_", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MMAIN, "M-G", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "^Y", 0, do_page_up, 0);
@@ -1175,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);
@@ -1190,9 +1263,13 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "M-;", 0, run_macro, 0);
add_to_sclist(MMAIN, "M-U", 0, do_undo, 0);
add_to_sclist(MMAIN, "M-E", 0, do_redo, 0);
add_to_sclist(MMAIN, "M-Bsp", CONTROL_SHIFT_DELETE, chop_previous_word, 0);
add_to_sclist(MMAIN, "Sh-^Del", CONTROL_SHIFT_DELETE, chop_previous_word, 0);
add_to_sclist(MMAIN, "^Del", CONTROL_DELETE, chop_next_word, 0);
add_to_sclist(MMAIN, "M-Del", ALT_DELETE, zap_text, 0);
add_to_sclist(MMAIN, "M-Ins", ALT_INSERT, put_or_lift_anchor, 0);
add_to_sclist(MMAIN, "M-PgUp", ALT_PAGEUP, to_prev_anchor, 0);
add_to_sclist(MMAIN, "M-PgDn", ALT_PAGEDOWN, to_next_anchor, 0);
#endif
#ifdef ENABLE_WORDCOMPLETION
add_to_sclist(MMAIN, "^]", 0, complete_a_word, 0);
@@ -1228,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);
@@ -1291,21 +1362,27 @@ void shortcut_init(void)
add_to_sclist(MMOST, "M-V", 0, do_verbatim_input, 0);
#ifndef NANO_TINY
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
if (!ISSET(VIEW_MODE))
add_to_sclist(MMAIN|MWHEREIS, "M-J", 0, do_full_justify, 0);
add_to_sclist(MMAIN, "M-J", 0, do_full_justify, 0);
add_to_sclist(MEXECUTE, "^J", 0, do_full_justify, 0);
#endif
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
add_to_sclist(MMAIN, "^L", 0, do_center, 0);
#endif
if (!ISSET(PRESERVE))
add_to_sclist(MMAIN|MBROWSER|MHELP, "^L", 0, total_refresh, 0);
add_to_sclist(MMOST|MBROWSER|MHELP|MYESNO, "^L", 0, full_refresh, 0);
else
add_to_sclist(MMAIN|MBROWSER, "^L", 0, total_refresh, 0);
add_to_sclist(MMAIN, "^Z", 0, do_suspend_void, 0);
add_to_sclist(MMOST|MBROWSER|MYESNO, "^L", 0, full_refresh, 0);
add_to_sclist(MMAIN|MEXECUTE, "^Z", 0, do_suspend_void, 0);
#ifndef NANO_TINY
/* Group of "Appearance" toggles. */
add_to_sclist(MMAIN, "M-X", 0, do_toggle_void, NO_HELP);
add_to_sclist((MMOST|MBROWSER|MYESNO) & ~MFINDINHELP, "M-X", 0, do_toggle_void, NO_HELP);
add_to_sclist(MMAIN, "M-C", 0, do_toggle_void, CONSTANT_SHOW);
add_to_sclist(MMAIN, "M-S", 0, do_toggle_void, SOFTWRAP);
add_to_sclist(MMAIN, "M-$", 0, do_toggle_void, SOFTWRAP);
@@ -1315,7 +1392,7 @@ void shortcut_init(void)
#endif
add_to_sclist(MMAIN, "M-P", 0, do_toggle_void, WHITESPACE_DISPLAY);
#ifdef ENABLE_COLOR
add_to_sclist(MMAIN, "M-Y", 0, do_toggle_void, NO_COLOR_SYNTAX);
add_to_sclist(MMAIN, "M-Y", 0, do_toggle_void, NO_SYNTAX);
#endif
/* Group of "Editing-behavior" toggles. */
@@ -1342,17 +1419,17 @@ void shortcut_init(void)
add_to_sclist(MWHEREIS|MREPLACE, "^R", 0, flip_replace, 0);
add_to_sclist(MWHEREIS|MGOTOLINE, "^T", 0, flip_goto, 0);
#ifdef ENABLE_HISTORIES
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "^P", 0, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "^N", 0, get_history_newer_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "^P", 0, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "^N", 0, get_history_newer_void, 0);
#ifdef ENABLE_UTF8
if (using_utf8()) {
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "\xE2\x96\xb2", KEY_UP, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "\xE2\x96\xbc", KEY_DOWN, get_history_newer_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\xb2", KEY_UP, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\xbc", KEY_DOWN, get_history_newer_void, 0);
} else
#endif
{
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "Up", KEY_UP, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXTCMD, "Down", KEY_DOWN, get_history_newer_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "Up", KEY_UP, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "Down", KEY_DOWN, get_history_newer_void, 0);
}
#endif
#ifdef ENABLE_JUSTIFY
@@ -1376,7 +1453,7 @@ void shortcut_init(void)
add_to_sclist(MBROWSER, "^_", 0, goto_dir, 0);
add_to_sclist(MBROWSER, "M-G", 0, goto_dir, 0);
#endif
if (ISSET(TEMP_FILE) && !ISSET(PRESERVE))
if (ISSET(SAVE_ON_EXIT) && !ISSET(PRESERVE))
add_to_sclist(MWRITEFILE, "^Q", 0, discard_buffer, 0);
#ifndef NANO_TINY
add_to_sclist(MWRITEFILE, "M-D", 0, dos_format_void, 0);
@@ -1387,16 +1464,16 @@ void shortcut_init(void)
add_to_sclist(MWRITEFILE, "M-A", 0, append_void, 0);
add_to_sclist(MWRITEFILE, "M-P", 0, prepend_void, 0);
add_to_sclist(MWRITEFILE, "M-B", 0, backup_file_void, 0);
add_to_sclist(MINSERTFILE|MEXTCMD, "^X", 0, flip_execute, 0);
add_to_sclist(MINSERTFILE|MEXECUTE, "^X", 0, flip_execute, 0);
}
add_to_sclist(MINSERTFILE, "M-N", 0, flip_convert, 0);
#endif
#ifdef ENABLE_MULTIBUFFER
/* Only when not in restricted mode, allow multiple buffers. */
if (!ISSET(RESTRICTED)) {
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, flip_newbuffer, 0);
add_to_sclist(MINSERTFILE|MEXECUTE, "M-F", 0, flip_newbuffer, 0);
#ifndef NANO_TINY
add_to_sclist(MEXTCMD, "M-\\", 0, flip_pipe, 0);
add_to_sclist(MEXECUTE, "M-\\", 0, flip_pipe, 0);
#endif
}
#endif
@@ -1432,10 +1509,15 @@ void shortcut_init(void)
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "F8", KEY_F(8), do_page_down, 0);
add_to_sclist(MMOST, "F9", KEY_F(9), cut_text, 0);
add_to_sclist(MMOST, "F10", KEY_F(10), paste_text, 0);
add_to_sclist(MMAIN, "F11", KEY_F(11), do_cursorpos_void, 0);
add_to_sclist(MMAIN, "F11", KEY_F(11), report_cursor_position, 0);
#ifdef ENABLE_SPELLER
add_to_sclist(MMAIN, "F12", KEY_F(12), do_spell, 0);
#endif
#if defined(KEY_CANCEL) && defined(KEY_SUSPEND) && defined(KEY_SIC)
add_to_sclist((MMOST & ~MMAIN) | MYESNO, "", KEY_CANCEL, do_cancel, 0);
add_to_sclist(MMAIN|MEXECUTE, "", KEY_SUSPEND, do_suspend_void, 0);
add_to_sclist(MMAIN, "", KEY_SIC, do_insertfile_void, 0);
#endif
#ifndef NANO_TINY
/* Catch and ignore bracketed paste marker keys. */
add_to_sclist(MMOST|MBROWSER|MHELP|MYESNO, "", BRACKETED_PASTE_MARKER, do_nothing, 0);
@@ -1457,7 +1539,7 @@ const char *flagtostr(int flag)
return N_("Soft wrapping of overlong lines");
case WHITESPACE_DISPLAY:
return N_("Whitespace display");
case NO_COLOR_SYNTAX:
case NO_SYNTAX:
return N_("Color syntax highlighting");
case SMART_HOME:
return N_("Smart home key");

View File

@@ -20,7 +20,7 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#ifdef ENABLE_HELP
@@ -29,266 +29,15 @@
static char *help_text = NULL;
/* The text displayed in the help window. */
static const char *start_of_body = NULL;
/* The point in the help text just after the title. */
static char *end_of_intro = NULL;
/* The point in the help text where the shortcut descriptions begin. */
static size_t location;
/* The offset (in bytes) of the topleft of the shown help text. */
/* Hard-wrap the concatenated help text, and write it into a new buffer. */
void wrap_help_text_into_buffer(void)
{
size_t sum = 0;
/* Avoid overtight and overwide paragraphs in the introductory text. */
size_t wrapping_point = (COLS < 40) ? 40 : (COLS > 74) ? 74 : COLS;
const char *ptr = start_of_body;
make_new_buffer();
/* Copy the help text into the just-created new buffer. */
while (*ptr != '\0') {
int length, shim;
char *oneline;
if (ptr == end_of_intro)
wrapping_point = (COLS < 40) ? 40 : COLS;
if (ptr > end_of_intro && *(ptr - 1) != '\n') {
length = break_line(ptr, (COLS < 40) ? 22 : COLS - 18, TRUE);
oneline = nmalloc(length + 5);
snprintf(oneline, length + 5, "\t\t %s", ptr);
} else {
length = break_line(ptr, wrapping_point, TRUE);
oneline = nmalloc(length + 1);
shim = (*(ptr + length - 1) == ' ') ? 0 : 1;
snprintf(oneline, length + shim, "%s", ptr);
}
free(openfile->current->data);
openfile->current->data = oneline;
ptr += length;
if (*ptr != '\n')
ptr--;
/* Create a new line, and then one more for each extra \n. */
do {
openfile->current->next = make_new_node(openfile->current);
openfile->current = openfile->current->next;
openfile->current->data = copy_of("");
} while (*(++ptr) == '\n');
}
openfile->filebot = openfile->current;
openfile->current = openfile->filetop;
remove_magicline();
#ifdef ENABLE_COLOR
color_update();
#endif
prepare_for_display();
/* Move to the position in the file where we were before. */
while (TRUE) {
sum += strlen(openfile->current->data);
if (sum > location)
break;
openfile->current = openfile->current->next;
}
openfile->edittop = openfile->current;
}
/* Assemble a help text, display it, and allow scrolling through it. */
void show_help(void)
{
int kbinput = ERR;
functionptrtype func;
/* The function of the key the user typed in. */
int oldmenu = currmenu;
/* The menu we were called from. */
#ifdef ENABLE_LINENUMBERS
int was_margin = margin;
#endif
ssize_t was_tabsize = tabsize;
#ifdef ENABLE_COLOR
char *was_syntax = syntaxstr;
#endif
char *saved_answer = (answer != NULL) ? copy_of(answer) : NULL;
/* The current answer when the user invokes help at the prompt. */
unsigned stash[sizeof(flags) / sizeof(flags[0])];
/* A storage place for the current flag settings. */
linestruct *line;
int length;
blank_statusbar();
/* Save the settings of all flags. */
memcpy(stash, flags, sizeof(flags));
/* Ensure that the help screen's shortcut list can be displayed. */
if (ISSET(NO_HELP) && LINES > 4) {
UNSET(NO_HELP);
window_init();
}
/* When searching, do it forward, case insensitive, and without regexes. */
UNSET(BACKWARDS_SEARCH);
UNSET(CASE_SENSITIVE);
UNSET(USE_REGEXP);
UNSET(WHITESPACE_DISPLAY);
UNSET(NOREAD_MODE);
#ifdef ENABLE_LINENUMBERS
UNSET(LINE_NUMBERS);
editwincols = COLS;
margin = 0;
#endif
tabsize = 8;
#ifdef ENABLE_COLOR
syntaxstr = "nanohelp";
#endif
curs_set(0);
/* Compose the help text from all the relevant pieces. */
help_init();
inhelp = TRUE;
location = 0;
didfind = 0;
bottombars(MHELP);
/* Extract the title from the head of the help text. */
length = break_line(help_text, MAX_BUF_SIZE, TRUE);
title = measured_copy(help_text, length);
titlebar(title);
/* Skip over the title to point at the start of the body text. */
start_of_body = help_text + length;
while (*start_of_body == '\n')
start_of_body++;
wrap_help_text_into_buffer();
edit_refresh();
while (TRUE) {
lastmessage = HUSH;
focusing = TRUE;
/* Show the cursor when we searched and found something. */
kbinput = get_kbinput(edit, didfind == 1 || ISSET(SHOW_CURSOR));
didfind = 0;
#ifndef NANO_TINY
if (bracketed_paste || kbinput == BRACKETED_PASTE_MARKER) {
beep();
continue;
}
#endif
func = interpret(&kbinput);
if (func == total_refresh) {
total_redraw();
} else if (ISSET(SHOW_CURSOR) && (func == do_left || func == do_right ||
func == do_up || func == do_down)) {
func();
} 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)
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();
} else if (func == do_search_forward || func == do_search_backward) {
func();
bottombars(MHELP);
#ifdef ENABLE_NANORC
} else if (func == (functionptrtype)implant) {
implant(first_sc_for(MHELP, func)->expansion);
#endif
#ifdef ENABLE_MOUSE
} else if (kbinput == KEY_MOUSE) {
int dummy_row, dummy_col;
get_mouseinput(&dummy_row, &dummy_col, TRUE);
#endif
#ifndef NANO_TINY
} else if (kbinput == KEY_WINCH) {
; /* Nothing to do. */
#endif
} else if (func == do_exit) {
break;
} else
unbound_key(kbinput);
currmenu = MHELP;
edit_refresh();
location = 0;
line = openfile->filetop;
/* Count how far (in bytes) edittop is into the file. */
while (line != openfile->edittop) {
location += strlen(line->data);
line = line->next;
}
}
/* Discard the help-text buffer. */
close_buffer();
/* Restore the settings of all flags. */
memcpy(flags, stash, sizeof(flags));
#ifdef ENABLE_LINENUMBERS
margin = was_margin;
editwincols = COLS - margin;
#endif
tabsize = was_tabsize;
#ifdef ENABLE_COLOR
syntaxstr = was_syntax;
have_palette = FALSE;
#endif
free(title);
title = NULL;
free(answer);
answer = saved_answer;
free(help_text);
inhelp = FALSE;
curs_set(0);
if (ISSET(NO_HELP)) {
currmenu = oldmenu;
window_init();
} else {
wipe_statusbar();
bottombars(oldmenu);
}
#ifdef ENABLE_BROWSER
if (oldmenu == MBROWSER || oldmenu == MWHEREISFILE || oldmenu == MGOTODIR)
browser_refresh();
else
#endif
{
titlebar(NULL);
edit_refresh();
}
}
/* Allocate space for the help text for the current menu, and concatenate
* the different pieces of text into it. */
/* Allocate space for the help text for the current menu,
* and concatenate the different pieces of text into it. */
void help_init(void)
{
size_t allocsize = 0;
@@ -296,9 +45,9 @@ void help_init(void)
const char *htx[3];
/* Untranslated help introduction. We break it up into three chunks
* in case the full string is too long for the compiler to handle. */
char *ptr;
const funcstruct *f;
const keystruct *s;
char *ptr;
/* First, set up the initial help text for the current function. */
if (currmenu == MWHEREIS || currmenu == MREPLACE || currmenu == MREPLACEWITH) {
@@ -408,7 +157,7 @@ void help_init(void)
}
#endif /* ENABLE_SPELLER */
#ifndef NANO_TINY
else if (currmenu == MEXTCMD) {
else if (currmenu == MEXECUTE) {
htx[0] = N_("Execute Command Help Text\n\n "
"This mode allows you to insert the output of a "
"command run by the shell into the current buffer (or "
@@ -416,7 +165,8 @@ void help_init(void)
"(the pipe symbol), the current contents of the buffer "
"(or marked region) will be piped to the command. ");
htx[1] = N_("If you just need another blank buffer, do not enter any "
"command.\n\n");
"command.\n\n You can also pick one of four tools, or cut a "
"large piece of the buffer, or put the editor to sleep.\n\n");
htx[2] = N_(" The following function keys are "
"available in Execute Command mode:\n\n");
} else if (currmenu == MLINTER) {
@@ -469,9 +219,9 @@ void help_init(void)
if (htx[2] != NULL)
allocsize += strlen(htx[2]);
/* Calculate the length of the shortcut help text. Each entry has
* one or two keys, which fill 17 cells, plus translated text,
* plus one or two \n's. */
/* Calculate the length of the descriptions of the shortcuts.
* Each entry has one or two keystrokes, which fill 17 cells,
* plus translated text, plus one or two \n's. */
for (f = allfuncs; f != NULL; f = f->next)
if (f->menus & currmenu)
allocsize += strlen(_(f->help)) + 21;
@@ -490,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]);
@@ -512,7 +262,7 @@ void help_init(void)
/* Show the first two shortcuts (if any) for each function. */
for (s = sclist; s != NULL; s = s->next) {
if ((s->menus & currmenu) && s->func == f->func) {
if ((s->menus & currmenu) && s->func == f->func && s->keystr[0]) {
/* Make the first column 7 cells wide and the second 10. */
if (++tally == 1) {
sprintf(ptr, "%s ", s->keystr);
@@ -552,9 +302,9 @@ void help_init(void)
counter++;
for (s = sclist; s != NULL; s = s->next)
if (s->toggle && s->ordinal == counter) {
ptr += sprintf(ptr, "%s\t\t %s %s\n", (s->menus == MMAIN ? s->keystr : ""),
ptr += sprintf(ptr, "%s\t\t %s %s\n", (s->menus & MMAIN ? s->keystr : ""),
_(flagtostr(s->toggle)), _("enable/disable"));
if (s->toggle == NO_COLOR_SYNTAX || s->toggle == TABS_TO_SPACES)
if (s->toggle == NO_SYNTAX || s->toggle == TABS_TO_SPACES)
ptr += sprintf(ptr, "\n");
break;
}
@@ -562,6 +312,252 @@ void help_init(void)
}
#endif /* !NANO_TINY */
}
/* Hard-wrap the concatenated help text, and write it into a new buffer. */
void wrap_help_text_into_buffer(void)
{
size_t sum = 0;
/* Avoid overtight and overwide paragraphs in the introductory text. */
size_t wrapping_point = ((COLS < 40) ? 40 : (COLS > 74) ? 74 : COLS) - thebar;
const char *ptr = start_of_body;
make_new_buffer();
/* Copy the help text into the just-created new buffer. */
while (*ptr != '\0') {
int length, shim;
char *oneline;
if (ptr == end_of_intro)
wrapping_point = ((COLS < 40) ? 40 : COLS) - thebar;
if (ptr < end_of_intro || *(ptr - 1) == '\n') {
length = break_line(ptr, wrapping_point, TRUE);
oneline = nmalloc(length + 1);
shim = (*(ptr + length - 1) == ' ') ? 0 : 1;
snprintf(oneline, length + shim, "%s", ptr);
} else {
length = break_line(ptr, ((COLS < 40) ? 22 : COLS - 18) - thebar, TRUE);
oneline = nmalloc(length + 5);
snprintf(oneline, length + 5, "\t\t %s", ptr);
}
free(openfile->current->data);
openfile->current->data = oneline;
ptr += length;
if (*ptr != '\n')
ptr--;
/* Create a new line, and then one more for each extra \n. */
do {
openfile->current->next = make_new_node(openfile->current);
openfile->current = openfile->current->next;
openfile->current->data = copy_of("");
} while (*(++ptr) == '\n');
}
openfile->filebot = openfile->current;
openfile->current = openfile->filetop;
remove_magicline();
#ifdef ENABLE_COLOR
find_and_prime_applicable_syntax();
#endif
prepare_for_display();
/* Move to the position in the file where we were before. */
while (TRUE) {
sum += strlen(openfile->current->data);
if (sum > location)
break;
openfile->current = openfile->current->next;
}
openfile->edittop = openfile->current;
}
/* Assemble a help text, display it, and allow scrolling through it. */
void show_help(void)
{
int kbinput = ERR;
functionptrtype func;
/* The function of the key the user typed in. */
int oldmenu = currmenu;
/* The menu we were called from. */
#ifdef ENABLE_LINENUMBERS
int was_margin = margin;
#endif
ssize_t was_tabsize = tabsize;
#ifdef ENABLE_COLOR
char *was_syntax = syntaxstr;
#endif
char *saved_answer = (answer != NULL) ? copy_of(answer) : NULL;
/* The current answer when the user invokes help at the prompt. */
unsigned stash[sizeof(flags) / sizeof(flags[0])];
/* A storage place for the current flag settings. */
linestruct *line;
int length;
/* Save the settings of all flags. */
memcpy(stash, flags, sizeof(flags));
/* Ensure that the help screen's shortcut list can be displayed. */
if (ISSET(NO_HELP) && LINES > 4) {
UNSET(NO_HELP);
window_init();
} else
blank_statusbar();
/* When searching, do it forward, case insensitive, and without regexes. */
UNSET(BACKWARDS_SEARCH);
UNSET(CASE_SENSITIVE);
UNSET(USE_REGEXP);
UNSET(WHITESPACE_DISPLAY);
UNSET(NOREAD_MODE);
#ifdef ENABLE_LINENUMBERS
UNSET(LINE_NUMBERS);
editwincols = COLS - thebar;
margin = 0;
#endif
tabsize = 8;
#ifdef ENABLE_COLOR
syntaxstr = "nanohelp";
#endif
curs_set(0);
/* Compose the help text from all the relevant pieces. */
help_init();
inhelp = TRUE;
location = 0;
didfind = 0;
bottombars(MHELP);
/* Extract the title from the head of the help text. */
length = break_line(help_text, HIGHEST_POSITIVE, TRUE);
title = measured_copy(help_text, length);
titlebar(title);
/* Skip over the title to point at the start of the body text. */
start_of_body = help_text + length;
while (*start_of_body == '\n')
start_of_body++;
wrap_help_text_into_buffer();
edit_refresh();
while (TRUE) {
lastmessage = VACUUM;
focusing = TRUE;
/* Show the cursor when we searched and found something. */
kbinput = get_kbinput(edit, didfind == 1 || ISSET(SHOW_CURSOR));
didfind = 0;
#ifndef NANO_TINY
if (bracketed_paste || kbinput == BRACKETED_PASTE_MARKER) {
beep();
continue;
}
#endif
func = interpret(&kbinput);
if (func == full_refresh) {
full_refresh();
} else if (ISSET(SHOW_CURSOR) && (func == do_left || func == do_right ||
func == do_up || func == do_down)) {
func();
} 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)
do_scroll_down();
} else if (func == do_page_up || func == do_page_down ||
func == to_first_line || func == to_last_line) {
func();
} else if (func == do_search_backward || func == do_search_forward ||
func == do_findprevious || func == do_findnext) {
func();
bottombars(MHELP);
#ifdef ENABLE_NANORC
} else if (func == (functionptrtype)implant) {
implant(first_sc_for(MHELP, func)->expansion);
#endif
#ifdef ENABLE_MOUSE
} else if (kbinput == KEY_MOUSE) {
int dummy_row, dummy_col;
get_mouseinput(&dummy_row, &dummy_col, TRUE);
#endif
#ifndef NANO_TINY
} else if (kbinput == KEY_WINCH) {
; /* Nothing to do. */
#endif
} else if (func == do_exit) {
break;
} else
unbound_key(kbinput);
edit_refresh();
location = 0;
line = openfile->filetop;
/* Count how far (in bytes) edittop is into the file. */
while (line != openfile->edittop) {
location += strlen(line->data);
line = line->next;
}
}
/* Discard the help-text buffer. */
close_buffer();
/* Restore the settings of all flags. */
memcpy(flags, stash, sizeof(flags));
#ifdef ENABLE_LINENUMBERS
margin = was_margin;
editwincols = COLS - margin - thebar;
#endif
tabsize = was_tabsize;
#ifdef ENABLE_COLOR
syntaxstr = was_syntax;
have_palette = FALSE;
#endif
free(title);
title = NULL;
free(answer);
answer = saved_answer;
free(help_text);
inhelp = FALSE;
curs_set(0);
if (ISSET(NO_HELP)) {
currmenu = oldmenu;
window_init();
} else {
blank_statusbar();
bottombars(oldmenu);
}
#ifdef ENABLE_BROWSER
if (oldmenu == MBROWSER || oldmenu == MWHEREISFILE || oldmenu == MGOTODIR)
browser_refresh();
else
#endif
{
titlebar(NULL);
edit_refresh();
}
}
#endif /* ENABLE_HELP */
/* Start the help viewer, or indicate that there is no help. */
@@ -570,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

@@ -19,7 +19,7 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#ifdef ENABLE_HISTORIES
@@ -27,19 +27,19 @@
#include <string.h>
#ifndef SEARCH_HISTORY
#define SEARCH_HISTORY "search_history"
#define SEARCH_HISTORY "search_history"
#endif
#ifndef POSITION_HISTORY
#define POSITION_HISTORY "filepos_history"
#define POSITION_HISTORY "filepos_history"
#endif
static bool history_changed = FALSE;
/* Whether any of the history lists has changed. */
static struct stat stat_of_positions_file;
/* The last-obtained stat information of the positions file. */
static char *poshistname = NULL;
/* The name of the positions-history file. */
static time_t latest_timestamp = 942927132;
/* The last time the positions-history file was written. */
static poshiststruct *position_history = NULL;
/* The list of filenames with their last cursor positions. */
@@ -178,53 +178,49 @@ void get_history_newer_void(void)
}
#ifdef ENABLE_TABCOMP
/* Move h to the next string that's a tab completion of the string s,
* looking at only the first len characters of s, and return that
* string. If there isn't one, or if len is 0, don't move h and return
* s. */
/* Go backward through one of three history lists, starting at its item h,
* searching for a string that is a tab completion of the given string s,
* looking at only the first len characters of s. When found, make h point
* at it and return that string; otherwise, don't move h and return s. */
char *get_history_completion(linestruct **h, char *s, size_t len)
{
if (len > 0) {
linestruct *htop = NULL, *hbot = NULL, *p;
linestruct *htop = NULL, *hbot = NULL, *p;
if (*h == search_history) {
htop = searchtop;
hbot = searchbot;
} else if (*h == replace_history) {
htop = replacetop;
hbot = replacebot;
} else if (*h == execute_history) {
htop = executetop;
hbot = executebot;
}
/* Search the history list from the current position to the top
* for a match of len characters. Skip over an exact match. */
p = find_history((*h)->prev, htop, s, len);
while (p != NULL && strcmp(p->data, s) == 0)
p = find_history(p->prev, htop, s, len);
if (p != NULL) {
*h = p;
return mallocstrcpy(s, (*h)->data);
}
/* Search the history list from the bottom to the current position
* for a match of len characters. Skip over an exact match. */
p = find_history(hbot, *h, s, len);
while (p != NULL && strcmp(p->data, s) == 0)
p = find_history(p->prev, *h, s, len);
if (p != NULL) {
*h = p;
return mallocstrcpy(s, (*h)->data);
}
if (*h == search_history) {
htop = searchtop;
hbot = searchbot;
} else if (*h == replace_history) {
htop = replacetop;
hbot = replacebot;
} else if (*h == execute_history) {
htop = executetop;
hbot = executebot;
}
/* If we're here, we didn't find a match, we didn't find an inexact
* match, or len is 0. Return s. */
/* First search from the current position to the top of the list
* for a match of len characters. Skip over an exact match. */
p = find_history((*h)->prev, htop, s, len);
while (p != NULL && strcmp(p->data, s) == 0)
p = find_history(p->prev, htop, s, len);
if (p != NULL) {
*h = p;
return mallocstrcpy(s, (*h)->data);
}
/* Now search from the bottom of the list to the original position. */
p = find_history(hbot, *h, s, len);
while (p != NULL && strcmp(p->data, s) == 0)
p = find_history(p->prev, *h, s, len);
if (p != NULL) {
*h = p;
return mallocstrcpy(s, (*h)->data);
}
/* When no useful match was found, simply return the given string. */
return (char *)s;
}
#endif /* ENABLE_TABCOMP */
@@ -285,53 +281,54 @@ bool have_statedir(void)
return TRUE;
}
/* Load the histories for Search and Replace and Execute Command. */
/* Load the histories for Search, Replace With, and Execute Command. */
void load_history(void)
{
char *histname = concatenate(statedir, SEARCH_HISTORY);
FILE *hisfile = fopen(histname, "rb");
FILE *histfile = fopen(histname, "rb");
if (hisfile == NULL) {
if (errno != ENOENT) {
/* When reading failed, don't save history when we quit. */
UNSET(HISTORYLOG);
jot_error(N_("Error reading %s: %s"), histname,
strerror(errno));
}
} else {
/* Load the three history lists -- first search, then replace,
* then execute -- from oldest entry to newest. Between two
* lists there is an empty line. */
linestruct **history = &search_history;
char *line = NULL;
size_t buf_len = 0;
ssize_t read;
while ((read = getline(&line, &buf_len, hisfile)) > 0) {
line[--read] = '\0';
if (read > 0) {
/* Encode any embedded NUL as 0x0A. */
unsunder(line, read);
update_history(history, line);
} else if (history == &search_history)
history = &replace_history;
else
history = &execute_history;
}
fclose(hisfile);
free(line);
/* If reading an existing file failed, don't save history when we quit. */
if (histfile == NULL && errno != ENOENT) {
jot_error(N_("Error reading %s: %s"), histname, strerror(errno));
UNSET(HISTORYLOG);
}
/* After reading them in, set the status of the lists to "unchanged". */
history_changed = FALSE;
if (histfile == NULL) {
free(histname);
return;
}
linestruct **history = &search_history;
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(&stanza, &dummy, histfile)) > 0) {
stanza[--read] = '\0';
if (read > 0) {
recode_NUL_to_LF(stanza, read);
update_history(history, stanza);
} else if (history == &search_history)
history = &replace_history;
else
history = &execute_history;
}
if (fclose(histfile) == EOF)
jot_error(N_("Error reading %s: %s"), histname, strerror(errno));
free(histname);
free(stanza);
/* Reading in the lists has marked them as changed; undo this side effect. */
history_changed = FALSE;
}
/* Write the lines of a history list, starting at head, from oldest to newest,
* to the given file. Return TRUE if writing succeeded, and FALSE otherwise. */
bool write_list(const linestruct *head, FILE *hisfile)
bool write_list(const linestruct *head, FILE *histfile)
{
const linestruct *item;
@@ -339,183 +336,194 @@ bool write_list(const linestruct *head, FILE *hisfile)
size_t length = strlen(item->data);
/* Decode 0x0A bytes as embedded NULs. */
sunder(item->data);
recode_LF_to_NUL(item->data);
if (fwrite(item->data, sizeof(char), length, hisfile) < length)
if (fwrite(item->data, sizeof(char), length, histfile) < length)
return FALSE;
if (putc('\n', hisfile) == EOF)
if (putc('\n', histfile) == EOF)
return FALSE;
}
return TRUE;
}
/* Save the histories for Search and Replace and Execute Command. */
/* Save the histories for Search, Replace With, and Execute Command. */
void save_history(void)
{
char *histname;
FILE *hisfile;
FILE *histfile;
/* If the histories are unchanged, don't bother saving them. */
if (!history_changed)
return;
histname = concatenate(statedir, SEARCH_HISTORY);
hisfile = fopen(histname, "wb");
histfile = fopen(histname, "wb");
if (hisfile == NULL)
fprintf(stderr, _("Error writing %s: %s\n"), histname,
strerror(errno));
else {
/* Don't allow others to read or write the history file. */
chmod(histname, S_IRUSR | S_IWUSR);
if (!write_list(searchtop, hisfile) ||
!write_list(replacetop, hisfile) ||
!write_list(executetop, hisfile))
fprintf(stderr, _("Error writing %s: %s\n"), histname,
strerror(errno));
fclose(hisfile);
if (histfile == NULL) {
jot_error(N_("Error writing %s: %s"), histname, strerror(errno));
free(histname);
return;
}
/* Don't allow others to read or write the history file. */
chmod(histname, S_IRUSR | S_IWUSR);
if (!write_list(searchtop, histfile) || !write_list(replacetop, histfile) ||
!write_list(executetop, histfile))
jot_error(N_("Error writing %s: %s"), histname, strerror(errno));
if (fclose(histfile) == EOF)
jot_error(N_("Error writing %s: %s"), histname, strerror(errno));
free(histname);
}
/* Load the recorded cursor positions for files that were edited. */
void load_poshistory(void)
{
FILE *hisfile = fopen(poshistname, "rb");
FILE *histfile = fopen(poshistname, "rb");
if (hisfile == NULL) {
if (errno != ENOENT) {
/* When reading failed, don't save history when we quit. */
UNSET(POSITIONLOG);
jot_error(N_("Error reading %s: %s"), poshistname, strerror(errno));
}
} else {
char *line = NULL, *lineptr, *xptr;
size_t buf_len = 0;
ssize_t read, count = 0;
poshiststruct *record_ptr = NULL, *newrecord;
/* Read and parse each line, and store the extracted data. */
while ((read = getline(&line, &buf_len, hisfile)) > 5) {
/* Decode NULs as embedded newlines. */
unsunder(line, read);
/* Find where the x index and line number are in the line. */
xptr = revstrstr(line, " ", line + read - 3);
if (xptr == NULL)
continue;
lineptr = revstrstr(line, " ", xptr - 2);
if (lineptr == NULL)
continue;
/* Now separate the three elements of the line. */
*(xptr++) = '\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->next = NULL;
/* Add the record to the list. */
if (position_history == NULL)
position_history = newrecord;
else
record_ptr->next = newrecord;
record_ptr = newrecord;
/* Impose a limit, so the file will not grow indefinitely. */
if (++count > 200) {
poshiststruct *drop_record = position_history;
position_history = position_history->next;
free(drop_record->filename);
free(drop_record);
}
}
fclose(hisfile);
free(line);
stat(poshistname, &stat_of_positions_file);
/* If reading an existing file failed, don't save history when we quit. */
if (histfile == NULL && errno != ENOENT) {
jot_error(N_("Error reading %s: %s"), poshistname, strerror(errno));
UNSET(POSITIONLOG);
}
if (histfile == NULL)
return;
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(&stanza, &dummy, histfile)) > 5) {
/* Decode NULs as embedded newlines. */
recode_NUL_to_LF(stanza, read);
/* Find the spaces before column number and line number. */
columnptr = revstrstr(stanza, " ", stanza + read - 3);
if (columnptr == NULL)
continue;
lineptr = revstrstr(stanza, " ", columnptr - 2);
if (lineptr == NULL)
continue;
/* Now separate the three elements of the line. */
*(columnptr++) = '\0';
*(lineptr++) = '\0';
/* Create a new position record. */
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. */
if (position_history == NULL)
position_history = newrecord;
else
record_ptr->next = newrecord;
record_ptr = newrecord;
/* Impose a limit, so the file will not grow indefinitely. */
if (++count > 200) {
poshiststruct *drop_record = position_history;
position_history = position_history->next;
free(drop_record->filename);
free(drop_record);
}
}
if (fclose(histfile) == EOF)
jot_error(N_("Error reading %s: %s"), poshistname, strerror(errno));
free(stanza);
if (stat(poshistname, &fileinfo) == 0)
latest_timestamp = fileinfo.st_mtime;
}
/* Save the recorded cursor positions for files that were edited. */
void save_poshistory(void)
{
poshiststruct *posptr;
FILE *hisfile = fopen(poshistname, "wb");
struct stat fileinfo;
FILE *histfile = fopen(poshistname, "wb");
if (hisfile == NULL)
fprintf(stderr, _("Error writing %s: %s\n"), poshistname, strerror(errno));
else {
/* Don't allow others to read or write the history file. */
chmod(poshistname, S_IRUSR | S_IWUSR);
for (posptr = position_history; posptr != NULL; posptr = posptr->next) {
char *path_and_place;
size_t length;
/* 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);
sprintf(path_and_place, "%s %zd %zd\n",
posptr->filename, posptr->lineno, posptr->xno);
length = strlen(path_and_place);
/* Encode newlines in filenames as NULs. */
sunder(path_and_place);
/* Restore the terminating newline. */
path_and_place[length - 1] = '\n';
if (fwrite(path_and_place, sizeof(char), length, hisfile) < length)
fprintf(stderr, _("Error writing %s: %s\n"),
poshistname, strerror(errno));
free(path_and_place);
}
fclose(hisfile);
stat(poshistname, &stat_of_positions_file);
if (histfile == NULL) {
jot_error(N_("Error writing %s: %s"), poshistname, strerror(errno));
return;
}
/* Don't allow others to read or write the history file. */
chmod(poshistname, S_IRUSR | S_IWUSR);
for (posptr = position_history; posptr != NULL; posptr = posptr->next) {
char *path_and_place;
size_t length;
/* Assume 20 decimal positions each for line and column number,
* plus two spaces, plus the line feed, plus the null byte. */
path_and_place = nmalloc(strlen(posptr->filename) + 44);
sprintf(path_and_place, "%s %zd %zd\n",
posptr->filename, posptr->linenumber, posptr->columnnumber);
length = strlen(path_and_place);
/* Encode newlines in filenames as NULs. */
recode_LF_to_NUL(path_and_place);
/* Restore the terminating newline. */
path_and_place[length - 1] = '\n';
if (fwrite(path_and_place, sizeof(char), length, histfile) < length)
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"), poshistname, strerror(errno));
if (stat(poshistname, &fileinfo) == 0)
latest_timestamp = fileinfo.st_mtime;
}
/* Reload the position history file if it has been modified since last load. */
void reload_positions_if_needed(void)
{
struct stat newstat;
struct stat fileinfo;
stat(poshistname, &newstat);
if (stat(poshistname, &fileinfo) == 0 && fileinfo.st_mtime != latest_timestamp) {
poshiststruct *item, *nextone;
if (newstat.st_mtime != stat_of_positions_file.st_mtime) {
poshiststruct *ptr, *nextone;
for (ptr = position_history; ptr != NULL; ptr = nextone) {
nextone = ptr->next;
free(ptr->filename);
free(ptr);
for (item = position_history; item != NULL; item = nextone) {
nextone = item->next;
free(item->filename);
free(item);
}
position_history = NULL;
load_poshistory();
}
}
/* Update the recorded last file positions, given a filename, a line
* and a column. If no entry is found, add a new one at the end. */
void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
/* Update the recorded last file positions with the current position in the
* current buffer. If no existing entry is found, add a new one at the end. */
void update_poshistory(void)
{
poshiststruct *posptr, *theone, *posprev = NULL;
char *fullpath = get_full_path(filename);
char *fullpath = get_full_path(openfile->filename);
if (fullpath == NULL || *filename == '\0') {
if (fullpath == NULL || openfile->filename[0] == '\0') {
free(fullpath);
return;
}
@@ -530,7 +538,7 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
}
/* Don't record files that have the default cursor position. */
if (lineno == 1 && xpos == 1) {
if (openfile->current->lineno == 1 && openfile->current_x == 0) {
if (posptr != NULL) {
if (posprev == NULL)
position_history = posptr->next;
@@ -549,7 +557,7 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
/* 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;
@@ -566,8 +574,8 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
}
/* Store the last cursor position. */
theone->lineno = lineno;
theone->xno = xpos;
theone->linenumber = openfile->current->lineno;
theone->columnnumber = xplustabs() + 1;
theone->next = NULL;
free(fullpath);
@@ -597,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

@@ -19,7 +19,7 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#include <string.h>
@@ -115,6 +115,7 @@ void do_page_up(void)
int mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
size_t leftedge, target_column;
#ifndef NANO_TINY
/* If we're not in smooth scrolling mode, put the cursor at the
* beginning of the top line of the edit window, as Pico does. */
if (ISSET(JUMPY_SCROLLING)) {
@@ -123,6 +124,7 @@ void do_page_up(void)
openfile->current_y = 0;
target_column = 0;
} else
#endif
get_edge_and_target(&leftedge, &target_column);
/* Move up the required number of lines or chunks. If we can't, we're
@@ -145,6 +147,7 @@ void do_page_down(void)
int mustmove = (editwinrows < 3) ? 1 : editwinrows - 2;
size_t leftedge, target_column;
#ifndef NANO_TINY
/* If we're not in smooth scrolling mode, put the cursor at the
* beginning of the top line of the edit window, as Pico does. */
if (ISSET(JUMPY_SCROLLING)) {
@@ -153,6 +156,7 @@ void do_page_down(void)
openfile->current_y = 0;
target_column = 0;
} else
#endif
get_edge_and_target(&leftedge, &target_column);
/* Move down the required number of lines or chunks. If we can't, we're
@@ -234,8 +238,8 @@ void to_prev_block(void)
seen_text = seen_text || is_text;
}
/* Step forward one line again if this one is blank. */
if (openfile->current->next != NULL &&
/* Step forward one line again if we passed text but this line is blank. */
if (seen_text && openfile->current->next != NULL &&
white_string(openfile->current->data))
openfile->current = openfile->current->next;
@@ -437,7 +441,7 @@ void do_home(void)
}
/* Move to the end of the current line (or softwrapped chunk).
* When softwrapping and alredy at the end of a chunk, go to the
* When softwrapping and already at the end of a chunk, go to the
* end of the full line. */
void do_end(void)
{
@@ -556,13 +560,21 @@ void do_scroll_down(void)
if (editwinrows > 1 && (openfile->edittop->next != NULL
#ifndef NANO_TINY
|| chunk_for(openfile->firstcolumn, openfile->edittop) <
number_of_chunks_in(openfile->edittop)
|| (ISSET(SOFTWRAP) && (extra_chunks_in(openfile->edittop) >
chunk_for(openfile->firstcolumn, openfile->edittop)))
#endif
))
edit_scroll(FORWARD);
}
#endif
/* Scroll the line with the cursor to the center of the screen. */
void do_center(void)
{
adjust_viewport(CENTERING);
draw_all_subwindows();
full_refresh();
}
#endif /* !NANO_TINY || ENABLE_HELP */
/* Move left one character. */
void do_left(void)

File diff suppressed because it is too large Load Diff

View File

@@ -19,7 +19,7 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#include <string.h>
@@ -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);
@@ -195,12 +195,15 @@ void inject_into_answer(char *burst, size_t count)
/* Get a verbatim keystroke and insert it into the answer. */
void do_statusbar_verbatim_input(void)
{
size_t count = 1;
char *bytes;
size_t count;
bytes = get_verbatim_kbinput(bottomwin, &count);
inject_into_answer(bytes, count);
if (0 < count && count < 999)
inject_into_answer(bytes, count);
else if (count == 0)
beep();
free(bytes);
}
@@ -250,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;
}
}
@@ -394,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++;
@@ -403,28 +406,22 @@ void add_or_remove_pipe_symbol_from_answer(void)
#endif
/* Get a string of input at the status-bar prompt. */
functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
bool allow_files, bool *listed, linestruct **history_list,
void (*refresh_func)(void))
functionptrtype acquire_an_answer(int *actual, bool *listed,
linestruct **history_list, void (*refresh_func)(void))
{
int kbinput = ERR;
bool finished;
functionptrtype func;
#ifdef ENABLE_TABCOMP
bool tabbed = FALSE;
/* Whether we've pressed Tab. */
#endif
#ifdef ENABLE_HISTORIES
char *history = NULL;
/* The current history string. */
char *magichistory = NULL;
/* The (partial) answer that was typed at the prompt, if any. */
#ifdef ENABLE_TABCOMP
int last_kbinput = ERR;
/* The key we pressed before the current key. */
size_t complete_len = 0;
/* The length of the original string that we're trying to
* tab complete, if any. */
bool previous_was_tab = FALSE;
/* Whether the previous keystroke was an attempt at tab completion. */
size_t fragment_length = 0;
/* The length of the fragment that the user tries to tab complete. */
#endif
#endif /* ENABLE_HISTORIES */
@@ -454,25 +451,23 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
break;
#ifdef ENABLE_TABCOMP
if (func != do_tab)
tabbed = FALSE;
if (func == do_tab) {
#ifdef ENABLE_HISTORIES
if (history_list != NULL) {
if (last_kbinput != the_code_for(do_tab, '\t'))
complete_len = strlen(answer);
if (!previous_was_tab)
fragment_length = strlen(answer);
if (complete_len > 0) {
if (fragment_length > 0) {
answer = get_history_completion(history_list,
answer, complete_len);
answer, fragment_length);
typing_x = strlen(answer);
}
} else
#endif
if (allow_tabs)
answer = input_tab(answer, allow_files, &typing_x,
&tabbed, refresh_func, listed);
/* Allow tab completion of filenames, but not in restricted mode. */
if ((currmenu == MINSERTFILE || currmenu == MWRITEFILE ||
currmenu == MGOTODIR) && !ISSET(RESTRICTED))
answer = input_tab(answer, &typing_x, refresh_func, listed);
} else
#endif /* ENABLE_TABCOMP */
#ifdef ENABLE_HISTORIES
@@ -509,17 +504,20 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
}
} else
#endif /* ENABLE_HISTORIES */
if (func == do_help) {
/* This key has a shortcut-list entry when it's used to go to
* the help viewer or display a message indicating that help
* is disabled, which means that finished has been set to TRUE.
* Set it back to FALSE here, so that we aren't kicked out of
* the status-bar prompt. */
/* If we ran a function that should not exit from the prompt... */
if (func == do_help || func == full_refresh)
finished = FALSE;
}
#ifndef NANO_TINY
else if (func == do_nothing)
finished = FALSE;
else if (func == do_toggle_void) {
TOGGLE(NO_HELP);
window_init();
focusing = FALSE;
refresh_func();
bottombars(currmenu);
finished = FALSE;
}
#endif
/* If we have a shortcut with an associated function, break out if
@@ -528,7 +526,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
break;
#if defined(ENABLE_HISTORIES) && defined(ENABLE_TABCOMP)
last_kbinput = kbinput;
previous_was_tab = (func == do_tab);
#endif
}
@@ -547,15 +545,10 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
/* Ask a question on the status bar. Return 0 when text was entered,
* -1 for a cancelled entry, -2 for a blank string, and the relevant
* keycode when a valid shortcut key was pressed.
*
* The allow_tabs parameter indicates whether tab completion is allowed,
* and allow_files indicates whether all files (and not just directories)
* can be tab completed. The 'provided' parameter is the default answer
* for when simply Enter is typed. */
int do_prompt(bool allow_tabs, bool allow_files,
int menu, const char *provided, linestruct **history_list,
void (*refresh_func)(void), const char *msg, ...)
* keycode when a valid shortcut key was pressed. The 'provided'
* parameter is the default answer for when simply Enter is typed. */
int do_prompt(int menu, const char *provided, linestruct **history_list,
void (*refresh_func)(void), const char *msg, ...)
{
va_list ap;
int retval;
@@ -573,15 +566,16 @@ int do_prompt(bool allow_tabs, bool allow_files,
#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);
/* Reserve five columns for colon plus angles plus answer, ":<aa>". */
prompt[actual_x(prompt, (COLS < 5) ? 0 : COLS - 5)] = '\0';
func = acquire_an_answer(&retval, allow_tabs, allow_files, &listed,
history_list, refresh_func);
lastmessage = VACUUM;
func = acquire_an_answer(&retval, &listed, history_list, refresh_func);
free(prompt);
prompt = saved_prompt;
@@ -602,11 +596,11 @@ int do_prompt(bool allow_tabs, bool allow_files,
else if (func == do_enter)
retval = (*answer == '\0') ? -2 : 0;
wipe_statusbar();
if (lastmessage == VACUUM)
wipe_statusbar();
#ifdef ENABLE_TABCOMP
/* If we've done tab completion, there might still be a list of
* filename matches on the edit window. Clear them off. */
/* If possible filename completions are still listed, clear them off. */
if (listed)
refresh_func();
#endif
@@ -678,6 +672,9 @@ int do_yesno_prompt(bool all, const char *msg)
kbinput = get_kbinput(bottomwin, !all);
#ifndef NANO_TINY
if (kbinput == KEY_WINCH)
continue;
/* Accept the first character of an external paste. */
if (bracketed_paste && kbinput == BRACKETED_PASTE_MARKER)
kbinput = get_kbinput(bottomwin, BLIND);
@@ -738,6 +735,17 @@ int do_yesno_prompt(bool all, const char *msg)
}
}
#endif /* ENABLE_MOUSE */
else if (func_from_key(&kbinput) == full_refresh)
full_refresh();
#ifndef NANO_TINY
else if (func_from_key(&kbinput) == do_toggle_void) {
TOGGLE(NO_HELP);
window_init();
titlebar(NULL);
focusing = FALSE;
edit_refresh();
}
#endif
else
beep();

View File

@@ -1,5 +1,5 @@
/**************************************************************************
* proto.h -- This file is part of GNU nano. *
* prototypes.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2020 Free Software Foundation, Inc. *
* *
@@ -18,7 +18,7 @@
* *
**************************************************************************/
#include "nano.h"
#include "definitions.h"
/* All external variables. See global.c for their descriptions. */
@@ -34,10 +34,11 @@ extern bool shift_held;
extern bool mute_modifiers;
extern bool bracketed_paste;
extern bool started_curses;
extern bool we_are_running;
extern bool more_than_one;
extern bool ran_a_tool;
extern bool inhelp;
extern char *title;
@@ -47,8 +48,6 @@ extern bool as_an_at;
extern bool control_C_was_pressed;
extern bool suppress_cursorpos;
extern message_type lastmessage;
extern linestruct *pletion_line;
@@ -76,7 +75,8 @@ extern int shiftcontrolup, shiftcontroldown;
extern int shiftcontrolhome, shiftcontrolend;
extern int altleft, altright;
extern int altup, altdown;
extern int altdelete;
extern int altpageup, altpagedown;
extern int altinsert, altdelete;
extern int shiftaltleft, shiftaltright;
extern int shiftaltup, shiftaltdown;
#endif
@@ -92,7 +92,9 @@ extern WINDOW *bottomwin;
extern int editwinrows;
extern int editwincols;
extern int margin;
extern int thebar;
#ifndef NANO_TINY
extern int *bardata;
extern ssize_t stripe_column;
#endif
@@ -184,18 +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 *do_browse_from(const char *inpath);
void read_the_list(const char *path, DIR *dir);
functionptrtype parse_browser_input(int *kbinput);
void browser_refresh(void);
void browser_select_dirname(const char *needle);
void do_filesearch(bool forwards);
void do_fileresearch(bool forwards);
void to_first_file(void);
void to_last_file(void);
char *strip_last_component(const char *path);
char *browse_in(const char *inpath);
#endif
/* Most functions in chars.c. */
@@ -210,40 +204,39 @@ bool is_word_char(const char *c, bool allow_punct);
char control_mbrep(const char *c, bool isdata);
#ifdef ENABLE_UTF8
int mbwidth(const char *c);
char *make_mbchar(long code, int *length);
#endif
char *make_mbchar(long chr, int *chr_mb_len);
int char_length(const char *pointer);
size_t mbstrlen(const char *s);
int collect_char(const char *buf, char *chr);
size_t mbstrlen(const char *pointer);
int collect_char(const char *string, char *thechar);
int advance_over(const char *string, size_t *column);
size_t step_left(const char *buf, size_t pos);
size_t step_right(const char *buf, size_t pos);
int mbstrcasecmp(const char *s1, const char *s2);
int mbstrncasecmp(const char *s1, const char *s2, size_t n);
char *mbstrcasestr(const char *haystack, const char *needle);
char *revstrstr(const char *haystack, const char *needle, const char *index);
char *mbrevstrcasestr(const char *haystack, const char *needle, const char *index);
char *revstrstr(const char *haystack, const char *needle, const char *pointer);
char *mbrevstrcasestr(const char *haystack, const char *needle, const char *pointer);
#if !defined(NANO_TINY) || defined(ENABLE_JUSTIFY)
char *mbstrchr(const char *s, const char *c);
char *mbstrchr(const char *string, const char *chr);
#endif
#ifndef NANO_TINY
char *mbstrpbrk(const char *s, const char *accept);
char *revstrpbrk(const char *head, const char *accept, const char *index);
char *mbrevstrpbrk(const char *head, const char *accept, const char *index);
char *mbstrpbrk(const char *string, const char *accept);
char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer);
#endif
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || defined(ENABLE_JUSTIFY))
bool has_blank_char(const char *s);
bool has_blank_char(const char *string);
#endif
bool white_string(const char *s);
bool white_string(const char *string);
#ifdef ENABLE_UTF8
bool is_valid_unicode(wchar_t wc);
#endif
/* Most functions in color.c. */
#ifdef ENABLE_COLOR
void set_colorpairs(void);
void color_init(void);
void color_update(void);
void set_interface_colorpairs(void);
void prepare_palette(void);
void find_and_prime_applicable_syntax(void);
void set_up_multicache(linestruct *line);
void check_the_multis(linestruct *line);
void precalc_multicolorinfo(void);
@@ -256,19 +249,19 @@ void do_backspace(void);
void chop_previous_word(void);
void chop_next_word(void);
#endif
void extract_segment(linestruct *top, size_t top_x,
linestruct *bot, size_t bot_x);
void ingraft_buffer(linestruct *somebuffer);
void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_x);
void ingraft_buffer(linestruct *topline);
void copy_from_buffer(linestruct *somebuffer);
#ifndef NANO_TINY
void cut_marked(bool *right_side_up);
void cut_marked_region(void);
#endif
void do_snip(bool copying, bool marked, bool until_eof, bool append);
void do_snip(bool marked, bool until_eof, bool append);
void cut_text(void);
#ifndef NANO_TINY
void copy_text(void);
void cut_till_eof(void);
void zap_text(void);
void copy_marked_region(void);
void copy_text(void);
#endif
void paste_text(void);
@@ -277,7 +270,7 @@ void make_new_buffer(void);
#ifndef NANO_TINY
bool delete_lockfile(const char *lockfilename);
#endif
bool open_buffer(const char *filename, bool new_buffer);
bool open_buffer(const char *filename, bool new_one);
void set_modified(void);
void prepare_for_display(void);
#ifdef ENABLE_MULTIBUFFER
@@ -287,11 +280,14 @@ void switch_to_next_buffer(void);
void close_buffer(void);
#endif
void read_file(FILE *f, int fd, const char *filename, bool undoable);
int open_file(const char *filename, bool newfie, FILE **f);
int open_file(const char *filename, bool new_one, FILE **f);
char *get_next_filename(const char *name, const char *suffix);
void do_insertfile_void(void);
#ifndef NANO_TINY
void do_execute(void);
#endif
char *get_full_path(const char *origpath);
char *safe_tempfile(FILE **f);
char *safe_tempfile(FILE **stream);
#ifdef ENABLE_OPERATINGDIR
void init_operating_dir(void);
bool outside_of_confinement(const char *currpath, bool allow_tabcomp);
@@ -300,30 +296,28 @@ bool outside_of_confinement(const char *currpath, bool allow_tabcomp);
void init_backup_dir(void);
#endif
int copy_file(FILE *inn, FILE *out, bool close_out);
bool write_file(const char *name, FILE *f_open, bool tmp,
bool write_file(const char *name, FILE *thefile, bool tmp,
kind_of_writing_type method, bool fullbuffer);
#ifndef NANO_TINY
bool write_marked_file(const char *name, FILE *f_open, bool tmp,
bool write_marked_file(const char *name, FILE *stream, bool tmp,
kind_of_writing_type method);
#endif
int do_writeout(bool exiting, bool withprompt);
void do_writeout_void(void);
void do_savefile(void);
char *real_dir_from_tilde(const char *buf);
char *real_dir_from_tilde(const char *path);
#if defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
int diralphasort(const void *va, const void *vb);
#endif
#ifdef ENABLE_TABCOMP
char *input_tab(char *buf, bool allow_files, size_t *place,
bool *lastwastab, void (*refresh_func)(void), bool *listed);
char *input_tab(char *buf, size_t *place, void (*refresh_func)(void), bool *listed);
#endif
/* Some functions in global.c. */
const keystruct *first_sc_for(int menu, void (*func)(void));
int the_code_for(void (*func)(void), int defaultval);
size_t shown_entries_for(int menu);
const keystruct *get_shortcut(int *kbinput);
functionptrtype func_from_key(int *kbinput);
const keystruct *get_shortcut(int *keycode);
functionptrtype func_from_key(int *keycode);
#if defined(ENABLE_BROWSER) || defined(ENABLE_HELP)
functionptrtype interpret(int *keycode);
#endif
@@ -331,19 +325,17 @@ int keycode_from_string(const char *keystring);
void shortcut_init(void);
const char *flagtostr(int flag);
/* All functions in help.c. */
/* Some functions in help.c. */
#ifdef ENABLE_HELP
void wrap_help_text_into_buffer(void);
void help_init(void);
functionptrtype parse_help_input(int *kbinput);
#endif
void do_help(void);
/* Most functions in history.c. */
#ifdef ENABLE_HISTORIES
void history_init(void);
void history_reset(const linestruct *h);
void update_history(linestruct **h, const char *s);
void history_reset(const linestruct *list);
void update_history(linestruct **item, const char *text);
char *get_history_older(linestruct **h);
char *get_history_newer(linestruct **h);
void get_history_older_void(void);
@@ -355,7 +347,7 @@ bool have_statedir(void);
void load_history(void);
void save_history(void);
void load_poshistory(void);
void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos);
void update_poshistory(void);
bool has_old_position(const char *file, ssize_t *line, ssize_t *column);
#endif
@@ -383,6 +375,7 @@ void do_down(void);
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
void do_scroll_up(void);
void do_scroll_down(void);
void do_center(void);
#endif
void do_left(void);
void do_right(void);
@@ -390,39 +383,35 @@ void do_right(void);
/* Most functions in nano.c. */
linestruct *make_new_node(linestruct *prevnode);
void splice_node(linestruct *afterthis, linestruct *newnode);
void unlink_node(linestruct *fileptr);
void delete_node(linestruct *fileptr);
void unlink_node(linestruct *line);
void delete_node(linestruct *line);
linestruct *copy_buffer(const linestruct *src);
void free_lines(linestruct *src);
void renumber_from(linestruct *line);
void partition_buffer(linestruct *top, size_t top_x,
linestruct *bot, size_t bot_x);
void unpartition_buffer(void);
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 die(const char *msg, ...);
void emergency_save(const char *die_filename, struct stat *die_stat);
void window_init(void);
void do_exit(void);
void close_and_go(void);
void do_exit(void);
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);
#if !defined(NANO_TINY) || defined(ENABLE_SPELLER)
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);
#endif
@@ -439,11 +428,10 @@ bool okay_for_view(const keystruct *shortcut);
void inject(char *burst, size_t count);
/* Most functions in prompt.c. */
size_t get_statusbar_page_start(size_t start_col, size_t column);
size_t get_statusbar_page_start(size_t base, size_t column);
void put_cursor_at_end_of_answer(void);
void add_or_remove_pipe_symbol_from_answer(void);
int do_prompt(bool allow_tabs, bool allow_files,
int menu, const char *curranswer, linestruct **history_list,
int do_prompt(int menu, const char *provided, linestruct **history_list,
void (*refresh_func)(void), const char *msg, ...);
int do_yesno_prompt(bool all, const char *msg);
@@ -467,7 +455,6 @@ bool regexp_init(const char *regexp);
void tidy_up_after_search(void);
int findnextstr(const char *needle, bool whole_word_only, int modus,
size_t *match_len, bool skipone, const linestruct *begin, size_t begin_x);
void do_search(void);
void do_search_forward(void);
void do_search_backward(void);
void do_findprevious(void);
@@ -477,13 +464,16 @@ void go_looking(void);
ssize_t do_replace_loop(const char *needle, bool whole_word_only,
const linestruct *real_current, size_t *real_current_x);
void do_replace(void);
void ask_for_replacement(void);
void ask_for_and_do_replacements(void);
void goto_line_posx(ssize_t line, size_t pos_x);
void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
void do_gotolinecolumn(ssize_t line, ssize_t column, bool retain_answer,
bool interactive);
void do_gotolinecolumn_void(void);
#ifndef NANO_TINY
void do_find_bracket(void);
void put_or_lift_anchor(void);
void to_prev_anchor(void);
void to_next_anchor(void);
#endif
/* Most functions in text.c. */
@@ -511,15 +501,15 @@ void update_undo(undo_type action);
bool do_wrap(void);
#endif
#if defined(ENABLE_HELP) || defined(ENABLED_WRAPORJUSTIFY)
ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl);
ssize_t break_line(const char *textstart, ssize_t goal, bool snap_at_nl);
#endif
#if !defined(NANO_TINY) || defined(ENABLED_WRAPORJUSTIFY)
size_t indent_length(const char *line);
#endif
#ifdef ENABLE_JUSTIFY
size_t quote_length(const char *line);
bool begpar(const linestruct *const foo, int depth);
bool inpar(const linestruct *const foo);
bool begpar(const linestruct *const line, int depth);
bool inpar(const linestruct *const line);
void do_justify(bool full_justify);
void do_justify_void(void);
void do_full_justify(void);
@@ -544,10 +534,10 @@ char *concatenate(const char *path, const char *name);
#ifdef ENABLE_LINENUMBERS
int digits(ssize_t n);
#endif
bool parse_num(const char *str, ssize_t *val);
bool parse_num(const char *str, ssize_t *result);
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column);
void unsunder(char *string, size_t length);
void sunder(char *string);
void recode_NUL_to_LF(char *string, size_t length);
void recode_LF_to_NUL(char *string);
#if !defined(ENABLE_TINY) || defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
void free_chararray(char **array, size_t len);
#endif
@@ -558,7 +548,7 @@ const char *strstrwrapper(const char *haystack, const char *needle,
const char *start);
void *nmalloc(size_t howmuch);
void *nrealloc(void *ptr, size_t howmuch);
char *measured_copy(const char *src, size_t n);
char *measured_copy(const char *string, size_t count);
char *mallocstrcpy(char *dest, const char *src);
char *copy_of(const char *string);
char *free_and_assign(char *dest, char *src);
@@ -573,13 +563,12 @@ void remove_magicline(void);
#endif
#ifndef NANO_TINY
bool mark_is_before_cursor(void);
void get_region(const linestruct **top, size_t *top_x,
const linestruct **bot, size_t *bot_x, bool *right_side_up);
void get_range(const linestruct **top, const linestruct **bot);
void get_region(linestruct **top, size_t *top_x, linestruct **bot, size_t *bot_x);
void get_range(linestruct **top, linestruct **bot);
#endif
size_t get_totsize(const linestruct *begin, const linestruct *end);
size_t number_of_characters_in(const linestruct *begin, const linestruct *end);
#ifndef NANO_TINY
linestruct *line_from_number(ssize_t lineno);
linestruct *line_from_number(ssize_t number);
#endif
/* Most functions in winio.c. */
@@ -591,29 +580,28 @@ void implant(const char *string);
#endif
int parse_kbinput(WINDOW *win);
int get_kbinput(WINDOW *win, bool showcursor);
int get_byte_kbinput(int kbinput);
int get_control_kbinput(int kbinput);
char *get_verbatim_kbinput(WINDOW *win, size_t *count);
#ifdef ENABLE_MOUSE
int get_mouseinput(int *mouse_row, int *mouse_col, bool allow_shortcuts);
int get_mouseinput(int *mouse_y, int *mouse_x, bool allow_shortcuts);
#endif
void blank_edit(void);
void blank_statusbar(void);
void wipe_statusbar(void);
void blank_bottombars(void);
void check_statusblank(void);
void set_blankdelay_to_one(void);
char *display_string(const char *buf, size_t column, size_t span,
bool isdata, bool isprompt);
void titlebar(const char *path);
void statusline(message_type importance, const char *msg, ...);
void statusbar(const char *msg);
void warn_and_shortly_pause(const char *msg);
void warn_and_briefly_pause(const char *msg);
void bottombars(int menu);
void post_one_key(const char *keystroke, const char *tag, int width);
void place_the_cursor(void);
int update_line(linestruct *fileptr, size_t index);
int update_line(linestruct *line, size_t index);
#ifndef NANO_TINY
int update_softwrapped_line(linestruct *fileptr);
int update_softwrapped_line(linestruct *line);
#endif
bool line_needs_update(const size_t old_column, const size_t new_column);
int go_back_chunks(int nrows, linestruct **line, size_t *leftedge);
@@ -626,24 +614,21 @@ size_t get_softwrap_breakpoint(const char *text, size_t leftedge,
size_t get_chunk_and_edge(size_t column, linestruct *line, size_t *leftedge);
size_t chunk_for(size_t column, linestruct *line);
size_t leftedge_for(size_t column, linestruct *line);
size_t number_of_chunks_in(linestruct *line);
size_t extra_chunks_in(linestruct *line);
void ensure_firstcolumn_is_aligned(void);
#endif
size_t actual_last_column(size_t leftedge, size_t column);
void edit_redraw(linestruct *old_current, update_type manner);
void edit_refresh(void);
void adjust_viewport(update_type location);
void total_redraw(void);
void total_refresh(void);
void do_cursorpos(bool force);
void do_cursorpos_void(void);
void adjust_viewport(update_type manner);
void full_refresh(void);
void draw_all_subwindows(void);
void report_cursor_position(void);
void spotlight(size_t from_col, size_t to_col);
#ifndef NANO_TINY
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
@@ -656,6 +641,8 @@ void flip_replace(void);
void flip_goto(void);
#ifdef ENABLE_BROWSER
void to_files(void);
void to_first_file(void);
void to_last_file(void);
void goto_dir(void);
#endif
#ifndef NANO_TINY

View File

@@ -21,7 +21,7 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#ifdef ENABLE_NANORC
@@ -32,10 +32,10 @@
#include <unistd.h>
#ifndef RCFILE_NAME
#define HOME_RC_NAME ".nanorc"
#define RCFILE_NAME "nanorc"
#define HOME_RC_NAME ".nanorc"
#define RCFILE_NAME "nanorc"
#else
#define HOME_RC_NAME RCFILE_NAME
#define HOME_RC_NAME RCFILE_NAME
#endif
static const rcoption rcopts[] = {
@@ -46,17 +46,19 @@ static const rcoption rcopts[] = {
#ifdef ENABLE_WRAPPING
{"breaklonglines", BREAK_LONG_LINES},
#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
@@ -86,24 +88,27 @@ static const rcoption rcopts[] = {
{"rawsequences", RAW_SEQUENCES},
{"rebinddelete", REBIND_DELETE},
{"regexp", USE_REGEXP},
{"saveonexit", SAVE_ON_EXIT},
#ifdef ENABLE_SPELLER
{"speller", 0},
#endif
{"suspend", SUSPENDABLE}, /* Deprecated; remove in 2022. */
{"suspendable", SUSPENDABLE},
{"tabsize", 0},
{"tempfile", TEMP_FILE},
{"tempfile", SAVE_ON_EXIT}, /* Deprecated; remove in 2022. */
{"view", VIEW_MODE},
#ifndef NANO_TINY
{"afterends", AFTER_ENDS},
{"allow_insecure_backup", INSECURE_BACKUP},
{"atblanks", AT_BLANKS},
{"autoindent", AUTOINDENT},
{"backup", BACKUP_FILE},
{"backup", MAKE_BACKUP},
{"backupdir", 0},
{"casesensitive", CASE_SENSITIVE},
{"bookstyle", BOOKSTYLE},
{"cutfromcursor", CUT_FROM_CURSOR},
{"emptyline", EMPTY_LINE},
{"guidestripe", 0},
{"indicator", INDICATOR},
{"jumpyscrolling", JUMPY_SCROLLING},
{"locking", LOCKING},
{"matchbrackets", 0},
{"noconvert", NO_CONVERT},
@@ -111,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},
@@ -123,6 +130,7 @@ static const rcoption rcopts[] = {
{"titlecolor", 0},
{"numbercolor", 0},
{"stripecolor", 0},
{"scrollercolor", 0},
{"selectedcolor", 0},
{"statuscolor", 0},
{"errorcolor", 0},
@@ -148,15 +156,15 @@ static colortype *lastcolor = NULL;
/* The end of the color list for the current syntax. */
#endif
#define NUMBER_OF_MENUS 16
#define NUMBER_OF_MENUS 17 /* Remove the deprecated 'extcmd' in 2022. */
char *menunames[NUMBER_OF_MENUS] = { "main", "search", "replace", "replacewith",
"yesno", "gotoline", "writeout", "insert",
"extcmd", "help", "spell", "linter",
"execute", "extcmd", "help", "spell", "linter",
"browser", "whereisfile", "gotodir",
"all" };
int menusymbols[NUMBER_OF_MENUS] = { MMAIN, MWHEREIS, MREPLACE, MREPLACEWITH,
MYESNO, MGOTOLINE, MWRITEFILE, MINSERTFILE,
MEXTCMD, MHELP, MSPELL, MLINTER,
MEXECUTE, MEXECUTE, MHELP, MSPELL, MLINTER,
MBROWSER, MWHEREISFILE, MGOTODIR,
MMOST|MBROWSER|MHELP|MYESNO };
#endif /* ENABLE_NANORC */
@@ -254,6 +262,8 @@ keystruct *strtosc(const char *input)
else if (!strcmp(input, "paste"))
s->func = paste_text;
#ifndef NANO_TINY
else if (!strcmp(input, "execute"))
s->func = do_execute;
else if (!strcmp(input, "cutrestoffile"))
s->func = cut_till_eof;
else if (!strcmp(input, "copy"))
@@ -271,13 +281,12 @@ keystruct *strtosc(const char *input)
#ifdef ENABLE_COLOR
else if (!strcmp(input, "linter"))
s->func = do_linter;
#ifdef ENABLE_SPELLER
else if (!strcmp(input, "formatter"))
s->func = do_formatter;
#endif
#endif
else if (!strcmp(input, "curpos"))
s->func = do_cursorpos_void;
else if (!strcmp(input, "location") ||
!strcmp(input, "curpos")) /* Deprecated; remove in 2022. */
s->func = report_cursor_position;
else if (!strcmp(input, "gotoline"))
s->func = do_gotolinecolumn_void;
#ifdef ENABLE_JUSTIFY
@@ -317,6 +326,12 @@ keystruct *strtosc(const char *input)
s->func = record_macro;
else if (!strcmp(input, "runmacro"))
s->func = run_macro;
else if (!strcmp(input, "anchor"))
s->func = put_or_lift_anchor;
else if (!strcmp(input, "prevanchor"))
s->func = to_prev_anchor;
else if (!strcmp(input, "nextanchor"))
s->func = to_next_anchor;
else if (!strcmp(input, "undo"))
s->func = do_undo;
else if (!strcmp(input, "redo"))
@@ -339,6 +354,8 @@ keystruct *strtosc(const char *input)
s->func = do_scroll_up;
else if (!strcmp(input, "scrolldown"))
s->func = do_scroll_down;
else if (!strcmp(input, "center"))
s->func = do_center;
#endif
else if (!strcmp(input, "prevword"))
s->func = to_prev_word;
@@ -379,7 +396,7 @@ keystruct *strtosc(const char *input)
else if (!strcmp(input, "backspace"))
s->func = do_backspace;
else if (!strcmp(input, "refresh"))
s->func = total_refresh;
s->func = full_refresh;
else if (!strcmp(input, "suspend"))
s->func = do_suspend_void;
else if (!strcmp(input, "casesens"))
@@ -448,7 +465,7 @@ keystruct *strtosc(const char *input)
s->toggle = WHITESPACE_DISPLAY;
#ifdef ENABLE_COLOR
else if (!strcmp(input, "nosyntax"))
s->toggle = NO_COLOR_SYNTAX;
s->toggle = NO_SYNTAX;
#endif
else if (!strcmp(input, "smarthome"))
s->toggle = SMART_HOME;
@@ -600,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);
@@ -650,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;
@@ -808,13 +825,17 @@ void parse_binding(char *ptr, bool dobind)
goto free_things;
/* Limit the given menu to those where the function exists;
* first handle three special cases, then the general case. */
* first handle five special cases, then the general case. */
if (is_universal(newsc->func))
menu &= MMOST|MBROWSER;
#ifndef NANO_TINY
else if (newsc->func == do_toggle_void && newsc->toggle == NO_HELP)
menu &= (MMOST|MBROWSER|MYESNO) & ~MFINDINHELP;
else if (newsc->func == do_toggle_void)
menu &= MMAIN;
#endif
else if (newsc->func == full_refresh)
menu &= MMOST|MBROWSER|MHELP|MYESNO;
else if (newsc->func == (functionptrtype)implant)
menu &= MMOST|MBROWSER|MHELP;
else {
@@ -837,8 +858,8 @@ void parse_binding(char *ptr, bool dobind)
newsc->keystr = keycopy;
newsc->keycode = keycode;
/* Disallow rebinding ^[ and frequent escape-sequence starter "Esc [". */
if (newsc->keycode == ESC_CODE || newsc->keycode == '[') {
/* Disallow rebinding <Esc> (^[). */
if (newsc->keycode == ESC_CODE) {
jot_error(N_("Keystroke %s may not be rebound"), keycopy);
free_things:
free(keycopy);
@@ -972,15 +993,27 @@ void parse_includes(char *ptr)
free(expanded);
}
/* Return the short value corresponding to the color named in colorname,
* and set bright to TRUE if that color is bright. */
short color_to_short(const char *colorname, bool *bright)
const char hues[9][7] = { "pink", "purple", "mauve", "lagoon", "mint",
"lime", "peach", "orange", "latte" };
short indices[9] = { 204, 163, 134, 38, 48, 148, 215, 208, 137 };
/* Return the short value corresponding to the given color name, and set
* vivid to TRUE for a lighter color, and thick for a heavier typeface. */
short color_to_short(const char *colorname, bool *vivid, bool *thick)
{
if (strncmp(colorname, "bright", 6) == 0) {
*bright = TRUE;
if (strncmp(colorname, "bright", 6) == 0 && colorname[6] != '\0') {
/* Prefix "bright" is deprecated; remove in 2024. */
*vivid = TRUE;
*thick = TRUE;
colorname += 6;
} else
*bright = FALSE;
} else if (strncmp(colorname, "light", 5) == 0 && colorname[5] != '\0') {
*vivid = TRUE;
*thick = FALSE;
colorname += 5;
} else {
*vivid = FALSE;
*thick = FALSE;
}
if (strcmp(colorname, "green") == 0)
return COLOR_GREEN;
@@ -999,7 +1032,18 @@ short color_to_short(const char *colorname, bool *bright)
else if (strcmp(colorname, "black") == 0)
return COLOR_BLACK;
else if (strcmp(colorname, "normal") == 0)
return USE_THE_DEFAULT;
return THE_DEFAULT;
else
for (int index = 0; index < 9; index++)
if (strcmp(colorname, hues[index]) == 0) {
if (*vivid) {
jot_error(N_("Color '%s' takes no prefix"), colorname);
return BAD_COLOR;
} else if (COLORS < 255)
return THE_DEFAULT;
else
return indices[index];
}
jot_error(N_("Color \"%s\" not understood"), colorname);
return BAD_COLOR;
@@ -1009,32 +1053,55 @@ short color_to_short(const char *colorname, bool *bright)
* Return FALSE when any color name is invalid; otherwise return TRUE. */
bool parse_combination(char *combostr, short *fg, short *bg, int *attributes)
{
char *comma = strchr(combostr, ',');
bool bright;
bool vivid, thick;
char *comma;
*attributes = A_NORMAL;
if (comma != NULL) {
*bg = color_to_short(comma + 1, &bright);
if (bright) {
jot_error(N_("A background color cannot be bright"));
if (strncmp(combostr, "bold", 4) == 0) {
*attributes |= A_BOLD;
if (combostr[4] != ',') {
jot_error(N_("An attribute requires a subsequent comma"));
return FALSE;
}
if (*bg == BAD_COLOR)
return FALSE;
*comma = '\0';
} else
*bg = USE_THE_DEFAULT;
combostr += 5;
}
if (comma != combostr) {
*fg = color_to_short(combostr, &bright);
if (strncmp(combostr, "italic", 6) == 0) {
#ifdef A_ITALIC
*attributes |= A_ITALIC;
#endif
if (combostr[6] != ',') {
jot_error(N_("An attribute requires a subsequent comma"));
return FALSE;
}
combostr += 7;
}
comma = strchr(combostr, ',');
if (comma)
*comma = '\0';
if (!comma || comma > combostr) {
*fg = color_to_short(combostr, &vivid, &thick);
if (*fg == BAD_COLOR)
return FALSE;
if (bright)
*attributes = A_BOLD;
if (vivid && !thick && COLORS > 8)
*fg += 8;
else if (vivid)
*attributes |= A_BOLD;
} else
*fg = USE_THE_DEFAULT;
*fg = THE_DEFAULT;
if (comma) {
*bg = color_to_short(comma + 1, &vivid, &thick);
if (*bg == BAD_COLOR)
return FALSE;
if (vivid && COLORS > 8)
*bg += 8;
} else
*bg = THE_DEFAULT;
return TRUE;
}
@@ -1104,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;
@@ -1186,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;
@@ -1225,7 +1292,7 @@ void pick_up_name(const char *kind, char *ptr, char **storage)
*storage = mallocstrcpy(*storage, ptr);
}
/* Handle the four syntax-only commands. */
/* Handle the six syntax-only commands. */
bool parse_syntax_commands(char *keyword, char *ptr)
{
if (strcmp(keyword, "color") == 0)
@@ -1237,9 +1304,7 @@ bool parse_syntax_commands(char *keyword, char *ptr)
pick_up_name("comment", ptr, &live_syntax->comment);
#endif
} else if (strcmp(keyword, "tabgives") == 0) {
#ifdef ENABLE_COLOR
pick_up_name("tabgives", ptr, &live_syntax->tab);
#endif
} else if (strcmp(keyword, "linter") == 0)
pick_up_name("linter", ptr, &live_syntax->linter);
else if (strcmp(keyword, "formatter") == 0)
@@ -1262,16 +1327,13 @@ static void check_vitals_mapped(void)
for (int v = 0; v < VITALS; v++) {
for (funcstruct *f = allfuncs; f != NULL; f = f->next) {
if (f->func == vitals[v] && f->menus & inmenus[v]) {
const keystruct *s = first_sc_for(inmenus[v], f->func);
if (!s) {
fprintf(stderr, _("No key is bound to function '%s' in "
"menu '%s'. Exiting.\n"), f->desc,
menu_to_name(inmenus[v]));
fprintf(stderr, _("If needed, use nano with the -I option "
"to adjust your nanorc settings.\n"));
exit(1);
}
break;
if (first_sc_for(inmenus[v], f->func) == NULL) {
jot_error(N_("No key is bound to function '%s' in menu '%s'. "
" Exiting.\n"), f->desc, menu_to_name(inmenus[v]));
die(_("If needed, use nano with the -I option "
"to adjust your nanorc settings.\n"));
} else
break;
}
}
}
@@ -1405,7 +1467,7 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
if (!opensyntax)
jot_error(N_("A '%s' command requires a preceding "
"'syntax' command"), keyword);
if (strcasestr("icolor", keyword))
if (strstr("icolor", keyword))
seen_color_command = TRUE;
continue;
} else if (parse_syntax_commands(keyword, ptr))
@@ -1494,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)
@@ -1521,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);
@@ -1564,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

@@ -19,9 +19,10 @@
* *
**************************************************************************/
#include "proto.h"
#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);
@@ -69,20 +70,16 @@ void tidy_up_after_search(void)
/* Prepare the prompt and ask the user what to search for. Keep looping
* as long as the user presses a toggle, and only take action and exit
* when <Enter> is pressed or a non-toggle shortcut was executed. */
void search_init(bool replacing, bool keep_the_answer)
void search_init(bool replacing, bool retain_answer)
{
char *thedefault;
/* What will be searched for when the user typed nothing. */
/* When starting a new search, clear the current answer. */
if (!keep_the_answer)
answer = mallocstrcpy(answer, "");
/* What will be searched for when the user types just <Enter>. */
/* If something was searched for earlier, include it in the prompt. */
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) ? "..." : "");
@@ -93,9 +90,9 @@ void search_init(bool replacing, bool keep_the_answer)
while (TRUE) {
functionptrtype func;
/* Ask the user what to search for (or replace). */
int response = do_prompt(FALSE, FALSE,
int response = do_prompt(
inhelp ? MFINDINHELP : (replacing ? MREPLACE : MWHEREIS),
answer, &search_history, edit_refresh,
retain_answer ? answer : "", &search_history, edit_refresh,
/* TRANSLATORS: This is the main search prompt. */
"%s%s%s%s%s%s", _("Search"),
/* TRANSLATORS: The next four modify the search prompt. */
@@ -125,19 +122,19 @@ void search_init(bool replacing, bool keep_the_answer)
#endif
}
/* When not doing a regular-expression search, just search;
* otherwise compile the search string, and only search when
* the expression is valid. */
if (!ISSET(USE_REGEXP) || regexp_init(last_search)) {
if (replacing)
ask_for_replacement();
else
go_looking();
}
if (ISSET(USE_REGEXP) && !regexp_init(last_search))
break;
if (replacing)
ask_for_and_do_replacements();
else
go_looking();
break;
}
retain_answer = TRUE;
func = func_from_key(&response);
/* If we're here, one of the five toggles was pressed, or
@@ -189,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) {
@@ -249,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"));
@@ -289,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 ||
@@ -309,33 +322,27 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
if (match_len != NULL)
*match_len = found_len;
/* Wipe the "Searching..." message and unset the suppression flag. */
/* Wipe the "Searching..." message and unsuppress cursor-position display. */
if (feedback > 0) {
wipe_statusbar();
suppress_cursorpos = FALSE;
lastmessage = VACUUM;
}
return 1;
}
/* Ask what to search for and then go looking for it. */
void do_search(void)
{
search_init(FALSE, FALSE);
}
/* Search forward for a string. */
/* Ask for a string and then search forward for it. */
void do_search_forward(void)
{
UNSET(BACKWARDS_SEARCH);
do_search();
search_init(FALSE, FALSE);
}
/* Search backwards for a string. */
/* Ask for a string and then search backwards for it. */
void do_search_backward(void)
{
SET(BACKWARDS_SEARCH);
do_search();
search_init(FALSE, FALSE);
}
/* Search for the last string without prompting. */
@@ -359,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();
@@ -398,7 +406,7 @@ void go_looking(void)
linestruct *was_current = openfile->current;
size_t was_current_x = openfile->current_x;
//#define TIMEIT 12
//#define TIMEIT 12
#ifdef TIMEIT
#include <time.h>
clock_t start = clock();
@@ -414,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);
@@ -483,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);
@@ -500,6 +510,19 @@ char *replace_line(const char *needle)
return copy;
}
#ifdef ENABLE_COLOR
/* Reset the multiline coloring info and then recalculate it. */
void wipe_and_recalculate_colorinfo(void)
{
for (linestruct *line = openfile->filetop; line != NULL; line = line->next)
if (line->multidata)
for (short index = 0; index < openfile->syntax->nmultis; index++)
line->multidata[index] = -1;
precalc_multicolorinfo();
}
#endif
/* Step through each occurrence of the search string and prompt the user
* before replacing it. We seek for needle, and replace it with answer.
* The parameters real_current and real_current_x are needed in order to
@@ -518,12 +541,11 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
linestruct *was_mark = openfile->mark;
linestruct *top, *bot;
size_t top_x, bot_x;
bool right_side_up = FALSE;
bool right_side_up = (openfile->mark && mark_is_before_cursor());
/* If the mark is on, frame the region, and turn the mark off. */
if (openfile->mark) {
get_region((const linestruct **)&top, &top_x,
(const linestruct **)&bot, &bot_x, &right_side_up);
get_region(&top, &top_x, &bot, &bot_x);
openfile->mark = NULL;
modus = INREGION;
@@ -645,17 +667,17 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
free(openfile->current->data);
openfile->current->data = copy;
if (!replaceall) {
#ifdef ENABLE_COLOR
/* When doing syntax coloring, the replacement might require
* a change of colors, so refresh the whole edit window. */
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX))
edit_refresh();
else
#ifndef NANO_TINY
if (ISSET(SOFTWRAP))
openfile->current->extrarows = extra_chunks_in(openfile->current);
#endif
update_line(openfile->current, openfile->current_x);
}
#ifdef ENABLE_COLOR
/* Check whether the replacement requires a change in the coloring. */
check_the_multis(openfile->current);
if (refresh_needed && !replaceall)
wipe_and_recalculate_colorinfo();
#endif
set_modified();
as_an_at = TRUE;
numreplaced++;
@@ -664,10 +686,12 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
if (numreplaced == -1)
not_found_msg(needle);
#ifdef ENABLE_COLOR
else if (numreplaced > 0)
refresh_needed = TRUE;
if (refresh_needed)
wipe_and_recalculate_colorinfo();
#endif
#ifndef NANO_TINY
openfile->mark = was_mark;
#endif
@@ -691,18 +715,20 @@ void do_replace(void)
}
}
/* Ask the user what the already given search string should be replaced with. */
void ask_for_replacement(void)
/* Ask the user what to replace the search string with, and do the replacements. */
void ask_for_and_do_replacements(void)
{
linestruct *edittop_save, *begin;
size_t firstcolumn_save, begin_x;
linestruct *was_edittop = openfile->edittop;
size_t was_firstcolumn = openfile->firstcolumn;
linestruct *beginline = openfile->current;
size_t begin_x = openfile->current_x;
ssize_t numreplaced;
int response = do_prompt(FALSE, FALSE, MREPLACEWITH, "",
int response = do_prompt(MREPLACEWITH, "", &replace_history,
/* TRANSLATORS: This is a prompt. */
&replace_history, edit_refresh, _("Replace with"));
edit_refresh, _("Replace with"));
#ifdef ENABLE_HISTORIES
/* If the replace string is not "", add it to the replace history list. */
/* When not "", add the replace string to the replace history list. */
if (response == 0)
update_history(&replace_history, answer);
#endif
@@ -714,18 +740,12 @@ void ask_for_replacement(void)
} else if (response > 0)
return;
/* Save where we are. */
edittop_save = openfile->edittop;
firstcolumn_save = openfile->firstcolumn;
begin = openfile->current;
begin_x = openfile->current_x;
numreplaced = do_replace_loop(last_search, FALSE, begin, &begin_x);
numreplaced = do_replace_loop(last_search, FALSE, beginline, &begin_x);
/* Restore where we were. */
openfile->edittop = edittop_save;
openfile->firstcolumn = firstcolumn_save;
openfile->current = begin;
openfile->edittop = was_edittop;
openfile->firstcolumn = was_firstcolumn;
openfile->current = beginline;
openfile->current_x = begin_x;
refresh_needed = TRUE;
@@ -750,15 +770,14 @@ void goto_line_posx(ssize_t line, size_t pos_x)
/* Go to the specified line and column, or ask for them if interactive
* is TRUE. In the latter case also update the screen afterwards.
* Note that both the line and column number should be one-based. */
void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
void do_gotolinecolumn(ssize_t line, ssize_t column, bool retain_answer,
bool interactive)
{
if (interactive) {
/* Ask for the line and column. */
int response = do_prompt(FALSE, FALSE, MGOTOLINE,
use_answer ? answer : "", NULL, edit_refresh,
int response = do_prompt(MGOTOLINE, retain_answer ? answer : "", NULL,
/* TRANSLATORS: This is a prompt. */
_("Enter line number, column number"));
edit_refresh, _("Enter line number, column number"));
/* If the user cancelled or gave a blank answer, get out. */
if (response < 0) {
@@ -768,7 +787,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
if (func_from_key(&response) == flip_goto) {
UNSET(BACKWARDS_SEARCH);
/* Retain what the user typed so far and switch to searching. */
/* Switch to searching but retain what the user typed so far. */
search_init(FALSE, TRUE);
return;
}
@@ -863,8 +882,8 @@ bool find_a_bracket(bool reverse, const char *bracket_pair)
linestruct *line = openfile->current;
const char *pointer, *found;
/* Step away from the current bracket, either backwards or forwards. */
if (reverse) {
/* First step away from the current bracket. */
if (openfile->current_x == 0) {
line = line->prev;
if (line == NULL)
@@ -872,31 +891,23 @@ bool find_a_bracket(bool reverse, const char *bracket_pair)
pointer = line->data + strlen(line->data);
} else
pointer = line->data + step_left(line->data, openfile->current_x);
} else
/* Now seek for any of the two brackets we are interested in. */
while (!(found = mbrevstrpbrk(line->data, bracket_pair, pointer))) {
line = line->prev;
if (line == NULL)
return FALSE;
pointer = line->data + strlen(line->data);
}
} else {
pointer = line->data + step_right(line->data, openfile->current_x);
/* Now seek for any of the two brackets, either backwards or forwards. */
while (TRUE) {
if (reverse)
found = mbrevstrpbrk(line->data, bracket_pair, pointer);
else
found = mbstrpbrk(pointer, bracket_pair);
if (found)
break;
if (reverse)
line = line->prev;
else
while (!(found = mbstrpbrk(pointer, bracket_pair))) {
line = line->next;
/* If we've reached the start or end of the buffer, get out. */
if (line == NULL)
return FALSE;
pointer = line->data;
if (reverse)
pointer += strlen(line->data);
if (line == NULL)
return FALSE;
pointer = line->data;
}
}
/* Set the current position to the found bracket. */
@@ -984,4 +995,55 @@ void do_find_bracket(void)
openfile->current = was_current;
openfile->current_x = was_current_x;
}
/* Place an anchor at the current line when none exists, otherwise remove it. */
void put_or_lift_anchor(void)
{
openfile->current->has_anchor = !openfile->current->has_anchor;
update_line(openfile->current, openfile->current_x);
if (openfile->current->has_anchor)
statusbar(_("Placed anchor"));
else
statusbar(_("Removed anchor"));
}
/* Make the given line the current line, or report the anchoredness. */
void go_to_and_confirm(linestruct *line)
{
linestruct *was_current = openfile->current;
if (line != openfile->current) {
openfile->current = line;
openfile->current_x = 0;
edit_redraw(was_current, CENTERING);
statusbar(_("Jumped to anchor"));
} else if (openfile->current->has_anchor)
statusbar(_("This is the only anchor"));
else
statusbar(_("There are no anchors"));
}
/* Jump to the first anchor before the current line; wrap around at the top. */
void to_prev_anchor(void)
{
linestruct *line = openfile->current;
do { line = (line->prev) ? line->prev : openfile->filebot;
} while (!line->has_anchor && line != openfile->current);
go_to_and_confirm(line);
}
/* Jump to the first anchor after the current line; wrap around at the bottom. */
void to_next_anchor(void)
{
linestruct *line = openfile->current;
do { line = (line->next) ? line->next : openfile->filetop;
} while (!line->has_anchor && line != openfile->current);
go_to_and_confirm(line);
}
#endif /* !NANO_TINY */

File diff suppressed because it is too large Load Diff

View File

@@ -19,7 +19,7 @@
* *
**************************************************************************/
#include "proto.h"
#include "prototypes.h"
#include <errno.h>
#ifdef HAVE_PWD_H
@@ -38,7 +38,7 @@ void get_homedir(void)
#ifdef HAVE_PWD_H
/* When HOME isn't set, or when we're root, get the home directory
* from the password file instead. */
if (homenv == NULL || geteuid() == 0) {
if (homenv == NULL || geteuid() == ROOT_UID) {
const struct passwd *userage = getpwuid(geteuid());
if (userage != NULL)
@@ -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);
@@ -160,7 +160,7 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
}
/* In the given string, recode each embedded NUL as a newline. */
void unsunder(char *string, size_t length)
void recode_NUL_to_LF(char *string, size_t length)
{
while (length > 0) {
if (*string == '\0')
@@ -171,7 +171,7 @@ void unsunder(char *string, size_t length)
}
/* In the given string, recode each embedded newline as a NUL. */
void sunder(char *string)
void recode_LF_to_NUL(char *string)
{
while (*string != '\0') {
if (*string == '\n')
@@ -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,9 +328,9 @@ char *mallocstrcpy(char *dest, const char *src)
* of the given string, and NUL-terminate the copy. */
char *measured_copy(const char *string, size_t count)
{
char *thecopy = charalloc(count + 1);
char *thecopy = nmalloc(count + 1);
strncpy(thecopy, string, count);
memcpy(thecopy, string, count);
thecopy[count] = '\0';
return thecopy;
@@ -431,6 +431,9 @@ void new_magicline(void)
openfile->filebot->next = make_new_node(openfile->filebot);
openfile->filebot->next->data = copy_of("");
openfile->filebot = openfile->filebot->next;
#ifndef NANO_TINY
openfile->filebot->extrarows = 0;
#endif
openfile->totsize++;
}
@@ -459,32 +462,26 @@ bool mark_is_before_cursor(void)
}
/* Return in (top, top_x) and (bot, bot_x) the start and end "coordinates"
* of the marked region. If right_side_up isn't NULL, set it to TRUE when
* the mark is at the top of the marked region, and to FALSE otherwise. */
void get_region(const linestruct **top, size_t *top_x,
const linestruct **bot, size_t *bot_x, bool *right_side_up)
* of the marked region. */
void get_region(linestruct **top, size_t *top_x, linestruct **bot, size_t *bot_x)
{
if (mark_is_before_cursor()) {
*top = openfile->mark;
*top_x = openfile->mark_x;
*bot = openfile->current;
*bot_x = openfile->current_x;
if (right_side_up != NULL)
*right_side_up = TRUE;
} else {
*bot = openfile->mark;
*bot_x = openfile->mark_x;
*top = openfile->current;
*top_x = openfile->current_x;
if (right_side_up != NULL)
*right_side_up = FALSE;
}
}
/* Get the set of lines to work on -- either just the current line, or the
* first to last lines of the marked region. When the cursor (or mark) is
* at the start of the last line of the region, exclude that line. */
void get_range(const linestruct **top, const linestruct **bot)
void get_range(linestruct **top, linestruct **bot)
{
if (!openfile->mark) {
*top = openfile->current;
@@ -492,7 +489,7 @@ void get_range(const linestruct **top, const linestruct **bot)
} else {
size_t top_x, bot_x;
get_region(top, &top_x, bot, &bot_x, NULL);
get_region(top, &top_x, bot, &bot_x);
if (bot_x == 0 && *bot != *top && !also_the_last)
*bot = (*bot)->prev;
@@ -518,19 +515,15 @@ linestruct *line_from_number(ssize_t number)
#endif /* !NANO_TINY */
/* Count the number of characters from begin to end, and return it. */
size_t get_totsize(const linestruct *begin, const linestruct *end)
size_t number_of_characters_in(const linestruct *begin, const linestruct *end)
{
const linestruct *line;
size_t totsize = 0;
size_t count = 0;
/* Sum the number of characters (plus a newline) in each line. */
for (line = begin; line != end->next; line = line->next)
totsize += mbstrlen(line->data) + 1;
count += mbstrlen(line->data) + 1;
/* The last line of a file doesn't have a newline -- otherwise it
* wouldn't be the last line -- so subtract 1 when at EOF. */
if (line == NULL)
totsize--;
return totsize;
/* Do not count the final newline. */
return (count - 1);
}

File diff suppressed because it is too large Load Diff

View File

@@ -5,11 +5,9 @@ pkgdata_DATA = asm.nanorc \
cmake.nanorc \
c.nanorc \
css.nanorc \
debian.nanorc \
default.nanorc \
elisp.nanorc \
fortran.nanorc \
gentoo.nanorc \
email.nanorc \
go.nanorc \
groff.nanorc \
guile.nanorc \
@@ -20,8 +18,7 @@ pkgdata_DATA = asm.nanorc \
lua.nanorc \
makefile.nanorc \
man.nanorc \
mgp.nanorc \
mutt.nanorc \
markdown.nanorc \
nanohelp.nanorc \
nanorc.nanorc \
nftables.nanorc \
@@ -31,16 +28,23 @@ pkgdata_DATA = asm.nanorc \
perl.nanorc \
php.nanorc \
po.nanorc \
postgresql.nanorc \
pov.nanorc \
python.nanorc \
ruby.nanorc \
rust.nanorc \
sh.nanorc \
spec.nanorc \
sql.nanorc \
tcl.nanorc \
tex.nanorc \
texinfo.nanorc \
xml.nanorc
EXTRA_DIST = $(pkgdata_DATA)
nobase_pkgdata_DATA = \
extra/ada.nanorc \
extra/debian.nanorc \
extra/fortran.nanorc \
extra/gentoo.nanorc \
extra/haskell.nanorc \
extra/povray.nanorc \
extra/spec.nanorc
EXTRA_DIST = $(pkgdata_DATA) $(nobase_pkgdata_DATA)

View File

@@ -1,4 +1,4 @@
## Here is an example for assembler.
## Syntax highlighting for assembler.
syntax asm "\.(S|s|asm)$"
magic "assembler source"
@@ -13,9 +13,6 @@ color brightcyan "^[[:space:]]*#[[:space:]]*(define|undef|include|ifn?def|endif|
# Strings.
color brightyellow "<[^= ]*>" ""(\\.|[^"])*""
# Multiline strings. This regex is VERY resource intensive,
# and sometimes colours things that shouldn't be coloured.
###color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
# Comments.
color brightblue "//.*"

View File

@@ -1,11 +1,14 @@
## Here is an example for Autoconf.
## Syntax highlighting for Autoconf.
## Original author: Benno Schulenberg
## License: GPL version 3 or newer
syntax autoconf "\.(ac|m4)$"
comment "#"
# Keywords:
color yellow "\<(if|test|then|elif|else|fi|for|in|do|done)\>"
color yellow "(=|!=|&&|\|\|)"
color yellow "=|!=|&&|\|\|"
# Macros:
color cyan "\<[[:upper:]_[:digit:]]+\>"
@@ -14,7 +17,7 @@ color cyan "\<[[:upper:]_[:digit:]]+\>"
color red "\<[-_.0-9]+\>"
# Strings:
color red "\"[^"]*\"" "\'[^']*\'"
color red ""[^"]*"" "'[^']*'"
# Backticks:
color green "`[^`]*`"

View File

@@ -1,4 +1,4 @@
## Here is an example for awk.
## Syntax highlighting for AWK scripts.
syntax awk "\.awk$"
header "^#!.*awk"
@@ -14,7 +14,7 @@ color red "\<(PROCINFO|RS|RT|RSTART|RLENGTH|SUBSEP|TEXTDOMAIN)\>"
# Function declarations and special patterns.
color brightgreen "\<(function|extension|BEGIN|END)\>"
# Operators.
color green "(\{|\}|\(|\)|\;|\]|\[|\\|<|>|!|=|&|\+|-|\*|%|/|\?:|\^|\|)"
color green "\{|\}|\(|\)|\;|\[|\]|\\|<|>|!|=|&|\+|-|\*|%|/|\?:|\^|\|"
# Flow control.
color brightyellow "\<(for|if|while|do|else|in|delete|exit)\>"
color brightyellow "\<(break|continue|return)\>"

View File

@@ -1,4 +1,4 @@
## Here is an example for C/C++.
## Syntax highlighting for C and C++ files.
syntax c "\.([ch](pp|xx)?|C|cc|c\+\+|cu|H|hh|ii?)$"
header "-\*-.*\<C(\+\+)?((;|\s).*)?-\*-"
@@ -6,31 +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:]=]*>"
# Multiline strings. This regex is VERY resource intensive,
# and sometimes colours things that shouldn't be coloured.
###color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
# 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,4 +1,7 @@
## Colouring for Changelogs.
## Syntax highlighting for Changelogs.
## Original author: Benno Schulenberg
## License: GPL version 3 or newer
syntax changelog "Change[Ll]og[^/]*$"
@@ -12,7 +15,7 @@ color yellow "<[^>]*@[^>]*>"
# Command-line options.
color cyan "[[:space:]]-[a-zA-Z\$]" "--[8a-z-]+"
# Bug and patch numbers.
color cyan "(BZ|bug|patch) #[0-9]+" "PR [[:alnum:]]+/[0-9]+"
color cyan "(BZ|bug|patch)[ ]#[0-9]+" "PR [[:alnum:]]+/[0-9]+"
# Probable constants, for variety.
color brightred "\<[A-Z_][0-9A-Z_]+\>"
# Key sequences.

View File

@@ -1,11 +1,20 @@
## Here is an example for CSS files.
## Syntax highlighting for CSS files.
syntax css "\.css$"
comment "/*|*/"
# First make everything red:
color brightred "."
# Then everything between braces yellow:
color brightyellow start="\{" end="\}"
color brightwhite start=":" end="([;^\{]|$)"
color brightblue ":active|:focus|:hover|:link|:visited|:link|:after|:before|$"
color brightblue start="\/\*" end="\\*/"
# Then everything after a colon white:
color brightwhite start=":" end="([;^{]|$)"
# Pseudo-classes:
color brightcyan ":(active|checked|focus|hover|link|visited|after|before)\>"
# Comments:
color brightblue start="/\*" end="\*/"
# Syntactic characters:
color green ";|:|\{|\}"

View File

@@ -1,4 +1,4 @@
## An example of a default syntax. The default syntax is used for
## This is an example of a default syntax. The default syntax is used for
## files that do not match any other syntax.
syntax default
@@ -11,10 +11,13 @@ color cyan "^[[:space:]]*#.*"
color ,red " + +"
# Nano's name, including version.
color brightred "(GNU )?[Nn]ano [1-4]\.[0-9][-.[:alnum:]]*\>"
color brightred "(GNU )?[Nn]ano [1-5]\.[0-9][-.[:alnum:]]*\>"
# Email addresses.
color magenta "<[[:alnum:].%_+-]+@[[:alnum:].-]+\.[[:alpha:]]{2,}>"
# Bracketed captions in certain config files.
color brightgreen "^\[[^][]+\]$"
# Control codes.
color latte "[[:cntrl:]]"

View File

@@ -1,4 +1,4 @@
## Here is an example for Emacs Lisp.
## Syntax highlighting for Emacs Lisp.
syntax elisp "\.el$"
magic "Lisp/Scheme program"
@@ -27,7 +27,7 @@ color brightred "\<(t|nil)\>"
# Keywords
color blue ":(\w|[?-])+"
# Strings
color yellow start="^[[:blank:]]+\"" end="[^\]\""
color yellow start="^[[:blank:]]+"" end="[^\]""
color yellow ""(\\.|[^"])*""
# Comments
color cyan "(^|[[:space:]]);.*"

17
syntax/email.nanorc Normal file
View File

@@ -0,0 +1,17 @@
## Syntax highlighting for emails.
syntax email "\.eml$"
# Quoted lines.
color green "^>.*"
color cyan "^> ?>.*"
color yellow "^> ?> ?>.*"
# Email addresses.
color brightmagenta "<[^@]+@[^@]+>"
# URLs.
color brightblue "(https?|ftp)://\S+\.\S+[^\s.)]"
# Signatures, even quoted ones.
color yellow start="^>* ?-- $" end="^>* ?$"

39
syntax/extra/ada.nanorc Normal file
View File

@@ -0,0 +1,39 @@
## Syntax highlighting for Ada.
## Original author: Andreas K. Foerster
## License: GPL version 3 or newer
## Language reference: http://www.ada-auth.org/standards/12rm/html/RM-TTL.html
syntax ada "\.ad[abcs]$"
comment "--"
# This linter command leaves an ALI file in the working directory.
linter gcc -c -gnatc
# Reserved Words (RM 2.9)
icolor yellow "\<(abort|abs|abstract|accept|access|aliased|all|and|array|at)\>"
icolor yellow "\<(begin|body|case|constant|declare|delay|delta|do)\>"
icolor yellow "\<(else|elsif|end|entry|exception|exit|for|function|generic|goto)\>"
icolor yellow "\<(if|in|interface|is|limited|loop|mod|new|not|null|of|or|others|out|overriding)\>"
icolor yellow "\<(package|pragma|private|procedure|protected|raise|range|record|rem|renames)\>"
icolor yellow "\<(requeue|return|reverse|select|separate|some|subtype|synchronized)\>"
icolor yellow "\<(tagged|task|terminate|then|type|until|use|when|while|with|xor)\>"
# Separators / Operators
color magenta "'|&|\*|\+|\-|\.|\,|\/|:|;|\(|\)|<|>|\||="
# Attributes
color cyan "'[[:alnum:]]+"
# Numbers (RM 2.4)
color green "\<[0-9][0-9A-Fa-f_#.+-]*"
# Characters / Strings
color red "'.'" ""[^"]*""
# Comments
color brightblue "--.*"
# Trailing whitespace
color ,blue "[[:space:]]+$"

View File

@@ -1,4 +1,4 @@
## Here is an example for apt's sources.list.
## Syntax highlighting for apt's sources.list.
syntax sources.list "sources\.list(\.d/.*\.list)?(~|\.old|\.save)?$"
comment "#"

View File

@@ -1,6 +1,6 @@
## Here is an example for Fortran 90/95.
## Syntax highlighting for Fortran 90/95.
syntax fortran "\.(f|f90|f95)$"
syntax fortran "\.(f|for|f90|f95)$"
comment "!"
color red "\<[0-9]+\>"

View File

@@ -1,5 +1,5 @@
## Here is an example for Gentoo ebuilds/eclasses,
## and (further down) one for Portage control files.
## Syntax highlighting for Gentoo ebuilds/eclasses,
## and (further down) for Portage control files.
syntax ebuild "\.e(build|class|blit)$"
comment "#"

View File

@@ -0,0 +1,40 @@
## Syntax highlighting for Haskell files.
## Original author: Alex Taber
## License: GPL version 3
syntax "haskell" "\.hs$"
comment "--"
# Keywords
color red "\<(as|case|of|class|data|default|deriving|do|forall|foreign|hiding|if|then|else|import|infix(l|r)?|instance|let|in|mdo|module|newtype|qualified|type|where)\>"
# Various symbols
color cyan "\||@|!|:|_|~|=|\\|;|\(\)|,|\[|\]|\{|\}"
# Operators
color magenta "==|/=|&&|\|\||<|>|<=|>="
# More symbols
color cyan "->|<-|=>"
color magenta "\.|\$"
# Data constructors
color magenta "\<(True|False|Nothing|Just|Left|Right|LT|EQ|GT)\>"
# Data classes
color magenta "\<(Bounded|Data|Enum|Eq|Floating|Fractional|Functor|Integral|Monad|MonadPlus|Num|Ord|Read|Real|RealFloat|RealFrac|Show|Typeable)\>"
# Special keyword
color brightred "undefined"
# Strings
color yellow ""([^\"]|\\.)*""
# Characters
color brightyellow "'([^\']|\\.)'"
# Comments
color green "--.*"
color green start="\{-" end="-\}"
# Trailing whitespace
color ,green "[[:space:]]+$"

View File

@@ -1,4 +1,4 @@
## Here is an example for POV-Ray.
## Syntax highlighting for POV-Ray files.
syntax pov "\.(pov|POV|povray|POVRAY)$"
comment "//"
@@ -8,7 +8,7 @@ color brightyellow "\<(sphere|cylinder|translate|matrix|rotate|scale)\>"
color brightyellow "\<(orthographic|location|up|right|direction|clipped_by)\>"
color brightyellow "\<(fog_type|fog_offset|fog_alt|rgb|distance|transform)\>"
color brightred "\<(background|camera|fog|light_source|object|texture)\>"
color green "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)"
color green "\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|"
color brightmagenta "\<(union|group|subgroup)\>"
# Comments.

View File

@@ -1,4 +1,4 @@
## Here is an example for Go.
## Syntax highlighting for Go.
syntax go "\.go$"
comment "//"
@@ -7,7 +7,8 @@ formatter gofmt -w
# Types.
color green "\<(bool|u?int(8|16|32|64)?|float(32|64)|complex(64|128)|byte|rune|uintptr|string|error)\>"
color green "\<((<-[[:space:]]*)chan|chan[[:space:]]*<-|const|func|interface|map|struct|type|var)\>"
color green "\<(chan|const|func|interface|map|struct|type|var)\>"
color green "<-[[:space:]]*chan\>|\<chan[[:space:]]*<-"
# Predefined functions.
color blue "\<(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)\>"
@@ -20,7 +21,6 @@ color magenta "\<(break|continue|fallthrough|goto|return)\>"
# Declarations.
color brightcyan "\<(package|import)\>"
color brightcyan "//[[:space:]]*\+build[[:space:]]+(([a-zA-Z_0-9]+[[:space:]]*)+,[[:space:]]*)*[a-zA-Z_0-9]+"
# Literals.
color red "\<([1-9][0-9]*|0[0-7]*|0[xX][0-9A-Fa-f]+)\>"
@@ -39,5 +39,8 @@ color red start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
color brightblue "//.*"
color brightblue start="/\*" end="\*/"
# Special comments.
color brightcyan "//[[:space:]]*\+build[[:space:]]+(([a-zA-Z_0-9]+[[:space:]]*)+,[[:space:]]*)*[a-zA-Z_0-9]+"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -1,4 +1,4 @@
## Here is an example for groff.
## Syntax highlighting for groff.
syntax groff "(/tmac\.[^/]+$|\.(m[ems]|rof|tmac)$)"
comment ".\""
@@ -8,17 +8,17 @@ color cyan "^\.(ds|nr) [^[:space:]]*"
# Single-character escapes
color brightmagenta "\\."
# The argument of \f or \s in the same color
color brightmagenta "\\f." "\\f\(.." "\\s(\+|\-)?[0-9]"
color brightmagenta "\\f(.|\(..)" "\\s(\+|\-)?[0-9]"
# Newlines
color cyan "(\\|\\\\)n(.|\(..)"
color cyan start="(\\|\\\\)n\[" end="]"
color cyan "\\(\\)?n(.|\(..)"
color cyan start="\\(\\)?n\[" end="]"
# Requests
color brightgreen "^\.[[:space:]]*[^[:space:]]*"
# Comments
color yellow "^\.\\".*"
# Strings
color green "(\\|\\\\)\*(.|\(..)"
color green start="(\\|\\\\)\*\[" end="]"
color green "\\(\\)?\*(.|\(..)"
color green start="\\(\\)?\*\[" end="]"
# Characters
color brightred "\\\(.."
color brightred start="\\\[" end="]"

View File

@@ -1,4 +1,4 @@
## Here is an example for Guile Scheme.
## Syntax highlighting for Guile Scheme.
syntax guile "\.scm$"
header "^#!.*guile"
@@ -18,7 +18,7 @@ color brightred "(#t|#f)\>"
# Keywords
color blue "#?:(\w|[?-])+"
# Strings
color yellow start="^[[:blank:]]+\"" end="[^\]\""
color yellow start="^[[:blank:]]+"" end="[^\]""
color yellow ""(\\.|[^"])*""
# Comments
color cyan "(^|[[:space:]]);.*"

View File

@@ -1,4 +1,4 @@
## Here is an example for HTML.
## Syntax highlighting for HTML.
syntax html "\.html?$"
magic "HTML document"

View File

@@ -1,4 +1,4 @@
## Here is an example for Java.
## Syntax highlighting for Java.
syntax java "\.java$"
magic "Java "

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