Compare commits

...

461 Commits
v2.9.2 ... v3.0

Author SHA1 Message Date
Benno Schulenberg
5b1229599e po: update translations and regenerate POT file and PO files 2018-09-09 11:50:47 +02:00
Benno Schulenberg
8efdd08a86 bump version numbers and add a news item for the 3.0 release 2018-09-09 11:29:00 +02:00
Benno Schulenberg
27d2db2d1f tweaks: improve a couple of comments in the sample nanorc 2018-09-09 10:14:04 +02:00
Benno Schulenberg
571676eb85 docs: improve a comment about rebinding <Backspace>
And move it up, to give the now-final comment a bit more prominence.
2018-09-09 08:33:23 +02:00
Benno Schulenberg
9e71de12cd tweaks: improve a translator hint and some other comments 2018-09-09 08:17:22 +02:00
Benno Schulenberg
c7affe17c0 build: fix compilation again when configured with --enable-tiny 2018-09-08 12:24:12 +02:00
Benno Schulenberg
e21ce0db1f cutting: when deleting whole words, don't join lines unexpectedly
That is, wait with deleting words until they start under cursor,
so the user can see which word is goin to be eaten, and join lines
only when the cursor already sits at the edge of a line.
2018-09-07 19:35:01 +02:00
Benno Schulenberg
e6429e782a bindings: hard-bind <Ctrl+Shift+Delete> to 'cutwordleft'
On FreeBSD and NetBSD (when reached through ssh from a Linux machine)
this has the absurd effect of making <Ctrl+Backspace> do a 'cutwordleft'
by default, out of the box, without needing any rebindings.  Weird, but
wonderful, because the ideal behavior.

Also ensure that <Shift+Delete> always does a Backspace.

This makes that we have the following set of "congruent" keys:

  <Tab> moves text to the right,
  <Shift+Tab> moves text to the left,
  <Delete> "eats" a character to the right,
  <Shift+Delete> "eats" a character to the left,
  <Ctrl+Delete> "eats" a word to the right,
  <Shift+Ctrl+Delete> "eats" a word to the left.
2018-09-07 19:31:38 +02:00
Brand Huntsman
3270aac7db input: give feedback for all unbound keys also in the help viewer
Silently doing nothing robs the user of a bit of information.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-09-01 10:05:23 +02:00
Mark-Weston
13615d0953 build: fix compilation when CC=tcc
Signed-off-by: Mark-Weston <markweston@cock.li>
2018-08-31 20:06:08 +02:00
Benno Schulenberg
921f8ae4c9 syntax: default: colorize also two-digit and capitalized nano versions 2018-08-30 19:46:34 +02:00
Benno Schulenberg
24487d48ff tweaks: adjust one more translator hint, for removed toggles 2018-08-29 20:25:57 +02:00
Benno Schulenberg
388cd0b514 tweaks: remove two needless words, and split up a changed text further 2018-08-29 20:21:20 +02:00
Benno Schulenberg
33c4bb22d5 tweaks: adjust some translator hints for past changes, and add two more 2018-08-29 20:20:43 +02:00
Brand Huntsman
6e80772311 tweaks: correct four spaces of indentation to a tab, in two places
Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-08-29 18:01:21 +02:00
Benno Schulenberg
5f00b02f7c tweaks: fix a pasting error from a month ago 2018-08-28 21:39:01 +02:00
Benno Schulenberg
c6bdc46bb0 gnulib: update to its current upstream state 2018-08-28 20:21:17 +02:00
Mark-Weston
bf5949395d syntax: lua: do not color strings inside comments, and add a linter
Also, don't partially color "..." as an operator, because it isn't,
and color also the unary operator "#".

Signed-off-by: Mark-Weston <markweston@cock.li>
2018-08-28 20:16:16 +02:00
Benno Schulenberg
a18b48f0f7 help: for ^R^X, mention that the buffer can be piped to the command 2018-08-28 20:09:31 +02:00
Brand Huntsman
25e9877607 statusbar: elevate three messages to an ALERT, to make them more visible
Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-08-28 20:02:59 +02:00
Benno Schulenberg
c524fbe6d0 tweaks: remove some ineffectual parts from header-line regexes
Adding "[abc]*" does not restrict the recognized header line in any way.

Also, improve the header-line regex for shell scripts, because it should
not match "barunscript" (for example).
2018-08-28 19:53:36 +02:00
David Lawrence Ramsey
93c8e316a8 justify: verify being in a paragraph before trying to find its beginning
If find_paragraph() detects that we're not in a paragraph, it moves
forward a paragraph and then backward to that paragraph's beginning.
Make it check whether we're in a paragraph before moving backward
(since there might not *be* any more paragraphs), to prevent going
forth-and-back and never reaching the end of the buffer.

This fixes https://savannah.gnu.org/bugs/?54573.
2018-08-27 20:27:02 +02:00
Benno Schulenberg
80bea3eb9b docs: slightly reword the description of four bindable functions 2018-08-26 09:41:27 +02:00
Brand Huntsman
b5ede4ff65 tweaks: remove the 'bright' field from the colortype struct
Put the corresponding value into the 'attributes' field sooner.

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-08-25 10:54:20 +02:00
Benno Schulenberg
63b15275bd bindings: remove the More-Space toggle entirely
It is so unlikely that a user will want to bind it that it
just clutters the help text (and the documentation).
2018-08-25 10:10:27 +02:00
Benno Schulenberg
772c324f25 bindings: remove backup and new-buffer toggles (M-B, M-F) from main menu
These are available in the menus where they are relevant: the Write-Out
and the Insert menu, respectively.  Having them duplicated in the main
menu is inconsistent and eats precious keystrokes.  (Sorry, Chris.)
2018-08-25 10:07:28 +02:00
Benno Schulenberg
f1e5872e6a tweaks: reshuffle the order of the bindings, for help-line esthetics 2018-08-25 10:06:13 +02:00
Benno Schulenberg
bc42ae42a9 docs: the 'noconvert' bindable function was renamed to 'flipconvert'
Also, move it to sit with the other toggles of the Insert menu, and
remove its mention from among the main-menu toggles.
2018-08-25 10:05:21 +02:00
Benno Schulenberg
6d62682ddb bindings: move the noconvert toggle from the main to the insert menu
Also add feedback, so that it will be clear whether a file will be
inserted unconverted or not.

This addresses https://savannah.gnu.org/bugs/?54536.
2018-08-25 10:04:03 +02:00
Benno Schulenberg
8d6b205e4c tweaks: remove a superfluous condition and a redundant refresh
When 'inhelp' is true, there are at least two buffers open: an
edit buffer and the help-text buffer.

And bottombars() already does a full refresh of the bottom window.
2018-08-22 18:10:55 +02:00
David Lawrence Ramsey
03f9761c35 undo: store the correct cursor position after a paired cut+insert
And restore the cursor to this position when redoing the cut+insert.

Also remove two unneeded conditions.

This fully fixes https://savannah.gnu.org/bugs/?54466.
2018-08-21 19:21:14 +02:00
Benno Schulenberg
ec339d3b08 filtering: wait for the data-sending process to terminate too
When piping the buffer (or the marked region) to an external command,
we should wait not only for the external command to terminate but also
for the data-sending process, so that it will release its resources.

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

With-help-from: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2018-08-20 19:46:38 +02:00
Benno Schulenberg
3218d8358a tweaks: remove a redundant "struct" word, and replace it in comments 2018-08-20 19:33:31 +02:00
Benno Schulenberg
a3a10dfafe tweaks: don't bother having debug code that deallocates all memory
Who runs debug builds for any length of time?
2018-08-18 11:00:03 +02:00
Benno Schulenberg
850e538ff7 syntax: python: avoid coloring the three special values inside strings
Reported-by: Benjamin Mintz <bmintz@protonmail.com>
Suggested-by: Brand Huntsman <alpha@qzx.com>
2018-08-16 19:56:01 +02:00
Benno Schulenberg
18419b5e3f syntax: awk: recognize any {g,m,n,}awk script also by its shebang line
This fulfills https://savannah.gnu.org/bugs/?54516.

Suggested-by: Javier Valencia <javiervalencia80@gmail.com>
2018-08-15 20:20:22 +02:00
David Lawrence Ramsey
07447f3278 undo: restore the cursor position when a cut and paste are paired
When undoing/redoing an alternate spell check (of the entire file
or of a backwards marked region), put the cursor back where it was
when the spell check was invoked/finished.

This fixes https://savannah.gnu.org/bugs/?54466.
2018-08-15 19:58:46 +02:00
David Lawrence Ramsey
fd65f74428 undo: always initialize the 'newsize' element in the undo struct
So that do_redo() cannot set the file size to a "random" value.

This fixes https://savannah.gnu.org/bugs/?54478.
2018-08-11 10:07:20 +02:00
Benno Schulenberg
e40e6bbf10 tweaks: rename a function to better match its counterpart
Also rename its parameter, to describe what it ought to be.
2018-08-11 09:55:22 +02:00
Benno Schulenberg
2147e161bf rcfile: when a vital function is not mapped, mention in which menu
Add the reverse of the name-to-menu function to accomplish this.

This fixes https://savannah.gnu.org/bugs/?54449.
2018-08-11 09:46:03 +02:00
Benno Schulenberg
dc079bdf31 tweaks: implement the name-to-menu function in another manner
Use arrays, to make it easy to also implement the reverse function.
2018-08-11 09:45:02 +02:00
Benno Schulenberg
8560a0a225 docs: mention that "normal" can be used to give things the default color 2018-08-10 19:42:31 +02:00
Benno Schulenberg
52d851a1aa startup: don't overwrite rcfile error messages on a Linux console
On a Linux VT, refuse to start when there are errors in a nanorc file,
so that the messages no longer get overwritten -- which prevented the
user from seeing and reading them.

This fixes https://savannah.gnu.org/bugs/?54442.
2018-08-10 19:41:54 +02:00
Benno Schulenberg
2d434f63e2 syntaxes: remove all traces of the 'formatter' command 2018-08-09 21:12:10 +02:00
Benno Schulenberg
5c179aae7d docs: mention that the 'formatter' command has been superseded 2018-08-09 20:29:30 +02:00
Benno Schulenberg
975b491235 dropping a feature: remove the ability to use the 'formatter' command
Since the last version, the user can filter an entire buffer through
an external command.  This external command can also be a formatting
program, so there is no longer any need for this specific and special
formatter command.
2018-08-09 20:29:30 +02:00
Benno Schulenberg
94b4f07281 tweaks: adjust indentation after the previous change
Also improve a couple of comments.
2018-08-08 19:53:05 +02:00
Benno Schulenberg
61b4eeda66 speller: do not replace the text when the temporary file did not change 2018-08-08 19:44:40 +02:00
Benno Schulenberg
667fcea65e undo: differentiate between general filtering and spell checking
With-help-from: David Lawrence Ramsey <pooka109@gmail.com>
2018-08-07 20:42:39 +02:00
David Lawrence Ramsey
c39c9c241b undo: actually enable undoing/redoing an alternative spellcheck
Make sure the inserts of the spell-checked text are undoable, and no
longer discard the undo stack after running the alternate spell checker.
2018-08-07 20:41:05 +02:00
David Lawrence Ramsey
115f089d5f speller: hook up a marked-text alternative spellcheck to the undo system 2018-08-07 20:39:50 +02:00
David Lawrence Ramsey
7f6460b804 speller: hook up a full alternative spellcheck to the undo system 2018-08-07 20:39:13 +02:00
David Lawrence Ramsey
bc6787826a speller: make replace_marked_buffer() use the cutting functions directly 2018-08-07 20:38:50 +02:00
David Lawrence Ramsey
b5f15cb574 speller: make replace_buffer() use the cutting functions directly 2018-08-07 20:38:21 +02:00
Benno Schulenberg
4c66a6259c tweaks: slightly improve error message when vital function is unmapped
This fails to fix https://savannah.gnu.org/bugs/?54449, because
it would take far too much code for an exceptional case.
2018-08-06 19:35:47 +02:00
Benno Schulenberg
db1893ef2d syntax: nanorc: recognize 'yesno' as a valid menu to bind/unbind keys in 2018-08-06 18:05:10 +02:00
Benno Schulenberg
ad79a4fcfb rcfile: ensure that in the yesno menu Cancel is bound to some keystroke
(In the Search and Replace menus Cancel is not essential.  And in the
Goto Line menu Cancel is not needed at all: a simple <Enter> after an
empty answer works fine.)

This fixes the second part of https://savannah.gnu.org/bugs/?54447.
2018-08-05 20:11:48 +02:00
Benno Schulenberg
418bd3be34 rcfile: allow to rebind the Cancel function in the yesno menu
This fixes the first part of https://savannah.gnu.org/bugs/?54447.
2018-08-05 20:01:47 +02:00
Benno Schulenberg
4170454837 tweaks: exclude a global flagging variable when it is not needed 2018-08-05 13:00:44 +02:00
Benno Schulenberg
e90b7cf4aa tweaks: elide an unneeded/duplicate variable 2018-08-04 11:34:44 +02:00
Benno Schulenberg
bb90de0eb4 tweaks: rename a constant, to match what it actually means
Wrapping is concerned with columns, not with number of characters.
2018-08-04 11:21:42 +02:00
Benno Schulenberg
157c7b1bc4 rcfile: explicitly check for disallowed keywords in included files
This fixes https://savannah.gnu.org/bugs/?54441.
2018-08-04 07:29:36 +02:00
Benno Schulenberg
ac102a7516 tweaks: show "Space" and "Bsp" in the help text of the browser
These keys make more mnemonic sense for scrolling than F7 and F8.

Also adjust the nanohelp syntax to cover the lone word "Space".
2018-07-31 20:36:32 +02:00
Benno Schulenberg
d249233ea7 bindings: unassign the M-? keystroke, to free it up for future use
There are at least three other ways to achieve the thing that it did:
^End, M-/, and ^W^V.  No need to have a fourth way by default.

For symmetry, also unassign the corresponding binding for M-|.
2018-07-31 20:36:27 +02:00
Benno Schulenberg
33fb54c75f bindings: reassign the M-| keystroke to 'cutwordleft' by default
The 'cutwordright' function has gotten ^Delete as its default binding,
so the 'cutwordleft' function needs a default binding too -- also to
keep the items on the two help lines nicely paired.  M-| was chosen
because it is close to the Backspace key on many keyboard layouts.
2018-07-31 20:36:07 +02:00
Benno Schulenberg
c231b774d7 tweaks: reshuffle some lines, in order to elide one 2018-07-30 21:03:08 +02:00
Benno Schulenberg
0c263bda7d tweaks: elide a bunch of unneeded constant strings 2018-07-30 20:45:15 +02:00
Benno Schulenberg
60ee4408be signals: don't call a print routine in a signal handler
Print routines are not asynchronous-safe.

But... the only reason the call of kill() could return an error code
is when the relevant process has already terminated -- which is not
a problem, because that was the goal of calling kill().

This fixes https://savannah.gnu.org/bugs/?54409.
Reported-by: Daniel Kozovsky <dkozovsk@redhat.com>
2018-07-30 20:22:24 +02:00
Benno Schulenberg
72a590d60a tweaks: rename a variable and a function, for more clarity 2018-07-30 20:07:25 +02:00
Benno Schulenberg
9a47a9c4c0 rcfile, docs: no longer recognize nor mention 'set backwards'
The option has been a no-op since 2.9.0.  And now that the
^W/^Q/M-W/M-Q set is available, 'set backwards' is entirely
outdated.
2018-07-29 21:00:12 +02:00
David Lawrence Ramsey
9c8e40b442 bindings: make "n" work again in file browser and help viewer
Also, "N" shouldn't be a synonym of "n" in tiny mode.
2018-07-29 20:49:56 +02:00
Benno Schulenberg
54a4123d4c bindings: remove the 'searchagain' function entirely
The user is obliged to make use of 'findprevious' and 'findnext' instead.

Also, adjust the description of 'wherewas' to its wider availability.
2018-07-29 11:43:13 +02:00
David Lawrence Ramsey
7a31507167 bindings: make ^Q start a backward search also in the file browser
This makes the four search keystrokes (^W/^Q/M-W/M-Q) available in
all three areas of nano: editor, help viewer, and file browser.
2018-07-29 11:43:13 +02:00
Benno Schulenberg
7f2031006a bindings: make ^Q and M-Q available also in the help viewer
As the help viewer is almost a normal buffer, commands that make sense
-- like searching backwards, and searching the previous occurrence --
should work in the help viewer too.

In addition, show all Search commands prominently in the help lines of
the help viewer, so that users are likely to notice them and will maybe
infer that they work in the editor itself too.

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

With-help-from: David Lawrence Ramsey <pooka109@gmail.com>
2018-07-29 11:43:13 +02:00
Benno Schulenberg
7e18b91ead help: move "Search Again" away from "Find Next" and "Find Previous"
Put "Where Was" in its place, to make the symmetry of ^W/M-W/^Q/M-Q
somewhat clearer.  Also, conditionally reshuffle "Save File", to try
and keep menu items nicely paired.
2018-07-29 11:43:13 +02:00
Benno Schulenberg
f82eefa303 tweaks: exclude the file-prepending code from the tiny version
The prepending and appending toggles are not available in tiny nano,
so there is no need to have the code either.
2018-07-24 19:31:03 +02:00
Benno Schulenberg
8e1ce7034d search: include 'findprevious' and 'findnext' in the tiny version
Thus fix a compilation failure when configured with --enable-tiny.

Now M-Q will be functional also in a tiny nano.
2018-07-24 19:19:27 +02:00
Benno Schulenberg
c4d09cc24b text: add auto-whitespace to the file size after creating the undo item
The undo item for ENTER should record the file size *before* the amount
of auto-indentation whitespace is added to it.

This fixes https://savannah.gnu.org/bugs/?54344.
Reported-by: Liu Hao <lh_mouse@126.com>
2018-07-23 17:57:47 +02:00
Benno Schulenberg
d04c8f88f1 docs: say that 'cutwordright' is now bound to <Ctrl+Delete> by default
Also, suggest to rebind ^H to 'cutwordleft' so that <Ctrl+Backspace>
will delete the word to the left of the cursor (on some terminals).
2018-07-22 19:27:50 +02:00
Marco Diego Aurélio Mesquita
a67f6c6031 input: erase the next word when Ctrl is held while pressing Delete
Bind the until-now unbound function 'cutwordright' to <Ctrl+Delete>.
The complementary function, 'cutwordleft', is not bound by default
because on many terminals the keystroke <Ctrl+Backspace> generates
^H -- the canonical ASCII backspace character.  We cannot change the
existing action of ^H without upsetting some users.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-07-22 19:27:50 +02:00
Benno Schulenberg
8d8f5788ce rcfile: do not accept rebinding F0 nor function keys above F16
To match the documentation and to match what the nanorc.nanorc
colors as valid.

In theory it would be possible to allow rebinding also F17...F63,
but nano does not recognize escape sequences for these high-order
function keys.  As no one ever complained about unknown sequences
when pressing function keys, I am guessing that no one has these
high-order keys, or at least that no one uses them.

This fixes https://savannah.gnu.org/bugs/?54332.
2018-07-20 19:12:36 +02:00
Devin Hussey
4a268678a5 syntax: sh: recognize more file extensions and header lines
Signed-off-by: Devin Hussey <husseydevin@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-07-20 19:12:20 +02:00
Benno Schulenberg
7c9a4793dd tweaks: properly escape "\" in a man page and "@" in a texi document
Also make the involved sentences more precise.
2018-07-19 20:17:27 +02:00
Benno Schulenberg
05592a84ec completion: when the cursor is not after a word fragment, say so
Instead of being entirely silent when ^] is hit after whitespace
or punctuation, report what is lacking -- similar to M-] saying
"Not a bracket" when the cursor is not sitting on a bracket.
This makes the ^] keystroke more discoverable.
2018-07-19 19:29:24 +02:00
Benno Schulenberg
c46696d40c tweaks: delete some old debugging code that no longer seems useful 2018-07-18 19:53:44 +02:00
Benno Schulenberg
bfe65af6f3 bindings: bind M-Q to 'findprevious' by default, and M-W to 'findnext'
This makes things symmetrical: ^W starts a forward search, ^Q starts
a backward search, M-W searches the next occurrence forward, and M-Q
searches the next occurrence backward.

The Tabs-To-Spaces toggle is moved to M-O, and thus the More-Space
toggle is no longer bound by default.
2018-07-18 19:18:45 +02:00
Benno Schulenberg
46f5d51fb5 input: fully consume modified PgUp and PgDn keys also in the tiny version
They should not enter a digit plus a squiggle into the buffer.
2018-07-17 18:28:55 +02:00
Benno Schulenberg
b99ec28a60 tweaks: recognize escape sequences of modified Ins/Del more precisely
The third character after the escape must be a semicolon.
2018-07-16 18:45:41 +02:00
Benno Schulenberg
b2acffe5be input: stop <Alt+Insert> from entering "3~" into the buffer 2018-07-16 18:45:21 +02:00
Benno Schulenberg
2fef7f647d input: stop a modified Delete key from entering stuff into the buffer
When using option -K on an xterm-like terminal, pressing <Shift+Del>,
<Alt+Del>, or <Ctrl+Del> would enter "2~", "3~", or "5~", respectively,
into the buffer.  Now it will just report an "Unknown sequence".
2018-07-15 09:22:55 +02:00
Benno Schulenberg
6d3b16b761 tweaks: close a temp file only when descriptor is valid [coverity scan] 2018-07-14 21:33:46 +02:00
Benno Schulenberg
89c0e7493f tweaks: don't call va_start() without calling va_end() [coverity scan] 2018-07-14 21:15:23 +02:00
Benno Schulenberg
14b9a42f5b tweaks: move a call to where it will be executed [coverity scan] 2018-07-14 21:02:32 +02:00
Benno Schulenberg
3227ba46d9 mouse: put the row/column arguments in the proper order [coverity scan]
(This one call was overlooked in commit f5c87a7f that changed the order.)

This makes clicking on the Yes/No/All/Cancel menu items work again.
2018-07-14 20:49:30 +02:00
Benno Schulenberg
d994af0334 tweaks: avoid dereferencing a pointer when it is NULL [coverity scan] 2018-07-14 20:02:03 +02:00
Benno Schulenberg
75c7c35cfd tweaks: use a shorter message, because when the screen is small... 2018-07-14 19:42:38 +02:00
Benno Schulenberg
eb84205426 bindings: rename two bindable functions: copytext to copy, uncut to paste
To match the common names used for these functions, for consistency,
and because 'uncut' sounds too much like "undo the cut".
2018-07-13 19:46:56 +02:00
Benno Schulenberg
c2593c1c5a docs: reshuffle a bindable function to a slightly better position 2018-07-13 19:46:56 +02:00
Benno Schulenberg
d92142c66a easter: show the crawl only when there is room enough for the lines
The crawl needs at least five rows to be perceived as a crawl, and
the widest line is 31 characters (ignoring translations, which might
be even longer).  Formerly, when only two or three rows were available,
nothing was shown at all, which was puzzling.  So, better do the credits
only when there is room enough for them, and print a message otherwise.
2018-07-13 19:45:15 +02:00
Benno Schulenberg
f598a4f12d files: add the file format on the status bar when switching buffers
Suggested-by: Brand Huntsman <alpha@qzx.com>
2018-07-13 11:15:48 +02:00
Benno Schulenberg
063a8b0870 startup: show the correct number of lines when opening multiple files
When switching to a different buffer, don't just show its name but
also the number of lines it contains.  This is useful extra info.

Then use this same message when at startup multiple files are opened
and (after reading them all) we switch back to the first buffer.

(This loses, when multiple files are opened, the information about
format conversion that nano still shows when a single file is opened,
but... this bug has shown that people don't really look at this line
anyway, so... let it be.  The info can still be seen when writing out
the file with ^O.)

This addresses https://savannah.gnu.org/bugs/?54047.
2018-07-13 09:37:04 +02:00
Benno Schulenberg
ecc9211afc input: ignore any <Escape>s before a valid command keystroke
Just like an <Esc> before a Ctrl+letter keystroke is ignored, an <Esc>
before an Alt+letter keystroke should be ignored too -- it should not
be interpreted as if the user had typed <Esc> <Esc> letter.

This fixes https://savannah.gnu.org/bugs/?54301.
2018-07-13 09:27:38 +02:00
Benno Schulenberg
ab0897072a input: consume the whole escape sequence for modified PgUp and PgDn keys
Even when we don't act on most of these combinations, at least eat up
the whole sequence so the unknown keystroke doesn't enter things like
"3~" into the buffer.

This fixes https://savannah.gnu.org/bugs/?54291.
2018-07-13 09:25:01 +02:00
Devin Hussey
b2ff574678 files: speed up reading by using getc_unlocked() instead of getc()
Unlike glibc, which in getc() locks the file only when it is needed,
FreeBSD and Bionic libc will always lock the file, causing a massive
slowdown, as the system has to create and destroy a mutex each time
getc() is called.

Avoid that massive overhead by locking the file before starting to read
and unlocking it after reading is complete, and using getc_unlocked() to
read each byte.  This makes reading on FreeBSD/macOS and Android anywhere
from 2 to 6 times faster, and on glibc roughly seventy percent faster.

This partially addresses https://savannah.gnu.org/bugs/?50406.

Signed-off-by: Devin Hussey <husseydevin@gmail.com>
2018-07-12 12:44:35 +02:00
Benno Schulenberg
3bac3c4c78 rcfile: reject things like "M-Del" and "^{" as invalid key names
This fixes https://savannah.gnu.org/bugs/?54274.
2018-07-11 14:42:10 +02:00
Benno Schulenberg
acadf71b13 syntax: nanorc: show ^@ as validly rebindable, but not any ^digit 2018-07-11 14:14:40 +02:00
David Lawrence Ramsey
4c02329205 docs: mention that "Ins" and "Del" are valid rebindable keys
Also, consistently refer to Latin letters and ASCII characters
where needed, and document more accepted characters.

This addresses https://savannah.gnu.org/bugs/?54071.
2018-07-11 14:10:35 +02:00
Benno Schulenberg
a31896011a tweaks: elide a one-line function -- no, a half-line function 2018-07-11 11:11:30 +02:00
Benno Schulenberg
769504c495 tweaks: rename a function, to better state what it does 2018-07-11 11:03:14 +02:00
Benno Schulenberg
18f13c3a75 tweaks: rename a variable, to better match its task
The 'statusbar_x' variable does not refer to a position in the status
bar, but to a position in the answer that is currently being typed at
the prompt.  So... let's call it 'typing_x', for lots of contrast.
2018-07-11 10:55:59 +02:00
Benno Schulenberg
aea54276b6 tweaks: rename a function and place its call better 2018-07-11 10:48:27 +02:00
Benno Schulenberg
0c455155ad prompt: concentrate manipulations of 'statusbar_x' into a single file 2018-07-11 10:45:58 +02:00
Benno Schulenberg
e6c6a72ee8 tweaks: remove some braces that are now superfluous
Also move a function to a better place: after the function that it calls.
2018-07-11 09:56:39 +02:00
Benno Schulenberg
4a853cf451 prompt: remove redundant redrawings of the prompt bar
The prompt bar is redrawn in acquire_an_answer() for every keystroke,
so there is no need to do this explicitly for some commands.
2018-07-11 09:49:00 +02:00
Benno Schulenberg
078265456c docs: mention that also Ctrl increases the stride when selecting text
The Alt key together with Shift is a special workaround for when
Shift+PgUp and Shift+PgDn don't work on the user's terminal.  But
probably it is more common to use the Ctrl key together with Shift
to select larger pieces of text.  So mention this possibility.
2018-07-10 15:58:41 +02:00
Benno Schulenberg
3ac821ee0c build: fix compilation when configured with --enable-tiny 2018-07-10 15:31:04 +02:00
Benno Schulenberg
ce0ecf67a6 tweaks: elide another function that is used just once 2018-07-10 13:57:05 +02:00
Benno Schulenberg
b6f7ff5c6f tweaks: normalize the indentation after the previous change
And remove two superfluous pairs of braces.
2018-07-10 13:55:51 +02:00
Benno Schulenberg
035b91cb15 chars: make the UTF-8 case ever so slightly faster by eliding an 'if'
And in the bargain get rid of some duplicate code.

This makes a binary without UTF-8 support slightly slower, but that's
not important -- it is more than fast enough anyway.  Important is that
the most used and longest code path, the UTF-8 case, becomes faster.

Note that 'is_cntrl_mbchar()' will fall back to 'is_cntrl_char()' for
a non-UTF-8 build, so the deleted piece of code really was equivalent
with the remaining piece for that case.
2018-07-10 12:22:11 +02:00
Benno Schulenberg
f456794045 tweaks: adjust two comments, to be more accurate and general 2018-07-08 17:40:19 +02:00
David Lawrence Ramsey
20971e8392 undo: position the cursor properly when undoing/redoing magicline cuts
Take our cue from undoing/redoing line joins: when they take place on
the magicline without --nonewlines, they produce undo/redo items that
don't do anything to the text, but still position the cursor properly.
Reshuffle a bit of code so that we can do the same for magicline cuts.

This fixes https://savannah.gnu.org/bugs/?54032.
2018-07-08 17:29:28 +02:00
Benno Schulenberg
fa454abb1c build: verify that 'msgfmt' is available when building from git
Fail during the configure phase when it is not,
instead of failing cryptically during 'make'.

This addresses https://savannah.gnu.org/bugs/?54265.
Reported-by: Peter Passchier <peter@passchier.net>
2018-07-08 14:13:25 +02:00
Benno Schulenberg
f2adefb158 tweaks: drop some old debugging code 2018-07-08 10:45:43 +02:00
Benno Schulenberg
7ae8f3bca4 tweaks: elide a function that is used just once 2018-07-08 10:40:22 +02:00
Benno Schulenberg
9a7ba5db79 chars: speed up the parsing of a character for the plain ASCII case
Again, if the most significant bit of a UTF-8 byte is zero, it means
the character is a single byte and we can skip the call of mblen(),
*and* if the character is one byte it also occupies just one column,
because all ASCII characters are single-column characters -- apart
from control codes.

This partially addresses https://savannah.gnu.org/bugs/?51491.
2018-06-04 14:07:43 +02:00
Benno Schulenberg
cc2b19c8fd chars: speed up the counting of string length for the plain ASCII case
For UTF-8, if the most significant bit of a byte is zero, it means the
character is just a single byte and we can skip the call of mblen().

For files consisting of pure ASCII bytes (between 0x00 and 0x7F), this
change reduces the counting time of mbstrlen() by ninety six percent.

This partially addresses https://savannah.gnu.org/bugs/?50406.
2018-06-03 20:07:04 +02:00
Benno Schulenberg
430d3bad7a debug: add some code to time the performance of get_totsize()
Don't activate this by passing --enable-debug.  Just remove the
relevant #ifdefs when you want to test the performance of changes
in the counting code.
2018-06-03 20:06:28 +02:00
Benno Schulenberg
4e667bd048 tweaks: reduce the counting of characters to just the needed function
Evade the indirect use of the general-purpose function parse_mbchar().
This reduces the counting time by roughly ten percent.
2018-06-03 17:58:05 +02:00
Benno Schulenberg
ba2e6f43c2 tweaks: elide a subfunction that is used just once
(Forgot to say: the previous two commits addressed
https://savannah.gnu.org/bugs/?54044.)
2018-06-03 17:47:02 +02:00
Benno Schulenberg
6c555828c9 tweaks: remove redundant braces and conditions after the previous change 2018-06-03 14:13:33 +02:00
Benno Schulenberg
0ff068380c tweaks: remove the superfluous calls that reset the mbtowc() state
When mbtowc() is never called with anything less than MAXCHARLEN as
the length parameter, it will apparently not get confused and will
not need to be reset.
2018-06-03 14:06:59 +02:00
Benno Schulenberg
fb372ed0a8 tweaks: remove two superfluous assignments
The variable 'last_action' is set at the end of these functions,
serving to prevent a fresh action from being merged with an older
action further down on the stack.  Setting 'last_action' before
exiting from undo()/redo() makes no sense.

Also adjust a sideways related old Changelog item.
2018-06-02 19:32:54 +02:00
Benno Schulenberg
ed433f6af0 tweaks: drop a condition that has been made redundant two commits ago 2018-06-02 18:17:31 +02:00
Benno Schulenberg
44814055b5 tweaks: correct a comment, rewrap a line, and drop some debugging stuff
An add can be contiguous even when the cursor has moved around in the
meantime but has returned to the same spot before more characters are
typed.
2018-06-02 18:04:36 +02:00
Benno Schulenberg
71f859377d cut: concentrate the logic for clearing the cutbuffer mostly in one place
It should not be the task of the undo code to take care that the
cutbuffer will be cleared at the right moments.
2018-06-02 17:57:19 +02:00
Benno Schulenberg
33d81fa1e6 build: add the release script to the repository 2018-06-02 11:18:04 +02:00
Benno Schulenberg
78dc7b8f0a po: update translations and regenerate POT file and PO files 2018-06-02 10:26:36 +02:00
Benno Schulenberg
1057ca7a16 bump version numbers and add a news item for the 2.9.8 release 2018-06-02 09:51:16 +02:00
Benno Schulenberg
5550d15418 tweaks: improve a couple of comments, and reshuffle a group of lines 2018-06-01 16:56:56 +02:00
Benno Schulenberg
54cab02030 docs: improve the description of --nonewlines, and properly sort it 2018-06-01 15:54:08 +02:00
Benno Schulenberg
2633114b8e docs: add a missing double quote in the default brackets string
It was accidentally lost three years ago, in commit 7e1bc82d.

Also improve the description of this option in the other documents.
2018-06-01 15:53:57 +02:00
Benno Schulenberg
2e1e157967 copyright: update the years for significantly changed files 2018-06-01 10:18:32 +02:00
Benno Schulenberg
6df30a634e docs: register Marco as the author of the filtering feature
The macro stuff, however, is basically my code: I told him exactly
how to do it, and I changed most of the patch before applying it.

Also, put myself in second place, as I've just about overtaken David
in the duration of maintainership.
2018-06-01 10:00:08 +02:00
Benno Schulenberg
856322b01e main: interpret only a double slash (//) as quoting, not a single one
Otherwise the first line of a multiline /*...*/-comment would be
seen as quoted and thus *not* as the first line of a paragraph.

In the code, use "/{2}" to prevent the remainder of the line
getting colored as a comment.
2018-06-01 09:21:03 +02:00
Benno Schulenberg
ad5d0f7530 wrapping: use "smart" autoindenting only when hard-wrapping is enabled
The paragraph-aware indenting is needed only when automatic long-line
wrapping is on (that is, when not using 'nowrap': when writing prose).
When writing code, the user most likely uses --nowrap, which will make
nano indent a new line always to the same amount as the preceding line
-- when --autoindent is in effect, of course.
2018-06-01 08:45:25 +02:00
Benno Schulenberg
0f2b0ffbd3 tweaks: reshuffle a condition, and adjust a comment and some indentation 2018-05-31 16:27:13 +02:00
Benno Schulenberg
f2f901c895 files: give feedback during writeout also when prepending or appending
The only time that feedback about the number of lines written is *not*
wanted is when writing a temporary file.

This fixes https://savannah.gnu.org/bugs/?54025.
2018-05-31 16:08:16 +02:00
Benno Schulenberg
a4e353799b docs: make quotes around regexes bold, as they are part of the command 2018-05-31 12:07:12 +02:00
Benno Schulenberg
64f28515fd docs: remove quotes around the name of a syntax -- they are not needed 2018-05-31 11:25:21 +02:00
Benno Schulenberg
b84dea9898 docs: improve description of 'speller' and related bindable functions 2018-05-30 20:38:27 +02:00
Benno Schulenberg
8492de53f7 syntax: makefile: color all keywords that GNU make recognizes
Plus one that automake recognizes: if.  Color them only at the start
of a line.  Also color all possible assignment sequences (surrounded
by spaces to not color the ones in shell fragments), and add some
comments.
2018-05-30 11:29:08 +02:00
Benno Schulenberg
a1dc1376be docs: describe what constitutes a paragraph
Also fix a typo.
2018-05-30 10:32:26 +02:00
Benno Schulenberg
6fe132194c docs: improve the description of the --autoindent option 2018-05-30 10:29:31 +02:00
Benno Schulenberg
0ea434b006 tweaks: reduce the abundance of the word 'toggle' in the Info manual 2018-05-30 10:01:45 +02:00
Benno Schulenberg
d430934f09 gnulib: update to its current upstream state 2018-05-29 11:08:55 +02:00
Benno Schulenberg
dc3261b685 tweaks: avoid a warning with --enable-{tiny,help,multibuffer}
This also places the Pipe toggle among the other, similar togglles,
which makes more sense.
2018-05-29 09:07:39 +02:00
David Lawrence Ramsey
dc4146f077 tweaks: avoid an unused variable warning with --enable-tiny
This fixes https://savannah.gnu.org/bugs/?53998.
2018-05-29 09:00:08 +02:00
Benno Schulenberg
59eb01b403 build: fix compilation with --enable-{tiny,help,multibuffer} 2018-05-28 11:31:30 +02:00
Benno Schulenberg
738487f13d tweaks: make better use of an existing variable 2018-05-28 10:39:47 +02:00
Benno Schulenberg
c8a9a96578 build: fix compilation when configured with --disable-justify 2018-05-28 09:57:24 +02:00
Benno Schulenberg
cd8e932c65 main: add "/" to the quoting regex, to allow justifying //-comments
And adjust the documentation accordingly.
2018-05-27 20:29:52 +02:00
David Lawrence Ramsey
fce54a724d tweaks: fix some grammar plus a typo in the comments 2018-05-27 20:19:46 +02:00
Benno Schulenberg
4ae1b99c92 docs: mark the filtering of text through an external command as done 2018-05-27 19:33:04 +02:00
Benno Schulenberg
ebdb647450 tweaks: adjust a translator hint 2018-05-27 17:53:36 +02:00
Benno Schulenberg
0c2aac5ff8 tweaks: reshuffle a couple of assignments 2018-05-27 17:45:51 +02:00
Benno Schulenberg
7952d68830 tweaks: frob a couple of comments 2018-05-27 17:27:07 +02:00
Benno Schulenberg
5cb4485fa5 tweaks: remove a superfluous assignment -- the lead length never changes 2018-05-27 17:16:04 +02:00
Benno Schulenberg
d7c1ab8e80 tweaks: rename two variables, to better fit their tasks 2018-05-27 17:11:18 +02:00
Benno Schulenberg
1881db099d tweaks: make better use of an intermediate variable 2018-05-27 16:41:55 +02:00
Benno Schulenberg
36c83d92dd tweaks: stop decreasing both the iterator and the limit of a loop 2018-05-27 16:34:20 +02:00
Benno Schulenberg
9021725d53 justification: limit the amount of recursion to prevent a stack overflow 2018-05-27 16:09:53 +02:00
Benno Schulenberg
d00ab406bc wrapping: when autoindenting, use indentation of next line as example
When doing autoindentation, and the next line is not the start of
a new paragraph, then use the indentation of that line for the new
line, as it is more likely to have the desired indentation -- the
current line might be the start of the paragraph and thus could
have a deviant indentation.
2018-05-27 16:09:53 +02:00
Benno Schulenberg
d63d79b067 tweaks: elide another function that is called just once 2018-05-27 16:09:53 +02:00
Benno Schulenberg
446c7d5fff tweaks: elide a function that is called just once 2018-05-27 16:09:53 +02:00
Benno Schulenberg
52efac535b tweaks: rename a variable, to give it some meaning 2018-05-27 16:09:53 +02:00
Benno Schulenberg
45c36f93e5 tweaks: simplify the determining of the prefix for justified lines 2018-05-27 16:09:53 +02:00
Benno Schulenberg
432a7d7729 justification: find the beginning of a paragraph in a better way
Any line whose indentation differs from that of a pair of adjacent lines
is the beginning of a paragraph, also when its indentation is smaller.

This fulfills https://savannah.gnu.org/bugs/?53932,
and fixes point 2) of https://savannah.gnu.org/bugs/?53933.
2018-05-27 16:09:53 +02:00
Benno Schulenberg
d7fe5a7db3 justification: recognize indented paragraphs also without --autoindent
Pico does not require any option to do this, so nano should neither.

This fixes point 1) of https://savannah.gnu.org/bugs/?53933.
2018-05-27 16:09:53 +02:00
David Lawrence Ramsey
a6c0212158 bindings: add the "flippipe" bindable function
So the toggle for piping to an external command can be rebound.

This fixes https://savannah.gnu.org/bugs/?53987.
2018-05-27 10:36:33 +02:00
Benno Schulenberg
a832f33291 justification: when leading whitespace exceeds fill width, wrap anyway
Pico wraps at the last blank character before or on the target column;
if there is no such blank, then it will wrap at the first blank *after*
the target column -- when it can wrap, it will wrap.  Nano should do
the same (and judging from the comments, it intended to do the same),
instead of turning the paragraph into a single unwrapped line.

This fixes https://savannah.gnu.org/bugs/?53986.
2018-05-27 10:24:02 +02:00
Benno Schulenberg
b9f533a69e tweaks: rename a function, for more aptness and extra contrast 2018-05-25 20:09:24 +02:00
Benno Schulenberg
ac31669ec3 linter: don't try to access absent stat info, as that gives a crash
This fixes https://savannah.gnu.org/bugs/?53981.
2018-05-25 19:25:11 +02:00
Benno Schulenberg
86c08560ad linter: make sure that the margin is updated before displaying a buffer
This fixes https://savannah.gnu.org/bugs/?53977.
Reported-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2018-05-25 17:58:25 +02:00
Benno Schulenberg
119a6f0de3 rcfile: don't crash when a bind to a string lacks the closing quote
This fixes https://savannah.gnu.org/bugs/?53972.
Reported-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2018-05-25 13:15:52 +02:00
Benno Schulenberg
3757683e3f build: fix compilation when configured with --disable-multibuffer 2018-05-24 21:09:14 +02:00
Benno Schulenberg
c07586d9f3 tweaks: condense some repetitious comments, and check before assigning
Check that the option argument is okay (contains no blank characters),
before assigning it to the relevant variable.
2018-05-24 20:49:29 +02:00
Benno Schulenberg
3e9ef3032f tweaks: use a more meaningful variable name, and avoid a distant 'else'
Also, indent a continuation line better.
2018-05-24 19:40:52 +02:00
Benno Schulenberg
6fb1509817 tweaks: condense two statements into one, and elide a 'break' 2018-05-24 18:17:58 +02:00
Benno Schulenberg
07ddf25cc0 tweaks: exclude an unneeded 'if' from the single-buffer version 2018-05-24 18:14:35 +02:00
Marco Diego Aurélio Mesquita
73d397c64b linter: check all open buffers, instead of just the next one
First step to the next buffer, and then iterate until we either
find a match or are back at the buffer where we started.

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

Signed-off-by: Marco Diego Aurélio Mesquita <address@hidden>
2018-05-24 18:10:52 +02:00
Benno Schulenberg
e0c7ff2a7e linter: make sure the shortcuts bar will redrawn when exiting early
The two help lines will be redrawn in main() only when the current
menu is not MMAIN.  So, set it to MLINTER as soon as the help lines
are cleared, just before preparing to invoke the linter.

This fixes https://savannah.gnu.org/bugs/?53967.
Reported-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2018-05-24 11:37:14 +02:00
Benno Schulenberg
84f8df2df8 tweaks: avoid an unused-variable warning with --enable-tiny 2018-05-23 12:00:43 +02:00
Benno Schulenberg
408d9b8708 build: fix compilation failure when configured with --enable-tiny 2018-05-23 11:57:55 +02:00
Brand Huntsman
b5427ebb98 tweaks: avoid two unused variable warnings when NLS is disabled
Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-05-23 11:54:45 +02:00
Cristian Caloghera
22663f8a2e syntax: makefile: recognize also an all-lowercase makefile name
Recognize not just "Makefile" but also "makefile" and "GNUmakefile".
And recognize these only when they are the full filenames, not when
they are the tail part of a longer name.

Signed-off-by: Cristian Caloghera <cristi.caloghera@gmail.com>
2018-05-22 20:41:43 +02:00
Benno Schulenberg
5d02ee64b6 filtering: pair the cut and the insert, so they can be undone together
When executing a command in the current buffer and piping this buffer
(or marked region) to that command, then the cutting of the existing
text and the insertion of the new text should be undone and redone
together, as to the user they appear as a single operation.

With-help-from: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2018-05-22 19:36:21 +02:00
Benno Schulenberg
5ffd8d96ae tweaks: rename a variable, for contrast, and improve two comments 2018-05-22 19:36:21 +02:00
Marco Diego Aurélio Mesquita
f304b9aee1 new feature: allow piping (selected) text to an external command
When executing a command, it is now possible to pipe the entire buffer
(or the marked region, if anything is marked) to the external command.
The output from the command replaces the buffer (or the marked region),
or goes to a new buffer.

This fulfills https://savannah.gnu.org/bugs/?28993,
and fulfills https://savannah.gnu.org/bugs/?53041.

Signed-off-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-05-22 19:36:21 +02:00
Benno Schulenberg
299e710845 docs, usage: make it clear that the argument of --quotestr is a regex
In the past, the argument could be either a regex or a literal string,
so the wording was kind of vague.  But nowadays we can count on having
regex support (through gnulib), so be more precise in the description.
2018-05-22 18:45:58 +02:00
Benno Schulenberg
d9ba6c10d2 tweaks: give some continuation lines a more obvious indentation
Also, put a translator hint in a better place: not in the middle
of a function call.
2018-05-22 18:07:50 +02:00
Benno Schulenberg
03c184d7f2 tweaks: condense a comment, and elide an unneeded 'if' 2018-05-22 18:01:15 +02:00
Benno Schulenberg
4ec19847a3 startup: provide a hint for people unfamiliar with the ^char convention
But give this hint only when nano was started without any file arguments.
2018-05-22 11:53:17 +02:00
Benno Schulenberg
3628863f90 docs: remove mention of the quotestr for when regex support is lacking
Since version 2.8.0, nano will use (wnen needed) the regex routines
from gnulib, so mentioning the quotestr for when regex support is
lacking, has been obsolete and pointless for more than a year.

Also, remove some superfluous backslashes, use a non-breaking space
in the texinfo document, and order the regex consistently.
2018-05-21 20:08:19 +02:00
Benno Schulenberg
9d6621afd0 tweaks: remove two superfluous checks, after making one of them so 2018-05-21 09:44:06 +02:00
Benno Schulenberg
cdd637d69f syntaxes: condense and/or correct some extension regexes 2018-05-18 20:40:08 +02:00
Benno Schulenberg
4d232a4aef tweaks: frob some comments, and rename two parameters to make sense 2018-05-18 13:24:07 +02:00
Benno Schulenberg
455899fe27 credits: sort the names roughly according to amount of influence
And spell-fix a name.
2018-05-16 12:05:40 +02:00
Benno Schulenberg
6aef1fa905 docs: thank Kamil for his bug fixes, and update an email address 2018-05-16 09:57:02 +02:00
Benno Schulenberg
06c3e1acde po: update translations and regenerate POT file and PO files 2018-05-15 09:14:23 +02:00
Benno Schulenberg
09d8ee82b7 bump version numbers and add a news item for the 2.9.7 release 2018-05-15 08:48:00 +02:00
Benno Schulenberg
dac3b25d16 docs: note a small difference with Pico in the default hard-wrapping 2018-05-14 12:10:38 +02:00
Benno Schulenberg
ca538e6f08 scrolling: only do a scroll when the edit window has more than one row
If the edit window consists of a single row, then the do_up() call has
already brought the desired line into view -- which means that trying
to scroll then (when already on the first line of the file) would fail.

This fixes https://savannah.gnu.org/bugs/?53891.
2018-05-13 19:31:57 +02:00
Benno Schulenberg
4b26308b6a tweaks: put Yes/No/All in a consistent order (for the translators)
So that it matches the order of the preceding Yy/Nn/Aa.
2018-05-13 09:57:49 +02:00
Benno Schulenberg
f5eeb92f40 tweaks: sort an option better, and reschedule a removal 2018-05-13 09:47:40 +02:00
Benno Schulenberg
ae1ba5e259 tweaks: put check for -h and -l options in their alphabetical positions
And put the Pico-compatibility flags last, as normally they are never
given.
2018-05-12 19:56:37 +02:00
Benno Schulenberg
cecf453b14 tweaks: use symbolic names instead of puzzling TRUE and FALSE 2018-05-10 18:19:12 +02:00
Benno Schulenberg
c3a02f8094 tweaks: rename two variables, to be more descriptive 2018-05-10 18:11:35 +02:00
Benno Schulenberg
87283711ee tweaks: improve a couple of comments 2018-05-10 18:10:23 +02:00
Benno Schulenberg
123f77ff1a docs: say thanks to three recent translators, and re-sort two others 2018-05-10 15:17:04 +02:00
Benno Schulenberg
10c49edd3b prompt: when asking for Yes/No/All, recognize also UTF-8 letters
Letters in other scripts than English often consist of multiple bytes.
When in a UTF-8 locale, correctly gather these bytes from the input and
put them together as the single letter that they are, before comparing
this letter against the translated "Yy", "Nn" and "Aa" strings.
2018-05-10 12:29:08 +02:00
Benno Schulenberg
2d5c917b1a signals: exclude the crash handler from the tiny version
The tiny version contains much less code, so is less likely
to crash.  And the users most likely use it for very simple
and short editing jobs, making the chance of a crash still
smaller.  So the handler would just be bloat.
2018-05-10 12:21:53 +02:00
Benno Schulenberg
95002da66c tweaks: normalize indentation and whitespace after previous changes 2018-05-10 11:33:24 +02:00
Mark-Weston
858663444e new feature: an option to make the 'nextword' function stop at word ends
When 'afterends' is set and Ctrl+Right or Shift+Ctrl+Right is pressed,
nano will stop at the ends of words instead of their beginnings.

Signed-off-by: Mark-Weston <markweston@cock.li>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-05-10 11:32:01 +02:00
Benno Schulenberg
4046dfca63 docs: break down some old improvements further per version 2018-05-09 11:55:16 +02:00
Benno Schulenberg
c0b15c2982 signals: don't trap segfault/abort when envvar NANO_NOCATCH is defined
When the user wants to get a backtrace, the crash handler shouldn't
kick in.
2018-05-09 11:53:34 +02:00
Devin Hussey
e889c28a95 signals: upon a crash, save changed buffers and reset terminal state
Upon a segmentation fault or an abort signal, instead of crashing,
losing all changes, and leaving the terminal in curses mode, nano
now calls die(), to save any changed buffers and to restore the
terminal to a usable state.

For the remote chance that nano segfaults in die(), the handler for
SIGSEGV and for SIGABRT is reset to its default value as soon as the
signal fires, to prevent a crash-handler loop.

Since a core dump is usually more helpful for debugging, the crash
handler is not included in a debug build.

This addresses https://savannah.gnu.org/patch/?9623.

Signed-off-by: Devin Hussey <husseydevin@gmail.com>
2018-05-06 16:36:25 +02:00
Benno Schulenberg
0da554e6d7 startup: suggest using ^D to finish reading from standard input
Also, add a period after the "Read nn lines" message, and
don't let the next shell prompt overwrite this message.

This addresses https://savannah.gnu.org/bugs/?53779.
2018-05-01 11:15:19 +02:00
Benno Schulenberg
f1530c7ba0 docs: add notes about deprecated options and function names
Also remove two notes that are obsolete by now.
2018-04-30 15:28:47 +02:00
Benno Schulenberg
0e46c0f4a5 main: clear a spurious error number, to avoid irrelevant messages later
This addresses https://savannah.gnu.org/bugs/?53777.
2018-04-29 12:08:42 +02:00
Benno Schulenberg
6a064503e5 docs: slightly improve the description of the file browser in the manual 2018-04-28 12:34:39 +02:00
Benno Schulenberg
4d92dffb3a bindings: rename constupdate to constantshow, cuttoend to cutfromcursor
This makes the names of these bindable functions equal to the names of
their corresponding options -- like for all the other toggles that have
a corresponding option.
2018-04-28 12:01:23 +02:00
Benno Schulenberg
4c1c425bbb bindings: add the 'linenumbers' bindable function
This makes the line-numbers toggle rebindable, like all the others.
2018-04-28 11:44:53 +02:00
Benno Schulenberg
21a54a3cf6 syntax: po: highlight also other escaped characters, not just \n 2018-04-27 11:17:12 +02:00
Benno Schulenberg
a0147c5a72 bump version numbers and add a news item for the 2.9.6 release 2018-04-27 10:56:10 +02:00
Benno Schulenberg
553940760e tweaks: set the correct flags just once for each spell-fixing session 2018-04-25 17:27:15 +02:00
Benno Schulenberg
faa0eb991e speller: don't add an extra newline when saving the text to a tempfile
Set the NO_NEWLINES flag to achieve this.  And move the saving and
restoring of the global flags to the main speller routine, so the
flags aren't saved and restored for each internal spell fix.

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

Acked-by: David Lawrence Ramsey <pooka109@gmail.com>
2018-04-25 17:26:14 +02:00
Benno Schulenberg
f54cd02652 tweaks: adjust the translator hint about Yes/No/All
There is no longer any need to burden the translators with also
providing the English letters.
2018-04-25 17:14:33 +02:00
Benno Schulenberg
6dd308d0fb prompt: recognize Yes/No/All in English when the locale gives no match 2018-04-25 17:03:13 +02:00
Benno Schulenberg
4872f42cd2 tweaks: rename a function, to be more distinct from its caller 2018-04-25 12:21:40 +02:00
Benno Schulenberg
62007c84c6 tweaks: invert two conditions and reshuffle, to reduce duplication 2018-04-24 13:27:57 +02:00
Benno Schulenberg
d0f37205af search: always go forward by default, also when coming from Goto-Line
This fixes https://savannah.gnu.org/bugs/?53735.
2018-04-24 13:13:38 +02:00
Benno Schulenberg
f05874ea23 gnulib: update to its current upstream state 2018-04-24 10:02:04 +02:00
Benno Schulenberg
0d9080a22c scrolling: don't redraw entire edit window when cursor goes offscreen
When the cursor is on the top or bottom line of the edit window, and
an <Up> or <Down> pushes the cursor offscreen, then use edit_scroll()
to bring it back into view, instead of using edit_redraw(), because
the latter would redraw *every row* on the screen, which is a waste
of time.

This addresses https://savannah.gnu.org/bugs/?53562.
Reported-by: Devin Hussey <husseydevin@gmail.com>
2018-04-24 09:59:39 +02:00
Benno Schulenberg
1ae90e205a command-execution: do not crash when opening the pipe would fail
This fixes https://savannah.gnu.org/bugs/?53723.
2018-04-23 18:04:25 +02:00
Benno Schulenberg
d53086d38d completion: correctly do a signed comparison, to avoid a segfault
Bug existed since commit 30fc197b (a month ago) which changed the
type of 'i' from int to size_t, causing the comparison to do the
wrong thing when 'threshold' is negative.

This fixes https://savannah.gnu.org/bugs/?53722.
Reported-by: Devin Hussey <husseydevin@gmail.com>
2018-04-23 17:09:54 +02:00
Benno Schulenberg
0b6bb37c56 tweaks: improve some comments, and exit with nonzero status upon error 2018-04-23 14:04:08 +02:00
Benno Schulenberg
c43a6fdcc1 tweaks: rename a variable, to match another and to be more visible 2018-04-23 13:04:31 +02:00
Benno Schulenberg
0c613cb1ac tweaks: rename a variable, to be more clear and to match another 2018-04-23 12:57:58 +02:00
Benno Schulenberg
1e5064ef84 tweaks: fix a typo, remove a blank line, and improve some comments 2018-04-23 12:19:25 +02:00
Benno Schulenberg
5b40bad629 files: prevent a hang when a call to sigaction() would fail
Don't try to re-enter curses mode when the terminal is not in
the correct state yet.

This fixes https://savannah.gnu.org/bugs/?53720.
2018-04-23 11:58:18 +02:00
Benno Schulenberg
45f8fc77e0 tweaks: rename a variable, to be a bit more fitting 2018-04-22 12:05:19 +02:00
Benno Schulenberg
94347f0811 memory: use a reallocation to reduce the amount of leakage 2018-04-22 12:00:26 +02:00
Benno Schulenberg
1a4a3de68b formatting, linting: redetermine the argument list for every run
The formatter or linter might have changed in the meantime -- when
the filename was changed to have a different extension, for example.

This fixes https://savannah.gnu.org/bugs/?53716.
2018-04-22 11:44:07 +02:00
Benno Schulenberg
bf8bd02558 build: do not prefix an alternative rcfilename with a dot
When the user configures nano with --enable-altrcname=name,
the specified name should not be prefixed with a dot.

This fixes https://savannah.gnu.org/bugs/?53694.
Reported-by: Cody A. Taylor <codemister99@yahoo.com>
2018-04-21 10:03:30 +02:00
Benno Schulenberg
544d426d86 tweaks: group some more of the empty functions together 2018-04-17 10:34:57 +02:00
Benno Schulenberg
30a984661b syntax: po: highlight also other escaped characters, not just \n
Especially color \a and \t, to make it easier to distinguish them
from contiguous text.
2018-04-17 09:56:19 +02:00
Benno Schulenberg
7ab8a4d835 tweaks: improve the ordering of a couple of functions 2018-04-13 21:09:44 +02:00
Benno Schulenberg
0353a24400 tweaks: rearrange a few if statements more symmetrically 2018-04-13 20:43:08 +02:00
Benno Schulenberg
d4304ca88c search: use a better value to mean "nothing was typed"
When the keyboard buffer is empty, return a value that is not equivalent
to <Ctrl+Space>, so that typing a bunch of these while searching is going
on will not result in some of them getting executed afterward.
2018-04-13 20:13:05 +02:00
Benno Schulenberg
02d8da3bdd tweaks: rename a function, to be more fitting and descriptive
It is not an abort but simply a bit of cleaning up.
2018-04-13 10:32:29 +02:00
Benno Schulenberg
7a09b655c1 tweaks: rename a variable, for clarity 2018-04-13 10:22:39 +02:00
Benno Schulenberg
c8b26baee8 tweaks: elide a function that is called just once
Also adjust and correct a comment.
2018-04-13 10:17:08 +02:00
Liu Hao
bb394990cd replacing: always clear the backwards flag for ^\, just like for ^W
This makes it easier to predict in which direction the replacements
will go when hitting ^\ or M-R.

Signed-off-by: Liu Hao <lh_mouse@126.com>
2018-04-12 20:32:15 +02:00
Benno Schulenberg
7c5d099c6f tweaks: frob a couple of comments 2018-04-01 21:07:18 +02:00
Benno Schulenberg
152cc24d1f tweaks: reshuffle two declarations 2018-04-01 20:08:57 +02:00
Benno Schulenberg
8965103a4d tweaks: remove the group handling for undoing/redoing (un)indents
Indenting/unindenting always happens in a single contiguous block.
Lines that cannot or should not be indented or unindented do not
need to remembered separately as it follows from their content.
2018-04-01 11:41:26 +02:00
Benno Schulenberg
d0d293b8af tweaks: correct or improve a couple of comments 2018-04-01 11:24:44 +02:00
Benno Schulenberg
839743fd24 tweaks: move a function to its proper location 2018-04-01 10:54:14 +02:00
Benno Schulenberg
0b30835dd0 tweaks: use meaningful names instead of puzzling values
Suggested-by: Brand Huntsman <alpha@qzx.com>
2018-04-01 09:49:58 +02:00
Benno Schulenberg
a865c25eea build: fix compilation when configured with --disable-help
This fixes https://savannah.gnu.org/bugs/?53532.
2018-03-31 16:52:22 +02:00
Benno Schulenberg
cf1129a8b4 syntax: sh: colorize options only when they are preceded by whitespace
To prevent any filenames containing hyphens getting partially colored.

Reported-by: Brand Huntsman <alpha@qzx.com>
2018-03-30 10:46:56 +02:00
Benno Schulenberg
0cd833e64b tweaks: move a function to its proper location
Put it after the function that it calls, and before the functions
it is called from.
2018-03-30 10:34:40 +02:00
Benno Schulenberg
cbf226476d rcfile: skip color commands where some color name is invalid
That is, do not fall back to the default background color when the
name for the background color is invalid, but reject the entire
color command, just like for an invalid foreground color.
2018-03-30 10:30:55 +02:00
Benno Schulenberg
9fcfee18e8 po: update translations and regenerate POT file and PO files 2018-03-29 10:17:00 +02:00
Benno Schulenberg
27eccbec23 bump version numbers and add a news item for the 2.9.5 release 2018-03-29 09:59:13 +02:00
Benno Schulenberg
0bce5ba4d9 syntax: sh: color options distinctively, and color also long options
Also add some comments, and accept hyphens in function names.
2018-03-29 09:51:39 +02:00
Benno Schulenberg
f9415e347a docs: clarify how the Linux console is deficient: in the arrow keys 2018-03-28 19:34:26 +02:00
Benno Schulenberg
f3c4dadcf6 build: fix compilation with --enable-{tiny,help,multibuffer} 2018-03-28 16:37:47 +02:00
Benno Schulenberg
20d1823d90 syntax: sh: uncolor "tar" when it's part of a filename 2018-03-28 14:04:00 +02:00
Benno Schulenberg
e01bcddf16 docs: document the newly added color name "normal" 2018-03-28 14:03:52 +02:00
Benno Schulenberg
570fb6c606 small addition: understand color name "normal" to mean the default color
This allows a syntax to remove the color from things that were colored
overeagerly by earlier regexes.
2018-03-28 14:03:22 +02:00
Benno Schulenberg
1de3667555 syntax: sh: color also the 'cut', 'head', 'tail', and 'sort' commands 2018-03-27 14:09:38 +02:00
Benno Schulenberg
5726514869 linting: drop messages for other files when configured for one buffer
This fixes https://savannah.gnu.org/bugs/?53445.
2018-03-26 08:56:03 +02:00
Benno Schulenberg
88234c90bc tweaks: adjust the indentation after the previous changes 2018-03-26 08:53:06 +02:00
Benno Schulenberg
02719ec4bf tweaks: fuse two ifs into one 2018-03-26 08:52:51 +02:00
Benno Schulenberg
415bf82690 tweaks: move an 'if' and then remove an unneeded label 2018-03-26 08:52:04 +02:00
Benno Schulenberg
9bce8bfeb3 build: fix compilation when configured with --disable-multibuffer 2018-03-23 19:14:56 +01:00
Benno Schulenberg
2c024a74a9 tweaks: adjust or correct some comments, and rename a function
Also, reshuffle a condition so it takes up less space.
2018-03-23 17:54:06 +01:00
Benno Schulenberg
ab8698df47 tweaks: condense some code, to remove a bit of duplication 2018-03-23 17:14:39 +01:00
Benno Schulenberg
206d89b739 tweaks: revert commit c88a2fd9 -- the extra variable is needed
This variable will be modified by go_forward_chunks(), but the value
of openfile->current itself should be maintained.
2018-03-23 11:31:08 +01:00
Benno Schulenberg
eff2e0e291 help: describe the Scroll-Up and Scroll-Down commands more precisely
An "if possible" would have been nice, but there is no room for that.
2018-03-23 11:10:19 +01:00
Benno Schulenberg
c5e20164c3 tweaks: rewrap and amend some lines in the NEWS file 2018-03-23 11:09:59 +01:00
Benno Schulenberg
0f1f53a441 tweaks: drop a handful of unhelpful asserts 2018-03-23 11:09:56 +01:00
Benno Schulenberg
bf1a080923 build: exclude more things when configured with --disable-multibuffer
This will make the tiny version slightly smaller.
2018-03-23 11:09:37 +01:00
Benno Schulenberg
b7f8d4819b tweaks: frob some comments plus miscellaneous other stuff 2018-03-22 19:54:20 +01:00
Benno Schulenberg
30fc197b66 tweaks: adjust a couple of types, to reduce the number of warnings
This avoids eleven warnings of the kind "comparison between signed
and unsigned integer expressions [-Wsign-compare]".
2018-03-22 19:33:22 +01:00
Benno Schulenberg
c88a2fd9ca tweaks: elide an unneeded and shadowing variable 2018-03-22 15:20:05 +01:00
Benno Schulenberg
b9de5525c4 tweaks: elide a parameter, as it's always the inverse of another 2018-03-22 12:52:28 +01:00
Benno Schulenberg
f4d1ef1c4e tweaks: remove unneeded settings and unsettings of MULTIBUFFER
In the preceding commit, open_buffer() was changed so that it gets
told whether to load into a new buffer or not, so it is no longer
needed to convey this information through a flag.
2018-03-22 12:50:48 +01:00
Benno Schulenberg
dd157f1494 tweaks: change a parameter of open_buffer() and invert its logic 2018-03-22 12:35:50 +01:00
Benno Schulenberg
624918800b tweaks: bundle some settings for a new buffer 2018-03-22 12:27:04 +01:00
Benno Schulenberg
8b8c6bb818 tweaks: factor out the check for 'viewok' into its own function
And also prevent a theoretical crash for restricted prompt functions.
2018-03-20 20:10:08 +01:00
Kamil Dudka
b830a7dd38 input: do not crash if sctofunc() returns NULL
This fixes a regression introduced by commit 54103d8e: a crash that
can be triggered by running 'nano --restrict' and pressing <Insert>.

This addresses https://bugzilla.redhat.com/1558532.
2018-03-20 19:36:55 +01:00
Benno Schulenberg
3e5b0ea5fd files: prevent an infinite loop when reading from standard input fails 2018-03-20 11:25:16 +01:00
Benno Schulenberg
a1132c81a1 files: prevent the undo of reading a file into a new buffer
When the file has just been read, it is in the state that it has
on disk, so there is nothing to undo.

This fixes https://savannah.gnu.org/bugs/?53387.
2018-03-20 11:14:55 +01:00
Liu Hao
0496aed4ab build: fix compilation error when configured with --disable-justify
Signed-off-by: Liu Hao <lh_mouse@126.com>
2018-03-19 13:39:15 +01:00
Benno Schulenberg
373e3b880f scrolling: first move the cursor before pushing current chunk offscreen
When the cursor is on the first or last row of the edit window, and
thus Scroll-Down or Scroll-Up would push it offscreen, first move
the cursor away from the edge row and then scroll.

This fixes https://savannah.gnu.org/bugs/?53376.
2018-03-18 20:06:29 +01:00
David Lawrence Ramsey
7b1f3f4fe7 tweaks: correct several parameter types
This avoids a bunch of warnings when compiled with -pedantic:

	ISO C forbids comparison of ‘void *’ with function pointer
2018-03-18 20:01:25 +01:00
Benno Schulenberg
9517972b58 build: fix compilation again when configured with --enable-tiny 2018-03-18 16:33:21 +01:00
Benno Schulenberg
95989e7dfe selecting: don't cancel a softmark when just scrolling the screen
As, since commit 0e30177d, the scrollup and scrolldown commands
no longer intend to move the cursor, they should not be seen as
movement functions.

Also, it is not guaranteed that functions are ordered in the same
way in the binary as in the source code, so an ordered comparison
of function pointers will not always work.

This fixes https://savannah.gnu.org/bugs/?53333.
2018-03-18 13:55:29 +01:00
Benno Schulenberg
dcda98fb73 tweaks: remove an inconsistent space from two pointer declarations
Reported-by: Brand Huntsman <alpha@qzx.com>
2018-03-17 15:53:22 +01:00
Benno Schulenberg
336fa40055 docs: clarify what the scrollup and scrolldown bindable functions do 2018-03-17 14:27:23 +01:00
Benno Schulenberg
93318b972d tweaks: elide two parameters and thus a pair of wrapper functions
When just scrolling and the cursor does not need to change position
(that is: it is not on the first or last row of the edit window),
then edit_scroll() has handled everything and there is no need to
additionally redraw anything or update 'placewewant'.
2018-03-17 14:07:42 +01:00
Benno Schulenberg
8656f160d7 tweaks: reshuffle some movement code, to reduce the number of conditions
Also, rename a parameter and invert its logic.
2018-03-17 14:02:55 +01:00
Benno Schulenberg
0e30177db7 scrolling: let Scroll-Up/Down keep the cursor in the same text position
Instead of keeping the cursor in the same spot on the screen,
let the cursor move with the text (whenever possible).

This makes these functions behave the same as in Vim and Emacs.
2018-03-17 14:00:00 +01:00
Benno Schulenberg
3089a98169 tweaks: fix a typo and adjust some wording and formatting in the FAQ 2018-03-12 11:43:43 +01:00
Benno Schulenberg
1b704e7c8c tweaks: reduce the font size of the questions in the FAQ
Make them smaller to make them sound less like shouting.
2018-03-12 11:25:03 +01:00
Benno Schulenberg
efb9192ee5 docs: mention in the FAQ that <Shift+Insert> pastes from the clipboard
This kind of addresses https://savannah.gnu.org/bugs/?53310.
2018-03-12 11:21:26 +01:00
Benno Schulenberg
f0734dae3e cut: avoid calling renumber() on what might be NULL
This fixes https://savannah.gnu.org/bugs/?53317.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2018-03-12 10:46:02 +01:00
Benno Schulenberg
e8505b2d3e memory: plug a leak, by actually freeing a discarded undo struct
This fixes https://savannah.gnu.org/bugs/?53269.
Reported-by: Ashish Kunwar <dorkerdevil280@gmail.com>

The leak was mistakenly introduced by commit dc3618a1
-- probably as a leftover of testing things.
2018-03-11 20:16:09 +01:00
Benno Schulenberg
1ebb1da382 tweaks: elide a parameter that is always 1
And adjust the comments accordingly.
2018-03-10 12:43:33 +01:00
Benno Schulenberg
1fb3218a14 help: do not reserve space for line numbers, as they are absent
Help texts are shown without any line numbers, so the full width
of the screen should be used to display the text.

This fixes https://savannah.gnu.org/bugs/?53308.
2018-03-09 12:03:48 +01:00
Benno Schulenberg
a7b1f0f03f po: update translations and regenerate POT file and PO files 2018-03-08 11:11:05 +01:00
Benno Schulenberg
c782b4cb72 bump version numbers and add a news item for the 2.9.4 release 2018-03-08 10:59:32 +01:00
Benno Schulenberg
5234475781 gnulib: update to its current upstream state 2018-03-06 12:07:30 +01:00
Benno Schulenberg
80605c3918 tweaks: exclude an unlikely warning from the tiny version 2018-03-06 12:05:52 +01:00
Benno Schulenberg
d3012be095 tweaks: don't call strcmp() to determine whether a string is empty 2018-03-06 11:59:03 +01:00
Brand Huntsman
03bc19fd0c color: remove unneeded bright comparision to prevent duplicate pairs
Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-03-05 20:03:03 +01:00
Benno Schulenberg
e4cef3086b tweaks: drop an assert, add a warning, and change a 'for' to a 'while' 2018-03-05 12:46:25 +01:00
Benno Schulenberg
9936a6357a tweaks: rename a parameter and a variable, to be more fitting 2018-03-05 12:46:25 +01:00
Benno Schulenberg
899bf0ae3a tweaks: exclude an unlikely error message from the tiny version 2018-03-05 12:45:19 +01:00
Benno Schulenberg
1f7384ebd2 tweaks: appease valgrind concerning syscalls with uninitialized values 2018-03-05 11:02:52 +01:00
Benno Schulenberg
95fffa99aa tweaks: adjust two comments, move two declarations, rewrap three lines 2018-03-05 10:43:05 +01:00
Benno Schulenberg
22f7861694 tweaks: reshuffle the undo types into mostly the same order everywhere
First the two that add something (ADD, ENTER), then the three that
delete something (BACK, DEL, JOIN), and then the one that changes
something (REPLACE).  Then the SPLITs, CUT, PASTE, and INSERT, and
then the INDENTs and COMMENTs, when they exist.
2018-03-05 10:05:07 +01:00
Benno Schulenberg
ba96d507dd tweaks: drop some debugging stuff, and adjust what remains of it 2018-03-05 09:42:57 +01:00
Benno Schulenberg
9bf57e5ca0 tweaks: do not needlessly renumber the lines in the buffer
For cuts, pastes, and inserts, the lines have already been renumbered;
for indents, comments, and replacements, the line numbers cannot have
changed.  (And anyway, variable 'f' is not set for those cases.)

Only when lines get split (ENTER) or fused together (JOIN) do the later
lines need to be renumbered.  This mirrors what is done for do_redo().
2018-03-04 10:27:07 +01:00
Benno Schulenberg
f9103a5cb5 tweaks: make the fsfromline() call only for the undo types that need it
The 'f' variable is used only in the ADD, BACK, DEL, ENTER, JOIN, and
REPLACE undo/redo cases.  So, avoid making a somewhat costly call when
it is entirely superfluous.  Rearrange the undo types to make checking
for the above six types easier.
2018-03-03 17:12:25 +01:00
Benno Schulenberg
e9eabdcdcb undo: when redoing, don't try to find a line number that might not exist
This fixes https://savannah.gnu.org/bugs/?53272.
2018-03-03 16:41:33 +01:00
Benno Schulenberg
a1be8b6a19 tweaks: condense a comment and elide an 'if' 2018-03-01 11:18:56 +01:00
Benno Schulenberg
de4fbadf20 tweaks: reshuffle some code, to be slightly less ugly 2018-03-01 11:08:13 +01:00
Benno Schulenberg
bdd8920081 bindings: make a key defined as string work also in browser and viewer 2018-03-01 10:55:04 +01:00
Benno Schulenberg
ae9ec6d4ad syntax: nanorc: color also bindings to a string as valid 2018-03-01 10:09:28 +01:00
Benno Schulenberg
8f1a657a37 bindings: revert the ^/ changes, as ^/ is not always Go-To-Line
On a Linux console, ^/ produces Backspace, making it unrebindable.

This fixes https://savannah.gnu.org/bugs/?53248.
2018-03-01 09:50:54 +01:00
Benno Schulenberg
7f88eff96f docs: mention that a key can be bound to a string 2018-02-28 17:28:16 +01:00
Benno Schulenberg
3b8c898880 help: tweak the descriptions of ^X and ^R
It is not a problem to say that ^X closes the current buffer
even when nano is compiled without multibuffer support.
2018-02-27 18:11:16 +01:00
Benno Schulenberg
6f4f1878fc selecting: cancel the softmark upon any attempt to move the cursor
This assumes that all movement functions are located together,
starting with to_first_line() and ending with do_right().

This fixes https://savannah.gnu.org/bugs/?53195.
Reported-by: Brand Huntsman <alpha@qzx.com>
2018-02-27 18:09:00 +01:00
Benno Schulenberg
082e5db4b7 syntax: color also ^/ in nano's help texts and in nanorc files
As of commit c79fe1a1, the more readable ^/ has replaced ^_ as the
advertised shortcut for Go-To-Line -- color it too as valid.
2018-02-27 18:06:33 +01:00
Benno Schulenberg
5eccaa7633 tweaks: refactor the implanting of a key expansion 2018-02-27 13:34:32 +01:00
Benno Schulenberg
d9ac785a07 input: handle the implant() function separately also for the prompt
To prevent getting kicked out of it.

This fixes https://savannah.gnu.org/bugs/?53234.
2018-02-27 13:20:27 +01:00
Benno Schulenberg
01457ae3d3 input: handle the implant() function separately, as it is special
The implant() function itself cannot be bound to anything, so it
is not in the linked list of functions -- trying to find it would
lead to a NULL pointer, and thus to a segfault.

This fixes https://savannah.gnu.org/bugs/?53233.
2018-02-27 11:11:02 +01:00
Benno Schulenberg
c757aee235 tweaks: correct a typo that broke binding a key to a string
Commit 0cf455bc introduced the typo.
2018-02-27 10:28:52 +01:00
Benno Schulenberg
48749a9500 docs: note also in the Info manual that text can be selected with Shift
And remove a detail that is untrue when 'set selectedcolor' is used.
2018-02-27 09:50:45 +01:00
Benno Schulenberg
4cd3987791 tweaks: correct a typo in NEWS 2018-02-27 09:45:38 +01:00
David Lawrence Ramsey
aa41eb69c0 docs: mention that errorcolor does have default colors
This fixes https://savannah.gnu.org/bugs/?53225.
2018-02-27 09:41:17 +01:00
Benno Schulenberg
54103d8ed1 tweaks: elide another variable, to call a function less often
Instead of always calling sctofunc(), it is now only called when
in view mode OR when (after the keystroke's function has been run)
no need for a refresh has been established yet.
2018-02-25 10:41:51 +01:00
Benno Schulenberg
53a10ddcaf tweaks: elide an unneeded variable
A shortcut's function must be among the existing ones, otherwise
nano's code is fundamentally broken.
2018-02-24 20:47:17 +01:00
Benno Schulenberg
65bf04060b tweaks: remove another superfluous check
Commit bb667beb removed do_gotolinecolumn_void() from the MWHEREIS
menu (replacing it with the empty flip_goto() function), so there
is no longer any need to check for this one special case.
2018-02-24 20:47:01 +01:00
Benno Schulenberg
a95fb64dd6 tweaks: remove a superfluous check
A shortcut's function can never be NULL.
2018-02-24 19:53:19 +01:00
Benno Schulenberg
b235404ade tweaks: elide an unused variable and parameter
It is only ever set and never referenced.
2018-02-24 19:42:43 +01:00
Benno Schulenberg
ffebd31cbb tweaks: shorten the name of two record elements
Exclude the confusing, pleonastic 'sc' abbreviation from their names.
2018-02-24 19:31:11 +01:00
Benno Schulenberg
e55227f65f tweaks: unabbreviate two variable names 2018-02-24 18:20:30 +01:00
Benno Schulenberg
b77b54bf73 tweaks: elide two unneeded booleans 2018-02-24 17:51:27 +01:00
Benno Schulenberg
2428620b16 prompt: disallow pasting when in restricted mode 2018-02-24 13:54:49 +01:00
Benno Schulenberg
cb0289f0dc tweaks: fix a copy-and-paste error 2018-02-24 13:31:59 +01:00
Benno Schulenberg
b027263a37 small addition: allow customizing the color of an error message
The new option 'set errorcolor' allows the user to specify the color
combination for the status bar when an error message is displayed.
2018-02-23 12:35:17 +01:00
Benno Schulenberg
1a926d79c5 help: mention that some keys work on a region when the mark is on
This fixes https://savannah.gnu.org/bugs/?53188.
Reported-by: Ken Tyler <kent@werple.net.au>
2018-02-23 12:35:12 +01:00
Benno Schulenberg
c79fe1a160 bindings: show ^/ instead of ^_ for Go-To-Line
The slash is easier to read than the underscore (which almost
disappears at the bottom of the screen), and easier to type
(no Shift needed on a US keyboard), and it kind of harmonizes
with the ^\ for Replace and the M-/ for End-of-buffer.
2018-02-23 12:26:30 +01:00
Tom Levy
fef195bce9 syntax: go: highlight also floats with leading zeroes as valid
See the discussion on the mailing list:
https://lists.gnu.org/archive/html/nano-devel/2018-01/msg00022.html
https://lists.gnu.org/archive/html/nano-devel/2018-02/msg00090.html

Signed-off-by: Tom Levy <tomlevy93@gmail.com>
2018-02-20 10:31:38 +01:00
Benno Schulenberg
dd9766c2e0 editing: when --smooth is used, make <Enter>-at-bottom scroll one row
When using --smooth or 'set smooth', the screen should scroll the
minimum amount needed to get the cursor back into view.  (The only
exceptions are search, undo, and redo -- when there the cursor goes
offscreen, the cursor line is centered.)

This change brings the behavior of pressing <Enter> on the bottom
row into line with, for example, pasting a single line.  See also
http://lists.gnu.org/archive/html/nano-devel/2018-02/msg00027.html.
2018-02-16 11:48:24 +01:00
Benno Schulenberg
5b870a7632 goto: avoid a segfault, by initializing 'answer' when it is NULL
This fixes https://savannah.gnu.org/bugs/?53157.
2018-02-14 19:40:30 +01:00
Benno Schulenberg
0cf455bc48 build: fix compilation when configured with --enable-tiny
And when configured with --enable-tiny --enable-nanorc.
2018-02-14 19:29:29 +01:00
Benno Schulenberg
3e1fc6385b syntaxes: remove quotes from each syntax name, and color it differently
The different color will make the name stand out, as it should, instead
of looking the same as all the regex strings.
2018-02-14 17:36:50 +01:00
Benno Schulenberg
544cda6a62 rcfile: allow a syntax name to be unquoted 2018-02-14 17:35:37 +01:00
Benno Schulenberg
28933cf572 tweaks: remove two superfluous checks, and restrict two others
When 'refresh_needed' is already TRUE, there is no need any more
to check whether it should be set.

[Those first two calls are leftovers from before the time that
reset_multis() morphed into check_the_multis().]
2018-02-14 17:29:59 +01:00
Benno Schulenberg
1635060ba6 tweaks: plug a memory leak when using Verbatim Input at a prompt
This fixes https://savannah.gnu.org/bugs/?53089.
2018-02-08 17:54:31 +01:00
David Lawrence Ramsey
7a038adfd4 input: don't stop prepending when the user adds text via a shortcut
When characters are added via Verbatim Input or by pressing <Tab>,
the prepend flag should be retained, just like when characters are
typed directly.

This fixes https://savannah.gnu.org/bugs/?52956.
2018-02-08 17:35:56 +01:00
Benno Schulenberg
f1b5be4bbf tweaks: elide an unneeded variable 2018-02-07 19:42:19 +01:00
Benno Schulenberg
9ceeabda38 memory: avoid a leak when toggling from Search to Goto
This fixes https://savannah.gnu.org/bugs/?53088.
2018-02-07 19:34:52 +01:00
Benno Schulenberg
204e1b8353 memory: squeal when there is something wrong, instead of stumbling on
When copying a string, source and destination may not be equal --
complain loudly when they are, instead of failing to free memory.

Also, instead of freeing the destination string and then allocating
it afresh, just reallocate it -- that should be slightly quicker.
2018-02-07 19:34:43 +01:00
Benno Schulenberg
d865d7ac8f search: clear the existing answer when starting a new search
When doing for example: ^W xx ^R ^C ^W, the "xx" would again be shown
after the prompt.  This is wrong -- when starting a new search, the
current answer should be empty.

Reported-by: Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
2018-02-05 12:47:55 +01:00
Benno Schulenberg
16d237ba1b tweaks: rename two variables, to be more meaningful 2018-02-04 22:07:33 +01:00
Benno Schulenberg
c3031b9b8f tweaks: reshuffle some of the search-and-replace cleanup calls 2018-02-04 21:31:04 +01:00
Benno Schulenberg
d289510724 tweaks: adjust comments and indentation after the previous change 2018-02-04 21:23:48 +01:00
Benno Schulenberg
60f1090da0 search: get rid of some unneeded recursion when just toggling things
Instead of weaving back and forth between do_search()/do_replace() and
search_init() every time that one of the options is toggled, just keep
looping in the latter function until the user presses <Enter>.

The weaving for the do_gotolinecolumn() function remains, but is
shortened to involve only search_init().
2018-02-04 20:26:06 +01:00
David Lawrence Ramsey
8f6ee22b41 tweaks: fix typo in rebindable function name
This fixes https://savannah.gnu.org/bugs/?53062.
2018-02-04 18:31:24 +01:00
Benno Schulenberg
a083d7f1e1 tweaks: rename a variable to be more distinct and greppable 2018-02-04 18:25:10 +01:00
Benno Schulenberg
919df09ffa general: detect in a better way whether we're running on a Linux console
Suggested-by: Mike Frysinger <vapier@gentoo.org>
2018-02-04 18:23:13 +01:00
Benno Schulenberg
ddbff6dcb2 tweaks: slightly rewrap the FAQ's table of contents 2018-02-04 18:20:13 +01:00
Benno Schulenberg
4295baa5fe tweaks: transform a 'do' to a 'while', and reshuffle a comment 2018-02-04 18:14:28 +01:00
Benno Schulenberg
467cc8edf3 tweaks: remove two deprecated options and six rebindable function names
This addresses https://savannah.gnu.org/bugs/?48992.
2018-02-04 13:51:13 +01:00
Benno Schulenberg
6d111c9343 new feature: allow binding a key to a string (in a nanorc file)
In this way a single keystroke can produce a fragment of text or a
series of commands, or a mix of the two.  It is like a prerecorded
macro.

This fulfills https://savannah.gnu.org/bugs/?52931.
2018-02-04 12:44:12 +01:00
Benno Schulenberg
bb667beb5a bindings: rename the bindable function 'gototext' to 'flipgoto'
This brings it in line with the other three "flip" toggles.
2018-02-04 10:34:39 +01:00
Benno Schulenberg
eed765f4f7 tweaks: elide an unneeded variable 2018-02-04 10:15:26 +01:00
Benno Schulenberg
361267cf25 po: update translations and regenerate POT file and PO files 2018-01-29 09:57:32 +01:00
Benno Schulenberg
ed493bb99b build: fix the source URL in the spec file 2018-01-29 09:46:47 +01:00
Benno Schulenberg
ae7366616f bump version numbers and add a news item for the 2.9.3 release 2018-01-29 09:31:12 +01:00
Benno Schulenberg
58ed3a8152 display: wipe the status bar when doing a total refresh
This fixes https://savannah.gnu.org/bugs/?52997.
2018-01-28 21:08:28 +01:00
Benno Schulenberg
e11021a7a5 input: recognize the deviant keycode for <Ctrl+End> in urxvt
This fixes https://savannah.gnu.org/bugs/?52972.
Reported-by: Brand Huntsman <alpha@qzx.com>
2018-01-28 16:15:21 +01:00
Benno Schulenberg
83c264939b tweaks: move a bunch of comments to the lines that they refer to 2018-01-28 13:41:46 +01:00
Benno Schulenberg
d48f3e5e7b help: don't get stuck when there is an unwrappable piece of text
When a fragment of help text does not contain any whitespace that
we can wrap at, just advance the pointer, because returning zero
would mean we stay forever at the same place: nano would hang.
2018-01-27 21:02:47 +01:00
Benno Schulenberg
b18e76d4d8 tweaks: drop two unneeded initializations, and trim a comment 2018-01-27 20:26:15 +01:00
Benno Schulenberg
f5c87a7fee tweaks: swap the row and col parameters to a more consistent order 2018-01-27 20:00:14 +01:00
Benno Schulenberg
90ebff00ca tweaks: rename two variables, and swap their declaration order 2018-01-27 19:47:00 +01:00
Benno Schulenberg
cdc9a29598 tweaks: move two functions to their proper place, orderingwise 2018-01-27 19:33:03 +01:00
Benno Schulenberg
ddc1de1939 docs: remove the note about needing a recent ncurses for macros to work
After commit e739448c, macros should work also when ncurses produces
escape sequences instead of keycodes.
2018-01-27 17:54:32 +01:00
Benno Schulenberg
18bf2af9c1 tweaks: rename a function, to be more distinct
So one doesn't find it when grepping for get_input().
2018-01-27 11:29:11 +01:00
Benno Schulenberg
452008c81d syntax: go: colorize only valid octal numbers
Reported-by: Tom Levy <tomlevy93@gmail.com>
2018-01-26 11:15:26 +01:00
Benno Schulenberg
97cbbb0cc8 prompt: show whitespace only in the filename, not in the whole line
That is, call display_string() just on the filename, not on the rest
of the prompt text.

This fixes https://savannah.gnu.org/bugs/?52967.
Reported-by: Andreas Schamanek <schamane@fam.tuwien.ac.at>
2018-01-26 09:37:18 +01:00
Benno Schulenberg
7b9bd65362 tweaks: drop a useless assert, and don't abort over an unhandled option 2018-01-24 10:29:50 +01:00
Benno Schulenberg
f72fecee9b copyright: update the years for the FSF
And one for me, for the much changed keyboard stuff.
2018-01-24 10:14:43 +01:00
Benno Schulenberg
97a8a62128 gnulib: update to its current upstream state 2018-01-24 10:02:28 +01:00
Benno Schulenberg
f095e20a86 tweaks: exclude --trimblanks when no wrapping or justifying is configured
Also, actually add the long option --trimblanks to the table.
2018-01-24 09:59:01 +01:00
Benno Schulenberg
fa7e9b11df input: recognize more escape sequences for <Shift+Home> and <Shift+End>
This fixes the second part of https://savannah.gnu.org/bugs/?52960.
2018-01-23 19:44:18 +01:00
Benno Schulenberg
838b175d4f input: recognize escape sequences for <Shift+PageUp> and <Shift+PageDown>
This fixes the first part of https://savannah.gnu.org/bugs/?52960.
2018-01-23 19:32:13 +01:00
Benno Schulenberg
ba1f990582 build: let ./configure fail (not just warn) when curses.h is missing
This fixes https://savannah.gnu.org/bugs/?52930.
Reported-by: Michail Tsiolkas <mtsio@cryptolab.net>
2018-01-23 19:15:18 +01:00
Benno Schulenberg
6795d079b1 tweaks: mark the two blocks that have a deviant indentation
Also, reshuffle a case, to put the short one first and lose a line.
2018-01-23 18:10:22 +01:00
Benno Schulenberg
e739448cd0 input: consume only the actual length of an escape sequence
Instead of assuming that the entire contents of the keybuffer are an
escape sequence (even if this is far longer than any escape sequence
can be), remove from the keybuffer only those integers that actually
constituted a sequence, valid or invalid.

This fixes https://savannah.gnu.org/bugs/?48659.
2018-01-23 17:31:48 +01:00
Benno Schulenberg
8e328e43c2 input: make <Shift+Tab> do an unindent also on a Manjaro console
This fixes https://savannah.gnu.org/bugs/?52943.
2018-01-23 16:52:51 +01:00
Benno Schulenberg
cb56a575fd options: recognize -M and --trimblanks on the command line 2018-01-23 13:49:48 +01:00
Benno Schulenberg
a429dc4a76 tweaks: rename a variable, to better fit its usage 2018-01-23 13:09:12 +01:00
Benno Schulenberg
91073be49c wrapping: don't trim a blank character that the user just typed
Trimming trailing spaces is good, but we should not trim the space
(or tab or other blank) that the user just typed and that caused the
hard-wrapping to occur.

This fixes https://savannah.gnu.org/bugs/?52948.
Reported-by: Andreas Schamanek <schamane@fam.tuwien.ac.at>
2018-01-23 13:06:05 +01:00
Benno Schulenberg
d5f9be7dc8 painting: look for an end match only after a start match, if any
This fixes https://savannah.gnu.org/bugs/?52925.

Reviewed-by: Brand Huntsman <alpha@qzx.com>
2018-01-22 11:03:40 +01:00
Benno Schulenberg
4ad0490ce4 tweaks: rename a variable, for more contrast 2018-01-20 18:22:24 +01:00
Benno Schulenberg
d85098abda tweaks: reshuffle a couple of lines, to make a bit more sense 2018-01-19 20:27:53 +01:00
Benno Schulenberg
13f8ddcaf2 tweaks: remove a handful of redundant (because always true) asserts
And rewrap some lines, three of them to make them equal to another.
2018-01-19 20:09:06 +01:00
Benno Schulenberg
37e9ada964 tweaks: change a 'do' to a 'while', and return early to elide an 'if' 2018-01-19 18:05:24 +01:00
Benno Schulenberg
a99158c7c0 tweaks: remove a fragment of dead code
At that point, ptr will necessarily point at EOL -- *ptr == '\0'.
2018-01-19 17:56:17 +01:00
Benno Schulenberg
3981217e5a startup: allow a named pipe as file argument when --noread is used
This fixes https://savannah.gnu.org/bugs/?52896.
Reported-by: Miki Strange <mik@mikistrange.com>
Tested-by: Miki Strange <mik@mikistrange.com>
2018-01-16 21:43:16 +01:00
Benno Schulenberg
96b47f2877 tweaks: transform a parameter, from a pointer to the value itself 2018-01-15 20:09:03 +01:00
Benno Schulenberg
7da391beb7 tweaks: drop a superfluous parameter, as it is always 1 2018-01-15 19:54:12 +01:00
Benno Schulenberg
90cf4838d2 tweaks: don't bother to reallocate when the keybuffer size decreases
It will be reallocated soon enough when the size increases again.
2018-01-15 19:46:16 +01:00
Benno Schulenberg
4c7ec18a55 tweaks: rewrap a bunch of lines in the NEWS file 2018-01-15 19:29:46 +01:00
Benno Schulenberg
704a7d7b4f tweaks: rename two variables, for preciseness and shortness
Also remove an unneeded nulling.
2018-01-15 16:38:13 +01:00
Benno Schulenberg
64366d9992 startup: make an error message succinct and to the point
The verbosity "hid" the really relevant information:
filename, line number, and the error message.

Valid values and other details can be found in the manual pages.
2018-01-15 13:24:14 +01:00
Benno Schulenberg
bd97ae7255 tweaks: set a modifier in a single place, for conciseness 2018-01-15 13:15:23 +01:00
Benno Schulenberg
2ff398c685 tweaks: reshuffle some stuff, and avoid a memory leak 2018-01-15 13:07:42 +01:00
Brand Huntsman
4b24ce1c11 startup: parse interface colors when they are read, not when initialized
When the palette is getting initialized, it is too late to send any
error messages about the rcfile options to standard error.

This fixes https://savannah.gnu.org/bugs/?52871.
Reported-by: Brand Huntsman <alpha@qzx.com>

Signed-off-by: Brand Huntsman <alpha@qzx.com>
2018-01-15 13:04:55 +01:00
Benno Schulenberg
00c1105c1b search: suppress the occurrence at the cursor only when replacing
When we're just searching, we do want to report the occurrence at
the cursor (after coming full circle) as a match, so that we can
mention that this is the only occurrence.  When replacing, we do
not want to replace this match twice.

This fixes https://savannah.gnu.org/bugs/?52888.
2018-01-15 11:38:19 +01:00
Benno Schulenberg
6a4d88cb4c docs: update the FAQ for the changed default location of history files
And reword some things about translations and Unicode support.
2018-01-14 11:51:21 +01:00
Benno Schulenberg
898c4c6fbb startup: move the initialization of colors, so any error gets printed
Suggested-by: Brand Huntsman <alpha@qzx.com>
2018-01-12 10:50:28 +01:00
Benno Schulenberg
c1bb6485de tweaks: check for the type of terminal far earlier
So the result could be used during RC-file reading.
2018-01-12 09:51:43 +01:00
Benno Schulenberg
4bcce96a4f docs: update the TODO file to the current state of affairs 2018-01-12 09:34:37 +01:00
Benno Schulenberg
caeed6821c tweaks: reshuffle two condition series, to look better 2018-01-11 13:02:55 +01:00
Benno Schulenberg
eb1bf8f927 tweaks: rename a variable, and further condense some comments 2018-01-11 12:52:14 +01:00
Benno Schulenberg
2c8b99d5e9 tweaks: condense and rewrap some comments, and reindent two lines
Also drop an old debugging fragment.
2018-01-11 10:51:18 +01:00
Benno Schulenberg
091dd71f08 tweaks: remove a superfluous case -- there can never be four digits 2018-01-11 10:31:23 +01:00
Benno Schulenberg
837475519b input: fully reset state when a three-digit character code is cut short
There shouldn't be two separate variables (but with the same name) that
count the number of digits seen.  Fuse them into a single static var.

This fixes https://savannah.gnu.org/bugs/?52863.
2018-01-11 10:17:51 +01:00
Benno Schulenberg
31540e3e7e tweaks: remove a superfluous check, as we insert always one code 2018-01-10 21:32:32 +01:00
Benno Schulenberg
ae3b8579fa tweaks: condense a condition and a comment, and reshuffle a line 2018-01-10 21:25:19 +01:00
Benno Schulenberg
e1199cd94d tweaks: elide a tiny intermediate buffer, and rename two variables
Use the same method as in parse_verbatim_kbinput() for Unicode input.
2018-01-10 20:33:12 +01:00
Benno Schulenberg
45d2458b47 tweaks: don't bother freeing the key buffer, just reallocate it 2018-01-10 19:25:23 +01:00
Benno Schulenberg
4c505e5127 tweaks: rename a function, for aptness, and drop a superfluous check 2018-01-10 17:40:07 +01:00
Benno Schulenberg
e3b13ae124 tweaks: reshuffle a couple of lines 2018-01-09 16:52:42 +01:00
Benno Schulenberg
e5440b390e replacing: don't skip the first character of a backwards-marked region
Also, when replacing forwards, do not first skip the occurrence at the
cursor and then replace it at the end of the cycle, but begin with it,
as one would expect.

This fixes https://savannah.gnu.org/bugs/?52789
and fixes https://savannah.gnu.org/bugs/?52791.
2018-01-09 16:52:42 +01:00
Benno Schulenberg
2a17527381 tweaks: indenting text files with tabs is not a good idea
The tabsize can vary by configuring editor or viewer, but
the text has some kind of intended alignment.

Also, change the indentation a bit, to make things line up
more neatly.
2018-01-09 16:51:16 +01:00
Benno Schulenberg
8067efa6cc syntax: nanohelp: color also the Sh-Tab key combo 2018-01-09 16:34:31 +01:00
Benno Schulenberg
0bb6c0234f tweaks: condense the conditional compilation of shortcut reassignments
These three functions are needed only when both linter and speller
are available.
2018-01-09 13:31:58 +01:00
Benno Schulenberg
7947d9d2a5 build: fix compilation when configured with --enable(tiny,color,nanorc}
This fixes https://savannah.gnu.org/bugs/?52834.
Reported-by: <akiko@mailbox.org>
2018-01-09 13:30:25 +01:00
Benno Schulenberg
c9ccb39752 tweaks: fully include Savefile and Wherewas in the tiny version
If help is enabled, those functions should be described too,
and if nanorc is enabled, they should both be rebindable.
2018-01-09 11:49:21 +01:00
Benno Schulenberg
ada78dc89d build: fix compilation with --enable-tiny --enable-justify 2018-01-08 19:12:41 +01:00
Benno Schulenberg
c6f367268b syntax: lua: do not color debug.setinfo as it doesn't exist
Reported-by: Tom Levy <tomlevy93@gmail.com>
2018-01-06 17:59:28 +01:00
117 changed files with 38491 additions and 35020 deletions

11
AUTHORS
View File

@@ -5,6 +5,11 @@ nano editor. Please see the ChangeLog for specific changes by author.
Chris Allegretta <chrisa@asty.org>
* Original program author and long-time maintainer.
Benno Schulenberg <bensberg@telfort.nl>
* An array of small bug fixes, the cut-word and block-jump
routines, text selection by holding Shift, macro recording
and replay, plus some key bindings. Current maintainer.
David Lawrence Ramsey <pooka109@gmail.com>
* Former stable series maintainer. Multiple buffer support,
operating dir (-o) option, bug fixes for display routines,
@@ -60,7 +65,5 @@ Sumedh Pendurkar <sumedh.pendurkar@gmail.com>
Rishabh Dave <rishabhddave@gmail.com>
* Searchable help.
Benno Schulenberg <bensberg@justemail.net>
* An array of small bug fixes, the cut-word and block-jump
routines, text selection by holding Shift, and some extra
key bindings. Current maintainer.
Marco Diego Aurélio Mesquita <marcodiegomesquita@gmail.com>
* Filtering text through an external command.

533
ChangeLog
View File

@@ -1,3 +1,536 @@
Changes between v2.9.8 and v3.0:
--------------------------------
Benno Schulenberg (113):
bindings: bind M-Q to 'findprevious' by default, and M-W to 'findnext'
bindings: hard-bind <Ctrl+Shift+Delete> to 'cutwordleft'
bindings: make ^Q and M-Q available also in the help viewer
bindings: move the noconvert toggle from the main to the insert menu
bindings: reassign the M-| keystroke to 'cutwordleft' by default
bindings: remove backup and new-buffer toggles (M-B, M-F) from main menu
bindings: remove the More-Space toggle entirely
bindings: remove the 'searchagain' function entirely
bindings: rename two bindable functions: copytext to copy, uncut to paste
bindings: unassign the M-? keystroke, to free it up for future use
build: add the release script to the repository
build: fix compilation again when configured with --enable-tiny
build: fix compilation when configured with --enable-tiny
build: verify that 'msgfmt' is available when building from git
bump version numbers and add a news item for the 3.0 release
chars: make the UTF-8 case ever so slightly faster by eliding an 'if'
chars: speed up the counting of string length for the plain ASCII case
chars: speed up the parsing of a character for the plain ASCII case
completion: when the cursor is not after a word fragment, say so
cut: concentrate the logic for clearing the cutbuffer mostly in one place
cutting: when deleting whole words, don't join lines unexpectedly
debug: add some code to time the performance of get_totsize()
docs: improve a comment about rebinding <Backspace>
docs: mention that also Ctrl increases the stride when selecting text
docs: mention that "normal" can be used to give things the default color
docs: mention that the 'formatter' command has been superseded
docs: reshuffle a bindable function to a slightly better position
docs: say that 'cutwordright' is now bound to <Ctrl+Delete> by default
docs: slightly reword the description of four bindable functions
docs: the 'noconvert' bindable function was renamed to 'flipconvert'
dropping a feature: remove the ability to use the 'formatter' command
easter: show the crawl only when there is room enough for the lines
files: add the file format on the status bar when switching buffers
filtering: wait for the data-sending process to terminate too
gnulib: update to its current upstream state
help: for ^R^X, mention that the buffer can be piped to the command
help: move "Search Again" away from "Find Next" and "Find Previous"
input: consume the whole escape sequence for modified PgUp and PgDn keys
input: fully consume modified PgUp and PgDn keys also in the tiny version
input: ignore any <Escape>s before a valid command keystroke
input: stop <Alt+Insert> from entering "3~" into the buffer
input: stop a modified Delete key from entering stuff into the buffer
mouse: put the row/column arguments in the proper order [coverity scan]
prompt: concentrate manipulations of 'statusbar_x' into a single file
prompt: remove redundant redrawings of the prompt bar
rcfile: allow to rebind the Cancel function in the yesno menu
rcfile, docs: no longer recognize nor mention 'set backwards'
rcfile: do not accept rebinding F0 nor function keys above F16
rcfile: ensure that in the yesno menu Cancel is bound to some keystroke
rcfile: explicitly check for disallowed keywords in included files
rcfile: reject things like "M-Del" and "^{" as invalid key names
rcfile: when a vital function is not mapped, mention in which menu
search: include 'findprevious' and 'findnext' in the tiny version
signals: don't call a print routine in a signal handler
speller: do not replace the text when the temporary file did not change
startup: don't overwrite rcfile error messages on a Linux console
startup: show the correct number of lines when opening multiple files
syntax: awk: recognize any {g,m,n,}awk script also by its shebang line
syntax: default: colorize also two-digit and capitalized nano versions
syntaxes: remove all traces of the 'formatter' command
syntax: nanorc: recognize 'yesno' as a valid menu to bind/unbind keys in
syntax: nanorc: show ^@ as validly rebindable, but not any ^digit
syntax: python: avoid coloring the three special values inside strings
text: add auto-whitespace to the file size after creating the undo item
tweaks: adjust indentation after the previous change
tweaks: adjust one more translator hint, for removed toggles
tweaks: adjust some translator hints for past changes, and add two more
tweaks: adjust two comments, to be more accurate and general
tweaks: avoid dereferencing a pointer when it is NULL [coverity scan]
tweaks: close a temp file only when descriptor is valid [coverity scan]
tweaks: correct a comment, rewrap a line, and drop some debugging stuff
tweaks: delete some old debugging code that no longer seems useful
tweaks: don't bother having debug code that deallocates all memory
tweaks: don't call va_start() without calling va_end() [coverity scan]
tweaks: drop a condition that has been made redundant two commits ago
tweaks: drop some old debugging code
tweaks: elide a bunch of unneeded constant strings
tweaks: elide a function that is used just once
tweaks: elide another function that is used just once
tweaks: elide an unneeded/duplicate variable
tweaks: elide a one-line function -- no, a half-line function
tweaks: elide a subfunction that is used just once
tweaks: exclude a global flagging variable when it is not needed
tweaks: exclude the file-prepending code from the tiny version
tweaks: fix a pasting error from a month ago
tweaks: implement the name-to-menu function in another manner
tweaks: improve a couple of comments in the sample nanorc
tweaks: improve a translator hint and some other comments
tweaks: move a call to where it will be executed [coverity scan]
tweaks: normalize the indentation after the previous change
tweaks: properly escape "\" in a man page and "@" in a texi document
tweaks: recognize escape sequences of modified Ins/Del more precisely
tweaks: reduce the counting of characters to just the needed function
tweaks: remove a redundant "struct" word, and replace it in comments
tweaks: remove a superfluous condition and a redundant refresh
tweaks: remove redundant braces and conditions after the previous change
tweaks: remove some braces that are now superfluous
tweaks: remove some ineffectual parts from header-line regexes
tweaks: remove the superfluous calls that reset the mbtowc() state
tweaks: remove two needless words, and split up a changed text further
tweaks: remove two superfluous assignments
tweaks: rename a constant, to match what it actually means
tweaks: rename a function and place its call better
tweaks: rename a function to better match its counterpart
tweaks: rename a function, to better state what it does
tweaks: rename a variable and a function, for more clarity
tweaks: rename a variable, to better match its task
tweaks: reshuffle some lines, in order to elide one
tweaks: reshuffle the order of the bindings, for help-line esthetics
tweaks: show "Space" and "Bsp" in the help text of the browser
tweaks: slightly improve error message when vital function is unmapped
tweaks: use a shorter message, because when the screen is small...
undo: differentiate between general filtering and spell checking
Brand Huntsman (4):
input: give feedback for all unbound keys also in the help viewer
statusbar: elevate three messages to an ALERT, to make them more visible
tweaks: correct four spaces of indentation to a tab, in two places
tweaks: remove the 'bright' field from the colortype struct
David Lawrence Ramsey (13):
bindings: make "n" work again in file browser and help viewer
bindings: make ^Q start a backward search also in the file browser
docs: mention that "Ins" and "Del" are valid rebindable keys
justify: verify being in a paragraph before trying to find its beginning
speller: hook up a full alternative spellcheck to the undo system
speller: hook up a marked-text alternative spellcheck to the undo system
speller: make replace_buffer() use the cutting functions directly
speller: make replace_marked_buffer() use the cutting functions directly
undo: actually enable undoing/redoing an alternative spellcheck
undo: always initialize the 'newsize' element in the undo struct
undo: position the cursor properly when undoing/redoing magicline cuts
undo: restore the cursor position when a cut and paste are paired
undo: store the correct cursor position after a paired cut+insert
Devin Hussey (2):
files: speed up reading by using getc_unlocked() instead of getc()
syntax: sh: recognize more file extensions and header lines
Marco Diego Aurélio Mesquita (1):
input: erase the next word when Ctrl is held while pressing Delete
Mark-Weston (2):
build: fix compilation when CC=tcc
syntax: lua: do not color strings inside comments, and add a linter
Changes between v2.9.7 and v2.9.8:
----------------------------------
Benno Schulenberg (64):
build: fix compilation failure when configured with --enable-tiny
build: fix compilation when configured with --disable-justify
build: fix compilation when configured with --disable-multibuffer
build: fix compilation with --enable-{tiny,help,multibuffer}
bump version numbers and add a news item for the 2.9.8 release
copyright: update the years for significantly changed files
credits: sort the names roughly according to amount of influence
docs: add a missing double quote in the default brackets string
docs: describe what constitutes a paragraph
docs: improve description of 'speller' and related bindable functions
docs: improve the description of --nonewlines, and properly sort it
docs: improve the description of the --autoindent option
docs: make quotes around regexes bold, as they are part of the command
docs: mark the filtering of text through an external command as done
docs: register Marco as the author of the filtering feature
docs: remove mention of the quotestr for when regex support is lacking
docs: remove quotes around the name of a syntax -- they are not needed
docs: thank Kamil for his bug fixes, and update an email address
docs, usage: make it clear that the argument of --quotestr is a regex
files: give feedback during writeout also when prepending or appending
filtering: pair the cut and the insert, so they can be undone together
gnulib: update to its current upstream state
justification: find the beginning of a paragraph in a better way
justification: limit the amount of recursion to prevent a stack overflow
justification: recognize indented paragraphs also without --autoindent
justification: when leading whitespace exceeds fill width, wrap anyway
linter: don't try to access absent stat info, as that gives a crash
linter: make sure that the margin is updated before displaying a buffer
linter: make sure the shortcuts bar will redrawn when exiting early
main: add "/" to the quoting regex, to allow justifying //-comments
main: interpret only a double slash (//) as quoting, not a single one
rcfile: don't crash when a bind to a string lacks the closing quote
startup: provide a hint for people unfamiliar with the ^char convention
syntaxes: condense and/or correct some extension regexes
syntax: makefile: color all keywords that GNU make recognizes
tweaks: adjust a translator hint
tweaks: avoid an unused-variable warning with --enable-tiny
tweaks: avoid a warning with --enable-{tiny,help,multibuffer}
tweaks: condense a comment, and elide an unneeded 'if'
tweaks: condense some repetitious comments, and check before assigning
tweaks: condense two statements into one, and elide a 'break'
tweaks: elide a function that is called just once
tweaks: elide another function that is called just once
tweaks: exclude an unneeded 'if' from the single-buffer version
tweaks: frob a couple of comments
tweaks: frob some comments, and rename two parameters to make sense
tweaks: give some continuation lines a more obvious indentation
tweaks: improve a couple of comments, and reshuffle a group of lines
tweaks: make better use of an existing variable
tweaks: make better use of an intermediate variable
tweaks: reduce the abundance of the word 'toggle' in the Info manual
tweaks: remove a superfluous assignment -- the lead length never changes
tweaks: remove two superfluous checks, after making one of them so
tweaks: rename a function, for more aptness and extra contrast
tweaks: rename a variable, for contrast, and improve two comments
tweaks: rename a variable, to give it some meaning
tweaks: rename two variables, to better fit their tasks
tweaks: reshuffle a condition, and adjust a comment and some indentation
tweaks: reshuffle a couple of assignments
tweaks: simplify the determining of the prefix for justified lines
tweaks: stop decreasing both the iterator and the limit of a loop
tweaks: use a more meaningful variable name, and avoid a distant 'else'
wrapping: use "smart" autoindenting only when hard-wrapping is enabled
wrapping: when autoindenting, use indentation of next line as example
Brand Huntsman (1):
tweaks: avoid two unused variable warnings when NLS is disabled
Cristian Caloghera (1):
syntax: makefile: recognize also an all-lowercase makefile name
David Lawrence Ramsey (3):
bindings: add the "flippipe" bindable function
tweaks: avoid an unused variable warning with --enable-tiny
tweaks: fix some grammar plus a typo in the comments
Marco Diego Aurélio Mesquita (2):
linter: check all open buffers, instead of just the next one
new feature: allow piping (selected) text to an external command
Changes between v2.9.6 and v2.9.7:
----------------------------------
Benno Schulenberg (21):
bindings: add the 'linenumbers' bindable function
bindings: rename constupdate to constantshow, cuttoend to cutfromcursor
bump version numbers and add a news item for the 2.9.7 release
docs: add notes about deprecated options and function names
docs: break down some old improvements further per version
docs: note a small difference with Pico in the default hard-wrapping
docs: say thanks to three recent translators, and re-sort two others
docs: slightly improve the description of the file browser in the manual
main: clear a spurious error number, to avoid irrelevant messages later
prompt: when asking for Yes/No/All, recognize also UTF-8 letters
scrolling: only do a scroll when the edit window has more than one row
signals: don't trap segfault/abort when envvar NANO_NOCATCH is defined
signals: exclude the crash handler from the tiny version
startup: suggest using ^D to finish reading from standard input
tweaks: improve a couple of comments
tweaks: normalize indentation and whitespace after previous changes
tweaks: put check for -h and -l options in their alphabetical positions
tweaks: put Yes/No/All in a consistent order (for the translators)
tweaks: rename two variables, to be more descriptive
tweaks: sort an option better, and reschedule a removal
tweaks: use symbolic names instead of puzzling TRUE and FALSE
Devin Hussey (1):
signals: upon a crash, save changed buffers and reset terminal state
Mark-Weston (1):
new feature: an option to make the 'nextword' function stop at word ends
Changes between v2.9.5 and v2.9.6:
----------------------------------
Benno Schulenberg (39):
build: do not prefix an alternative rcfilename with a dot
build: fix compilation when configured with --disable-help
bump version numbers and add a news item for the 2.9.6 release
command-execution: do not crash when opening the pipe would fail
completion: correctly do a signed comparison, to avoid a segfault
files: prevent a hang when a call to sigaction() would fail
formatting, linting: redetermine the argument list for every run
gnulib: update to its current upstream state
memory: use a reallocation to reduce the amount of leakage
prompt: recognize Yes/No/All in English when the locale gives no match
rcfile: skip color commands where some color name is invalid
scrolling: don't redraw entire edit window when cursor goes offscreen
search: always go forward by default, also when coming from Goto-Line
search: use a better value to mean "nothing was typed"
speller: don't add an extra newline when saving the text to a tempfile
syntax: po: highlight also other escaped characters, not just \n
syntax: sh: colorize options only when they are preceded by whitespace
tweaks: adjust the translator hint about Yes/No/All
tweaks: correct or improve a couple of comments
tweaks: elide a function that is called just once
tweaks: fix a typo, remove a blank line, and improve some comments
tweaks: frob a couple of comments
tweaks: group some more of the empty functions together
tweaks: improve some comments, and exit with nonzero status upon error
tweaks: improve the ordering of a couple of functions
tweaks: invert two conditions and reshuffle, to reduce duplication
tweaks: move a function to its proper location
tweaks: move a function to its proper location
tweaks: rearrange a few if statements more symmetrically
tweaks: remove the group handling for undoing/redoing (un)indents
tweaks: rename a function, to be more distinct from its caller
tweaks: rename a function, to be more fitting and descriptive
tweaks: rename a variable, for clarity
tweaks: rename a variable, to be a bit more fitting
tweaks: rename a variable, to be more clear and to match another
tweaks: rename a variable, to match another and to be more visible
tweaks: reshuffle two declarations
tweaks: set the correct flags just once for each spell-fixing session
tweaks: use meaningful names instead of puzzling values
Liu Hao (1):
replacing: always clear the backwards flag for ^\, just like for ^W
Changes between v2.9.4 and v2.9.5:
----------------------------------
Benno Schulenberg (45):
build: exclude more things when configured with --disable-multibuffer
build: fix compilation again when configured with --enable-tiny
build: fix compilation when configured with --disable-multibuffer
build: fix compilation with --enable-{tiny,help,multibuffer}
bump version numbers and add a news item for the 2.9.5 release
cut: avoid calling renumber() on what might be NULL
docs: clarify how the Linux console is deficient: in the arrow keys
docs: clarify what the scrollup and scrolldown bindable functions do
docs: document the newly added color name "normal"
docs: mention in the FAQ that <Shift+Insert> pastes from the clipboard
files: prevent an infinite loop when reading from standard input fails
files: prevent the undo of reading a file into a new buffer
help: describe the Scroll-Up and Scroll-Down commands more precisely
help: do not reserve space for line numbers, as they are absent
linting: drop messages for other files when configured for one buffer
memory: plug a leak, by actually freeing a discarded undo struct
scrolling: first move the cursor before pushing current chunk offscreen
scrolling: let Scroll-Up/Down keep the cursor in the same text position
selecting: don't cancel a softmark when just scrolling the screen
small addition: understand color name "normal" to mean the default color
syntax: sh: color also the 'cut', 'head', 'tail', and 'sort' commands
syntax: sh: color options distinctively, and color also long options
syntax: sh: uncolor "tar" when it's part of a filename
tweaks: adjust a couple of types, to reduce the number of warnings
tweaks: adjust or correct some comments, and rename a function
tweaks: adjust the indentation after the previous changes
tweaks: bundle some settings for a new buffer
tweaks: change a parameter of open_buffer() and invert its logic
tweaks: condense some code, to remove a bit of duplication
tweaks: drop a handful of unhelpful asserts
tweaks: elide an unneeded and shadowing variable
tweaks: elide a parameter, as it's always the inverse of another
tweaks: elide a parameter that is always 1
tweaks: elide two parameters and thus a pair of wrapper functions
tweaks: factor out the check for 'viewok' into its own function
tweaks: fix a typo and adjust some wording and formatting in the FAQ
tweaks: frob some comments plus miscellaneous other stuff
tweaks: fuse two ifs into one
tweaks: move an 'if' and then remove an unneeded label
tweaks: reduce the font size of the questions in the FAQ
tweaks: remove an inconsistent space from two pointer declarations
tweaks: remove unneeded settings and unsettings of MULTIBUFFER
tweaks: reshuffle some movement code, to reduce the number of conditions
tweaks: revert commit c88a2fd9 -- the extra variable is needed
tweaks: rewrap and amend some lines in the NEWS file
David Lawrence Ramsey (1):
tweaks: correct several parameter types
Kamil Dudka (1):
input: do not crash if sctofunc() returns NULL
Liu Hao (1):
build: fix compilation error when configured with --disable-justify
Changes between v2.9.3 and v2.9.4:
----------------------------------
Benno Schulenberg (65):
bindings: make a key defined as string work also in browser and viewer
bindings: rename the bindable function 'gototext' to 'flipgoto'
bindings: revert the ^/ changes, as ^/ is not always Go-To-Line
bindings: show ^/ instead of ^_ for Go-To-Line
build: fix compilation when configured with --enable-tiny
bump version numbers and add a news item for the 2.9.4 release
docs: mention that a key can be bound to a string
docs: note also in the Info manual that text can be selected with Shift
editing: when --smooth is used, make <Enter>-at-bottom scroll one row
general: detect in a better way whether we're running on a Linux console
gnulib: update to its current upstream state
goto: avoid a segfault, by initializing 'answer' when it is NULL
help: mention that some keys work on a region when the mark is on
help: tweak the descriptions of ^X and ^R
input: handle the implant() function separately also for the prompt
input: handle the implant() function separately, as it is special
memory: avoid a leak when toggling from Search to Goto
memory: squeal when there is something wrong, instead of stumbling on
new feature: allow binding a key to a string (in a nanorc file)
prompt: disallow pasting when in restricted mode
rcfile: allow a syntax name to be unquoted
search: clear the existing answer when starting a new search
search: get rid of some unneeded recursion when just toggling things
selecting: cancel the softmark upon any attempt to move the cursor
small addition: allow customizing the color of an error message
syntax: color also ^/ in nano's help texts and in nanorc files
syntaxes: remove quotes from each syntax name, and color it differently
syntax: nanorc: color also bindings to a string as valid
tweaks: adjust comments and indentation after the previous change
tweaks: adjust two comments, move two declarations, rewrap three lines
tweaks: appease valgrind concerning syscalls with uninitialized values
tweaks: condense a comment and elide an 'if'
tweaks: correct a typo in NEWS
tweaks: correct a typo that broke binding a key to a string
tweaks: do not needlessly renumber the lines in the buffer
tweaks: don't call strcmp() to determine whether a string is empty
tweaks: drop an assert, add a warning, and change a 'for' to a 'while'
tweaks: drop some debugging stuff, and adjust what remains of it
tweaks: elide another variable, to call a function less often
tweaks: elide an unneeded variable
tweaks: elide an unneeded variable
tweaks: elide an unneeded variable
tweaks: elide an unused variable and parameter
tweaks: elide two unneeded booleans
tweaks: exclude an unlikely error message from the tiny version
tweaks: exclude an unlikely warning from the tiny version
tweaks: fix a copy-and-paste error
tweaks: make the fsfromline() call only for the undo types that need it
tweaks: plug a memory leak when using Verbatim Input at a prompt
tweaks: refactor the implanting of a key expansion
tweaks: remove another superfluous check
tweaks: remove a superfluous check
tweaks: remove two deprecated options and six rebindable function names
tweaks: remove two superfluous checks, and restrict two others
tweaks: rename a parameter and a variable, to be more fitting
tweaks: rename a variable to be more distinct and greppable
tweaks: rename two variables, to be more meaningful
tweaks: reshuffle some code, to be slightly less ugly
tweaks: reshuffle some of the search-and-replace cleanup calls
tweaks: reshuffle the undo types into mostly the same order everywhere
tweaks: shorten the name of two record elements
tweaks: slightly rewrap the FAQ's table of contents
tweaks: transform a 'do' to a 'while', and reshuffle a comment
tweaks: unabbreviate two variable names
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
David Lawrence Ramsey (3):
docs: mention that errorcolor does have default colors
input: don't stop prepending when the user adds text via a shortcut
tweaks: fix typo in rebindable function name
Tom Levy (1):
syntax: go: highlight also floats with leading zeroes as valid
Changes between v2.9.2 and v2.9.3:
----------------------------------
Benno Schulenberg (65):
build: fix compilation when configured with --enable(tiny,color,nanorc}
build: fix compilation with --enable-tiny --enable-justify
build: let ./configure fail (not just warn) when curses.h is missing
bump version numbers and add a news item for the 2.9.3 release
copyright: update the years for the FSF
display: wipe the status bar when doing a total refresh
docs: remove the note about needing a recent ncurses for macros to work
docs: update the FAQ for the changed default location of history files
docs: update the TODO file to the current state of affairs
gnulib: update to its current upstream state
help: don't get stuck when there is an unwrappable piece of text
input: consume only the actual length of an escape sequence
input: fully reset state when a three-digit character code is cut short
input: make <Shift+Tab> do an unindent also on a Manjaro console
input: recognize escape sequences for <Shift+PageUp> and <Shift+PageDown>
input: recognize more escape sequences for <Shift+Home> and <Shift+End>
input: recognize the deviant keycode for <Ctrl+End> in urxvt
options: recognize -M and --trimblanks on the command line
painting: look for an end match only after a start match, if any
prompt: show whitespace only in the filename, not in the whole line
replacing: don't skip the first character of a backwards-marked region
search: suppress the occurrence at the cursor only when replacing
startup: allow a named pipe as file argument when --noread is used
startup: make an error message succinct and to the point
startup: move the initialization of colors, so any error gets printed
syntax: go: colorize only valid octal numbers
syntax: lua: do not color debug.setinfo as it doesn't exist
syntax: nanohelp: color also the Sh-Tab key combo
tweaks: change a 'do' to a 'while', and return early to elide an 'if'
tweaks: check for the type of terminal far earlier
tweaks: condense a condition and a comment, and reshuffle a line
tweaks: condense and rewrap some comments, and reindent two lines
tweaks: condense the conditional compilation of shortcut reassignments
tweaks: don't bother freeing the key buffer, just reallocate it
tweaks: don't bother to reallocate when the keybuffer size decreases
tweaks: drop a superfluous parameter, as it is always 1
tweaks: drop a useless assert, and don't abort over an unhandled option
tweaks: drop two unneeded initializations, and trim a comment
tweaks: elide a tiny intermediate buffer, and rename two variables
tweaks: exclude --trimblanks when no wrapping or justifying is configured
tweaks: fully include Savefile and Wherewas in the tiny version
tweaks: indenting text files with tabs is not a good idea
tweaks: mark the two blocks that have a deviant indentation
tweaks: move a bunch of comments to the lines that they refer to
tweaks: move two functions to their proper place, orderingwise
tweaks: remove a fragment of dead code
tweaks: remove a handful of redundant (because always true) asserts
tweaks: remove a superfluous case -- there can never be four digits
tweaks: remove a superfluous check, as we insert always one code
tweaks: rename a function, for aptness, and drop a superfluous check
tweaks: rename a function, to be more distinct
tweaks: rename a variable, and further condense some comments
tweaks: rename a variable, for more contrast
tweaks: rename a variable, to better fit its usage
tweaks: rename two variables, and swap their declaration order
tweaks: rename two variables, for preciseness and shortness
tweaks: reshuffle a couple of lines
tweaks: reshuffle a couple of lines, to make a bit more sense
tweaks: reshuffle some stuff, and avoid a memory leak
tweaks: reshuffle two condition series, to look better
tweaks: rewrap a bunch of lines in the NEWS file
tweaks: set a modifier in a single place, for conciseness
tweaks: swap the row and col parameters to a more consistent order
tweaks: transform a parameter, from a pointer to the value itself
wrapping: don't trim a blank character that the user just typed
Brand Huntsman (1):
startup: parse interface colors when they are read, not when initialized
Changes between v2.9.1 and v2.9.2:
----------------------------------

View File

@@ -8278,7 +8278,7 @@ nano 0.7.6 - 2000.01.15
having a newline at the end doesn't get read, bugfix in do_replace
with replace all, more/better comments. (Robert Siemborski)
0.7.2 Our first patch accepted into the source! configure fixes
and optimizations (Erik Anderson). Added missing stdarg.h to winio.c.
and optimizations (Erik Andersen). Added missing stdarg.h to winio.c.
Bug fix in update_line for editing long lines. Fixed arguments
being put into the filename when none is specified. Preliminary
+line command argument function.

View File

@@ -3555,10 +3555,10 @@ GNU nano 2.1.4 - 2008.08.09
* text.c (add_undo): Fix check for multi-line cut check skips adding other new legit events.
2008-07-23 Chris Allegretta <chrisa@asty.org>
* text.c: Reset openfile-> to OTHER after an undo or redo so we don't
mistakenly think this is an update when it's really an add. Also
fix an extra ; after an if statement which makes nano try to free
a struct which may be NULL.
* text.c: Reset openfile->last_action to OTHER after an undo or redo
so we don't mistakenly think this is an update when it's really an
add. Also fix a mistaken ; after an if statement which made nano
try to free a struct which might be NULL.
GNU nano 2.1.3 - 2008.08.04

View File

@@ -1,7 +1,18 @@
Improvements in GNU nano
========================
Since 3.0:
- <Ctrl+Delete> wipes next word and <Shift+Ctrl+Delete> preceding word.
- An external spell check can be undone.
Since 2.9.0:
- The ability to filter text through an external command.
- Better detection of paragraphs, allowing a less indented beginning.
- 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.
- 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'.
- The ability to record and replay a series of keystrokes (a macro).
@@ -31,24 +42,25 @@ Since 2.6.0:
- The option 'wordchars' for specifying extra word characters.
- Hi-bit control characters are shown in a more readable manner.
- The ability to use negative numbers at the Go To Line prompt.
Noteworthy changes since 2.2
----------------------------
- The ability to comment/uncomment lines with a single keystroke (M-3).
- The ability to refresh the file list in the browser (^L).
- The ability to abort re-searches (^C after an M-W).
- Better feedback at startup when opening large or multiple files.
Since 2.5.0:
- The option 'justifytrim' for snipping whitespace from justified lines.
- The ability to discard a buffer (^O ^Q) when --tempfile is used.
- Replacing things in a marked region now takes place in situ, in context,
instead of changing the view to only the marked text.
- On some terminals Ctrl+Left / Ctrl+Right now work for PrevWord/NextWord.
- On most terminals Ctrl+Left / Ctrl+Right now work for PrevWord/NextWord.
- When in the middle of a word, PrevWord now jumps to the start of this
word (like Pico does) instead of to the start of the preceding word.
Since 2.4.0:
- Replacing things in a marked region now takes place in situ, in context,
instead of changing the view to only the marked text.
- Invalid byte sequences are properly displayed and not mistakenly found.
- Resizing the window does not exit from help viewer nor file browser.
- Improved arrangement of the shortcuts in the two help lines.
- Several small bug fixes in the syntax highlighting.
Since 2.3.0:
- System syntaxes can be improved upon with the 'extendsyntax' command.
- The ability to delete whole words with 'cutwordleft' and 'cutwordright'.
- The ability to save a file without prompting for its name ('savefile').

2911
NEWS

File diff suppressed because it is too large Load Diff

92
README
View File

@@ -1,76 +1,76 @@
GNU nano -- an enhanced clone of the Pico text editor
GNU nano -- an enhanced clone of the Pico text editor
Overview
The nano project was started because of a few "problems" with the
wonderfully easy-to-use and friendly Pico text editor.
The nano project was started because of a few "problems" with the
wonderfully easy-to-use and friendly Pico text editor.
First and foremost was its license: the Pine suite does not use
the GPL or a GPL-friendly license, and has unclear restrictions on
redistribution. Because of this, Pine and Pico are not included
with many GNU/Linux distributions. Also, other features (like
go-to-line-number or search-and-replace) were unavailable until
recently or require a command-line flag. Yuck.
First and foremost was its license: the Pine suite does not use
the GPL or a GPL-friendly license, and has unclear restrictions on
redistribution. Because of this, Pine and Pico are not included
with many GNU/Linux distributions. Also, other features (like
go-to-line-number or search-and-replace) were unavailable until
recently or require a command-line flag. Yuck.
nano aims to solve these problems by emulating the functionality of
Pico as closely as possible while addressing the problems above and
providing other extra functionality.
nano aims to solve these problems by emulating the functionality of
Pico as closely as possible while addressing the problems above and
providing other extra functionality.
The nano editor is an official GNU package. For more information on
GNU and the Free Software Foundation, please see http://www.gnu.org/.
The nano editor is an official GNU package. For more information on
GNU and the Free Software Foundation, please see http://www.gnu.org/.
How to compile and install nano
Download the nano source code, then:
Download the nano source code, then:
tar xvzf nano-x.y.z.tar.gz
cd nano-x.y.z
./configure
make
make install
tar xvzf nano-x.y.z.tar.gz
cd nano-x.y.z
./configure
make
make install
It's that simple. Use --prefix with configure to override the
default installation directory of /usr/local.
It's that simple. Use --prefix with configure to override the
default installation directory of /usr/local.
If you haven't configured with the --disable-nanorc option, after
installation you may want to copy the doc/sample.nanorc file to
your home directory, rename it to ".nanorc", and then edit it
according to your taste.
If you haven't configured with the --disable-nanorc option, after
installation you may want to copy the doc/sample.nanorc file to
your home directory, rename it to ".nanorc", and then edit it
according to your taste.
Web Page
https://nano-editor.org/
https://nano-editor.org/
Mailing Lists
There are three nano-related mailing-lists.
There are three nano-related mailing-lists.
+ info-nano@gnu.org is a very low traffic list used to announce
new nano versions or other important info about the project.
+ help-nano@gnu.org is for those seeking to get help without
wanting to hear about the technical details of its development.
+ nano-devel@gnu.org is the list used by the people that make nano
and a general development discussion list, with moderate traffic.
+ info-nano@gnu.org is a very low traffic list used to announce
new nano versions or other important info about the project.
+ help-nano@gnu.org is for those seeking to get help without
wanting to hear about the technical details of its development.
+ nano-devel@gnu.org is the list used by the people that make nano
and a general development discussion list, with moderate traffic.
To subscribe, send email to <name>-request@gnu.org with a subject
of "subscribe", where <name> is the list you want to subscribe to.
To subscribe, send email to <name>-request@gnu.org with a subject
of "subscribe", where <name> is the list you want to subscribe to.
Bug Reports
To report a bug, please file a description of the problem on nano's
bug tracker (https://savannah.gnu.org/bugs/?group=nano -- hover on
"Bugs", then click "Submit new"). The issue may have already been
reported, so please look first.
To report a bug, please file a description of the problem on nano's
bug tracker (https://savannah.gnu.org/bugs/?group=nano -- hover on
"Bugs", then click "Submit new"). The issue may have already been
reported, so please look first.
Current Status
Since version 2.5.0, GNU nano has abandoned the distinction between
a stable and a development branch: it is now on a "rolling" release
-- fixing bugs and adding new features go hand in hand.
Since version 2.5.0, GNU nano has abandoned the distinction between
a stable and a development branch: it is now on a "rolling" release
-- fixing bugs and adding new features go hand in hand.
Copyright Years
When in any file of this package a copyright notice mentions a
year range (such as 1999-2011), it is a shorthand for a list of
all the years in that interval.
When in any file of this package a copyright notice mentions a
year range (such as 1999-2011), it is a shorthand for a list of
all the years in that interval.

8
THANKS
View File

@@ -4,7 +4,7 @@ If we missed you here, let us know!
Translations:
============
Sharuzzaman Ahmat Raslan <sharuzzaman@excite.com> Malay
Pedro Albuquerque <palbuquerque73@gmail.com> Portuguese
Josef Andersson <josef.andersson@fripost.org> Swedish
Laurentiu Buzdugan <buzdugan@voyager.net> Romanian
Mario Blättermann <mario.blaettermann@gmail.com> German
@@ -44,16 +44,18 @@ João Victor Duarte Martins <jvdm@sdf.lonestar.org> Brazilian Portuguese
Pavel Maryanov <acid@jack.kiev.ua> Russian
Daniele Medri <madrid@linux.it> Italian
Gergely Nagy <algernon@debian.org> Hungarian
Claudio Neves <cneves@nextis.com> Brazilian Portuguese
Kalle Olavi Niemitalo <kon@iki.fi> Finnish
Мирослав Николић <miroslavnikolic@rocketmail.com> Serbian
Claudio Neves <cneves@nextis.com> Brazilian Portuguese
Lauri Nurmi <lanurmi@iki.fi> Finnish
Daniel Nylander <po@danielnylander.se> Swedish
Mikel Olasagasti <hey_neken@mundurat.net> Basque
Yi-Jyun Pan <pan93412@gmail.com> Chinese (traditional)
Michael Piefel <piefel@informatik.hu-berlin.de> German
Sergey Poznyakoff <gray@gnu.org> Polish
Božidar Putanec <bozidarp@yahoo.com> Croatian
Trần Ngọc Quân <vnwildman@gmail.com> Vietnamese
Sharuzzaman Ahmat Raslan <sharuzzaman@excite.com> Malay
Sergey A. Ribalchenko <fisher@obu.ck.ua> Ukrainian and Russian
Michel Robitaille <robitail@IRO.UMontreal.CA> French
Christian Rose <menthos@menthos.com> Swedish
@@ -76,6 +78,7 @@ Miquel Vidal <miquel@sindominio.net> Catalan
Phan Vinh Thinh <teppi82@gmail.com> Vietnamese
Pauli Virtanen <pauli.virtanen@saunalahti.fi> Finnish
Aron Xu <happyaron.xu@gmail.com> Chinese (simplified)
Boyuan Yang <073plan@gmail.com> Chinese (simplified)
Peio Ziarsolo <peio@sindominio.net> Basque
Anton Zinoviev <zinoviev@debian.org> Bulgarian
@@ -84,6 +87,7 @@ Other stuff:
===========
Ben Armstrong <synrg@sanctuary.nslug.ns.ca> Negative -r value idea, code
Thomas Dickey <dickey@herndon4.his.com> Curses help and advice
Kamil Dudka <kdudka@redhat.com> Several small bug fixes
Sven Guckes <guckes@math.fu-berlin.de> Advice and advocacy
Thijs Kinkhorst <thijs@kinkhorst.com> rnano.1 manpage
Jim Knoble <jmknoble@pobox.com> Pico compat for browser

21
TODO
View File

@@ -2,28 +2,26 @@ A list of desired features
--------------------------
Somewhat urgent:
- Make undo/redo work also for justifying and indenting.
- Make undo/redo work also for justifying.
- Detect when text is being pasted, so that we can handle it faster.
See https://savannah.gnu.org/bugs/?40060.
- Allow to define and execute a macro: a stored sequence of keystrokes.
See https://savannah.gnu.org/bugs/?50314.
- 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.
- Allow piping marked text to an external command and replacing it with
the command's output -- that is: generalize the spell-check flow.
See also https://savannah.gnu.org/bugs/?28993.
Vague musings:
- FriBidi support?
- Add support for right-to-left text (RTL), through FriBidi?
- Allow setting marks (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?
- Make matching bracket searches sophisticated enough to skip over
brackets inside comments?
- Allow indentation of marked text by spaces as well as tabs?
- Allow indentation to add just enough columns to reach the nearest
multiple of tabsize, rather than always adding tabsize columns?
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]
@@ -41,8 +39,7 @@ For version 2.2:
- 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]
- Allow color syntaxes to be selected based on more than just filename
extension. [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:

View File

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

View File

@@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
AC_INIT([GNU nano], [2.9.2], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [3.0], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.14])
@@ -565,10 +565,10 @@ if eval "test x$CURSES_LIB_NAME = x"; then
fi
if eval "test x$CURSES_LIB_NAME = x"; then
AC_MSG_WARN([
*** No curses lib available. Consider getting the official ncurses
*** distribution from ftp://ftp.gnu.org/pub/gnu/ncurses if you get
*** errors compiling nano.])
AC_MSG_ERROR([
*** No curses lib was found. Please install the curses header files
*** 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])
fi
@@ -762,6 +762,14 @@ else
fi
AM_CONDITIONAL(BUILDING_FROM_GIT, test x$from_git = xyes)
if test x$from_git = xyes; then
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. ***])
fi
fi
AC_CONFIG_FILES([
Makefile
doc/Makefile

View File

@@ -7,21 +7,23 @@
<body text="#330000" bgcolor="#ffffff" link="#0000ef" vlink="#51188e" alink="#ff0000">
<h1>The GNU nano editor FAQ</h1>
<h2>Table of Contents</h2>
<h2><a href="#1">1. General</a></h2>
<h3>Table of Contents</h3>
<h3><a href="#1">1. General</a></h3>
<blockquote><p>
<a href="#1.1">1.1. What is GNU nano?</a><br>
<a href="#1.2">1.2. What is the history behind nano?</a><br>
<a href="#1.3">1.3. Why the name change from TIP?</a><br>
<a href="#1.4">1.4. What is the current version of nano?</a><br>
<a href="#1.5">1.5. I want to read the manpage without having to download the program!</a></p></blockquote>
<h2><a href="#2">2. Where to get GNU nano.</a></h2>
<a href="#1.5">1.5. I want to read the manpage without having to download the program!</a>
</p></blockquote>
<h3><a href="#2">2. Where to get GNU nano.</a></h3>
<blockquote><p>
<a href="#2.1">2.1. FTP and WWW sites that carry nano.</a><br>
<a href="#2.2">2.2. RedHat and derivatives (.rpm) packages.</a><br>
<a href="#2.3">2.3. Debian (.deb) packages.</a><br>
<a href="#2.4">2.4. By GIT (for the brave).</a></p></blockquote>
<h2><a href="#3">3. Installation and Configuration</a></h2>
<a href="#2.4">2.4. By GIT (for the brave).</a>
</p></blockquote>
<h3><a href="#3">3. Installation and Configuration</a></h3>
<blockquote><p>
<a href="#3.1">3.1. How do I install the RPM or DEB package?</a><br>
<a href="#3.2">3.2. Compiling from source: WHAT THE HECK DO I DO NOW?</a><br>
@@ -31,46 +33,52 @@
<a href="#3.7">3.7. Tell me more about this multibuffer stuff!</a><br>
<a href="#3.8">3.8. Tell me more about this verbatim input stuff!</a><br>
<a href="#3.9a">3.9a. How do I make a .nanorc file that nano will read when I start it?</a><br>
<a href="#3.9b">3.9b. How about in Win32?</a></p></blockquote>
<h2><a href="#4">4. Running</a></h2>
<a href="#3.9b">3.9b. How about in Win32?</a>
</p></blockquote>
<h3><a href="#4">4. Running</a></h3>
<blockquote><p>
<a href="#4.1">4.1. How do I open a file with a name beginning with '+' from the command line?</a><br>
<a href="#4.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.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. Ack! When I hold down a Meta key combination for a while, the character of the held key gets inserted now and then. What gives?</a><br>
<a href="#4.5">4.5. How do I type the F13-F16 keys listed in the help viewer? My keyboard only has F1-F12!</a><br>
<a href="#4.6">4.6. nano crashes when I type &lt;insert keystroke here&gt;!</a><br>
<a href="#4.6">4.6. nano crashes when I type &lt;insert keystrokes here&gt;!</a><br>
<a href="#4.7">4.7. nano crashes when I resize my window. How can I fix that?</a><br>
<a href="#4.8a">4.8a. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</a><br>
<a href="#4.8b">4.8b. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?<a><br>
<a href="#4.8a">4.8a. With what keystroke can I paste text from the clipboard into nano?</a><br>
<a href="#4.8b">4.8b. 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.8c">4.8c. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?<a><br>
<a href="#4.9">4.9. I've compiled nano with color support, but I don't see any color when I run it!</a><br>
<a href="#4.10">4.10. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
<a href="#4.11">4.11. How do I select text for or paste text from the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?</a><br>
<a href="#4.12">4.12. On startup I get a message that says "Detected a legacy nano history file". Now older nano versions can't find my search history!</a></p></blockquote>
<h2><a href="#5">5. Internationalization</a></h2>
<a href="#4.12">4.12. On startup I get a message that says "Detected a legacy nano history file". Now older nano versions can't find my search history!</a>
</p></blockquote>
<h3><a href="#5">5. Internationalization</a></h3>
<blockquote><p>
<a href="#5.1">5.1. There's no translation for my language!</a><br>
<a href="#5.2">5.2. I don't like the translation for &lt;x&gt; in my language. How can I fix it?</a><br>
<a href="#5.3">5.3. What is the status of Unicode support?</a></p></blockquote>
<h2><a href="#6">6. Advocacy and Licensing</a></h2>
<a href="#5.3">5.3. What is the status of Unicode support?</a>
</p></blockquote>
<h3><a href="#6">6. Advocacy and Licensing</a></h3>
<blockquote><p>
<a href="#6.1">6.1. Why should I use nano instead of Pico?</a><br>
<a href="#6.2">6.2. Why should I use Pico instead of nano?</a><br>
<a href="#6.3">6.3. What is so bad about the older Pine license?</a><br>
<a href="#6.4">6.4. Okay, well, what mail program should I use then?</a></p></blockquote>
<h2><a href="#7">7. Miscellaneous</a></h2>
<a href="#6.4">6.4. Okay, well, what mail program should I use then?</a>
</p></blockquote>
<h3><a href="#7">7. Miscellaneous</a></h3>
<blockquote><p>
<a href="#7.1">7.1. Where can I ask questions or send suggestions?</a><br>
<a href="#7.2">7.2. How do I submit a bug report or patch?</a><br>
<a href="#7.3">7.3. I want to send the development team a big load of cash (or just a thank you).</a><br>
<a href="#7.4">7.4. How do I join the development team?</a><br>
<a href="#7.5">7.5. Can I have write access to the GIT tree?</a></p></blockquote>
<a href="#7.5">7.5. Can I have write access to the GIT tree?</a>
</p></blockquote>
<hr width="100%">
<h1><a name="1"></a>1. General</h1>
<h2><a name="1.1"></a>1.1. What is GNU nano?</h2>
<h3><a name="1.1"></a>1.1. What is GNU nano?</h3>
<blockquote><p>GNU nano is designed to be a free replacement for the Pico text editor, part of the Pine email suite from <a href="http://www.washington.edu/pine/">The University of Washington</a>. It aims to &quot;emulate Pico as closely as possible and then include extra functionality&quot;.</p></blockquote>
<h2><a name="1.2"></a>1.2. What is the history behind nano?</h2>
<h3><a name="1.2"></a>1.2. What is the history behind nano?</h3>
<blockquote><p>Funny you should ask!</p>
<p><b>In the beginning...</b></p>
<p>For years Pine was THE program used to read email on a Unix system. The Pico text editor is the portion of the program one would use to compose his or her mail messages. Many beginners to Unix flocked to Pico and Pine because of their well organized, easy to use interfaces. With the proliferation of GNU/Linux in the mid to late 90's, many University students became intimately familiar with the strengths (and weaknesses) of Pine and Pico.</p>
@@ -80,30 +88,30 @@
<p>It was in late 1999 when Chris Allegretta (our hero) was yet again complaining to himself about the less-than-perfect license Pico was distributed under, the 1000 makefiles that came with it and how just a few small improvements could make it the Best Editor in the World (TM). Having been a convert from Slackware to Debian, he missed having a simple binary package that included Pine and Pico, and had grown tired of downloading them himself.</p>
<p>Finally something snapped inside and Chris coded and hacked like a madman for many hours straight one weekend to make a (barely usable) Pico clone, at the time called TIP (Tip Isn't Pico). The program could not be invoked without a filename, could not save files, had no help text display, spell checker, and so forth. But over time it improved, and with the help of a few great coders it matured to the (hopefully) stable state it is in today.</p>
<p>In February 2001, nano was declared an official GNU program by Richard Stallman. nano also reached its first production release on March 22, 2001.</p></blockquote>
<h2><a name="1.3"></a>1.3. Why the name change from TIP?</h2>
<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>
<h2><a name="1.4"></a>1.4. What is the current version of nano?</h2>
<blockquote><p>The current version of nano <i>should</i> be <b>2.9.2</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<h2><a name="1.5"></a>1.5. I want to read the man page without having to download the program!</h2>
<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>3.0</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<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%">
<h1><a name="2"></a>2. Where to get GNU nano.</h1>
<h2><a name="2.1"></a>2.1. Web sites that carry nano.</h2>
<h3><a name="2.1"></a>2.1. Web sites that carry nano.</h3>
<blockquote><p>The nano source tarballs can be downloaded from the following web sites:</p>
<ul>
<li><a href="https://nano-editor.org/dist/">https://nano-editor.org/dist/</a></li>
<li><a href="https://ftp.gnu.org/gnu/nano/">https://ftp.gnu.org/gnu/nano/</a></li>
</ul>
</blockquote>
<h2><a name="2.2"></a>2.2. RPM packages (RedHat, OpenSuse, and derivatives).</h2>
<h3><a name="2.2"></a>2.2. RPM packages (RedHat, OpenSuse, and derivatives).</h3>
<blockquote>
<ul>
<li><a href="https://kojipkgs.fedoraproject.org//packages/nano/">https://kojipkgs.fedoraproject.org//packages/nano/</a></li>
<li><a href="https://software.opensuse.org/package/nano">https://software.opensuse.org/package/nano</a></li>
</ul>
</blockquote>
<h2><a name="2.3"></a>2.3. Deb packages (Debian and derivatives):</h2>
<h3><a name="2.3"></a>2.3. Deb packages (Debian and derivatives):</h3>
<blockquote><p>Debian users can check out the current nano packages for:</p>
<ul>
<li><a href="http://packages.debian.org/stable/editors/nano">stable</a></li>
@@ -112,14 +120,14 @@
</ul>
<p>You can also have a look at the <a href="ftp://ftp.debian.org/debian/pool/main/n/nano/">Package Pool</a> to see all the available binary and source packages.</p>
</blockquote>
<h2><a name="2.4"></a>2.4. By GIT (for the brave).</h2>
<h3><a name="2.4"></a>2.4. By GIT (for the brave).</h3>
<blockquote><p>For the 'bleeding edge' current version of nano, you can use GIT to download the current source code. <b>Note:</b> believe it or not, by downloading code that has not yet stabilized into an official release, there could quite possibly be bugs, in fact the code may not even compile! Anyway, see <a href="http://git.savannah.gnu.org/cgit/nano.git/tree/README.GIT">the nano GIT document</a> for info on anonymous GIT access to the nano source.</p></blockquote>
<hr width="100%">
<h1><a name="3"></a>3. Installation and Configuration</h1>
<h2><a name="3.1"></a>3.1. How do I install the RPM or DEB package?</h2>
<h3><a name="3.1"></a>3.1. How do I install the RPM or DEB package?</h3>
<blockquote><p>It's simple really! As root, type <b>rpm -Uvh nano-x.y.z-1.i386.rpm</b> if you have a RedHat-ish system or <b>dpkg -i nano_x.y.z-1.deb</b> if you have a Debian-ish system, where <b>x.y.z</b> is the release of nano. There are other programs to install packages, and if you wish to use those, knock yourself out.</p></blockquote>
<h2><a name="3.2"></a>3.2. Compiling from source: WHAT THE HECK DO I DO NOW?</h2>
<h3><a name="3.2"></a>3.2. Compiling from source: WHAT THE HECK DO I DO NOW?</h3>
<blockquote><p>Okay, take a deep breath, this really isn't hard. Unpack the nano source with a command like:</p>
<p><b>tar -xvf nano-x.y.z.tar.gz</b></p>
<p>Then you need to run <b>configure</b> with any options you might want (if any).</p>
@@ -128,13 +136,13 @@
<b>./configure</b><br>
<b>make</b><br>
<b>make install</b> (as root, of course)</p></blockquote>
<h2><a name="3.3"></a>3.3. Why does everything go into /usr/local?</h2>
<h3><a name="3.3"></a>3.3. Why does everything go into /usr/local?</h3>
<blockquote><p>Well, that's what the <b>configure</b> script defaults to. If you wish to change this, simply do this:</p>
<p><b>./configure --prefix=/usr</b></p>
<p>to put nano into /usr/bin when you run <b>make install</b>.</p></blockquote>
<h2><a name="3.5"></a>3.5. nano should automatically run strip on the binary when installing it!</h2>
<h3><a name="3.5"></a>3.5. nano should automatically run strip on the binary when installing it!</h3>
<blockquote><p>Actually, it does, but you have to use <b>make install-strip</b>. The default make install does not, and will not, run strip automatically.</p></blockquote>
<h2><a name="3.6"></a>3.6. How can I make the executable smaller? This is too bloated!</h2>
<h3><a name="3.6"></a>3.6. How can I make the executable smaller? This is too bloated!</h3>
<blockquote><p>Actually, there are several parts of the editor that can be disabled. You can pass arguments to the <b>configure</b> script that disable certain features. Here's a brief list:</p>
<pre>
<b>--disable-browser</b> Disable the built-in file browser
@@ -157,49 +165,51 @@
<p>There's also the <b>--enable-tiny</b> option which disables everything above, as well as some larger chunks of the program (like the marker code that you use with Control-^ to select text). Also, if you know you aren't going to be using other languages, you can use <b>--disable-nls</b> to disable internationalization and save a few K to a few dozen K depending on whether you have locale support on your system. And finally, there's always good old <b>strip</b> to strip all debugging code and code that exists in libraries on your system.</p>
<p>With <b>--disable-wrapping-as-root</b> you can disable any hard-wrapping by default when the user is root, useful to prevent accidentally changing long lines in system configuration files.</p>
</blockquote>
<h2><a name="3.7"></a>3.7. Tell me more about this multibuffer stuff!</h2>
<blockquote><p>To use multiple file buffers, you must not have configured nano with <b>--disable-multibuffer</b> nor with <b>--enable-tiny</b> (use <b>nano -V</b> to check the compilation options). Then when you want to insert a file into its own buffer instead of into the current file, just hit <b>Meta-F</b> after typing <b>^R</b>. If you always want files to be loaded into their own buffers, use the <b>--multibuffer</b> or <b>-F</b> flag when you invoke nano.</p>
<p>You can move between the buffers you have open with the <b>Meta-&lt;</b> and <b>Meta-&gt;</b> keys, or more easily without holding Shift: <b>Meta-,</b> and <b>Meta-.</b> (clear as mud, right? =-). When you have more than one file buffer open, the ^X shortcut will say &quot;Close&quot;, instead of the normal &quot;Exit&quot; when only one buffer is open.</p></blockquote>
<h2><a name="3.8"></a>3.8. Tell me more about this verbatim input stuff!</h2>
<h3><a name="3.7"></a>3.7. Tell me more about this multibuffer stuff!</h3>
<blockquote><p>To use multiple file buffers, you must not have configured nano with <b>--disable-multibuffer</b> nor with <b>--enable-tiny</b> (use <b>nano -V</b> to check the compilation options). Then when you want to insert a file into its own buffer instead of into the current file, just hit <b>Meta-F</b> after typing <b>^R</b>. If you always want files to be loaded into their own buffers, use the <b>-F</b> or <b>--multibuffer</b> flag when you invoke nano, or add <b>set multibuffer</b> to your .nanorc file.</p>
<p>You can move between the buffers you have open with the <b>Meta-&lt;</b> and <b>Meta-&gt;</b> keys, or more easily without holding Shift: <b>Meta-,</b> and <b>Meta-.</b> (clear as mud, right? =-). When you have more than one buffer open, the ^X shortcut will say &quot;Close&quot;, instead of &quot;Exit&quot;.</p></blockquote>
<h3><a name="3.8"></a>3.8. Tell me more about this verbatim input stuff!</h3>
<blockquote><p>When you want to insert a literal character into the file you're editing, such as a control character that nano usually treats as a command, first press <b>Meta-V</b> (if you're not at a prompt, you'll get the message &quot;Verbatim Input&quot; on the status bar), then press the key(s) that generate the character you want.</p>
<p>Alternatively, if you've enabled Unicode support (see section <a href="#5.3">5.3</a>), you can press <b>Meta-V</b> and then type a six-digit hexadecimal code (from 000000 to 10FFFF, case-insensitive), and the character with the corresponding value will be inserted. The statubar will change to &quot;Unicode Input: ......&quot; when you do this.</p></blockquote>
<h2><a name="3.9a"></a>3.9a. How do I make a .nanorc file that will be read when I start nano?</h2>
<p>Alternatively, if Unicode support is enabled (see section <a href="#5.3">5.3</a>), you can press <b>Meta-V</b> and then type a six-digit hexadecimal code (from 000000 to 10FFFF, case-insensitive), and the character with the corresponding value will be inserted. The status bar will change to &quot;Unicode Input: ......&quot; when you do this.</p></blockquote>
<h3><a name="3.9a"></a>3.9a. How do I make a .nanorc file that will be read when I start nano?</h3>
<blockquote><p>It's not hard at all! But, your nano must <b>not</b> have been compiled with <b>--disable-nanorc</b>. Then simply copy the <b>sample.nanorc</b> that came with the nano source or your nano package (most likely in /usr/doc/nano) to .nanorc in your home directory. If you didn't get one, the syntax of the file is simple. Flags are turned on and off by using the words <b>set</b> and <b>unset</b> plus the long option name for the feature. For example, &quot;set nowrap&quot; or &quot;set smarthome&quot;.</p></blockquote>
<h2><a name="3.9b"></a>3.9b. How about in Win32?</h2>
<h3><a name="3.9b"></a>3.9b. How about in Win32?</h3>
<blockquote><p>If you're using the official nano .zip file and have extracted all the files, you should take the file nano.rc and place it somewhere on your Win32 system (for example, if you have write permission to do so, at the top of C:\). Then you must create an Environment variable called HOME which points to the directory where you put nano.rc. In Windows XP, you can get to Environment variables by right-clicking "My Computer" either on the desktop or in the Start Menu, and selecting Properties. This should bring up the System Properties panel. Then click the Advanced Tab, and there should be a button called Environment Variables. Click that to bring up the Environment Variables section. Now, under User Variables you should be able to click the New button, and make a new Variables Name called HOME, with the Variable Value of whatever path you copied nano.rc into (just the directory name; don't add nano.rc onto the end).</p>
<p>We're still working on documentation for enabling syntax highlighting on Win32; please bear with us.</p>
<p>Note that the nano.rc file must remain Unix-formatted in order for nano to understand it. In other words, you should probably use only nano to edit its config file. Other programs like Wordpad and Notepad will convert the file to DOS format when saving, and the latter does not even properly read Unix-formatted files to begin with.</p></blockquote>
<hr width="100%">
<h1><a name="4"></a>4. Running</h1>
<h2><a name="4.1"></a>4.1. How do I open a file with a name beginning with '+' from the command line?</h2>
<h3><a name="4.1"></a>4.1. How do I open a file with a name beginning with '+' from the command line?</h3>
<blockquote><p>If a command-line option that begins with '+' is followed by another option, the former is always treated as a starting line and column number, and the latter is always treated as a filename. If a command-line option that begins with '+' isn't followed by another option, it's always treated as a filename. Examples:</p>
<p>To open '+filename.txt' starting on line 1: <b>nano +filename.txt</b><br>
To open '+filename.txt' starting on line 10: <b>nano +10 +filename.txt</b><br>
To open '+filename.txt' starting on line 1, column 20: <b>nano +,20 +filename.txt</b><br>
To open '+filename.txt' starting on line 10, column 20: <b>nano +10,20 +filename.txt</b><br>
To open '+filename.txt' starting on line 1 and 'filename.txt' starting on line 40 (if nano has been compiled with multibuffer support): <b>nano +1 +filename.txt +40 filename.txt</b></p></blockquote>
<h2><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?</h2>
<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>
<h2><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?</h2>
<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>--rebindkeypad</b> option on the command line, or add the line <b>set rebindkeypad</b> to your .nanorc. However, nano's mouse support won't work properly if you do any of these things.</p></blockquote>
<h2><a name="4.4"></a>4.4. Ack! When I hold down a Meta key combination for a while, the character of the held key gets inserted now and then. What gives?</h2>
<h3><a name="4.4"></a>4.4. Ack! When I hold down a Meta key combination for a while, the character of the held key gets inserted now and then. What gives?</h3>
<blockquote><p>This was a bug in how nano handled consecutive escape sequences. It should be fixed since version 2.6.0.</p></blockquote>
<h2><a name="4.5"></a>4.5. How do I type the F13-F16 keys listed in the help viewer? My keyboard only has F1-F12!</h2>
<h3><a name="4.5"></a>4.5. How do I type the F13-F16 keys listed in the help viewer? My keyboard only has F1-F12!</h3>
<blockquote><p>It depends on the terminal type you're using. On some terminals, such as the FreeBSD console, xterm, konsole, and gnome-terminal, Shift-F1 to Shift-F4 will generate F13 to F16. On other terminals, such as the Linux console, rxvt, and Eterm, Shift-F3 to Shift-F6 will generate F13 to F16.</p></blockquote>
<h2><a name="4.6"></a>4.6. nano crashes when I type &lt;insert keystroke here&gt;!</h2>
<h3><a name="4.6"></a>4.6. nano crashes when I type &lt;insert keystrokes here&gt;!</h3>
<blockquote><p>If you aren't trying some bizarre keystroke combination with some bizarre $TERM entry, chances are you have found a bug. You are welcome to submit it to the <a href="mailto:nano-devel@gnu.org">nano-devel</a> list or in the <a href="https://savannah.gnu.org/bugs/?group=nano">bug tracker</a> on Savannah.</p></blockquote>
<h2><a name="4.7"></a>4.7. nano crashes when I resize my window. How can I fix that?</h2>
<h3><a name="4.7"></a>4.7. nano crashes when I resize my window. How can I fix that?</h3>
<blockquote><p>Older versions of nano had this problem. Please upgrade to version 2.7.0 or newer.</p></blockquote>
<h2><a name="4.8a"></a>4.8a. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</h2>
<blockquote><p>You have the autoindent feature turned on. Hit Meta-I to turn it off, paste your text, and then hit Meta-I again to turn it back on.</p></blockquote>
<h2><a name="4.8b"></a>4.8b. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?</h2>
<h3><a name="4.8a"></a>4.8a. With what keystroke can I paste text from the clipboard into nano?</h3>
<blockquote><p>In most desktop environments <b>Shift+Insert</b> will paste the contents of the clipboard.</p></blockquote>
<h3><a name="4.8b"></a>4.8b. When I paste text into a document, each line gets indented further than the last. Why? And how can I stop this?</h3>
<blockquote><p>You have the <i>autoindent</i> feature turned on. Hit <b>Meta-I</b> to turn it off, paste your text, and then hit <b>Meta-I</b> again to turn it back on.</p></blockquote>
<h3><a name="4.8c"></a>4.8c. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?</h3>
<blockquote><p>When pasting from Windows, in some situations linefeeds are sent instead of carriage returns (Enters). And linefeeds are <b>^J</b>s, which make nano justify (rewrap) the current paragraph. To prevent these linefeeds from causing these unwanted justifications, add this line to your .nanorc on the remote Linux box: <b>unbind ^J main</b> or <b>bind ^J enter main</b>, depending on whether the paste contains CR + LF or only LF.</p></blockquote>
<h2><a name="4.9"></a>4.9. I've compiled nano with color support, but I don't see any color when I run it!</h2>
<h3><a name="4.9"></a>4.9. I've compiled nano with color support, but I don't see any color when I run it!</h3>
<blockquote><p>If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Several example configurations are in the <b>syntax/</b> subdirectory of the nano source, which are normally installed to <b>/usr/local/share/nano/</b>. To enable all of them, uncomment the line <b># include "/usr/local/share/nano/*.nanorc"</b> in your nanorc. See also section <a href="#3.9a">3.9a</a>.</p></blockquote>
<h2><a name="4.10"></a>4.10. How do I make nano my default editor (in Pine, mutt, etc.)?</h2>
<h3><a name="4.10"></a>4.10. How do I make nano my default editor (in Pine, mutt, etc.)?</h3>
<blockquote><p>You need to make nano your $EDITOR. If you want this to be saved, you should put a line like this in your <b>.bashrc</b> if you use bash (or <b>.zshrc</b> if you believe in zsh):</p>
<p><b>export EDITOR=/usr/local/bin/nano</b></p>
<p>or, if you use tcsh, put this in your <b>.cshrc</b> file:</p>
@@ -212,53 +222,53 @@
<p>If you're a mutt user, you should see an effect immediately the next time you log in. No further configuration is needed. However, if you want to let people know you use nano to compose your email messages, you can put a line like this in your <b>.muttrc</b>:</p>
<p><b>my_hdr X-Composer: nano x.y.z</b></p>
<p>Again, replace x.y.z with the version of nano you use.</p></blockquote>
<h2><a name="4.11"></a>4.11. How do I select text for or paste text from the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?</h2>
<h3><a name="4.11"></a>4.11. How do I select text for or paste text from the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?</h3>
<blockquote><p>Try holding down the Shift key and selecting or pasting the text as you normally would.</p></blockquote>
<h2><a name="4.12"></a>4.12. On startup I get a message that says "Detected a legacy nano history file". Now older nano versions can't find my search history!</h2>
<h3><a name="4.12"></a>4.12. On startup I get a message that says "Detected a legacy nano history file". Now older nano versions can't find my search history!</h3>
<blockquote><p>In nano 2.3.0, cursor-position history was introduced, and both history files now reside in a .nano subdirectory in your home directory. A newer nano will move an existing search-history file to this new location so it can continue to be used. This means that if you then try and use an earlier version of nano, it will be unable to see your current search history. To fix this, run the following command:</p>
<p><b>ln -sf ~/.nano/search_history ~/.nano_history</b></p>
<p>The "migration service" (moving the search-history file to its new location) will be deleted from nano in early 2018.</p></blockquote>
<p>The "migration service" (moving the search-history file to its new location) has been deleted from nano in late 2017, since version 2.9.0. The search-history and position-history files will now be looked for first in ~/.nano/ and, when not found there, then in ~/.local/share/nano/.</p></blockquote>
<hr width="100%">
<h1><a name="5"></a>5. Internationalization</h1>
<h2><a name="5.1"></a>5.1. There's no translation for my language!</h2>
<h3><a name="5.1"></a>5.1. There's no translation for my language!</h3>
<blockquote><p>In June 2001, GNU nano entered the <a href="http://translationproject.org/html/welcome.html">Translation Project</a> and since then, translations should be managed from there.</p>
<p>If there isn't a translation for your language, you could ask <a href="http://translationproject.org/team/">your language team</a> to translate nano, or better still, join that team and do it yourself. Joining a team is easy. You just need to ask the team leader to add you, and then send a <a href="http://translationproject.org/disclaim.txt">translation disclaimer to the FSF</a> (this is necessary as nano is an official GNU package, but it does <b>not</b> mean that you transfer the rights of your work to the FSF, it's just so the FSF can legally manage them).</p>
<p>In any case, translating nano is very easy. Just grab the latest <b>nano.pot</b> file listed on <a href="http://translationproject.org/domain/nano.html">nano's page</a> at the TP, and translate each <b>msgid</b> line into your native language on the <b>msgstr</b> line. When you're done, you should send it to the TP's central po repository.</p></blockquote>
<h2><a name="5.2"></a>5.2. I don't like the translation for &lt;x&gt; in my language. How can I fix it?</h2>
<blockquote><p>The best way would probably be to send an e-mail to the team's mailing listed mentione in the <code>Language-Team:</code> field in the <b>&lt;your_language&gt;.po</b> file with your suggested corrections, and then they can make the changes reach the nano-devel list.</p></blockquote>
<h2><a name="5.3"></a>5.3. What is the status of Unicode support?</h2>
<blockquote><p>Since versions 1.3.12, Unicode should be usable. With your terminal, locale (LC_ALL and similar environment variables), and encoding configured to properly support UTF-8, you should be able to enter and save Unicode text.</p></blockquote>
<p>In any case, translating nano is easy. Just grab the latest <b>nano.pot</b> file listed on <a href="http://translationproject.org/domain/nano.html">nano's page</a> at the TP, and translate each <b>msgid</b> line into your native language on the <b>msgstr</b> line. When you're done, you should send it to the TP's central PO-file repository.</p></blockquote>
<h3><a name="5.2"></a>5.2. I don't like the translation for &lt;x&gt; in my language. How can I fix it?</h3>
<blockquote><p>The best way is to send an e-mail with your suggested corrections to the team's mailing list. The address is mentioned in the <code>Language-Team:</code> field in the relevant PO file. The team leader or the assigned translator can then make the changes reach the nano-devel list.</p></blockquote>
<h3><a name="5.3"></a>5.3. What is the status of Unicode support?</h3>
<blockquote><p>Unicode should be fully usable nowadays. When the encoding of your terminal is set to UTF-8, and your locale (mainly the LANG environment variable) is UTF-8 too, then you should be able to read, enter and save Unicode text.</p></blockquote>
<hr width="100%">
<h1><a name="6"></a>6. Advocacy and Licensing</h1>
<h2><a name="6.1"></a>6.1. Why should I use nano instead of Pico?</h2>
<h3><a name="6.1"></a>6.1. Why should I use nano instead of Pico?</h3>
<blockquote><p>There are many reasons to use nano instead of Pico. A more complete list can be found at the <a href="https://nano-editor.org/">nano homepage</a>.</p></blockquote>
<h2><a name="6.2"></a>6.2. Why should I use Pico instead of nano?</h2>
<h3><a name="6.2"></a>6.2. Why should I use Pico instead of nano?</h3>
<blockquote><p>Again, check out the <a href="https://nano-editor.org/">nano homepage</a> for a good summary of reasons. It really is a matter of personal preference as to which editor you should use. If you're the type of person who likes using the original version of a program, then Pico is the editor for you. If you don't mind sacrificing mailer integration with Pine, and are looking for a few more features, as well as a 'better' license in terms of adding your own changes, nano is the way to go.</p>
<p>Note that the last of these no longer applies to the new version of Pine, <a href="http://www.washington.edu/alpine/">Alpine</a>, which is under the Apache License, version 2.0.</p></blockquote>
<h2><a name="6.3"></a>6.3. What is so bad about the older Pine license?</h2>
<h3><a name="6.3"></a>6.3. What is so bad about the older Pine license?</h3>
<blockquote><p>The U of W license for older versions of Pine and Pico is not considered truly Free Software according to both the Free Software Foundation and the <a href="http://www.debian.org/social_contract#guidelines">Debian Free Software Guidelines</a>. The main problem regards the limitations on distributing derived works: according to UW, you can distribute their software, and you can modify it, but you can not do both, i.e. distribute modified binaries.</p></blockquote>
<h2><a name="6.4"></a>6.4. Okay, well, what mail program should I use then?</h2>
<h3><a name="6.4"></a>6.4. Okay, well, what mail program should I use then?</h3>
<blockquote><p>If you are looking to use a Free Software program similar to Pine, and Emacs is not your thing, you should definitely take a look at <a href="http://www.mutt.org/">mutt</a>. It is a full-screen, console based mail program that actually has a lot more flexibility than Pine, but has a keymap included in the distribution that allows you to use the same keystrokes as Pine would to send and receive mail. It's also under the GNU General Public License, version 2.0.</p>
<p>Of course, due to the license change you can now use the <a href="http://www.washington.edu/alpine/">Alpine distribution</a> of PINE as it is now considered Free Software, but you would be sacrificing many of nano's features to do so.</p></blockquote>
<hr width="100%">
<h1><a name="7"></a>7. Miscellaneous</h1>
<h2><a name="7.1"></a>7.1. Where can I ask questions or send suggestions?</h2>
<h3><a name="7.1"></a>7.1. Where can I ask questions or send suggestions?</h3>
<blockquote><p>There are three mailing lists for nano hosted at <a href="http://savannah.gnu.org/">Savannah</a>: info-nano, help-nano and nano-devel. info-nano is a very low traffic list where new versions of nano are announced (surprise!). help-nano is for getting help with the editor without needing to hear all of the development issues surrounding it. nano-devel is a normally low, sometimes high traffic list for discussing the present and future development of nano. Here are links to where you can sign up for a given list:</p>
<p>info-nano - <a href="http://mail.gnu.org/mailman/listinfo/info-nano/">http://mail.gnu.org/mailman/listinfo/info-nano/</a><br>
help-nano - <a href="http://mail.gnu.org/mailman/listinfo/help-nano/">http://mail.gnu.org/mailman/listinfo/help-nano/</a><br>
nano-devel - <a href="http://mail.gnu.org/mailman/listinfo/nano-devel/">http://mail.gnu.org/mailman/listinfo/nano-devel/</a></p></blockquote>
<h2><a name="7.2"></a>7.3. How do I submit a bug report or patch?</h2>
<h3><a name="7.2"></a>7.3. How do I submit a bug report or patch?</h3>
<blockquote>
<p>The best way to submit bugs is through the <a href="https://savannah.gnu.org/bugs/?group=nano">Savannah bug tracker</a>, as you can check whether the bug you are reporting has already been submitted, and it makes it easier for the maintainers to keep track of them.
<p>You can submit patches for nano via <a href="https://savannah.gnu.org/patch/?group=nano">Savannah's patch manager</a>.</p></blockquote>
<h2><a name="7.3"></a>7.3. I want to send the development team a big load of cash (or just a thank you).</h2>
<h3><a name="7.3"></a>7.3. I want to send the development team a big load of cash (or just a thank you).</h3>
<blockquote><p>That's fine. Send it <a href="mailto:nano-devel@gnu.org">our way</a>! Better yet, fix a <a href="https://savannah.gnu.org/bugs/?group=nano">bug</a> in the program or implement a <a href="https://nano-editor.org/dist/latest/TODO">cool feature</a> and send us that instead (though cash is fine too).</p></blockquote>
<h2><a name="7.4"></a>7.4. How do I join the development team?</h2>
<h3><a name="7.4"></a>7.4. How do I join the development team?</h3>
<blockquote><p>The easiest way is to consistently send in good patches that add some needed functionality, fix a bug or two, and/or make the program more optimized/efficient. Then ask nicely and you will probably be added to the Savannah development list and be given write access after a while. There is a lot of responsibility that goes along with being a team member, so don't think it's just something to add to your resume.</p></blockquote>
<h2><a name="7.5"></a>7.5. Can I have write access to the git tree?</h2>
<h3><a name="7.5"></a>7.5. Can I have write access to the git tree?</h3>
<blockquote><p>Re-read section <a href="#7.4">7.4</a> and you should know the answer.</p></blockquote>
<hr width="100%">

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 2.9.2" "January 2018"
.TH NANO 1 "version 3.0" "September 2018"
.SH NAME
nano \- Nano's ANOther editor, an enhanced free Pico clone
@@ -54,9 +54,10 @@ highlighted), and then use \fB^K\fR to cut it, or \fBM\-6\fR to copy it to the
cutbuffer. One can also save the marked text to a file with \fB^O\fR, or
spell check it with \fB^T\fR.
.PP
Since nano-2.7.0, text can also be selected by holding Shift and moving the
cursor with the arrow keys. Holding down the Alt key too will increase the
stride.
On some terminals, text can be selected also by holding down Shift while
using the arrow keys. Holding down the Ctrl or Alt key too will increase
the stride.
Any cursor movement without Shift being held will cancel such a selection.
.PP
The two lines at the bottom of the screen show some important commands;
the built-in help (\fB^G\fR) lists all the available ones.
@@ -106,7 +107,11 @@ should only need to use this option if they don't, as mouse support
won't work properly with this option enabled.
.TP
.BR \-L ", " \-\-nonewlines
Don't add newlines to the ends of files.
Don't automatically add a newline when a file does not end with one.
.TP
.BR \-M ", " \-\-trimblanks
Snip trailing whitespace from the wrapped line when automatic
hard-wrapping occurs or when text is justified.
.TP
.BR \-N ", " \-\-noconvert
Disable automatic conversion of files from DOS/Mac format.
@@ -117,13 +122,12 @@ Use the blank line below the title bar as extra editing space.
.BR \-P ", " \-\-positionlog
For the 200 most recent files, log the last position of the cursor,
and place it at that position again upon reopening such a file.
(The old form of this option, \fB\-\-poslog\fR, is deprecated.)
.TP
.BR "\-Q ""\fIcharacters\fB""" ", " "\-\-quotestr=""" \fIcharacters """
Set the quoting string for justifying. The default is
\fB"^([\ \\t]*[#:>\\|}])+"\fP if extended regular expression support is
available, or \fB">\ "\fP otherwise. Note that \fB\\t\fP stands for a
Tab.
.BR "\-Q ""\fIregex\fB""" ", " "\-\-quotestr=""" \fIregex """
Set the regular expression for matching the quoting part of a line.
This is used when justifying.
The default value is \fB"^([\ \\t]*([#:>|}]|//))+"\fP.
Note that \fB\\t\fP stands for an actual Tab.
.TP
.BR \-R ", " \-\-restricted
Restricted mode: don't read or write to any file not specified on the
@@ -184,8 +188,9 @@ highlighted item. Useful for braille users.
Show a summary of the available command-line options and exit.
.TP
.BR \-i ", " \-\-autoindent
Indent new lines to the previous line's indentation. Useful when
editing source code.
Automatically indent a newly created line to the same number of tabs
and/or spaces as the previous line (or as the next line if the previous
line is the beginning of a paragraph).
.TP
.BR \-k ", " \-\-cutfromcursor
Make the 'Cut Text' command (normally \fB^K\fR) cut from the current cursor
@@ -247,6 +252,9 @@ Disable the hard-wrapping of long lines. This option conflicts with
.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.
.TP
.BR \-z ", " \-\-suspend
Enable the suspend ability.
.TP
@@ -300,12 +308,16 @@ cannot be undone any more. The workaround is, of course, to exit without
saving.
.sp
The recording and playback of keyboard macros works correctly only on a
terminal emulator, not on a Linux console (VT), because the latter is a
deficient terminal. And it works only with recent versions of ncurses.
terminal emulator, not on a Linux console (VT), because the latter does
not by default distinguish modified from unmodified arrow keys.
.sp
Please report any other bugs that you encounter via:
.br
\fIhttps://savannah.gnu.org/bugs/?group=nano\fR.
.sp
When nano crashes, it will save any modified buffers to emergency .save files.
If you are able to reproduce the crash and you want to get a backtrace, define
the environment variable \fBNANO_NOCATCH\fR.
.SH HOMEPAGE
\fIhttps://nano-editor.org/\fR

View File

@@ -8,8 +8,8 @@
@smallbook
@set EDITION 0.5
@set VERSION 2.9.2
@set UPDATED January 2018
@set VERSION 3.0
@set UPDATED September 2018
@dircategory Editors
@direntry
@@ -23,7 +23,7 @@
@titlepage
@title GNU @command{nano}
@subtitle a small and friendly text editor
@subtitle version 2.9.2
@subtitle version 3.0
@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 2.9.2.
This manual documents the GNU @command{nano} editor, version 3.0.
@menu
* Introduction::
@@ -198,7 +198,12 @@ won't work properly with this option enabled.
@item -L
@itemx --nonewlines
Don't add newlines to the ends of files.
Don't automatically add a newline when a file does not end with one.
@item -M
@itemx --trimblanks
Snip trailing whitespace from the wrapped line when automatic
hard-wrapping occurs or when text is justified.
@item -N
@itemx --noconvert
@@ -212,13 +217,11 @@ Use the blank line below the title bar as extra editing space.
@itemx --positionlog
For the 200 most recent files, log the last position of the cursor,
and place it at that position again upon reopening such a file.
(The old form of this option, @option{--poslog}, is deprecated.)
@item -Q "@var{characters}"
@itemx --quotestr="@var{characters}"
Set the quoting string for justifying. The default value is
@t{"^([ \t]*[|>:@}#])+"} if extended regular expression support
is available, and @t{"> "} otherwise.
@item -Q "@var{regex}"
@itemx --quotestr="@var{regex}"
Set the regular expression for matching the quoting part of a line, used
when justifying. The default value is @t{"^([@w{ }\t]*([#:>|@}]|//))+"}.
Note that @code{\t} stands for a literal Tab character.
@item -R
@@ -295,8 +298,9 @@ Show a summary of command-line options and exit.
@item -i
@itemx --autoindent
Automatically indent new lines to the same number of spaces and tabs as
the previous line.
Automatically indent a newly created line to the same number of tabs
and/or spaces as the previous line (or as the next line if the previous
line is the beginning of a paragraph).
@item -k
@itemx --cutfromcursor
@@ -351,7 +355,7 @@ The default value is @t{-8}. This option conflicts with @option{-w}
@itemx --speller=@var{program}
Use the given program to do spell checking and correcting. By default,
@command{nano} uses the command specified in the @env{SPELL} environment
variable for this. If @env{SPELL} is not set, and @option{--speller} is
variable. If @env{SPELL} is not set, and @option{--speller} is
not specified either, then @command{nano} uses its own interactive spell
corrector, which requires the GNU @command{spell} program to be installed.
@@ -388,6 +392,10 @@ is located at the very bottom of the editor.
Note: When accessing the help system, Expert Mode is temporarily
disabled to display the help-system navigation keys.
@item -y
@itemx --afterends
Make Ctrl+Right stop at word ends instead of beginnings.
@item -z
@itemx --suspend
Enable the ability to suspend @command{nano} using the system's suspend
@@ -493,12 +501,16 @@ the 'Copy Text' command (default key binding: @kbd{M-6}).
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
to be selected. The selected portion of text will be highlighted in
reverse video (or in bold if you set the boldtext option).
to be selected. The selected portion of text will be highlighted.
This selection can now be cut or copied in its entirety with a single
@kbd{^K} or @kbd{M-6}. Or the selection can be used to limit the scope of
a search-and-replace (@kbd{^\}) or spell-checking session (@kbd{^T}).
On some terminals, text can be selected also by holding down @kbd{Shift}
while using the cursor keys. Holding down the @kbd{Ctrl} or @kbd{Alt}
key too will increase the stride. Such a selection is cancelled
upon any cursor movement where @kbd{Shift} isn't held.
Cutting or copying selected text will toggle the mark off automatically.
If necessary, it can be toggled off manually with another @kbd{^6} or @kbd{M-A}.
@@ -562,8 +574,8 @@ cannot be undone any more. The workaround is, of course, to exit without
saving.
The recording and playback of keyboard macros works correctly only on a
terminal emulator, not on a Linux console (VT), because the latter is a
deficient terminal. And it works only with recent versions of ncurses.
terminal emulator, not on a Linux console (VT), because the latter does
not by default distinguish modified from unmodified arrow keys.
@node Built-in Help
@chapter Built-in Help
@@ -584,59 +596,47 @@ The following global toggles are available:
@table @code
@item Backup Files toggle
@kbd{Meta-B} toggles the @option{-B} (@option{--backup}) command-line option.
@item Constant Cursor Position Display toggle
@item Constant Cursor Position Display
@kbd{Meta-C} toggles the @option{-c} (@option{--constantshow}) command-line option.
@item Multiple File Buffers toggle
@kbd{Meta-F} toggles the @option{-F} (@option{--multibuffer}) command-line option.
@item Smart Home Key toggle
@item Smart Home Key
@kbd{Meta-H} toggles the @option{-A} (@option{--smarthome}) command-line option.
@item Auto Indent toggle
@item Auto Indent
@kbd{Meta-I} toggles the @option{-i} (@option{--autoindent}) command-line option.
@item Cut From Cursor To End-of-Line toggle
@item Cut From Cursor To End-of-Line
@kbd{Meta-K} toggles the @option{-k} (@option{--cutfromcursor}) command-line option.
@item Long-Line Wrapping toggle
@item Long-Line Wrapping
@kbd{Meta-L} toggles the @option{-w} (@option{--nowrap}) command-line option.
@item Mouse Support toggle
@item Mouse Support
@kbd{Meta-M} toggles the @option{-m} (@option{--mouse}) command-line option.
@item No Conversion From DOS/Mac Format toggle
@kbd{Meta-N} toggles the @option{-N} (@option{--noconvert}) command-line option.
@item Tabs To Spaces
@kbd{Meta-O} toggles the @option{-E} (@option{--tabstospaces}) command-line option.
@item More Space For Editing toggle
@kbd{Meta-O} toggles the @option{-O} (@option{--morespace}) command-line option.
@item Whitespace Display
@kbd{Meta-P} toggles the displaying of whitespace (@pxref{Whitespace}).
@item Whitespace Display toggle
@kbd{Meta-P} toggles the whitespace-display mode (@pxref{Whitespace}).
@item Tabs To Spaces toggle
@kbd{Meta-Q} toggles the @option{-E} (@option{--tabstospaces}) command-line option.
@item Smooth Scrolling toggle
@item Smooth Scrolling
@kbd{Meta-S} toggles the @option{-S} (@option{--smooth}) command-line option.
@item Expert/No Help toggle
@item Expert/No Help
@kbd{Meta-X} toggles the @option{-x} (@option{--nohelp}) command-line option.
@item Color Syntax Highlighting toggle
@item Color Syntax Highlighting
@kbd{Meta-Y} toggles color syntax highlighting (if your nanorc defines syntaxes
--- @pxref{Syntax Highlighting}).
@item Suspension toggle
@item Suspension
@kbd{Meta-Z} toggles the @option{-z} (@option{--suspend}) command-line option.
@item Line Numbers toggle
@item Line Numbers
@kbd{Meta-#} toggles the @option{-l} (@option{--linenumbers}) command-line option.
@item Soft Wrapping toggle
@item Soft Wrapping
@kbd{Meta-$} toggles the @option{-$} (@option{--softwrap}) command-line option.
@end table
@@ -682,6 +682,9 @@ The supported settings in a nanorc file are:
@table @code
@item set afterends
Make Ctrl+Right stop at word ends instead of beginnings.
@item set allow_insecure_backup
When backing up files, allow the backup to succeed even if its
permissions can't be (re)set due to special OS considerations.
@@ -692,7 +695,9 @@ When soft line wrapping is enabled, make it wrap lines at blank characters
(tabs and spaces) instead of always at the edge of the screen.
@item set autoindent
Use auto-indentation.
Automatically indent a newly created line to the same number of tabs
and/or spaces as the previous line (or as the next line if the previous
line is the beginning of a paragraph).
@item set backup
When saving a file, back up the previous version of it, using the current
@@ -704,10 +709,6 @@ numbered one every time a file is saved --- when backups are enabled
with @code{set backup} or @option{--backup} or @option{-B}.
The uniquely numbered files are stored in the specified directory.
@item set backwards
Obsolete option. Recognized but ignored. @code{^Q} is available to
start a backward search.
@item set boldtext
Use bold instead of reverse video for the title bar, status bar, key combos,
function tags, line numbers, and selected text. This can be overridden by
@@ -719,20 +720,23 @@ 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 casesensitive
Do case-sensitive searches by default.
@item set constantshow
Constantly display the cursor position on the status bar.
(The old form of this option, @code{set const}, is deprecated.)
Note that this overrides @option{quickblank}.
@item set cutfromcursor
Use cut-from-cursor-to-end-of-line by default, instead of cutting the whole line.
(The old form of this option, @code{set cut}, is deprecated.)
@item set errorcolor @var{fgcolor},@var{bgcolor}
Use this color combination for the status bar when an error message is displayed.
@xref{@code{set functioncolor}} for valid color names.
@item set fill @var{number}
Hard-wrap lines at column number @var{number}. If @var{number} is 0 or less,
the maximum line length will be the screen width less @var{number} columns.
@@ -745,7 +749,8 @@ 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}, and @code{magenta}.
@code{red}, @code{cyan}, @code{yellow}, @code{magenta}, 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.
@@ -786,13 +791,13 @@ Don't convert files from DOS/Mac format.
@item set nohelp
Don't display the help lists at the bottom of the screen.
@item set nonewlines
When a file does not end with a newline, don't automatically add one.
@item set nopauses
Don't pause between warnings at startup. This means that only
the last one will be visible (when there are multiple ones).
@item set nonewlines
Don't add newlines to the ends of files.
@item set nowrap
Don't hard-wrap text at all. This option conflicts with
@option{fill}; the last one given takes effect.
@@ -810,7 +815,6 @@ directory feature is turned off.
@item set positionlog
Save the cursor position of files between editing sessions.
The cursor position is remembered for the 200 most-recently edited files.
(The old form of this option, @code{set poslog}, is deprecated.)
@item set preserve
Preserve the XON and XOFF keys (@kbd{^Q} and @kbd{^S}).
@@ -829,12 +833,10 @@ keystroke instead of 25. Note that @option{constantshow} overrides this.
@item set quiet
Obsolete option. Recognized but ignored.
@item set quotestr "@var{string}"
@item set quotestr "@var{regex}"
The email-quote string, used to justify email-quoted paragraphs. This
is an extended regular expression if your system supports them,
otherwise a literal string. The default value is
@t{"^([ \\t]*[#:>\\|@}])+"} if you have extended regular expression
support, and @t{"> "} otherwise.
is an extended regular expression. The default value is
@t{"^([@w{ }\t]*([#:>|@}]|//))+"}.
Note that @code{\t} stands for a literal Tab character.
@item set rebinddelete
@@ -899,6 +901,7 @@ Use this color combination for the title bar.
@item set trimblanks
Remove trailing whitespace from wrapped lines when automatic
hard-wrapping occurs or when text is justified.
(The old form of this option, @code{set justifytrim}, is deprecated.)
@item set unix
Save a file by default in Unix format. This overrides nano's
@@ -940,7 +943,7 @@ via the following commands in a nanorc file:
@table @code
@item syntax "@var{name}" ["@var{fileregex}" @dots{}]
@item syntax @var{name} ["@var{fileregex}" @dots{}]
Start the definition of a syntax with this @var{name}.
All subsequent @code{color} and other such commands
will be added to this syntax, until a new @code{syntax}
@@ -971,14 +974,9 @@ file, to determine whether this syntax should be used for it.
on the system and will be silently ignored otherwise.)
@item linter @var{program} [@var{arg} @dots{}]
Use the given @var{program} to do a syntax check on the current file.
Use the given @var{program} to do a syntax check on the current buffer.
(This overrides the speller function.)
@item formatter @var{program} [@var{arg} @dots{}]
Use the given @var{program} to automatically reformat text ---
useful for a programming language like Go.
(This overrides the speller and linter functions.)
@item comment "@var{string}"
Use the given string for commenting and uncommenting lines.
If the string contains a vertical bar or pipe character (@t{|}),
@@ -994,8 +992,11 @@ The default value is @t{"#"}.
Display all pieces of text that match the
extended regular expression "regex" with foreground color "fgcolor" and
background color "bgcolor", at least one of which must be specified.
Valid colors for foreground and background are: white, black, red,
blue, green, yellow, magenta, and cyan. You may use the prefix "bright"
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}
--- where @code{normal} means the default foreground or background color.
You may use the prefix @code{bright}
to get a stronger color highlight for the foreground. If your
terminal supports transparency, not specifying a "bgcolor" tells @command{nano}
to attempt to use a transparent background.
@@ -1022,17 +1023,32 @@ to @code{icolor}.
@item extendsyntax @var{name} @var{command} [@var{arg} @dots{}]
Extend the syntax previously defined as "@var{name}" with another @var{command}.
This allows you to add a new @code{color}, @code{icolor}, @code{header},
@code{magic}, @code{comment}, @code{linter}, or @code{formatter} command
to an already
@code{magic}, @code{comment}, or @code{linter} command to an already
defined syntax --- useful when you want to slightly improve a syntax defined
in one of the system-installed files (which normally are not writable).
@end table
Note: the @code{formatter} command has been removed. It was superseded by
a more general mechanism: the filtering of buffer or marked text through
an external command. Such filtering is done by typing @code{^R^X} and then
preceding your formatter command with the pipe symbol (@code{|}). It has
the added advantage that the operation can be undone.
If you use such a formatting command regularly, you could assign the relevant
series of keystrokes to a single key in your nanorc:
@example
bind M-F "^R^X|yourformatcommand^M" main
@end example
(Note that the @key{^R}, @key{^X}, and @key{^M} are each a single, literal
control character. You can enter them by preceding each with @key{M-V}.)
@node Rebinding Keys
@section Rebinding Keys
Key bindings can be changed via the following two commands in a
Key bindings can be changed via the following three commands in a
nanorc file:
@table @code
@@ -1041,6 +1057,13 @@ nanorc file:
Rebinds @code{key} to @code{function} in the context of @code{menu}
(or in all menus where the function exists by using @code{all}).
@item bind key "string" menu
Makes @code{key} produce @code{string} in the context of @code{menu}
(or in all menus where the key exists when @code{all} is used).
The @code{string} can consist of text or commands or a mix of them.
(To enter a command into the @code{string}, precede its keystroke
with @kbd{M-V}.)
@item unbind key menu
Unbinds @code{key} from @code{menu}
(or from all menus where it exists by using @code{all}).
@@ -1052,16 +1075,20 @@ The format of @code{key} should be one of:
@itemize @w{}
@item
@code{^}@ followed by an ASCII character or the word "Space".
@code{^}@ followed by a Latin letter, by one of several ASCII characters
(@@, ], \, ^, or _), or by the word "Space".
Example: @code{^C}.
@item
@code{M-}@ followed by a ASCII character or the word "Space".
@code{M-}@ followed by any ASCII character except [, or by the word "Space".
Example: @code{M-C}.
@item
@code{F}@ followed by a numeric value from 1 to 16.
Example: @code{F10}.
@item
the word "Ins" or the word "Del".
@end itemize
@sp 1
@@ -1093,17 +1120,14 @@ Starts a forward search for text in the current buffer --- or for filenames
matching a string in the current list in the file browser.
@item wherewas
Starts a backward search for text in the current buffer.
@item searchagain
Repeats the last search command without prompting.
(The form @code{research} is deprecated.)
Starts a backward search for text in the current buffer --- or for filenames
matching a string in the current list in the file browser.
@item findprevious
As @code{searchagain}, but always in the backward direction.
Searches the next occurrence in the backward direction.
@item findnext
As @code{searchagain}, but always in the forward direction.
Searches the next occurrence in the forward direction.
@item replace
Interactively replaces text within the current buffer.
@@ -1111,38 +1135,47 @@ Interactively replaces text within the current buffer.
@item cut
Cuts and stores the current line (or the marked region).
@item copytext
@item copy
Copies the current line (or the marked region) without deleting it.
(The old form 'copytext' is deprecated.)
@item uncut
Copies the currently stored text into the current buffer at the
@item paste
Pastes the currently stored text into the current buffer at the
current cursor position.
@item mark
Sets the mark at the current position, to start selecting text.
(The old form 'uncut' is deprecated.)
@item cutwordleft
Cuts from the cursor position to the beginning of the preceding word.
(This function is not bound by default. If your terminal produces
@code{^H} for <Ctrl+Backspace>, you can make <Ctrl+Backspace> delete
the word to the left of the cursor by rebinding ^H to this function.)
@item cutwordright
Cuts from the cursor position to the beginning of the next word.
(This function is bound by default to <Ctrl+Delete>.)
@item cutrestoffile
Cuts all text from the cursor position till the end of the buffer.
@item mark
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.
(The form @code{cursorpos} is deprecated.)
@item wordcount
Counts the number of words, lines and characters in the current buffer.
@item speller
Invokes a spell-checking program (or a linting program, if the current
syntax highlighting defines one).
Invokes a spell-checking program (or linting program,
if the active syntax defines such a thing).
@item justify
Justifies the current paragraph.
Justifies the current paragraph. A paragraph is a group of contiguous lines
that, apart from possibly the first line, all have the same indentation. The
beginning of a paragraph is detected by either this lone line with a differing
indentation or by a preceding blank line.
@item fulljustify
Justifies the entire current buffer.
@@ -1174,10 +1207,12 @@ Goes one line up (in the editor or browser).
Goes one line down (in the editor or browser).
@item scrollup
Scrolls up one line of text from the current position.
Scrolls the viewport up one row (meaning that the text slides down)
while keeping the cursor in the same text position, if possible.
@item scrolldown
Scrolls down one line of text from the current position.
Scrolls the viewport down one row (meaning that the text slides up)
while keeping the cursor in the same text position, if possible.
@item prevword
Moves the cursor to the beginning of the previous word.
@@ -1220,9 +1255,6 @@ Goes to the last line of the file.
Goes to a specific line (and column if specified). Negative numbers count
from the end of the file (and end of the line).
@item gototext
Switches from targeting a line number to searching for text.
@item findbracket
Moves the cursor to the bracket (brace, parenthesis, etc.) that matches
(pairs) with the one under the cursor.
@@ -1269,32 +1301,42 @@ Suspends the editor (if the suspending function is enabled, see the
"suspendenable" entry below).
@item casesens
Toggles case sensitivity in searching (search/replace menus only).
Toggles whether searching/replacing ignores or respects the case of
the given characters.
@item regexp
Toggles whether searching/replacing is based on literal strings or regular expressions.
(The form @code{regex} is deprecated.)
Toggles whether searching/replacing uses literal strings or regular expressions.
@item backwards
Toggles whether searching/replacing goes forward or backward.
@item prevhistory
Shows the previous history entry in the prompt menus (e.g.@: search).
Retrieves the previous (older) entry at a prompt.
@item nexthistory
Shows the next history entry in the prompt menus (e.g.@: search).
Retrieves the next (newer) entry at a prompt.
@item flipreplace
Toggles between searching for something and replacing something.
(The form @code{dontreplace} is deprecated.)
@item flipgoto
Toggles between searching for text and targeting a line number.
(The form @code{gototext} is deprecated.)
@item flipexecute
Toggles between inserting a file and executing a command.
@item flippipe
When executing a command, toggles whether the current buffer (or marked
region) is piped to the command.
@item flipnewbuffer
Toggles between inserting into the current buffer and into a new
empty buffer.
(The form @code{newbuffer} is deprecated.)
@item flipconvert
When reading in a file, toggles between converting and not converting
it from DOS/Mac format. Converting is the default.
@item dosformat
When writing a file, switches to writing a DOS format (CR/LF).
@@ -1332,11 +1374,9 @@ Goes to the last file when using the file browser (reading or writing files).
@item nohelp
Toggles the presence of the two-line list of key bindings at the bottom of the screen.
@item constupdate
@item constantshow
Toggles the constant display of the current line, column, and character positions.
@item morespace
Toggles the presence of the blank line that 'separates' the title bar from the file text.
(The form @code{constupdate} is deprecated.)
@item smoothscroll
Toggles smooth scrolling (when moving around with the arrow keys).
@@ -1344,6 +1384,9 @@ Toggles smooth scrolling (when moving around with the arrow keys).
@item softwrap
Toggles the displaying of overlong lines on multiple screen lines.
@item linenumbers
Toggles the display of line numbers in front of the text.
@item whitespacedisplay
Toggles the showing of whitespace.
@@ -1354,11 +1397,14 @@ Toggles syntax highlighting.
Toggles the smartness of the Home key.
@item autoindent
Toggles whether new lines will contain the same amount of whitespace as the preceding line.
Toggles whether a newly created line will contain the same amount of leading
whitespace as the preceding line --- or as the next line if the preceding line
is the beginning of a paragraph.
@item cuttoend
@item cutfromcursor
Toggles whether cutting text will cut the whole line or just from the current cursor
position to the end of the line.
(The form @code{cuttoend} is deprecated.)
@item nowrap
Toggles whether long lines will be hard-wrapped to the next line.
@@ -1366,19 +1412,9 @@ Toggles whether long lines will be hard-wrapped to the next line.
@item tabstospaces
Toggles whether typed tabs will be converted to spaces.
@item backupfile
Toggles whether a backup will be made of the file to be edited.
@item multibuffer
Toggles whether a file is inserted into the current buffer
or read into a new buffer.
@item mouse
Toggles mouse support.
@item noconvert
Toggles automatic conversion of files from DOS/Mac format.
@item suspendenable
Toggles whether the suspend shortcut (normally @kbd{^Z}) will suspend the editor.
@@ -1400,7 +1436,9 @@ The 'search to replace' menu.
@item replacewith
The 'replace with' menu, which comes up after 'search to replace'.
(The form @code{replace2} is deprecated.)
@item yesno
The 'yesno' menu, where the Yes/No/All/Cancel question is asked.
@item gotoline
The 'goto line (and column)' menu.
@@ -1424,7 +1462,7 @@ The interactive spell checker Yes/no menu.
The linter menu.
@item browser
The file browser for inserting or writing a file.
The file browser, for choosing a file to read from or write to.
@item whereisfile
The 'search for a file' menu in the file browser.
@@ -1443,14 +1481,15 @@ it means all menus where the specified @code{key} exists.
@node The File Browser
@chapter The File Browser
When reading or writing files, pressing @kbd{^T} will invoke 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 keys,
page up, and page down. More advanced movement is accomplished by
searching via @kbd{^W} (or @kbd{w'} and changing directories via
@kbd{^_} (or @kbd{g}). The behavior of the @kbd{Enter} key (or @kbd{s})
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
@@ -1491,6 +1530,11 @@ The output of the "Display Cursor Position" command (@kbd{^C}) displays
not only the current line and character position of the cursor,
but also (between the two) the current column position.
@item Hard-Wrapping
By default, @command{nano} hard-wraps lines at screen width minus eight
columns, whereas Pico does it at screen width minus six columns. You can
make @command{nano} do the same as Pico by using @option{--fill=-6}.
@item Spell Checking
In the internal spell checker misspelled words are sorted alphabetically
and trimmed for uniqueness, such that the words 'apple' and 'Apple' will

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 2.9.2" "January 2018"
.TH NANORC 5 "version 3.0" "September 2018"
.SH NAME
nanorc \- GNU nano's configuration file
@@ -53,6 +53,9 @@ match \fB"\fP, \fB'\fP, \fB)\fP, \fB>\fP, \fB]\fP, and \fB}\fP.
The supported commands and arguments are:
.TP 3
.B set afterends
Make Ctrl+Right 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
can't be (re)set due to special OS considerations. You should
@@ -63,7 +66,9 @@ When soft line wrapping is enabled, make it wrap lines at blank characters
(tabs and spaces) instead of always at the edge of the screen.
.TP
.B set autoindent
Use auto-indentation.
Automatically indent a newly created line to the same number of tabs
and/or spaces as the previous line (or as the next line if the previous
line is the beginning of a paragraph).
.TP
.B set backup
When saving a file, create a backup file by adding a tilde (\fB~\fP) to
@@ -75,10 +80,6 @@ numbered one every time a file is saved -- when backups are enabled
with \fBset backup\fR or \fB\-\-backup\fR or \fB\-B\fR.
The uniquely numbered files are stored in the specified \fIdirectory\fR.
.TP
.B set backwards
Obsolete option. Recognized but ignored. \fB^Q\fR is available to
start a backward search.
.TP
.B set boldtext
Use bold instead of reverse video for the title bar, status bar, key combos,
function tags, line numbers, and selected text. This can be overridden by
@@ -88,7 +89,7 @@ setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, \fBkeycolor\fP,
.B set brackets "\fIstring\fP"
Set the characters treated as closing brackets when justifying
paragraphs. This may not include blank characters. Only closing
punctuation (see \fBpunct\fP), optionally followed by the specified
punctuation (see \fBset punct\fP), optionally followed by the specified
closing brackets, can end sentences. The default value is "\fB"')>]}\fP".
.TP
.B set casesensitive
@@ -96,13 +97,16 @@ Do case-sensitive searches by default.
.TP
.B set constantshow
Constantly display the cursor position in the status bar.
(The old form of this option, '\fBset const\fR', is deprecated.)
This overrides the option \fBquickblank\fR.
.TP
.B set cutfromcursor
Use cut-from-cursor-to-end-of-line by default, instead of cutting the whole line.
(The old form of this option, '\fBset cut\fR', is deprecated.)
.TP
.B set errorcolor \fIfgcolor\fR,\fIbgcolor\fR
Use this color combination for the status bar when an error message is displayed.
See \fBset titlecolor\fR for valid color names.
.TP
.B set fill \fInumber\fR
Hard-wrap lines at column number \fInumber\fR. If \fInumber\fR is 0 or less,
the maximum line length will be the screen width less \fInumber\fP columns.
@@ -155,7 +159,7 @@ Don't convert files from DOS/Mac format.
Don't display the two help lines at the bottom of the screen.
.TP
.B set nonewlines
Don't automatically add a newline to the ends of files.
When a file does not end with a newline, don't automatically add one.
.TP
.B set nopauses
Don't pause between warnings at startup. This means that only
@@ -178,7 +182,6 @@ directory feature is turned off.
.B set positionlog
Save the cursor position of files between editing sessions.
The cursor position is remembered for the 200 most-recently edited files.
(The old form of this option, '\fBset poslog\fR', is deprecated.)
.TP
.B set preserve
Preserve the XON and XOFF keys (^Q and ^S).
@@ -196,12 +199,10 @@ keystroke instead of 25. The option \fBconstantshow\fR overrides this.
.B set quiet
Obsolete option. Recognized but ignored.
.TP
.B set quotestr "\fIstring\fP"
.B set quotestr "\fIregex\fP"
The email-quote string, used to justify email-quoted paragraphs. This
is an extended regular expression if your system supports them,
otherwise a literal string. The default value is
"\fB^([\ \\t]*[#:>\\|}])+\fP" if you have extended regular expression
support, and "\fB>\ \fP" otherwise. Note that '\\t' stands for a literal
is an extended regular expression. The default value is
"\fB^([\ \\t]*([#:>|}]|//))+\fP". Note that \fB\\t\fR stands for an actual
Tab character.
.TP
.B set rebinddelete
@@ -238,9 +239,9 @@ Use smooth scrolling by default.
.B set softwrap
Enable soft line wrapping for easier viewing of very long lines.
.TP
.B set speller "\fIspellprog\fP"
Use spelling checker \fIspellprog\fP instead of the built-in one, which
calls \fIspell\fP.
.B set speller "\fIprogram\fP"
Use the given \fIprogram\fR to do spell checking and correcting,
instead of the built-in corrector that calls \fBspell\fR.
.TP
.B set statuscolor \fIfgcolor\fR,\fIbgcolor\fR
Specify the color combination to use for the status bar.
@@ -262,13 +263,16 @@ Save automatically on exit, don't prompt.
.B set titlecolor \fIfgcolor\fR,\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 ", " cyan ", " yellow ", and " magenta .
.BR white ", " black ", " blue ", " green ", " red ", "
.BR cyan ", " yellow ", " magenta ", 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.
.TP
.B set trimblanks
Remove trailing whitespace from wrapped lines when automatic
hard-wrapping occurs or when text is justified.
(The old form of this option, '\fBset justifytrim\fR', is deprecated.)
.TP
.B set unix
Save a file by default in Unix format. This overrides nano's
@@ -303,7 +307,7 @@ good fit for a small editor like \fBnano\fR.
For each kind of file a separate syntax can be defined
via the following commands:
.TP
.BR syntax " ""\fIname\fR"" [""\fIfileregex\fR"" ...]"
.BI syntax " name \fR[" """" fileregex """ " \fR...]
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
@@ -315,17 +319,17 @@ 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.
The syntax "\fBdefault\fP" is special: it takes no \fIfileregex\fR,
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
The syntax \fBnone\fP is reserved; specifying it on the command line
is the same as not having a syntax at all.
.TP
.BR header " ""\fIregex\fR"" " ...
.BI "header """ regex """ \fR...
If from all defined syntaxes no \fIfileregex\fR matched, then compare
this \fIregex\fR (or regexes) against the first line of the current file,
to determine whether this syntax should be used for it.
.TP
.BR magic " ""\fIregex\fR"" " ...
.BI "magic """ regex """ \fR...
If no \fIfileregex\fR matched and no \fBheader\fR regex matched
either, then compare this \fIregex\fR (or regexes) against the
result of querying the \fBmagic\fP database about the current
@@ -334,16 +338,11 @@ file, to determine whether this syntax should be used for it.
system and will be silently ignored otherwise.)
.TP
.BI linter " program " \fR[ "arg " \fR...]
Use the given \fIprogram\fR to run a syntax check on the current file.
Use the given \fIprogram\fR to run a syntax check on the current buffer.
(This overrides the speller function.)
.TP
.BI formatter " program " \fR[ "arg " \fR...]
Use the given \fIprogram\fR to automatically reformat text --
useful in a programming language like Go.
(This overrides the speller and linter functions.)
.TP
.BR comment " ""\fIstring\fR"""
Use the given string for commenting and uncommenting lines.
.BI "comment """ string """
Use the given \fIstring\fR for commenting and uncommenting lines.
If the string contains a vertical bar or pipe character (\fB|\fR),
this designates bracket-style comments; for example, "\fB/*|*/\fR" for
CSS files. The characters before the pipe are prepended to the line and the
@@ -353,21 +352,23 @@ for Python files. If empty double quotes are specified, the comment/uncomment
function is disabled; for example, "" for JSON.
The default value is "\fB#\fP".
.TP
.B color \fIfgcolor\fR,\fIbgcolor\fR """\fIregex\fR""" ...
.BI "color " fgcolor , bgcolor " """ regex """ " \fR...
Display all pieces of text that match
the extended regular expression \fIregex\fP with foreground color
\fIfgcolor\fP and background color \fIbgcolor\fP, at least one of which
must be specified. Valid colors for foreground and background
are: white, black, red, blue, green, yellow, magenta, and cyan. You may
use the prefix "bright" to get a stronger color highlight for the
must be specified. Valid names for foreground and background colors are:
.BR white ", " black ", " blue ", " green ", " red ", "
.BR cyan ", " yellow ", " magenta ", and " normal
-- where \fBnormal\fR means the default foreground or background color.
You may use the prefix \fBbright\fR to get a stronger color highlight for the
foreground. If your terminal supports transparency, not specifying a
\fIbgcolor\fP tells \fBnano\fP to attempt to use a transparent
background.
.TP
.B icolor \fIfgcolor\fR,\fIbgcolor\fR """\fIregex\fR""" ...
.BI "icolor " fgcolor , bgcolor " """ regex """ " \fR...
Same as above, except that the matching is case insensitive.
.TP
.BR color " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIfromrx\fR"" " end= """\fItorx\fR""
.BI "color " fgcolor , bgcolor " start=""" fromrx """ end=""" torx """
Display all pieces of text whose start matches extended regular expression
\fIfromrx\fP and whose end matches extended regular expression \fItorx\fP with
foreground color \fIfgcolor\fP and background color \fIbgcolor\fP,
@@ -376,10 +377,10 @@ 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
.BR icolor " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIfromrx\fR"" " end= """\fItorx\fR""
.BI "icolor " fgcolor , bgcolor " start=""" fromrx """ end=""" torx """
Same as above, except that the matching is case insensitive.
.TP
.BR include " ""\fIsyntaxfile\fR"""
.BI "include """ syntaxfile """
Read in self-contained color syntaxes from \fIsyntaxfile\fP. Note that
\fIsyntaxfile\fP may contain only the above commands, from \fBsyntax\fP
to \fBicolor\fP.
@@ -387,38 +388,68 @@ to \fBicolor\fP.
.BI extendsyntax " name command " \fR[ "arg " \fR...]
Extend the syntax previously defined as \fIname\fR with another
\fIcommand\fR. This allows adding a new \fBcolor\fP, \fBicolor\fP,
\fBheader\fP, \fBmagic\fP, \fBcomment\fP, \fBlinter\fP, or \fBformatter\fP
\fBheader\fP, \fBmagic\fP, \fBcomment\fP, or \fBlinter\fP
command to an already defined syntax -- useful when you want to
slightly improve a syntax defined in one of the system-installed
files (which normally are not writable).
.P
Note: the \fBformatter\fR command has been removed. It was superseded by
a more general mechanism: the filtering of buffer or marked text through
an external command. Such filtering is done by typing \fB^R^X\fR and then
preceding your formatter command with the pipe symbol (\fB|\fR). It has
the added advantage that the operation can be undone.
.PP
If you use such a formatting command regularly, you could assign the relevant
series of keystrokes to a single key in your nanorc:
.PP
.RS
.B "bind M\-F \(dq^R^X|yourformatcommand^M\(dq main"
.RE
.PP
(Note that the \fB^R\fR, \fB^X\fR, and \fB^M\fR are each a single, literal
control character. You can enter them by preceding each with \fBM-V\fR.)
.SH REBINDING KEYS
Key bindings can be changed via the following two commands:
Key bindings can be changed via the following three commands:
.RS 3
.TP
.BI bind " key function menu"
Rebinds the key \fIkey\fP to a new function named \fIfunction\fP in the
context of menu \fImenu\fP (or in all menus where the function exists
by using \fBall\fP).
.TP
.BI bind " key " """" string """" " menu"
Makes the given \fIkey\fR produce the given \fIstring\fR in the given
\fImenu\fR (or in all menus where the key exists when \fBall\fR is used).
The \fIstring\fR can consist of text or commands or a mix of them.
(To enter a command into the \fIstring\fR, precede its keystroke
with \fBM-V\fR.)
.TP
.BI unbind " key menu"
Unbinds the key \fIkey\fP from the menu named \fImenu\fP (or from all
menus where it exists by using \fBall\fP).
.RE
.TP
The format of \fIkey\fP should be one of:
.RS 3
.TP 3
.B ^
followed by an alpha character or the word "Space".
Example: ^C
followed by a Latin letter, by one of several ASCII characters
(@, ], \\, ^, or _), or by the word "Space".
Example: ^C.
.TP
.B M-
followed by a printable character or the word "Space".
Example: M-C
followed by any ASCII character except [, or by the word "Space".
Example: M-C.
.TP
.B F
followed by a numeric value from 1 to 16.
Example: F10
Example: F10.
.TP
the word "Ins" or the word "Del".
.RE
.TP
@@ -449,17 +480,14 @@ Starts a forward search for text in the current buffer -- or for filenames
matching a string in the current list in the file browser.
.TP
.B wherewas
Starts a backward search for text in the current buffer.
.TP
.B searchagain
Repeats the last search command without prompting.
(The form 'research' is deprecated.)
Starts a backward search for text in the current buffer -- or for filenames
matching a string in the current list in the file browser.
.TP
.B findprevious
As \fBsearchagain\fR, but always in the backward direction.
Searches the next occurrence in the backward direction.
.TP
.B findnext
As \fBsearchagain\fR, but always in the forward direction.
Searches the next occurrence in the forward direction.
.TP
.B replace
Interactively replaces text within the current buffer.
@@ -467,41 +495,50 @@ Interactively replaces text within the current buffer.
.B cut
Cuts and stores the current line (or the marked region).
.TP
.B copytext
.B copy
Copies the current line (or the marked region) without deleting it.
(The old form 'copytext' is deprecated.)
.TP
.B uncut
Copies the currently stored text into the current buffer at the
.B paste
Pastes the currently stored text into the current buffer at the
current cursor position.
.TP
.B mark
Sets the mark at the current position, to start selecting text.
(The old form 'uncut' is deprecated.)
.TP
.B cutwordleft
Cuts from the cursor position to the beginning of the preceding word.
(This function is not bound by default. If your terminal produces
\fB^H\fR for <Ctrl+Backspace>, you can make <Ctrl+Backspace> delete
the word to the left of the cursor by rebinding ^H to this function.)
.TP
.B cutwordright
Cuts from the cursor position to the beginning of the next word.
(This function is bound by default to <Ctrl+Delete>.)
.TP
.B cutrestoffile
Cuts all text from the cursor position till the end of the buffer.
.TP
.B mark
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.
(The form 'cursorpos' is deprecated.)
.TP
.B wordcount
Counts the number of words, lines and characters in the current buffer.
.TP
.B speller
Invokes a spell-checking program (or a linting program, if the current
syntax highlighting defines one).
Invokes a spell-checking program (or linting program,
if the active syntax defines such a thing).
.TP
.B linter
A synonym of \fBspeller\fR (for when the speller has not been configured).
.TP
.B justify
Justifies the current paragraph.
Justifies the current paragraph. A paragraph is a group of contiguous lines
that, apart from possibly the first line, all have the same indentation. The
beginning of a paragraph is detected by either this lone line with a differing
indentation or by a preceding blank line.
.TP
.B fulljustify
Justifies the entire current buffer.
@@ -533,10 +570,12 @@ Goes one line up (in the editor or browser).
Goes one line down (in the editor or browser).
.TP
.B scrollup
Scrolls up one line of text from the current position.
Scrolls the viewport up one row (meaning that the text slides down)
while keeping the cursor in the same text position, if possible.
.TP
.B scrolldown
Scrolls down one line of text from the current position.
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 prevword
Moves the cursor to the beginning of the previous word.
@@ -579,9 +618,6 @@ Goes to the last line of the file.
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 gototext
Switches from targeting a line number to searching for text.
.TP
.B findbracket
Moves the cursor to the bracket (brace, parenthesis, etc.) that matches
(pairs) with the one under the cursor.
@@ -628,32 +664,42 @@ Suspends the editor (if the suspending function is enabled, see the
"suspendenable" entry below).
.TP
.B casesens
Toggles case sensitivity in searching (search/replace menus only).
Toggles whether searching/replacing ignores or respects the case of
the given characters.
.TP
.B regexp
Toggles whether searching/replacing is based on literal strings or regular expressions.
(The form 'regex' is deprecated.)
Toggles whether searching/replacing uses literal strings or regular expressions.
.TP
.B backwards
Toggles whether searching/replacing goes forward or backward.
.TP
.B prevhistory
Shows the previous history entry in the prompt menus (e.g. search).
Retrieves the previous (older) entry at a prompt.
.TP
.B nexthistory
Shows the next history entry in the prompt menus (e.g. search).
Retrieves the next (newer) entry at a prompt.
.TP
.B flipreplace
Toggles between searching for something and replacing something.
(The form 'dontreplace' is deprecated.)
.TP
.B flipgoto
Toggles between searching for text and targeting a line number.
(The form 'gototext' is deprecated.)
.TP
.B flipexecute
Toggles between inserting a file and executing a command.
.TP
.B flippipe
When executing a command, toggles whether the current buffer (or marked
region) is piped to the command.
.TP
.B flipnewbuffer
Toggles between inserting into the current buffer and into a new
empty buffer.
(The form 'newbuffer' is deprecated.)
.TP
.B flipconvert
When reading in a file, toggles between converting and not converting
it from DOS/Mac format. Converting is the default.
.TP
.B dosformat
When writing a file, switches to writing a DOS format (CR/LF).
@@ -691,11 +737,9 @@ Goes to the last file when using the file browser (reading or writing files).
.B nohelp
Toggles the presence of the two-line list of key bindings at the bottom of the screen.
.TP
.B constupdate
.B constantshow
Toggles the constant display of the current line, column, and character positions.
.TP
.B morespace
Toggles the presence of the blank line that 'separates' the title bar from the file text.
(The form 'constupdate' is deprecated.)
.TP
.B smoothscroll
Toggles smooth scrolling (when moving around with the arrow keys).
@@ -703,6 +747,9 @@ Toggles smooth scrolling (when moving around with the arrow keys).
.B softwrap
Toggles the displaying of overlong lines on multiple screen lines.
.TP
.B linenumbers
Toggles the display of line numbers in front of the text.
.TP
.B whitespacedisplay
Toggles the showing of whitespace.
.TP
@@ -713,11 +760,14 @@ Toggles syntax highlighting.
Toggles the smartness of the Home key.
.TP
.B autoindent
Toggles whether new lines will contain the same amount of whitespace as the preceding line.
Toggles whether a newly created line will contain the same amount of leading
whitespace as the preceding line -- or as the next line if the preceding line
is the beginning of a paragraph.
.TP
.B cuttoend
.B cutfromcursor
Toggles whether cutting text will cut the whole line or just from the current cursor
position to the end of the line.
(The form 'cuttoend' is deprecated.)
.TP
.B nowrap
Toggles whether long lines will be hard-wrapped to the next line.
@@ -725,19 +775,9 @@ Toggles whether long lines will be hard-wrapped to the next line.
.B tabstospaces
Toggles whether typed tabs will be converted to spaces.
.TP
.B backupfile
Toggles whether a backup will be made of the file being edited.
.TP
.B multibuffer
Toggles whether a file is inserted into the current buffer
or read into a new buffer.
.TP
.B mouse
Toggles mouse support.
.TP
.B noconvert
Toggles automatic conversion of files from DOS/Mac format.
.TP
.B suspendenable
Toggles whether the suspend sequence (normally ^Z) will suspend the editor window.
.RE
@@ -757,7 +797,9 @@ The 'search to replace' menu.
.TP
.B replacewith
The 'replace with' menu, which comes up after 'search to replace'.
(The form 'replace2' is deprecated.)
.TP
.B yesno
The 'yesno' menu, where the Yes/No/All/Cancel question is asked.
.TP
.B gotoline
The 'goto line (and column)' menu.

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH RNANO 1 "version 2.9.2" "January 2018"
.TH RNANO 1 "version 3.0" "September 2018"
.SH NAME
rnano \- a restricted nano

View File

@@ -1,9 +1,7 @@
## Sample initialization file for GNU nano.
##
## Please note that you must have configured nano with --enable-nanorc
## for this file to be read! Also note that this file should not be in
## DOS or Mac format, and that characters specially interpreted by the
## shell should not be escaped here.
## This file should not be in DOS or Mac format, and characters
## specially interpreted by the shell should not be escaped here.
##
## To make sure an option is disabled, use "unset <option>".
##
@@ -15,11 +13,17 @@
## its end. For example, for the "brackets" option, ""')>]}" will match
## ", ', ), >, ], and }.
## Make the 'nextword' function (Ctrl+Right) stop at word ends
## instead of at beginnings.
# set afterends
## When soft line wrapping is enabled, make it wrap lines at blanks
## (tabs and spaces) instead of always at the edge of the screen.
# set atblanks
## Use auto-indentation.
## Automatically indent a newly created line to the same number of
## tabs and/or spaces as the preceding line -- or as the next line
## if the preceding line is the beginning of a paragraph.
# set autoindent
## Back up files to the current filename plus a tilde.
@@ -31,10 +35,9 @@
## Use bold text instead of reverse video text.
# set boldtext
## The characters treated as closing brackets when justifying
## paragraphs. They cannot contain blank characters. Only closing
## punctuation, optionally followed by closing brackets, can end
## sentences.
## 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.
# set brackets ""')>]}"
## Do case-sensitive searches by default.
@@ -43,15 +46,14 @@
## Constantly display the cursor position in the status bar. Note that
## this overrides "quickblank".
# set constantshow
## (The old form, 'const', is deprecated.)
## Use cut-from-cursor-to-end-of-line by default.
# set cutfromcursor
## (The old form, 'cut', is deprecated.)
## Set the line length for wrapping text and justifying paragraphs.
## If the value is 0 or less, the wrapping point will be the screen
## width less this number.
## Enable hard-wrapping and set the target width, both for automatic
## line wrapping and for justifying paragraphs. If the value is 0 or
## less, the wrapping point will be the screen width minus this number.
# set fill -8
## Remember the used search/replace strings for the next session.
@@ -89,14 +91,14 @@
## Don't display the helpful shortcut lists at the bottom of the screen.
# set nohelp
## Don't automatically add a newline when a file does not end with one.
# set nonewlines
## Don't pause between warnings at startup. Which means that only the
## last one will be readable (when there are multiple ones).
# set nopauses
## Don't add newlines to the ends of files.
# set nonewlines
## Don't wrap text at all.
## Do not automatically hard-wrap text.
# set nowrap
## Set operating directory. nano will not read or write files outside
@@ -107,7 +109,6 @@
## Remember the cursor position in each file for the next editing session.
# set positionlog
## (The old form, 'poslog', is deprecated.)
## Preserve the XON and XOFF keys (^Q and ^S).
# set preserve
@@ -123,12 +124,8 @@
# set quickblank
## The email-quote string, used to justify email-quoted paragraphs.
## This is an extended regular expression if your system supports them,
## otherwise a literal string.
## If you have extended regular expression support, the default is:
# set quotestr "^([ ]*[#:>\|}])+"
## Otherwise:
# set quotestr "> "
## This is an extended regular expression. The default is:
# set quotestr "^([ ]*([#:>|}]|//))+"
## Fix Backspace/Delete confusion problem.
# set rebinddelete
@@ -150,7 +147,7 @@
## beginning of the line.
# set smarthome
## Use smooth scrolling as the default.
## Use line-by-line scrolling instead of chunk-by-chunk.
# set smooth
## Enable soft line wrapping (AKA full-line display).
@@ -174,6 +171,7 @@
## Snip whitespace at the end of lines when justifying or hard-wrapping.
# set trimblanks
## (The old form, 'justifytrim', is deprecated.)
## Disallow file modification. Why would you want this in an rcfile? ;)
# set view
@@ -196,17 +194,19 @@
# set wordchars "<_>."
## Paint the interface elements of nano.
## These are examples; by default there are no colors.
## 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 numbercolor cyan
# set keycolor cyan
# set functioncolor green
## In root's .nanorc you might want to use:
# set titlecolor brightwhite,red
# set statuscolor brightwhite,red
# set titlecolor brightwhite,magenta
# set statuscolor brightwhite,magenta
# set errorcolor brightwhite,red
# set selectedcolor brightwhite,cyan
# set numbercolor magenta
# set keycolor brightmagenta
@@ -231,9 +231,9 @@
## "color" will do case-sensitive matches, while "icolor" will do
## case-insensitive matches.
##
## Valid colors: white, black, red, blue, green, yellow, magenta, cyan.
## For foreground colors, you may use the prefix "bright" to get a
## stronger highlight.
## Valid color names ares: white, black, normal, red, blue, green,
## yellow, magenta, cyan. For foreground colors, you may use the
## prefix "bright" to get a stronger highlight.
##
## To use multi-line regexes, use the start="regex" end="regex"
## [start="regex" end="regex"...] format.
@@ -253,18 +253,23 @@
## ".nanorc" extension) should be the same as the "short description"
## name inside that file. These names are kept fairly short to make
## them easier to remember and faster to type using nano's -Y option.
##
## To include all existing syntax definitions, you can do:
# include "@PKGDATADIR@/*.nanorc"
## Key bindings.
## See nanorc(5) (section REBINDING KEYS) for more details on this.
##
## The following two functions are not bound to any key by default.
## You may wish to choose other keys than the ones suggested here.
# bind M-B cutwordleft main
# bind M-N cutwordright main
## Set this if your Backspace key sends Del most of the time.
## If your Backspace key behaves as Delete (when ssh'ing in from another
## machine, for example), set this to make it behave as Backspace again:
# bind Del backspace all
## The <Ctrl+Delete> keystroke deletes the word to the right of the cursor.
## On some terminals the <Ctrl+Backspace> keystroke produces ^H, which is
## the ASCII character for backspace, so it is bound by default to the
## backspace function. The <Backspace> key itself produces a different
## keycode, which is hard-bound to the backspace function. So, if you
## normally use <Backspace> for backspacing and not ^H, you can make
## <Ctrl+Backspace> delete the word to the left of the cursor with:
# bind ^H cutwordleft main

View File

@@ -10,7 +10,7 @@ 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/v2.6/%{name}-%{version}.tar.gz
Source : https://nano-editor.org/dist/latest/%{name}-%{version}.tar.gz
BuildRoot : %{_tmppath}/%{name}-%{version}-root
BuildRequires : autoconf, automake, gettext-devel, ncurses-devel, texinfo

View File

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

1697
po/bg.po

File diff suppressed because it is too large Load Diff

1719
po/ca.po

File diff suppressed because it is too large Load Diff

1746
po/cs.po

File diff suppressed because it is too large Load Diff

2236
po/da.po

File diff suppressed because it is too large Load Diff

1460
po/de.po

File diff suppressed because it is too large Load Diff

1591
po/eo.po

File diff suppressed because it is too large Load Diff

1572
po/es.po

File diff suppressed because it is too large Load Diff

1873
po/eu.po

File diff suppressed because it is too large Load Diff

1869
po/fi.po

File diff suppressed because it is too large Load Diff

3203
po/fr.po

File diff suppressed because it is too large Load Diff

2173
po/ga.po

File diff suppressed because it is too large Load Diff

1696
po/gl.po

File diff suppressed because it is too large Load Diff

2297
po/hr.po

File diff suppressed because it is too large Load Diff

1721
po/hu.po

File diff suppressed because it is too large Load Diff

1752
po/id.po

File diff suppressed because it is too large Load Diff

1473
po/it.po

File diff suppressed because it is too large Load Diff

1551
po/ja.po

File diff suppressed because it is too large Load Diff

1970
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1675
po/nb.po

File diff suppressed because it is too large Load Diff

1567
po/nl.po

File diff suppressed because it is too large Load Diff

1705
po/nn.po

File diff suppressed because it is too large Load Diff

1796
po/pl.po

File diff suppressed because it is too large Load Diff

2689
po/pt.po Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1536
po/ro.po

File diff suppressed because it is too large Load Diff

1685
po/ru.po

File diff suppressed because it is too large Load Diff

1691
po/sl.po

File diff suppressed because it is too large Load Diff

1704
po/sr.po

File diff suppressed because it is too large Load Diff

1600
po/sv.po

File diff suppressed because it is too large Load Diff

1632
po/tr.po

File diff suppressed because it is too large Load Diff

1589
po/uk.po

File diff suppressed because it is too large Load Diff

1529
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

27
roll-a-release.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/bin/bash
VERSION="3.0"
echo "Pulling..." && git pull &&
echo "Running autogen..." && ./autogen.sh &&
rm -v -f m4/*.m4~ *.asc *.sig *.gz *.xz &&
echo "Rebuilding..." && make &&
po/update_linguas.sh &&
make distcheck && make dist-xz &&
git commit -a -m "$(git log -1 --grep 'po: up' | grep o: | sed 's/^ //')" &&
gpg -a -b nano-$VERSION.tar.gz &&
gpg -a -b nano-$VERSION.tar.xz &&
gpg --verify nano-$VERSION.tar.gz.asc &&
gpg --verify nano-$VERSION.tar.xz.asc &&
git tag -u A0ACE884 -a v$VERSION -m "the nano $VERSION release" &&
for file in nano-$VERSION.tar.*z*; do scp $file bens@wh0rd.org:$file; done &&
gnupload --to ftp.gnu.org:nano nano-$VERSION.tar.*z &&
echo "Tarballs have been rolled and uploaded."

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* browser.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2015-2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -32,9 +32,9 @@ static char **filelist = NULL;
/* The list of files to display in the file browser. */
static size_t filelist_len = 0;
/* The number of files in the list. */
static int width = 0;
static size_t width = 0;
/* The number of files that we can display per screen row. */
static int longest = 0;
static size_t longest = 0;
/* The number of columns in the longest filename in the list. */
static size_t selected = 0;
/* The currently selected filename in the list; zero-based. */
@@ -121,7 +121,7 @@ char *do_browser(char *path)
int mouse_x, mouse_y;
/* We can click on the edit window to select a filename. */
if (get_mouseinput(&mouse_x, &mouse_y, TRUE) == 0 &&
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. */
@@ -166,15 +166,13 @@ char *do_browser(char *path)
say_there_is_no_help();
#endif
} else if (func == do_search_forward) {
do_filesearch();
} else if (func == do_research) {
do_fileresearch(TRUE);
#ifndef NANO_TINY
do_filesearch(FORWARD);
} else if (func == do_search_backward) {
do_filesearch(BACKWARD);
} else if (func == do_findprevious) {
do_fileresearch(FALSE);
do_fileresearch(BACKWARD);
} else if (func == do_findnext) {
do_fileresearch(TRUE);
#endif
do_fileresearch(FORWARD);
} else if (func == do_left) {
if (selected > 0)
selected--;
@@ -187,10 +185,10 @@ char *do_browser(char *path)
selected += width - 1 - (selected % width);
if (selected >= filelist_len)
selected = filelist_len - 1;
} else if (func == do_up_void) {
} else if (func == do_up) {
if (selected >= width)
selected -= width;
} else if (func == do_down_void) {
} else if (func == do_down) {
if (selected + width <= filelist_len - 1)
selected += width;
} else if (func == do_prev_block) {
@@ -258,9 +256,9 @@ char *do_browser(char *path)
/* In case the specified directory cannot be entered, select it
* (if it is in the current list) so it will be highlighted. */
for (i = 0; i < filelist_len; i++)
if (strcmp(filelist[i], path) == 0)
selected = i;
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;
@@ -303,6 +301,10 @@ char *do_browser(char *path)
/* 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
} else if (func == do_exit) {
/* Exit from the file browser. */
break;
@@ -357,7 +359,7 @@ char *do_browse_from(const char *inpath)
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);
char *currentdir = charalloc(PATH_MAX + 1);
free(path);
path = getcwd(currentdir, PATH_MAX + 1);
@@ -484,11 +486,9 @@ functionptrtype parse_browser_input(int *kbinput)
case '/':
return do_search_forward;
case 'N':
#ifndef NANO_TINY
return do_findprevious;
#endif
case 'n':
return do_research;
return do_findnext;
}
}
return func_from_key(kbinput);
@@ -521,7 +521,7 @@ void browser_refresh(void)
/* The length of the filename in columns. */
size_t infolen;
/* The length of the file information in columns. */
int infomaxlen = 7;
size_t infomaxlen = 7;
/* The maximum length of the file information in columns:
* normally seven, but will be twelve for "(parent dir)". */
bool dots = (COLS >= 15 && namelen >= longest - infomaxlen);
@@ -655,42 +655,42 @@ void browser_select_dirname(const char *needle)
}
}
/* Set up the system variables for a filename search. Return -1 or -2 if
* the search should be canceled (due to Cancel or a blank search string),
* return 0 when we have a string, and return a positive value when some
* function was run. */
int filesearch_init(void)
/* 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)
{
int input;
char *buf;
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);
buf = charalloc(strlen(disp) + 7);
thedefault = charalloc(strlen(disp) + 7);
/* We use (COLS / 3) here because we need to see more on the line. */
sprintf(buf, " [%s%s]", disp,
sprintf(thedefault, " [%s%s]", disp,
(strlenpt(last_search) > COLS / 3) ? "..." : "");
free(disp);
} else
buf = mallocstrcpy(NULL, "");
thedefault = mallocstrcpy(NULL, "");
/* This is now one simple call. It just does a lot. */
input = do_prompt(FALSE, FALSE, MWHEREISFILE, NULL, &search_history,
browser_refresh, "%s%s", _("Search"), buf);
/* Release buf now that we don't need it anymore. */
free(buf);
/* Now ask what to search for. */
response = do_prompt(FALSE, FALSE, MWHEREISFILE, NULL, &search_history,
browser_refresh, "%s%s%s", _("Search"),
!forwards ? _(" [Backwards]") : "", thedefault);
free(thedefault);
/* If only Enter was pressed but we have a previous string, it's okay. */
if (input == -2 && *last_search != '\0')
if (response == -2 && *last_search != '\0')
return 0;
/* Otherwise negative inputs are a bailout. */
if (input < 0)
/* Otherwise negative responses are a bailout. */
if (response < 0)
statusbar(_("Cancelled"));
return input;
return response;
}
/* Look for the given needle in the list of files. If forwards is TRUE,
@@ -752,11 +752,12 @@ void findfile(const char *needle, bool forwards)
selected = looking_at;
}
/* Search for a filename. */
void do_filesearch(void)
/* Search for a filename. If forwards is TRUE, search forward in the list;
* otherwise, search backward.*/
void do_filesearch(bool forwards)
{
/* If the user cancelled or jumped to first or last file, don't search. */
if (filesearch_init() != 0)
if (filesearch_init(forwards) != 0)
return;
/* If answer is now "", copy last_search into answer. */
@@ -771,7 +772,7 @@ void do_filesearch(void)
update_history(&search_history, answer);
#endif
findfile(answer, TRUE);
findfile(answer, forwards);
}
/* Search again without prompting for the last given search string,

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* chars.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2016-2017 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -62,11 +62,6 @@ bool is_byte(int c)
return ((unsigned int)c == (unsigned char)c);
}
void mbtowc_reset(void)
{
IGNORE_CALL_RESULT(mbtowc(NULL, NULL, 0));
}
/* This function is equivalent to isalpha() for multibyte characters. */
bool is_alpha_mbchar(const char *c)
{
@@ -74,10 +69,8 @@ bool is_alpha_mbchar(const char *c)
if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return 0;
}
return iswalpha(wc);
} else
@@ -92,10 +85,8 @@ bool is_alnum_mbchar(const char *c)
if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return 0;
}
return iswalnum(wc);
} else
@@ -110,10 +101,8 @@ bool is_blank_mbchar(const char *c)
if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return 0;
}
return iswblank(wc);
} else
@@ -128,13 +117,6 @@ bool is_ascii_cntrl_char(int c)
return (0 <= c && c < 32);
}
/* This function is equivalent to iscntrl(), except in that it also
* handles high-bit control characters. */
bool is_cntrl_char(int c)
{
return ((c & 0x60) == 0 || c == 127);
}
/* This function is equivalent to iscntrl() for multibyte characters,
* except in that it also handles multibyte control characters with
* their high bits set. */
@@ -146,7 +128,7 @@ bool is_cntrl_mbchar(const char *c)
((signed char)c[0] == -62 && (signed char)c[1] < -96));
} else
#endif
return is_cntrl_char((unsigned char)*c);
return (((unsigned char)*c & 0x60) == 0 || (unsigned char)*c == 127);
}
/* This function is equivalent to ispunct() for multibyte characters. */
@@ -156,10 +138,8 @@ bool is_punct_mbchar(const char *c)
if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return 0;
}
return iswpunct(wc);
} else
@@ -232,10 +212,8 @@ int length_of_char(const char *c, int *width)
int charlen = mbtowc(&wc, c, MAXCHARLEN);
/* If the sequence is invalid... */
if (charlen < 0) {
mbtowc_reset();
if (charlen < 0)
return -1;
}
/* If the codepoint is invalid... */
if (!is_valid_unicode(wc))
@@ -260,10 +238,8 @@ int mbwidth(const char *c)
wchar_t wc;
int width;
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return 1;
}
width = wcwidth(wc);
@@ -309,65 +285,45 @@ char *make_mbchar(long chr, int *chr_mb_len)
* col isn't NULL, add the character's width (in columns) to it. */
int parse_mbchar(const char *buf, char *chr, size_t *col)
{
int length;
#ifdef ENABLE_UTF8
if (use_utf8) {
/* Get the number of bytes in the multibyte character. */
int length = mblen(buf, MAXCHARLEN);
/* If this is a UTF-8 starter byte, get the number of bytes of the character. */
if ((signed char)*buf < 0) {
length = mblen(buf, MAXCHARLEN);
/* When the multibyte sequence is invalid, only take the first byte. */
if (length <= 0) {
IGNORE_CALL_RESULT(mblen(NULL, 0));
if (length <= 0)
length = 1;
}
/* When requested, store the multibyte character in chr. */
if (chr != NULL) {
int i;
for (i = 0; i < length; i++)
chr[i] = buf[i];
}
/* When requested, add the width of the character to col. */
if (col != NULL) {
/* If we have a tab, compute its width in columns based on the
* current value of col. */
if (*buf == '\t')
*col += tabsize - *col % tabsize;
/* If we have a control character, it's two columns wide: one
* column for the "^", and one for the visible character. */
else if (is_cntrl_mbchar(buf)) {
*col += 2;
/* If we have a normal character, get its width normally. */
} else
*col += mbwidth(buf);
}
return length;
} else
#endif
{
/* When requested, store the byte character in chr. */
if (chr != NULL)
*chr = *buf;
length = 1;
/* When requested, add the width of the character to col. */
if (col != NULL) {
/* If we have a tab, compute its width in columns using the
* current value of col. */
if (*buf == '\t')
*col += tabsize - *col % tabsize;
/* If we have a control character, it's two columns wide: one
* column for the "^", and one for the visible character. */
else if (is_cntrl_char((unsigned char)*buf))
*col += 2;
/* If we have a normal character, it's one column wide. */
else
(*col)++;
}
/* When requested, store the multibyte character in chr. */
if (chr != NULL)
for (int i = 0; i < length; i++)
chr[i] = buf[i];
return 1;
/* When requested, add the width of the character to col. */
if (col != NULL) {
/* If we have a tab, compute its width in columns based on the
* current value of col. */
if (*buf == '\t')
*col += tabsize - *col % tabsize;
/* If we have a control character, it's two columns wide: one
* column for the "^", and one for the visible character. */
else if (is_cntrl_mbchar(buf))
*col += 2;
/* If we have a normal character, get its width normally. */
else if (length == 1)
*col += 1;
#ifdef ENABLE_UTF8
else
*col += mbwidth(buf);
#endif
}
return length;
}
/* Return the index in buf of the beginning of the multibyte character
@@ -430,17 +386,8 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
wchar_t wc1, wc2;
while (*s1 != '\0' && *s2 != '\0' && n > 0) {
bool bad1 = FALSE, bad2 = FALSE;
if (mbtowc(&wc1, s1, MAXCHARLEN) < 0) {
mbtowc_reset();
bad1 = TRUE;
}
if (mbtowc(&wc2, s2, MAXCHARLEN) < 0) {
mbtowc_reset();
bad2 = TRUE;
}
bool bad1 = (mbtowc(&wc1, s1, MAXCHARLEN) < 0);
bool bad2 = (mbtowc(&wc2, s2, MAXCHARLEN) < 0);
if (bad1 || bad2) {
if (*s1 != *s2)
@@ -556,22 +503,26 @@ char *mbrevstrcasestr(const char *haystack, const char *needle,
return revstrcasestr(haystack, needle, pointer);
}
/* This function is equivalent to strlen() for multibyte strings. */
/* Count the number of (multibyte) characters in the given string. */
size_t mbstrlen(const char *s)
{
return mbstrnlen(s, (size_t)-1);
}
size_t maxlen = (size_t)-1;
/* This function is equivalent to strnlen() for multibyte strings. */
size_t mbstrnlen(const char *s, size_t maxlen)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
size_t n = 0;
for (; *s != '\0' && maxlen > 0; s += move_mbright(s, 0),
maxlen--, n++)
;
while (*s != '\0' && maxlen > 0) {
if ((signed char)*s < 0) {
int length = mblen(s, MAXCHARLEN);
s += (length < 0 ? 1 : length);
} else
s++;
maxlen--;
n++;
}
return n;
} else
@@ -591,7 +542,6 @@ char *mbstrchr(const char *s, const char *c)
wchar_t ws, wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
wc = (unsigned char)*c;
bad_c_mb = TRUE;
}
@@ -600,7 +550,6 @@ char *mbstrchr(const char *s, const char *c)
int sym_len = parse_mbchar(s, symbol, NULL);
if (mbtowc(&ws, symbol, sym_len) < 0) {
mbtowc_reset();
ws = (unsigned char)*s;
bad_s_mb = TRUE;
}
@@ -731,17 +680,3 @@ bool is_valid_unicode(wchar_t wc)
(0xFFFF < wc && wc <= 0x10FFFF && (wc & 0xFFFF) <= 0xFFFD));
}
#endif
#ifdef ENABLE_NANORC
/* Check if the string s is a valid multibyte string. Return TRUE if it
* is, and FALSE otherwise. */
bool is_valid_mbstring(const char *s)
{
#ifdef ENABLE_UTF8
if (use_utf8)
return (mbstowcs(NULL, s, 0) != (size_t)-1);
else
#endif
return TRUE;
}
#endif /* ENABLE_NANORC */

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* color.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -45,7 +45,6 @@ void set_colorpairs(void)
{
const syntaxtype *sint;
bool using_defaults = FALSE;
short foreground, background;
size_t i;
/* Tell ncurses to enable colors. */
@@ -58,27 +57,27 @@ void set_colorpairs(void)
/* Initialize the color pairs for nano's interface elements. */
for (i = 0; i < NUMBER_OF_ELEMENTS; i++) {
bool bright = FALSE;
colortype *combo = color_combo[i];
if (specified_color_combo[i] != NULL &&
parse_color_names(specified_color_combo[i],
&foreground, &background, &bright)) {
if (foreground == -1 && !using_defaults)
foreground = COLOR_WHITE;
if (background == -1 && !using_defaults)
background = COLOR_BLACK;
init_pair(i + 1, foreground, background);
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;
init_pair(i + 1, combo->fg, combo->bg);
interface_color_pair[i] = COLOR_PAIR(i + 1) | A_BANDAID |
(bright ? A_BOLD : A_NORMAL);
combo->attributes;
} else {
if (i != FUNCTION_TAG)
interface_color_pair[i] = hilite_attribute;
else
if (i == FUNCTION_TAG)
interface_color_pair[i] = A_NORMAL;
else if (i == ERROR_MESSAGE) {
init_pair(i + 1, COLOR_WHITE, COLOR_RED);
interface_color_pair[i] = COLOR_PAIR(i + 1) | A_BOLD | A_BANDAID;
} else
interface_color_pair[i] = hilite_attribute;
}
free(specified_color_combo[i]);
specified_color_combo[i] = NULL;
free(color_combo[i]);
}
/* For each syntax, go through its list of colors and assign each
@@ -91,8 +90,7 @@ void set_colorpairs(void)
const colortype *beforenow = sint->color;
while (beforenow != ink && (beforenow->fg != ink->fg ||
beforenow->bg != ink->bg ||
beforenow->bright != ink->bright))
beforenow->bg != ink->bg))
beforenow = beforenow->next;
if (beforenow != ink)
@@ -100,8 +98,7 @@ void set_colorpairs(void)
else
ink->pairnum = new_number++;
ink->attributes = COLOR_PAIR(ink->pairnum) | A_BANDAID |
(ink->bright ? A_BOLD : A_NORMAL);
ink->attributes |= COLOR_PAIR(ink->pairnum) | A_BANDAID;
}
}
}
@@ -127,10 +124,10 @@ void color_init(void)
foreground = ink->fg;
background = ink->bg;
if (foreground == -1 && !using_defaults)
if (foreground == USE_THE_DEFAULT && !using_defaults)
foreground = COLOR_WHITE;
if (background == -1 && !using_defaults)
if (background == USE_THE_DEFAULT && !using_defaults)
background = COLOR_BLACK;
init_pair(ink->pairnum, foreground, background);
@@ -293,6 +290,7 @@ void check_the_multis(filestruct *line)
const colortype *ink;
bool astart, anend;
regmatch_t startmatch, endmatch;
char *afterstart;
/* If there is no syntax or no multiline regex, there is nothing to do. */
if (openfile->syntax == NULL || openfile->syntax->nmultis == 0)
@@ -306,7 +304,8 @@ void check_the_multis(filestruct *line)
alloc_multidata_if_needed(line);
astart = (regexec(ink->start, line->data, 1, &startmatch, 0) == 0);
anend = (regexec(ink->end, line->data, 1, &endmatch, 0) == 0);
afterstart = line->data + (astart ? startmatch.rm_eo : 0);
anend = (regexec(ink->end, afterstart, 1, &endmatch, 0) == 0);
/* Check whether the multidata still matches the current situation. */
if (line->multidata[ink->id] == CNONE ||

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* cut.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2014 Mark Majeres *
* Copyright (C) 2016 Benno Schulenberg *
* *
@@ -111,7 +111,7 @@ void cut_to_eof(void)
* copy_text is TRUE, copy the text back into the buffer afterward.
* If cut_till_eof is TRUE, move all text from the current cursor
* position to the end of the file into the cutbuffer. */
void do_cut_text(bool copy_text, bool cut_till_eof)
void do_cut_text(bool copy_text, bool marked, bool cut_till_eof)
{
#ifndef NANO_TINY
filestruct *cb_save = NULL;
@@ -125,12 +125,12 @@ void do_cut_text(bool copy_text, bool cut_till_eof)
#endif
size_t was_totsize = openfile->totsize;
/* If a chain of cuts was broken, empty the cutbuffer. */
if (!keep_cutbuffer) {
/* If cuts were not continuous, or when cutting a region, clear the slate. */
if (!keep_cutbuffer || marked || cut_till_eof) {
free_filestruct(cutbuffer);
cutbuffer = NULL;
/* Indicate that future cuts should add to the cutbuffer. */
keep_cutbuffer = TRUE;
/* After a line cut, future line cuts should add to the cutbuffer. */
keep_cutbuffer = !marked && !cut_till_eof;
}
#ifndef NANO_TINY
@@ -187,14 +187,6 @@ void do_cut_text(bool copy_text, bool cut_till_eof)
set_modified();
refresh_needed = TRUE;
#ifdef ENABLE_COLOR
check_the_multis(openfile->current);
#endif
#ifdef DEBUG
dump_filestruct(cutbuffer);
#endif
}
/* Move text from the current buffer into the cutbuffer. */
@@ -202,10 +194,10 @@ void do_cut_text_void(void)
{
#ifndef NANO_TINY
add_undo(CUT);
#endif
do_cut_text(FALSE, FALSE);
#ifndef NANO_TINY
do_cut_text(FALSE, openfile->mark, FALSE);
update_undo(CUT);
#else
do_cut_text(FALSE, FALSE, FALSE);
#endif
}
@@ -215,7 +207,7 @@ void do_cut_text_void(void)
* was moved, blow away previous contents of the cutbuffer. */
void do_copy_text(void)
{
static struct filestruct *next_contiguous_line = NULL;
static filestruct *next_contiguous_line = NULL;
bool mark_is_set = (openfile->mark != NULL);
/* Remember the current viewport and cursor position. */
@@ -227,7 +219,7 @@ void do_copy_text(void)
if (mark_is_set || openfile->current != next_contiguous_line)
cutbuffer_reset();
do_cut_text(TRUE, FALSE);
do_cut_text(TRUE, mark_is_set, FALSE);
/* If the mark was set, blow away the cutbuffer on the next copy. */
next_contiguous_line = (mark_is_set ? NULL : openfile->current);
@@ -245,7 +237,7 @@ void do_copy_text(void)
void do_cut_till_eof(void)
{
add_undo(CUT_TO_EOF);
do_cut_text(FALSE, TRUE);
do_cut_text(FALSE, FALSE, TRUE);
update_undo(CUT_TO_EOF);
}
#endif /* !NANO_TINY */
@@ -286,8 +278,4 @@ void do_uncut_text(void)
set_modified();
refresh_needed = TRUE;
#ifdef ENABLE_COLOR
check_the_multis(openfile->current);
#endif
}

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* files.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2015-2017 Benno Schulenberg *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2015-2018 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -66,16 +66,19 @@ void make_new_buffer(void)
if (openfile == NULL) {
/* Make the first open file the only element in the list. */
#ifdef ENABLE_MULTIBUFFER
newnode->prev = newnode;
newnode->next = newnode;
#endif
firstfile = newnode;
} else {
/* Add the new open file after the current one in the list. */
#ifdef ENABLE_MULTIBUFFER
newnode->prev = openfile;
newnode->next = openfile->next;
openfile->next->prev = newnode;
openfile->next = newnode;
#endif
/* There is more than one file open: show "Close" in help lines. */
exitfunc->desc = close_tag;
more_than_one = !inhelp || more_than_one;
@@ -345,6 +348,9 @@ int do_lockfile(const char *filename)
pidstring = charalloc(11);
sprintf (pidstring, "%u", (unsigned int)lockpid);
/* Display newlines in filenames as ^J. */
as_an_at = FALSE;
/* TRANSLATORS: The second %s is the name of the user, the third that of the editor. */
question = _("File %s is being edited (by %s with %s, PID %s); continue?");
room = COLS - strlenpt(question) + 7 - strlenpt(lockuser) -
@@ -359,7 +365,7 @@ int do_lockfile(const char *filename)
strcat(postedname, fragment);
free(fragment);
} else
postedname = mallocstrcpy(NULL, filename);
postedname = display_string(filename, 0, room, FALSE);
/* Allow extra space for username (14), program name (8), PID (8),
* and terminating \0 (1), minus the %s (2) for the file name. */
@@ -403,13 +409,11 @@ void stat_with_alloc(const char *filename, struct stat **pstat)
}
#endif /* !NANO_TINY */
/* This does one of three things. If the filename is "", just create a new
* empty buffer. Otherwise, read the given file into the existing buffer,
* or into a new buffer when MULTIBUFFER is set or there is no buffer yet. */
bool open_buffer(const char *filename, bool undoable)
/* This does one of three things. If the filename is "", it just creates
* a new empty buffer. When the filename is not empty, it reads that file
* into a new buffer when requested, otherwise into the existing buffer. */
bool open_buffer(const char *filename, bool new_buffer)
{
bool new_buffer = (openfile == NULL || ISSET(MULTIBUFFER));
/* Whether we load into the current buffer or a new one. */
char *realname;
/* The filename after tilde expansion. */
FILE *f;
@@ -432,10 +436,11 @@ bool open_buffer(const char *filename, bool undoable)
/* When the specified filename is not empty, and the corresponding
* file exists, verify that it is a normal file. */
if (strcmp(filename, "") != 0) {
if (*filename != '\0') {
struct stat fileinfo;
if (stat(realname, &fileinfo) == 0 && !S_ISREG(fileinfo.st_mode)) {
if (stat(realname, &fileinfo) == 0 && !(S_ISREG(fileinfo.st_mode) ||
(ISSET(NOREAD_MODE) && S_ISFIFO(fileinfo.st_mode)))) {
if (S_ISDIR(fileinfo.st_mode))
statusline(ALERT, _("\"%s\" is a directory"), realname);
else
@@ -471,24 +476,20 @@ bool open_buffer(const char *filename, bool undoable)
rc = (filename[0] != '\0' && !ISSET(NOREAD_MODE)) ?
open_file(realname, new_buffer, inhelp, &f) : -2;
/* If we have a file, and we're loading into a new buffer, update
* the filename. */
if (rc != -1 && new_buffer)
openfile->filename = mallocstrcpy(openfile->filename, realname);
/* If we have a non-new file, read it in. Then, if the buffer has
* no stat, update the stat, if applicable. */
if (rc > 0) {
read_file(f, rc, realname, undoable, new_buffer);
read_file(f, rc, realname, !new_buffer);
#ifndef NANO_TINY
if (openfile->current_stat == NULL)
stat_with_alloc(realname, &openfile->current_stat);
#endif
}
/* If we have a file, and we're loading into a new buffer, move back
* to the beginning of the first line of the buffer. */
/* If we have a file, and we've loaded it into a new buffer, set
* the filename and put the cursor at the start of the buffer. */
if (rc != -1 && new_buffer) {
openfile->filename = mallocstrcpy(openfile->filename, realname);
openfile->current = openfile->fileage;
openfile->current_x = 0;
openfile->placewewant = 0;
@@ -511,6 +512,7 @@ void replace_buffer(const char *filename)
{
FILE *f;
int descriptor;
filestruct *was_cutbuffer = cutbuffer;
/* Open the file quietly. */
descriptor = open_file(filename, FALSE, TRUE, &f);
@@ -519,29 +521,44 @@ void replace_buffer(const char *filename)
if (descriptor < 0)
return;
/* Reinitialize the text of the current buffer. */
free_filestruct(openfile->fileage);
initialize_buffer_text();
#ifndef NANO_TINY
add_undo(COUPLE_BEGIN);
openfile->undotop->strdata = mallocstrcpy(NULL, _("spelling correction"));
#endif
/* Throw away the text of the file. */
cutbuffer = NULL;
openfile->current = openfile->fileage;
openfile->current_x = 0;
#ifndef NANO_TINY
add_undo(CUT_TO_EOF);
#endif
do_cut_text(FALSE, FALSE, TRUE);
#ifndef NANO_TINY
update_undo(CUT_TO_EOF);
#endif
free_filestruct(cutbuffer);
cutbuffer = was_cutbuffer;
/* Insert the processed file into its place. */
read_file(f, descriptor, filename, FALSE, TRUE);
read_file(f, descriptor, filename, TRUE);
/* Put current at a place that is certain to exist. */
openfile->current = openfile->fileage;
#ifndef NANO_TINY
add_undo(COUPLE_END);
openfile->undotop->strdata = mallocstrcpy(NULL, _("spelling correction"));
#endif
}
#ifndef NANO_TINY
/* Open the specified file, and if that succeeds, blow away the text of
* the current buffer at the given coordinates and read the file
* the current buffer covered by the mark and read the file
* contents into its place. */
void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
filestruct *bot, size_t bot_x)
void replace_marked_buffer(const char *filename)
{
FILE *f;
int descriptor;
bool old_no_newlines = ISSET(NO_NEWLINES);
filestruct *trash_top = NULL;
filestruct *trash_bot = NULL;
filestruct *was_cutbuffer = cutbuffer;
descriptor = open_file(filename, FALSE, TRUE, &f);
@@ -551,15 +568,26 @@ void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
/* Don't add a magicline when replacing text in the buffer. */
SET(NO_NEWLINES);
/* Throw away the text under the mark, and insert the processed file
* where the marked text was. */
extract_buffer(&trash_top, &trash_bot, top, top_x, bot, bot_x);
free_filestruct(trash_top);
read_file(f, descriptor, filename, FALSE, TRUE);
add_undo(COUPLE_BEGIN);
openfile->undotop->strdata = mallocstrcpy(NULL, _("spelling correction"));
/* Throw away the text under the mark. */
cutbuffer = NULL;
add_undo(CUT);
do_cut_text(FALSE, TRUE, FALSE);
update_undo(CUT);
free_filestruct(cutbuffer);
cutbuffer = was_cutbuffer;
/* Insert the processed file where the marked text was. */
read_file(f, descriptor, filename, TRUE);
/* Restore the magicline behavior now that we're done fiddling. */
if (!old_no_newlines)
UNSET(NO_NEWLINES);
add_undo(COUPLE_END);
openfile->undotop->strdata = mallocstrcpy(NULL, _("spelling correction"));
}
#endif /* !NANO_TINY */
#endif /* ENABLE_SPELLER */
@@ -584,12 +612,31 @@ void prepare_for_display(void)
}
#ifdef ENABLE_MULTIBUFFER
/* Show name of current buffer and its number of lines on the status bar. */
void mention_name_and_linecount(void)
{
size_t count = openfile->filebot->lineno -
(openfile->filebot->data[0] == '\0' ? 1 : 0);
#ifndef NANO_TINY
if (openfile->fmt != NIX_FILE)
/* TRANSLATORS: first %s is file name, second %s is file format. */
statusline(HUSH, P_("%s -- %zu line (%s)", "%s -- %zu lines (%s)", count),
openfile->filename[0] == '\0' ?
_("New Buffer") : tail(openfile->filename), count,
openfile->fmt == DOS_FILE ? _("DOS") : _("Mac"));
else
#endif
statusline(HUSH, P_("%s -- %zu line", "%s -- %zu lines", count),
openfile->filename[0] == '\0' ?
_("New Buffer") : tail(openfile->filename), count);
}
/* Switch to a neighbouring file buffer; to the next if to_next is TRUE;
* otherwise, to the previous one. */
void switch_to_adjacent_buffer(bool to_next)
{
/* If only one file buffer is open, say so and get out. */
if (openfile == openfile->next && !inhelp) {
if (openfile == openfile->next) {
statusbar(_("No more open file buffers"));
return;
}
@@ -614,14 +661,8 @@ void switch_to_adjacent_buffer(bool to_next)
/* Ensure that the main loop will redraw the help lines. */
currmenu = MMOST;
/* Indicate the switch on the statusbar. */
statusline(HUSH, _("Switched to %s"),
((openfile->filename[0] == '\0') ?
_("New Buffer") : openfile->filename));
#ifdef DEBUG
dump_filestruct(openfile->current);
#endif
/* Indicate on the status bar where we switched to. */
mention_name_and_linecount();
}
/* Switch to the previous entry in the list of open files. */
@@ -712,13 +753,10 @@ char *encode_data(char *buf, size_t buf_len)
return mallocstrcpy(NULL, buf);
}
/* Read an open file into the current buffer. f should be set to the
* open file, and filename should be set to the name of the file.
* undoable means do we want to create undo records to try and undo
* this. Will also attempt to check file writability if fd > 0 and
* checkwritable == TRUE. */
void read_file(FILE *f, int fd, const char *filename, bool undoable,
bool checkwritable)
/* Read the given open file f into the current buffer. filename should be
* set to the name of the file. undoable means that undo records should be
* created and that the file does not need to be checked for writability. */
void read_file(FILE *f, int fd, const char *filename, bool undoable)
{
ssize_t was_lineno = openfile->current->lineno;
/* The line number where we start the insertion. */
@@ -762,8 +800,12 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
topline = make_new_node(NULL);
bottomline = topline;
/* Lock the file before starting to read it, to avoid the overhead
* of locking it for each single byte that we read from it. */
flockfile(f);
/* Read the entire file into the new buffer. */
while ((input_int = getc(f)) != EOF) {
while ((input_int = getc_unlocked(f)) != EOF) {
input = (char)input_int;
/* If it's a *nix file ("\n") or a DOS file ("\r\n"), and file
@@ -830,11 +872,14 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
#endif
}
/* We are done with the file, unlock it. */
funlockfile(f);
/* Perhaps this could use some better handling. */
if (ferror(f))
nperror(filename);
fclose(f);
if (fd > 0 && checkwritable) {
if (fd > 0 && !undoable) {
close(fd);
writable = is_file_writable(filename);
}
@@ -1038,7 +1083,7 @@ void do_insertfile(void)
if (execute) {
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER))
/* TRANSLATORS: The next four messages are prompts. */
/* TRANSLATORS: The next six messages are prompts. */
msg = _("Command to execute in new buffer");
else
#endif
@@ -1048,10 +1093,20 @@ void do_insertfile(void)
{
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER))
msg = _("File to insert into new buffer [from %s]");
#ifndef NANO_TINY
if ISSET(NO_CONVERT)
msg = _("File to read unconverted into new buffer [from %s]");
else
#endif
msg = _("File to read into new buffer [from %s]");
else
#endif
msg = _("File to insert [from %s]");
#ifndef NANO_TINY
if ISSET(NO_CONVERT)
msg = _("File to insert unconverted [from %s]");
else
#endif
msg = _("File to insert [from %s]");
}
present_path = mallocstrcpy(present_path, "./");
@@ -1094,6 +1149,10 @@ void do_insertfile(void)
}
#endif
#ifndef NANO_TINY
if (func == flip_convert) {
TOGGLE(NO_CONVERT);
continue;
}
if (func == flip_execute) {
execute = !execute;
continue;
@@ -1111,6 +1170,13 @@ void do_insertfile(void)
answer = chosen;
i = 0;
}
#endif
#ifndef NANO_TINY
if (func == flip_pipe) {
add_or_remove_pipe_symbol_from_answer();
given = mallocstrcpy(given, answer);
continue;
}
#endif
/* If we don't have a file yet, go back to the prompt. */
if (i != 0 && (!ISSET(MULTIBUFFER) || i != -2))
@@ -1121,7 +1187,7 @@ void do_insertfile(void)
#ifdef ENABLE_MULTIBUFFER
/* When in multibuffer mode, first open a blank buffer. */
if (ISSET(MULTIBUFFER))
open_buffer("", FALSE);
open_buffer("", TRUE);
#endif
/* If the command is not empty, execute it and read its output
* into the buffer, and add the command to the history list. */
@@ -1148,8 +1214,8 @@ void do_insertfile(void)
/* Make sure the specified path is tilde-expanded. */
answer = free_and_assign(answer, real_dir_from_tilde(answer));
/* Read the specified file into the current buffer. */
open_buffer(answer, TRUE);
/* Read the file into a new buffer or into current buffer. */
open_buffer(answer, ISSET(MULTIBUFFER));
}
#ifdef ENABLE_MULTIBUFFER
@@ -1757,6 +1823,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
umask(original_umask);
}
#ifndef NANO_TINY
/* If we're prepending, copy the file to a temp file. */
if (method == PREPEND) {
int fd_source;
@@ -1803,6 +1870,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
goto cleanup_and_exit;
}
}
#endif /* !NANO_TINY */
if (f_open == NULL) {
/* Now open the file in place. Use O_EXCL if tmp is TRUE. This
@@ -1884,6 +1952,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
lineswritten++;
}
#ifndef NANO_TINY
/* If we're prepending, open the temp file, and append it to f. */
if (method == PREPEND) {
int fd_source;
@@ -1911,22 +1980,24 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
}
unlink(tempname);
} else if (fclose(f) != 0) {
} else
#endif
if (fclose(f) != 0) {
statusline(ALERT, _("Error writing %s: %s"), realname,
strerror(errno));
goto cleanup_and_exit;
}
if (method == OVERWRITE && !tmp) {
/* If we must set the filename, and it changed, adjust things. */
if (fullbuffer && strcmp(openfile->filename, realname) != 0) {
/* When having written an entire buffer, update some administrivia. */
if (fullbuffer && method == OVERWRITE && !tmp) {
/* If the filename was changed, check if this means a new syntax. */
if (strcmp(openfile->filename, realname) != 0) {
#ifdef ENABLE_COLOR
const char *oldname, *newname;
oldname = openfile->syntax ? openfile->syntax->name : "";
#endif
openfile->filename = mallocstrcpy(openfile->filename, realname);
#ifdef ENABLE_COLOR
/* See if the applicable syntax has changed. */
color_update();
@@ -1943,29 +2014,27 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
line->multidata = NULL;
line = line->next;
}
precalc_multicolorinfo();
refresh_needed = TRUE;
}
#endif
}
if (fullbuffer) {
#ifndef NANO_TINY
/* Get or update the stat info to reflect the current state. */
stat_with_alloc(realname, &openfile->current_stat);
/* Get or update the stat info to reflect the current state. */
stat_with_alloc(realname, &openfile->current_stat);
/* Record at which point in the undo stack the file was saved. */
openfile->last_saved = openfile->current_undo;
openfile->last_action = OTHER;
/* Record at which point in the undo stack the file was saved. */
openfile->last_saved = openfile->current_undo;
openfile->last_action = OTHER;
#endif
openfile->modified = FALSE;
titlebar(NULL);
}
statusline(HUSH, P_("Wrote %zu line", "Wrote %zu lines",
lineswritten), lineswritten);
openfile->modified = FALSE;
titlebar(NULL);
}
if (!tmp)
statusline(HUSH, P_("Wrote %zu line", "Wrote %zu lines",
lineswritten), lineswritten);
retval = TRUE;
cleanup_and_exit:
@@ -2142,8 +2211,12 @@ int do_writeout(bool exiting, bool withprompt)
* egg. Display the credits. */
if (!did_credits && exiting && !ISSET(TEMP_FILE) &&
strcasecmp(answer, "zzy") == 0) {
do_credits();
did_credits = TRUE;
if (LINES > 5 && COLS > 31) {
do_credits();
did_credits = TRUE;
} else
/* TRANSLATORS: Concisely say the screen is too small. */
statusbar(_("Too tiny"));
break;
}
#endif
@@ -2192,12 +2265,17 @@ int do_writeout(bool exiting, bool withprompt)
if (name_exists) {
char *question = _("File \"%s\" exists; OVERWRITE? ");
char *name = display_string(answer, 0,
COLS - strlenpt(question) + 1, FALSE);
char *message = charalloc(strlen(question) +
strlen(answer) + 1);
sprintf(message, question, answer);
strlen(name) + 1);
sprintf(message, question, name);
i = do_yesno_prompt(FALSE, message);
free(message);
free(name);
if (i < 1)
continue;
@@ -2420,8 +2498,8 @@ char **username_tab_completion(const char *buf, size_t *num_matches,
/* We consider the first buf_len characters of buf for filename tab
* completion. */
char **cwd_tab_completion(const char *buf, bool allow_files, size_t
*num_matches, size_t buf_len)
char **cwd_tab_completion(const char *buf, bool allow_files,
size_t *num_matches, size_t buf_len)
{
char *dirname = mallocstrcpy(NULL, buf);
char *slash, *filename;
@@ -2600,7 +2678,8 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
if (!*lastwastab)
*lastwastab = TRUE;
else if (num_matches > 1) {
int longest_name = 0, ncols, editline = 0;
size_t longest_name = 0, ncols;
int editline = 0;
/* Sort the list of available choices. */
qsort(matches, num_matches, sizeof(char *), diralphasort);

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* help.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2000-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2000-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2017 Rishabh Dave *
* Copyright (C) 2014-2017 Benno Schulenberg *
* *
@@ -46,7 +46,7 @@ char *tempfilename = NULL;
* read that file into a new buffer. */
void wrap_the_help_text(bool redisplaying)
{
int sum = 0;
size_t sum = 0;
const char *ptr = start_of_body;
FILE *tempfile = fopen(tempfilename, "w+b");
@@ -75,7 +75,7 @@ void wrap_the_help_text(bool redisplaying)
if (redisplaying)
close_buffer();
open_buffer(tempfilename, FALSE);
open_buffer(tempfilename, TRUE);
remove_magicline();
prepare_for_display();
@@ -142,10 +142,10 @@ void do_help(void)
UNSET(WHITESPACE_DISPLAY);
UNSET(NOREAD_MODE);
SET(MULTIBUFFER);
#ifdef ENABLE_LINENUMBERS
UNSET(LINE_NUMBERS);
editwincols = COLS;
margin = 0;
#endif
tabsize = 8;
@@ -161,7 +161,6 @@ void do_help(void)
didfind = 0;
bottombars(MHELP);
wnoutrefresh(bottomwin);
/* Extract the title from the head of the help text. */
length = break_line(help_text, MAX_BUF_SIZE, TRUE);
@@ -191,12 +190,12 @@ void do_help(void)
if (func == total_refresh) {
total_redraw();
} else if (func == do_up_void) {
do_up(TRUE);
} else if (func == do_down_void) {
} else if (func == do_up) {
do_scroll_up();
} else if (func == do_down) {
if (openfile->edittop->lineno + editwinrows - 1 <
openfile->filebot->lineno)
do_down(TRUE);
do_scroll_down();
} else if (func == do_page_up) {
do_page_up();
} else if (func == do_page_down) {
@@ -206,22 +205,27 @@ void do_help(void)
} else if (func == to_last_line) {
to_last_line();
} else if (func == do_search_forward) {
do_search();
do_search_forward();
bottombars(MHELP);
} else if (func == do_search_backward) {
do_search_backward();
bottombars(MHELP);
} else if (func == do_research) {
do_research();
#ifndef NANO_TINY
} else if (func == do_findprevious) {
do_findprevious();
} else if (func == do_findnext) {
do_findnext();
#ifdef ENABLE_NANORC
} else if (func == (functionptrtype)implant) {
implant(first_sc_for(MHELP, func)->expansion);
#endif
#ifndef NANO_TINY
} else if (kbinput == KEY_WINCH) {
; /* Nothing to do. */
#endif
#ifdef ENABLE_MOUSE
} else if (kbinput == KEY_MOUSE) {
int dummy_x, dummy_y;
get_mouseinput(&dummy_x, &dummy_y, TRUE);
int dummy_row, dummy_col;
get_mouseinput(&dummy_row, &dummy_col, TRUE);
#endif
} else if (func == do_exit) {
/* Exit from the help viewer. */
@@ -249,6 +253,7 @@ void do_help(void)
#ifdef ENABLE_LINENUMBERS
margin = was_margin;
editwincols = COLS - margin;
#endif
tabsize = was_tabsize;
#ifdef ENABLE_COLOR
@@ -409,12 +414,13 @@ void help_init(void)
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 "
"a new buffer in multiple file buffer mode). If you "
"need another blank buffer, do not enter any "
"command.\n\n The following function keys are "
"into a new buffer). If the command is preceded by '|' "
"(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");
htx[2] = N_(" The following function keys are "
"available in Execute Command mode:\n\n");
htx[1] = NULL;
htx[2] = NULL;
}
#endif /* !NANO_TINY */
else {
@@ -471,7 +477,7 @@ void help_init(void)
size_t endis_len = strlen(_("enable/disable"));
for (s = sclist; s != NULL; s = s->next)
if (s->scfunc == do_toggle_void)
if (s->func == do_toggle_void)
allocsize += strlen(_(flagtostr(s->toggle))) + endis_len + 8;
}
#endif
@@ -504,7 +510,7 @@ void help_init(void)
if ((s->menus & currmenu) == 0)
continue;
if (s->scfunc == f->scfunc) {
if (s->func == f->func) {
scsfound++;
/* Make the first column narrower (6) than the second (10),
* but allow it to spill into the second, for "M-Space". */
@@ -577,11 +583,9 @@ functionptrtype parse_help_input(int *kbinput)
case '/':
return do_search_forward;
case 'N':
#ifndef NANO_TINY
return do_findprevious;
#endif
case 'n':
return do_research;
return do_findnext;
case 'E':
case 'e':
case 'Q':
@@ -620,7 +624,7 @@ size_t help_line_len(const char *ptr)
else if (wrap_location > 0)
return wrap_location;
else
return 0;
return 1;
}
#endif /* ENABLE_HELP */

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* history.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2003-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2003-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2016-2017 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -227,7 +227,7 @@ char *get_history_completion(filestruct **h, char *s, size_t len)
* match, or len is 0. Return s. */
return (char *)s;
}
#endif /* ENSABLE_TABCOMP */
#endif /* ENABLE_TABCOMP */
void history_error(const char *msg, ...)
{

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* move.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017 Benno Schulenberg *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2014-2018 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -179,7 +179,7 @@ void do_para_begin(bool update_screen)
if (openfile->current != openfile->fileage)
openfile->current = openfile->current->prev;
while (!begpar(openfile->current))
while (!begpar(openfile->current, 0))
openfile->current = openfile->current->prev;
openfile->current_x = 0;
@@ -204,7 +204,7 @@ void do_para_end(bool update_screen)
while (openfile->current != openfile->filebot &&
inpar(openfile->current->next) &&
!begpar(openfile->current->next)) {
!begpar(openfile->current->next, 0)) {
openfile->current = openfile->current->next;
}
@@ -314,15 +314,19 @@ void do_prev_word(bool allow_punct, bool update_screen)
edit_redraw(was_current, FLOWING);
}
/* Move to the next word. If allow_punct is TRUE, treat punctuation
* as part of a word. When requested, update the screen afterwards.
/* Move to the next word. If after_ends is TRUE, stop at the ends of words
* instead of their beginnings. If allow_punct is TRUE, treat punctuation
* as part of a word. When requested, update the screen afterwards.
* Return TRUE if we started on a word, and FALSE otherwise. */
bool do_next_word(bool allow_punct, bool update_screen)
bool do_next_word(bool after_ends, bool allow_punct, bool update_screen)
{
filestruct *was_current = openfile->current;
bool started_on_word = is_word_mbchar(openfile->current->data +
openfile->current_x, allow_punct);
bool seen_space = !started_on_word;
#ifndef NANO_TINY
bool seen_word = started_on_word;
#endif
/* Move forward until we reach the start of a word. */
while (TRUE) {
@@ -340,13 +344,26 @@ bool do_next_word(bool allow_punct, bool update_screen)
openfile->current_x);
}
/* If this is not a word character, then it's a separator; else
* if we've already seen a separator, then it's a word start. */
if (!is_word_mbchar(openfile->current->data + openfile->current_x,
#ifndef NANO_TINY
if (after_ends) {
/* If this is a word character, continue; else it's a separator,
* and if we've already seen a word, then it's a word end. */
if (is_word_mbchar(openfile->current->data + openfile->current_x,
allow_punct))
seen_space = TRUE;
else if (seen_space)
break;
seen_word = TRUE;
else if (seen_word)
break;
} else
#endif
{
/* If this is not a word character, then it's a separator; else
* if we've already seen a separator, then it's a word start. */
if (!is_word_mbchar(openfile->current->data + openfile->current_x,
allow_punct))
seen_space = TRUE;
else if (seen_space)
break;
}
}
if (update_screen)
@@ -363,11 +380,12 @@ void do_prev_word_void(void)
do_prev_word(ISSET(WORD_BOUNDS), TRUE);
}
/* Move to the next word in the file, treating punctuation as part of a word
* if the WORD_BOUNDS flag is set, and update the screen afterwards. */
/* Move to the next word in the file. If the AFTER_ENDS flag is set, stop
* at word ends instead of beginnings. If the WORD_BOUNDS flag is set, treat
* punctuation as part of a word. Update the screen afterwards. */
void do_next_word_void(void)
{
do_next_word(ISSET(WORD_BOUNDS), TRUE);
do_next_word(ISSET(AFTER_ENDS), ISSET(WORD_BOUNDS), TRUE);
}
/* Move to the beginning of the current line (or softwrapped chunk).
@@ -481,18 +499,12 @@ void do_end(void)
update_line(openfile->current, openfile->current_x);
}
/* Move the cursor to the preceding line or chunk. If scroll_only is TRUE,
* also scroll the screen one row, so the cursor stays in the same spot. */
void do_up(bool scroll_only)
/* Move the cursor to the preceding line or chunk. */
void do_up(void)
{
filestruct *was_current = openfile->current;
size_t leftedge, target_column;
/* When just scrolling and the top of the file is onscreen, get out. */
if (scroll_only && openfile->edittop == openfile->fileage &&
openfile->firstcolumn == 0)
return;
get_edge_and_target(&leftedge, &target_column);
/* If we can't move up one line or chunk, we're at top of file. */
@@ -501,18 +513,17 @@ void do_up(bool scroll_only)
set_proper_index_and_pww(&leftedge, target_column, FALSE);
if (scroll_only)
edit_scroll(BACKWARD, 1);
edit_redraw(was_current, FLOWING);
if (openfile->current_y == 0 && ISSET(SMOOTH_SCROLL))
edit_scroll(BACKWARD);
else
edit_redraw(was_current, FLOWING);
/* <Up> should not change placewewant, so restore it. */
openfile->placewewant = leftedge + target_column;
}
/* Move the cursor to next line or chunk. If scroll_only is TRUE, also
* scroll the screen one row, so the cursor stays in the same spot. */
void do_down(bool scroll_only)
/* Move the cursor to next line or chunk. */
void do_down(void)
{
filestruct *was_current = openfile->current;
size_t leftedge, target_column;
@@ -525,38 +536,43 @@ void do_down(bool scroll_only)
set_proper_index_and_pww(&leftedge, target_column, TRUE);
if (scroll_only)
edit_scroll(FORWARD, 1);
edit_redraw(was_current, FLOWING);
if (openfile->current_y == editwinrows - 1 && ISSET(SMOOTH_SCROLL))
edit_scroll(FORWARD);
else
edit_redraw(was_current, FLOWING);
/* <Down> should not change placewewant, so restore it. */
openfile->placewewant = leftedge + target_column;
}
/* Move up one line or chunk. */
void do_up_void(void)
{
do_up(FALSE);
}
/* Move down one line or chunk. */
void do_down_void(void)
{
do_down(FALSE);
}
#ifndef NANO_TINY
#ifdef ENABLE_HELP
/* Scroll up one line or chunk without scrolling the cursor. */
void do_scroll_up(void)
{
do_up(TRUE);
/* When the top of the file is onscreen, we can't scroll. */
if (openfile->edittop->prev == NULL && openfile->firstcolumn == 0)
return;
if (openfile->current_y == editwinrows - 1)
do_up();
if (editwinrows > 1)
edit_scroll(BACKWARD);
}
/* Scroll down one line or chunk without scrolling the cursor. */
void do_scroll_down(void)
{
do_down(TRUE);
if (openfile->current_y == 0)
do_down();
if (openfile->edittop->next != NULL
#ifndef NANO_TINY
|| chunk_for(openfile->firstcolumn, openfile->edittop) <
number_of_chunks_in(openfile->edittop)
#endif
)
edit_scroll(FORWARD);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* nano.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2014-2017 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -142,6 +142,11 @@
#define REPLACING 1
#define INREGION 2
#ifdef ENABLE_COLOR
#define USE_THE_DEFAULT -1
#define BAD_COLOR -2
#endif
/* Enumeration types. */
typedef enum {
NIX_FILE, DOS_FILE, MAC_FILE
@@ -163,8 +168,9 @@ typedef enum {
CENTERING, FLOWING, STATIONARY
} update_type;
/* The kinds of undo actions. ADD...REPLACE must come first. */
typedef enum {
ADD, DEL, BACK, CUT, CUT_TO_EOF, REPLACE,
ADD, ENTER, BACK, DEL, JOIN, REPLACE,
#ifdef ENABLE_WRAPPING
SPLIT_BEGIN, SPLIT_END,
#endif
@@ -172,7 +178,7 @@ typedef enum {
#ifdef ENABLE_COMMENT
COMMENT, UNCOMMENT, PREFLIGHT,
#endif
JOIN, PASTE, INSERT, ENTER, OTHER
CUT, CUT_TO_EOF, PASTE, INSERT, COUPLE_BEGIN, COUPLE_END, OTHER
} undo_type;
/* Structure types. */
@@ -182,8 +188,6 @@ typedef struct colortype {
/* This syntax's foreground color. */
short bg;
/* This syntax's background color. */
bool bright;
/* Is this color A_BOLD? */
int pairnum;
/* The color pair number used for this foreground color and
* background color. */
@@ -223,8 +227,6 @@ typedef struct syntaxtype {
/* The list of libmagic results that this syntax applies to. */
char *linter;
/* The command with which to lint this type of file. */
char *formatter;
/* The formatting command (for programming languages mainly). */
#ifdef ENABLE_COMMENT
char *comment;
/* The line comment prefix (and postfix) for this type of file. */
@@ -407,10 +409,12 @@ typedef struct openfilestruct {
colortype *colorstrings;
/* The file's associated colors. */
#endif
#ifdef ENABLE_MULTIBUFFER
struct openfilestruct *next;
/* The next open file, if any. */
struct openfilestruct *prev;
/* The preceding open file, if any. */
#endif
} openfilestruct;
#ifdef ENABLE_NANORC
@@ -431,7 +435,7 @@ typedef struct sc {
/* The integer that, together with meta, identifies the keystroke. */
int menus;
/* Which menus this applies to. */
void (*scfunc)(void);
void (*func)(void);
/* The function we're going to run. */
#ifndef NANO_TINY
int toggle;
@@ -439,13 +443,17 @@ typedef struct sc {
int ordinal;
/* The how-manieth toggle this is, in order to be able to
* keep them in sequence. */
#endif
#ifdef ENABLE_NANORC
char *expansion;
/* The string of keycodes to which this shortcut is expanded. */
#endif
struct sc *next;
/* Next in the list. */
} sc;
typedef struct subnfunc {
void (*scfunc)(void);
void (*func)(void);
/* The actual function to call. */
int menus;
/* In what menus this function applies. */
@@ -480,6 +488,7 @@ enum
LINE_NUMBER,
SELECTED_TEXT,
STATUS_BAR,
ERROR_MESSAGE,
KEY_COMBO,
FUNCTION_TAG,
NUMBER_OF_ELEMENTS
@@ -530,7 +539,8 @@ enum
SHOW_CURSOR,
LINE_NUMBERS,
NO_PAUSES,
AT_BLANKS
AT_BLANKS,
AFTER_ENDS
};
/* Flags for the menus in which a given function should be present. */
@@ -571,6 +581,7 @@ enum
#define CONTROL_DOWN 0x404
#define CONTROL_HOME 0x405
#define CONTROL_END 0x406
#define CONTROL_DELETE 0x407
#define SHIFT_CONTROL_LEFT 0x411
#define SHIFT_CONTROL_RIGHT 0x412
#define SHIFT_CONTROL_UP 0x413
@@ -608,7 +619,6 @@ enum
#define WAS_FINAL_BACKSPACE (1<<1)
#define WAS_WHOLE_LINE (1<<2)
#define WAS_FINAL_LINE (1<<3)
/* The flags for the mark need to be the highest. */
#define MARK_WAS_SET (1<<4)
#define WAS_MARKED_FORWARD (1<<5)
#endif /* !NANO_TINY */
@@ -616,9 +626,8 @@ enum
/* The maximum number of entries displayed in the main shortcut list. */
#define MAIN_VISIBLE (((COLS + 40) / 20) * 2)
/* The default number of characters from the end of the line where
* wrapping occurs. */
#define CHARS_FROM_EOL 8
/* The default number of columns from end of line where wrapping occurs. */
#define COLUMNS_FROM_EOL 8
/* The default width of a tab in spaces. */
#define WIDTH_OF_TAB 8

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* prompt.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2016 Benno Schulenberg *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2016, 2018 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -25,14 +25,35 @@
static char *prompt = NULL;
/* The prompt string used for statusbar questions. */
static size_t statusbar_x = HIGHEST_POSITIVE;
static size_t typing_x = HIGHEST_POSITIVE;
/* The cursor position in answer. */
#ifdef ENABLE_MOUSE
/* Handle a mouse click on the statusbar prompt or the shortcut list. */
int do_statusbar_mouse(void)
{
int click_row, click_col;
int retval = get_mouseinput(&click_row, &click_col, TRUE);
/* We can click on the statusbar window text to move the cursor. */
if (retval == 0 && wmouse_trafo(bottomwin, &click_row, &click_col, FALSE)) {
size_t start_col = strlenpt(prompt) + 2;
/* Move to where the click occurred. */
if (click_row == 0 && click_col >= start_col)
typing_x = actual_x(answer,
get_statusbar_page_start(start_col, start_col +
strnlenpt(answer, typing_x)) + click_col - start_col);
}
return retval;
}
#endif
/* Read in a keystroke, interpret it if it is a shortcut or toggle, and
* return it. Set ran_func to TRUE if we ran a function associated with
* a shortcut key, and set finished to TRUE if we're done after running
* return it. Set finished to TRUE if we're done after running
* or trying to run a function associated with a shortcut key. */
int do_statusbar_input(bool *ran_func, bool *finished)
int do_statusbar_input(bool *finished)
{
int input;
/* The character we read in. */
@@ -40,11 +61,8 @@ int do_statusbar_input(bool *ran_func, bool *finished)
/* The input buffer. */
static size_t kbinput_len = 0;
/* The length of the input buffer. */
const sc *s;
bool have_shortcut = FALSE;
const subnfunc *f;
const sc *shortcut;
*ran_func = FALSE;
*finished = FALSE;
/* Read in a character. */
@@ -67,15 +85,11 @@ int do_statusbar_input(bool *ran_func, bool *finished)
#endif
/* Check for a shortcut in the current list. */
s = get_shortcut(&input);
/* If we got a shortcut from the current list, or a "universal"
* statusbar prompt shortcut, set have_shortcut to TRUE. */
have_shortcut = (s != NULL);
shortcut = get_shortcut(&input);
/* If we got a non-high-bit control key, a meta key sequence, or a
* function key, and it's not a shortcut or toggle, throw it out. */
if (!have_shortcut) {
if (shortcut == NULL) {
if (is_ascii_cntrl_char(input) || meta_key || !is_byte(input)) {
beep();
input = ERR;
@@ -84,7 +98,7 @@ int do_statusbar_input(bool *ran_func, bool *finished)
/* If the keystroke isn't a shortcut nor a toggle, it's a normal text
* character: add the it to the input buffer, when allowed. */
if (input != ERR && !have_shortcut) {
if (input != ERR && shortcut == NULL) {
/* Only accept input when not in restricted mode, or when not at
* the "Write File" prompt, or when there is no filename yet. */
if (!ISSET(RESTRICTED) || currmenu != MWRITEFILE ||
@@ -98,7 +112,7 @@ int do_statusbar_input(bool *ran_func, bool *finished)
/* If we got a shortcut, or if there aren't any other keystrokes waiting
* after the one we read in, we need to insert all the characters in the
* input buffer (if not empty) into the answer. */
if ((have_shortcut || get_key_buffer_len() == 0) && kbinput != NULL) {
if ((shortcut || get_key_buffer_len() == 0) && kbinput != NULL) {
/* Inject all characters in the input buffer at once, filtering out
* control characters. */
do_statusbar_output(kbinput, kbinput_len, TRUE);
@@ -109,55 +123,54 @@ int do_statusbar_input(bool *ran_func, bool *finished)
kbinput = NULL;
}
if (have_shortcut) {
if (s->scfunc == do_tab || s->scfunc == do_enter)
if (shortcut) {
if (shortcut->func == do_tab || shortcut->func == do_enter)
;
else if (s->scfunc == do_left)
else if (shortcut->func == do_left)
do_statusbar_left();
else if (s->scfunc == do_right)
else if (shortcut->func == do_right)
do_statusbar_right();
#ifndef NANO_TINY
else if (s->scfunc == do_prev_word_void)
else if (shortcut->func == do_prev_word_void)
do_statusbar_prev_word();
else if (s->scfunc == do_next_word_void)
else if (shortcut->func == do_next_word_void)
do_statusbar_next_word();
#endif
else if (s->scfunc == do_home)
else if (shortcut->func == do_home)
do_statusbar_home();
else if (s->scfunc == do_end)
else if (shortcut->func == do_end)
do_statusbar_end();
/* When in restricted mode at the "Write File" prompt and the
* filename isn't blank, disallow any input and deletion. */
else if (ISSET(RESTRICTED) && currmenu == MWRITEFILE &&
openfile->filename[0] != '\0' &&
(s->scfunc == do_verbatim_input ||
s->scfunc == do_cut_text_void ||
s->scfunc == do_delete ||
s->scfunc == do_backspace))
(shortcut->func == do_verbatim_input ||
shortcut->func == do_cut_text_void ||
shortcut->func == do_uncut_text ||
shortcut->func == do_delete ||
shortcut->func == do_backspace))
;
else if (s->scfunc == do_verbatim_input)
#ifdef ENABLE_NANORC
else if (shortcut->func == (functionptrtype)implant)
implant(shortcut->expansion);
#endif
else if (shortcut->func == do_verbatim_input)
do_statusbar_verbatim_input();
else if (s->scfunc == do_cut_text_void)
else if (shortcut->func == do_cut_text_void)
do_statusbar_cut_text();
else if (s->scfunc == do_delete)
else if (shortcut->func == do_delete)
do_statusbar_delete();
else if (s->scfunc == do_backspace)
else if (shortcut->func == do_backspace)
do_statusbar_backspace();
else if (s->scfunc == do_uncut_text) {
else if (shortcut->func == do_uncut_text) {
if (cutbuffer != NULL)
do_statusbar_uncut_text();
} else {
/* Handle any other shortcut in the current menu, setting
* ran_func to TRUE if we try to run their associated functions,
* and setting finished to TRUE to indicatethat we're done after
* running or trying to run their associated functions. */
f = sctofunc(s);
if (s->scfunc != NULL) {
*ran_func = TRUE;
if (f && (!ISSET(VIEW_MODE) || f->viewok) &&
f->scfunc != do_gotolinecolumn_void)
f->scfunc();
}
/* Handle any other shortcut in the current menu, setting finished
* to TRUE to indicate that we're done after running or trying to
* run its associated function. */
if (!ISSET(VIEW_MODE) || okay_for_view(shortcut))
shortcut->func();
*finished = TRUE;
}
}
@@ -165,32 +178,6 @@ int do_statusbar_input(bool *ran_func, bool *finished)
return input;
}
#ifdef ENABLE_MOUSE
/* Handle a mouse click on the statusbar prompt or the shortcut list. */
int do_statusbar_mouse(void)
{
int mouse_x, mouse_y;
int retval = get_mouseinput(&mouse_x, &mouse_y, TRUE);
/* We can click on the statusbar window text to move the cursor. */
if (retval == 0 && wmouse_trafo(bottomwin, &mouse_y, &mouse_x, FALSE)) {
size_t start_col;
start_col = strlenpt(prompt) + 2;
/* Move to where the click occurred. */
if (mouse_x >= start_col && mouse_y == 0) {
statusbar_x = actual_x(answer,
get_statusbar_page_start(start_col, start_col +
statusbar_xplustabs()) + mouse_x - start_col);
update_the_statusbar();
}
}
return retval;
}
#endif
/* The user typed input_len multibyte characters. Add them to the answer,
* filtering out ASCII control characters if filtering is TRUE. */
void do_statusbar_output(int *the_input, size_t input_len,
@@ -198,127 +185,122 @@ void do_statusbar_output(int *the_input, size_t input_len,
{
char *output = charalloc(input_len + 1);
char onechar[MAXCHARLEN];
int i, char_len;
size_t char_len, i, j = 0;
/* Copy the typed stuff so it can be treated. */
for (i = 0; i < input_len; i++)
output[i] = (char)the_input[i];
output[i] = '\0';
i = 0;
while (i < input_len) {
while (j < input_len) {
/* Encode any NUL byte as 0x0A. */
if (output[i] == '\0')
output[i] = '\n';
if (output[j] == '\0')
output[j] = '\n';
/* Interpret the next multibyte character. */
char_len = parse_mbchar(output + i, onechar, NULL);
char_len = parse_mbchar(output + j, onechar, NULL);
i += char_len;
j += char_len;
/* When filtering, skip any ASCII control character. */
if (filtering && is_ascii_cntrl_char(*(output + i - char_len)))
if (filtering && is_ascii_cntrl_char(*(output + j - char_len)))
continue;
/* Insert the typed character into the existing answer string. */
answer = charealloc(answer, strlen(answer) + char_len + 1);
charmove(answer + statusbar_x + char_len, answer + statusbar_x,
strlen(answer) - statusbar_x + 1);
strncpy(answer + statusbar_x, onechar, char_len);
charmove(answer + typing_x + char_len, answer + typing_x,
strlen(answer) - typing_x + 1);
strncpy(answer + typing_x, onechar, char_len);
statusbar_x += char_len;
typing_x += char_len;
}
free(output);
update_the_statusbar();
}
/* Move to the beginning of the answer. */
void do_statusbar_home(void)
{
statusbar_x = 0;
update_the_statusbar();
typing_x = 0;
}
/* Move to the end of the answer. */
void do_statusbar_end(void)
{
statusbar_x = strlen(answer);
update_the_statusbar();
typing_x = strlen(answer);
}
/* Move left one character. */
void do_statusbar_left(void)
{
if (statusbar_x > 0) {
statusbar_x = move_mbleft(answer, statusbar_x);
update_the_statusbar();
}
if (typing_x > 0)
typing_x = move_mbleft(answer, typing_x);
}
/* Move right one character. */
void do_statusbar_right(void)
{
if (answer[statusbar_x] != '\0') {
statusbar_x = move_mbright(answer, statusbar_x);
update_the_statusbar();
if (answer[typing_x] != '\0')
typing_x = move_mbright(answer, typing_x);
}
/* Delete one character. */
void do_statusbar_delete(void)
{
if (answer[typing_x] != '\0') {
int char_len = parse_mbchar(answer + typing_x, NULL, NULL);
charmove(answer + typing_x, answer + typing_x + char_len,
strlen(answer) - typing_x - char_len + 1);
}
}
/* Backspace over one character. */
void do_statusbar_backspace(void)
{
if (statusbar_x > 0) {
statusbar_x = move_mbleft(answer, statusbar_x);
if (typing_x > 0) {
typing_x = move_mbleft(answer, typing_x);
do_statusbar_delete();
}
}
/* Delete one character. */
void do_statusbar_delete(void)
{
if (answer[statusbar_x] != '\0') {
int char_len = parse_mbchar(answer + statusbar_x, NULL, NULL);
charmove(answer + statusbar_x, answer + statusbar_x + char_len,
strlen(answer) - statusbar_x - char_len + 1);
update_the_statusbar();
}
}
/* Zap some or all text from the answer. */
void do_statusbar_cut_text(void)
{
if (!ISSET(CUT_FROM_CURSOR))
statusbar_x = 0;
typing_x = 0;
answer[statusbar_x] = '\0';
update_the_statusbar();
answer[typing_x] = '\0';
}
#ifndef NANO_TINY
/* Move to the next word in the answer. */
void do_statusbar_next_word(void)
{
bool seen_space = !is_word_mbchar(answer + statusbar_x, FALSE);
bool seen_space = !is_word_mbchar(answer + typing_x, FALSE);
bool seen_word = !seen_space;
/* Move forward until we reach the start of a word. */
while (answer[statusbar_x] != '\0') {
statusbar_x = move_mbright(answer, statusbar_x);
/* Move forward until we reach either the end or the start of a word,
* depending on whether the AFTER_ENDS flag is set or not. */
while (answer[typing_x] != '\0') {
typing_x = move_mbright(answer, typing_x);
/* If this is not a word character, then it's a separator; else
* if we've already seen a separator, then it's a word start. */
if (!is_word_mbchar(answer + statusbar_x, FALSE))
seen_space = TRUE;
else if (seen_space)
break;
if (ISSET(AFTER_ENDS)) {
/* If this is a word character, continue; else it's a separator,
* and if we've already seen a word, then it's a word end. */
if (is_word_mbchar(answer + typing_x, FALSE))
seen_word = TRUE;
else if (seen_word)
break;
} else {
/* If this is not a word character, then it's a separator; else
* if we've already seen a separator, then it's a word start. */
if (!is_word_mbchar(answer + typing_x, FALSE))
seen_space = TRUE;
else if (seen_space)
break;
}
}
update_the_statusbar();
}
/* Move to the previous word in the answer. */
@@ -327,10 +309,10 @@ void do_statusbar_prev_word(void)
bool seen_a_word = FALSE, step_forward = FALSE;
/* Move backward until we pass over the start of a word. */
while (statusbar_x != 0) {
statusbar_x = move_mbleft(answer, statusbar_x);
while (typing_x != 0) {
typing_x = move_mbleft(answer, typing_x);
if (is_word_mbchar(answer + statusbar_x, FALSE))
if (is_word_mbchar(answer + typing_x, FALSE))
seen_a_word = TRUE;
else if (seen_a_word) {
/* This is space now: we've overshot the start of the word. */
@@ -341,9 +323,7 @@ void do_statusbar_prev_word(void)
if (step_forward)
/* Move one character forward again to sit on the start of the word. */
statusbar_x = move_mbright(answer, statusbar_x);
update_the_statusbar();
typing_x = move_mbright(answer, typing_x);
}
#endif /* !NANO_TINY */
@@ -356,12 +336,8 @@ void do_statusbar_verbatim_input(void)
kbinput = get_verbatim_kbinput(bottomwin, &kbinput_len);
do_statusbar_output(kbinput, kbinput_len, FALSE);
}
/* Return the zero-based column position of the cursor in the answer. */
size_t statusbar_xplustabs(void)
{
return strnlenpt(answer, statusbar_x);
free(kbinput);
}
/* Paste the first line of the cutbuffer into the current answer. */
@@ -372,13 +348,13 @@ void do_statusbar_uncut_text(void)
/* Concatenate: the current answer before the cursor, the first line
* of the cutbuffer, plus the rest of the current answer. */
strncpy(fusion, answer, statusbar_x);
strncpy(fusion + statusbar_x, cutbuffer->data, pastelen);
strcpy(fusion + statusbar_x + pastelen, answer + statusbar_x);
strncpy(fusion, answer, typing_x);
strncpy(fusion + typing_x, cutbuffer->data, pastelen);
strcpy(fusion + typing_x + pastelen, answer + typing_x);
free(answer);
answer = fusion;
statusbar_x += pastelen;
typing_x += pastelen;
}
/* Return the column number of the first character of the answer that is
@@ -396,19 +372,19 @@ size_t get_statusbar_page_start(size_t base, size_t column)
}
/* Reinitialize the cursor position in the answer. */
void reinit_statusbar_x(void)
void put_cursor_at_end_of_answer(void)
{
statusbar_x = HIGHEST_POSITIVE;
typing_x = HIGHEST_POSITIVE;
}
/* Redraw the promptbar and place the cursor at the right spot. */
void update_the_statusbar(void)
void draw_the_promptbar(void)
{
size_t base = strlenpt(prompt) + 2;
size_t the_page, end_page, column;
char *expanded;
the_page = get_statusbar_page_start(base, base + strnlenpt(answer, statusbar_x));
the_page = get_statusbar_page_start(base, base + strnlenpt(answer, typing_x));
end_page = get_statusbar_page_start(base, base + strlenpt(answer) - 1);
/* Color the promptbar over its full width. */
@@ -431,19 +407,36 @@ void update_the_statusbar(void)
wmove(bottomwin, 0, 0);
wrefresh(bottomwin);
/* Place the cursor at statusbar_x in the answer. */
column = base + statusbar_xplustabs();
/* Place the cursor at the right spot. */
column = base + strnlenpt(answer, typing_x);
wmove(bottomwin, 0, column - get_statusbar_page_start(base, column));
wnoutrefresh(bottomwin);
}
#ifndef NANO_TINY
/* Remove or add the pipe character at the answer's head. */
void add_or_remove_pipe_symbol_from_answer(void)
{
if (answer[0] == '|') {
charmove(answer, answer + 1, strlen(answer) + 1);
if (typing_x > 0)
typing_x--;
} else {
answer = charealloc(answer, strlen(answer) + 2);
charmove(answer + 1, answer, strlen(answer) + 1);
answer[0] = '|';
typing_x++;
}
}
#endif
/* Get a string of input at the statusbar prompt. */
functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
bool allow_files, bool *listed, filestruct **history_list,
void (*refresh_func)(void))
{
int kbinput = ERR;
bool ran_func, finished;
bool finished;
functionptrtype func;
#ifdef ENABLE_TABCOMP
bool tabbed = FALSE;
@@ -464,13 +457,13 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
#endif
#endif /* ENABLE_HISTORIES */
if (statusbar_x > strlen(answer))
statusbar_x = strlen(answer);
update_the_statusbar();
if (typing_x > strlen(answer))
typing_x = strlen(answer);
while (TRUE) {
kbinput = do_statusbar_input(&ran_func, &finished);
draw_the_promptbar();
kbinput = do_statusbar_input(&finished);
#ifndef NANO_TINY
/* If the window size changed, go reformat the prompt string. */
@@ -502,12 +495,12 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
if (complete_len > 0) {
answer = get_history_completion(history_list,
answer, complete_len);
statusbar_x = strlen(answer);
typing_x = strlen(answer);
}
} else
#endif
if (allow_tabs)
answer = input_tab(answer, allow_files, &statusbar_x,
answer = input_tab(answer, allow_files, &typing_x,
&tabbed, refresh_func, listed);
} else
#endif /* ENABLE_TABCOMP */
@@ -523,7 +516,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
* answer. If there is no older search, don't do anything. */
if ((history = get_history_older(history_list)) != NULL) {
answer = mallocstrcpy(answer, history);
statusbar_x = strlen(answer);
typing_x = strlen(answer);
}
/* This key has a shortcut-list entry when it's used to
@@ -538,7 +531,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
* answer. If there is no newer search, don't do anything. */
if ((history = get_history_newer(history_list)) != NULL) {
answer = mallocstrcpy(answer, history);
statusbar_x = strlen(answer);
typing_x = strlen(answer);
}
/* If, after scrolling down, we're at the bottom of the
@@ -547,7 +540,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
if ((*history_list)->next == NULL &&
*answer == '\0' && magichistory != NULL) {
answer = mallocstrcpy(answer, magichistory);
statusbar_x = strlen(answer);
typing_x = strlen(answer);
}
/* This key has a shortcut-list entry when it's used to
@@ -572,8 +565,6 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
if (finished)
break;
update_the_statusbar();
#if defined(ENABLE_HISTORIES) && defined(ENABLE_TABCOMP)
last_kbinput = kbinput;
#endif
@@ -612,12 +603,13 @@ int do_prompt(bool allow_tabs, bool allow_files,
functionptrtype func = NULL;
bool listed = FALSE;
/* Save a possible current statusbar x position and prompt. */
size_t was_statusbar_x = statusbar_x;
size_t was_typing_x = typing_x;
char *saved_prompt = prompt;
bottombars(menu);
answer = mallocstrcpy(answer, curranswer);
if (answer != curranswer || answer == NULL)
answer = mallocstrcpy(answer, curranswer);
#ifndef NANO_TINY
redo_theprompt:
@@ -642,7 +634,7 @@ int do_prompt(bool allow_tabs, bool allow_files,
/* If we're done with this prompt, restore the x position to what
* it was at a possible previous prompt. */
if (func == do_cancel || func == do_enter)
statusbar_x = was_statusbar_x;
typing_x = was_typing_x;
/* If we left the prompt via Cancel or Enter, set the return value
* properly. */
@@ -669,25 +661,25 @@ int do_prompt(bool allow_tabs, bool allow_files,
int do_yesno_prompt(bool all, const char *msg)
{
int response = -2, width = 16;
char *message = display_string(msg, 0, COLS, FALSE);
/* TRANSLATORS: For the next three strings, if possible, specify
* the single-byte letters for both your language and English.
* For example, in French: "OoYy", for both "Oui" and "Yes". */
/* TRANSLATORS: For the next three strings, specify the starting letters
* of the translations for "Yes"/"No"/"All". The first letter of each of
* these strings MUST be a single-byte letter; others may be multi-byte. */
const char *yesstr = _("Yy");
const char *nostr = _("Nn");
const char *allstr = _("Aa");
/* The above three variables consist of all the single-byte characters
* that are accepted for the corresponding answer. Of each variable,
* the first character is displayed in the help lines. */
while (response == -2) {
#ifdef ENABLE_NLS
char letter[MAXCHARLEN + 1];
int index = 0;
#endif
int kbinput;
if (!ISSET(NO_HELP)) {
char shortstr[MAXCHARLEN + 2];
/* Temporary string for (translated) " Y", " N" and " A". */
const sc *cancelshortcut = first_sc_for(MYESNO, do_cancel);
/* The keystroke that is bound to the Cancel function. */
if (COLS < 32)
width = COLS / 2;
@@ -700,24 +692,24 @@ int do_yesno_prompt(bool all, const char *msg)
wmove(bottomwin, 1, 0);
post_one_key(shortstr, _("Yes"), width);
shortstr[1] = nostr[0];
wmove(bottomwin, 2, 0);
post_one_key(shortstr, _("No"), width);
if (all) {
shortstr[1] = allstr[0];
wmove(bottomwin, 1, width);
post_one_key(shortstr, _("All"), width);
}
shortstr[1] = nostr[0];
wmove(bottomwin, 2, 0);
post_one_key(shortstr, _("No"), width);
wmove(bottomwin, 2, width);
post_one_key("^C", _("Cancel"), width);
post_one_key(cancelshortcut->keystr, _("Cancel"), width);
}
/* Color the statusbar over its full width and display the question. */
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
blank_statusbar();
mvwaddnstr(bottomwin, 0, 0, message, actual_x(message, COLS - 1));
mvwaddnstr(bottomwin, 0, 0, msg, actual_x(msg, COLS - 1));
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
wnoutrefresh(bottomwin);
@@ -726,12 +718,34 @@ int do_yesno_prompt(bool all, const char *msg)
/* When not replacing, show the cursor while waiting for a key. */
kbinput = get_kbinput(bottomwin, !all);
/* See if the pressed key is in the Yes, No, or All strings. */
if (strchr(yesstr, kbinput) != NULL)
#ifdef ENABLE_NLS
letter[index++] = (unsigned char)kbinput;
#ifdef ENABLE_UTF8
/* If the received code is a UTF-8 starter byte, get also the
* continuation bytes and assemble them into one letter. */
if (using_utf8() && 0xC0 <= kbinput && kbinput <= 0xF7) {
int extras = (kbinput / 16) % 4 + (kbinput <= 0xCF ? 1 : 0);
while (extras <= get_key_buffer_len() && extras-- > 0)
letter[index++] = (unsigned char)get_kbinput(bottomwin, !all);
}
#endif
letter[index] = '\0';
/* See if the typed letter is in the Yes, No, or All strings. */
if (strstr(yesstr, letter) != NULL)
response = 1;
else if (strchr(nostr, kbinput) != NULL)
else if (strstr(nostr, letter) != NULL)
response = 0;
else if (all && strchr(allstr, kbinput) != NULL)
else if (all && strstr(allstr, letter) != NULL)
response = 2;
else
#endif /* ENABLE_NLS */
if (strchr("Yy", kbinput) != NULL)
response = 1;
else if (strchr("Nn", kbinput) != NULL)
response = 0;
else if (all && strchr("Aa", kbinput) != NULL)
response = 2;
else if (func_from_key(&kbinput) == do_cancel)
response = -1;
@@ -739,7 +753,7 @@ int do_yesno_prompt(bool all, const char *msg)
else if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y;
/* We can click on the Yes/No/All shortcuts to select an answer. */
if (get_mouseinput(&mouse_x, &mouse_y, FALSE) == 0 &&
if (get_mouseinput(&mouse_y, &mouse_x, FALSE) == 0 &&
wmouse_trafo(bottomwin, &mouse_y, &mouse_x, FALSE) &&
mouse_x < (width * 2) && mouse_y > 0) {
int x = mouse_x / width;
@@ -755,7 +769,5 @@ int do_yesno_prompt(bool all, const char *msg)
#endif /* ENABLE_MOUSE */
}
free(message);
return response;
}

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* proto.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -30,7 +30,7 @@ extern volatile sig_atomic_t the_window_resized;
#endif
#ifdef __linux__
extern bool console;
extern bool on_a_vt;
#endif
extern bool meta_key;
@@ -40,9 +40,6 @@ extern bool focusing;
extern bool as_an_at;
extern int margin;
extern int editwincols;
extern bool suppress_cursorpos;
extern message_type lastmessage;
@@ -64,6 +61,8 @@ extern int controlup;
extern int controldown;
extern int controlhome;
extern int controlend;
extern int controldelete;
extern int controlshiftdelete;
#ifndef NANO_TINY
extern int shiftcontrolleft;
extern int shiftcontrolright;
@@ -83,7 +82,6 @@ extern int shiftaltdown;
#ifdef ENABLED_WRAPORJUSTIFY
extern ssize_t fill;
extern ssize_t wrap_at;
#endif
extern char *last_search;
@@ -91,10 +89,13 @@ extern char *last_search;
extern char *present_path;
extern unsigned flags[4];
extern WINDOW *topwin;
extern WINDOW *edit;
extern WINDOW *bottomwin;
extern int editwinrows;
extern int editwincols;
extern int margin;
extern filestruct *cutbuffer;
extern filestruct *cutbottom;
@@ -172,13 +173,15 @@ extern regmatch_t regmatches[10];
extern int hilite_attribute;
#ifdef ENABLE_COLOR
extern char* specified_color_combo[NUMBER_OF_ELEMENTS];
extern colortype *color_combo[NUMBER_OF_ELEMENTS];
#endif
extern int interface_color_pair[NUMBER_OF_ELEMENTS];
extern char *homedir;
extern char *statedir;
#ifdef ENABLE_NANORC
extern char *rcfile_with_errors;
#endif
typedef void (*functionptrtype)(void);
@@ -189,7 +192,7 @@ 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(void);
void do_filesearch(bool forwards);
void do_fileresearch(bool forwards);
void to_first_file(void);
void to_last_file(void);
@@ -221,7 +224,6 @@ 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);
size_t mbstrlen(const char *s);
size_t mbstrnlen(const char *s, size_t maxlen);
#if !defined(NANO_TINY) || defined(ENABLE_JUSTIFY)
char *mbstrchr(const char *s, const char *c);
#endif
@@ -236,9 +238,6 @@ bool has_blank_mbchars(const char *s);
#ifdef ENABLE_UTF8
bool is_valid_unicode(wchar_t wc);
#endif
#ifdef ENABLE_NANORC
bool is_valid_mbstring(const char *s);
#endif
/* Most functions in color.c. */
#ifdef ENABLE_COLOR
@@ -256,7 +255,7 @@ bool keeping_cutbuffer(void);
#ifndef NANO_TINY
void cut_marked(bool *right_side_up);
#endif
void do_cut_text(bool copy_text, bool cut_till_eof);
void do_cut_text(bool copy_text, bool marked, bool cut_till_eof);
void do_cut_text_void(void);
#ifndef NANO_TINY
void do_copy_text(void);
@@ -267,22 +266,21 @@ void do_uncut_text(void);
/* Most functions in files.c. */
void initialize_buffer_text(void);
void set_modified(void);
bool open_buffer(const char *filename, bool undoable);
bool open_buffer(const char *filename, bool new_buffer);
#ifdef ENABLE_SPELLER
void replace_buffer(const char *filename);
#ifndef NANO_TINY
void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
filestruct *bot, size_t bot_x);
void replace_marked_buffer(const char *filename);
#endif
#endif
void prepare_for_display(void);
#ifdef ENABLE_MULTIBUFFER
void mention_name_and_linecount(void);
void switch_to_prev_buffer(void);
void switch_to_next_buffer(void);
bool close_buffer(void);
#endif
void read_file(FILE *f, int fd, const char *filename, bool undoable,
bool checkwritable);
void read_file(FILE *f, int fd, const char *filename, bool undoable);
int open_file(const char *filename, bool newfie, bool quiet, FILE **f);
char *get_next_filename(const char *name, const char *suffix);
void do_insertfile_void(void);
@@ -326,15 +324,15 @@ void assign_keyinfo(sc *s, const char *keystring, const int keycode);
void print_sclist(void);
void shortcut_init(void);
#ifdef ENABLE_COLOR
void set_lint_or_format_shortcuts(void);
void set_spell_shortcuts(void);
void set_linter_shortcut(void);
void set_speller_shortcut(void);
#endif
const subnfunc *sctofunc(const sc *s);
const char *flagtostr(int flag);
#ifdef ENABLE_NANORC
sc *strtosc(const char *input);
int strtomenu(const char *input);
#ifdef DEBUG
void thanks_for_all_the_fish(void);
int name_to_menu(const char *name);
char *menu_to_name(int menu);
#endif
/* All functions in help.c. */
@@ -381,16 +379,14 @@ void do_para_end_void(void);
void do_prev_block(void);
void do_next_block(void);
void do_prev_word(bool allow_punct, bool update_screen);
bool do_next_word(bool allow_punct, bool update_screen);
bool do_next_word(bool after_ends, bool allow_punct, bool update_screen);
void do_prev_word_void(void);
void do_next_word_void(void);
void do_home(void);
void do_end(void);
void do_up(bool scroll_only);
void do_down(bool scroll_only);
void do_up_void(void);
void do_down_void(void);
#ifndef NANO_TINY
void do_up(void);
void do_down(void);
#ifdef ENABLE_HELP
void do_scroll_up(void);
void do_scroll_down(void);
#endif
@@ -404,7 +400,7 @@ void unlink_node(filestruct *fileptr);
void delete_node(filestruct *fileptr);
filestruct *copy_filestruct(const filestruct *src);
void free_filestruct(filestruct *src);
void renumber(filestruct *fileptr);
void renumber(filestruct *line);
partition *partition_filestruct(filestruct *top, size_t top_x,
filestruct *bot, size_t bot_x);
void unpartition_filestruct(partition **p);
@@ -413,8 +409,10 @@ void extract_buffer(filestruct **file_top, filestruct **file_bot,
void ingraft_buffer(filestruct *somebuffer);
void copy_from_buffer(filestruct *somebuffer);
openfilestruct *make_new_opennode(void);
#ifdef ENABLE_MULTIBUFFER
void unlink_opennode(openfilestruct *fileptr);
void delete_opennode(openfilestruct *fileptr);
#endif
void print_view_warning(void);
void show_restricted_warning(void);
#ifndef ENABLE_HELP
@@ -422,11 +420,14 @@ void say_there_is_no_help(void);
#endif
void finish(void);
void die(const char *msg, ...);
void die_save_file(const char *die_filename, struct stat *die_stat);
void emergency_save(const char *die_filename, struct stat *die_stat);
void window_init(void);
void do_exit(void);
void close_and_go(void);
RETSIGTYPE handle_hupterm(int signal);
#ifndef DEBUG
RETSIGTYPE handle_crash(int signal);
#endif
RETSIGTYPE do_suspend(int signal);
RETSIGTYPE do_continue(int signal);
#ifndef NANO_TINY
@@ -434,23 +435,20 @@ RETSIGTYPE handle_sigwinch(int signal);
void regenerate_screen(void);
void allow_sigwinch(bool allow);
void do_toggle(int flag);
void do_toggle_void(void);
void enable_signals(void);
#endif
void disable_flow_control(void);
void enable_flow_control(void);
void terminal_init(void);
void unbound_key(int code);
int do_input(bool allow_funcs);
#ifdef ENABLE_MOUSE
int do_mouse(void);
#ifdef ENABLE_LINENUMBERS
void confirm_margin(void);
#endif
void unbound_key(int code);
bool okay_for_view(const sc *shortcut);
int do_input(bool allow_funcs);
void do_output(char *output, size_t output_len, bool allow_cntrls);
/* Most functions in prompt.c. */
#ifdef ENABLE_MOUSE
int do_statusbar_mouse(void);
#endif
void do_statusbar_output(int *the_input, size_t input_len, bool filtering);
void do_statusbar_home(void);
void do_statusbar_end(void);
@@ -465,10 +463,9 @@ void do_statusbar_prev_word(void);
void do_statusbar_next_word(void);
#endif
void do_statusbar_verbatim_input(void);
size_t statusbar_xplustabs(void);
size_t get_statusbar_page_start(size_t start_col, size_t column);
void reinit_statusbar_x(void);
void update_the_statusbar(void);
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, filestruct **history_list,
void (*refresh_func)(void), const char *msg, ...);
@@ -477,7 +474,6 @@ int do_yesno_prompt(bool all, const char *msg);
/* Most functions in rcfile.c. */
#ifdef ENABLE_NANORC
#ifdef ENABLE_COLOR
bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright);
void grab_and_store(const char *kind, char *ptr, regexlisttype **storage);
#endif
void parse_rcfile(FILE *rcstream, bool syntax_only);
@@ -485,22 +481,20 @@ void do_rcfiles(void);
#endif /* ENABLE_NANORC */
/* Most functions in search.c. */
void not_found_msg(const char *str);
void search_replace_abort(void);
void tidy_up_after_search(void);
int findnextstr(const char *needle, bool whole_word_only, int modus,
size_t *match_len, bool skipone, const filestruct *begin, size_t begin_x);
void do_search(void);
void do_search_forward(void);
void do_search_backward(void);
#ifndef NANO_TINY
void do_findprevious(void);
void do_findnext(void);
#endif
void do_research(void);
void not_found_msg(const char *str);
void go_looking(void);
ssize_t do_replace_loop(const char *needle, bool whole_word_only,
const filestruct *real_current, size_t *real_current_x);
void do_replace(void);
void ask_for_replacement(void);
void goto_line_posx(ssize_t line, size_t pos_x);
void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
bool interactive);
@@ -527,7 +521,6 @@ void do_unindent(void);
bool white_string(const char *s);
#ifdef ENABLE_COMMENT
void do_comment(void);
bool comment_line(undo_type action, filestruct *f, const char *comment_seq);
#endif
void do_undo(void);
void do_redo(void);
@@ -552,7 +545,7 @@ size_t indent_length(const char *line);
#endif
#ifdef ENABLE_JUSTIFY
void justify_format(filestruct *paragraph, size_t skip);
bool begpar(const filestruct *const foo);
bool begpar(const filestruct *const foo, int depth);
bool inpar(const filestruct *const foo);
void do_justify(bool full_justify);
void do_justify_void(void);
@@ -563,7 +556,6 @@ void do_spell(void);
#endif
#ifdef ENABLE_COLOR
void do_linter(void);
void do_formatter(void);
#endif
#ifndef NANO_TINY
void do_wordlinechar_count(void);
@@ -617,16 +609,16 @@ size_t get_totsize(const filestruct *begin, const filestruct *end);
#ifndef NANO_TINY
filestruct *fsfromline(ssize_t lineno);
#endif
#ifdef DEBUG
void dump_filestruct(const filestruct *inptr);
#endif
/* Most functions in winio.c. */
void record_macro(void);
void run_macro(void);
void get_key_buffer(WINDOW *win);
size_t get_key_buffer_len(void);
void put_back(int keycode);
void unget_kbinput(int kbinput, bool metakey);
#ifdef ENABLE_NANORC
void implant(const char *string);
#endif
int get_kbinput(WINDOW *win, bool showcursor);
int parse_kbinput(WINDOW *win);
int arrow_from_abcd(int kbinput);
@@ -636,7 +628,7 @@ int get_control_kbinput(int kbinput);
int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len);
int *parse_verbatim_kbinput(WINDOW *win, size_t *count);
#ifdef ENABLE_MOUSE
int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts);
int get_mouseinput(int *mouse_row, int *mouse_col, bool allow_shortcuts);
#endif
const sc *get_shortcut(int *kbinput);
void blank_row(WINDOW *win, int y, int x, int n);
@@ -663,7 +655,7 @@ bool line_needs_update(const size_t old_column, const size_t new_column);
int go_back_chunks(int nrows, filestruct **line, size_t *leftedge);
int go_forward_chunks(int nrows, filestruct **line, size_t *leftedge);
bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge);
void edit_scroll(bool direction, int nrows);
void edit_scroll(bool direction);
#ifndef NANO_TINY
size_t get_softwrap_breakpoint(const char *text, size_t leftedge,
bool *end_of_line);
@@ -694,27 +686,30 @@ void do_credits(void);
#endif
/* These are just name definitions. */
void do_cancel(void);
void case_sens_void(void);
void regexp_void(void);
void backwards_void(void);
void flip_replace(void);
void gototext_void(void);
void flip_goto(void);
#ifdef ENABLE_BROWSER
void to_files_void(void);
void goto_dir_void(void);
#endif
#ifndef NANO_TINY
void do_toggle_void(void);
void dos_format_void(void);
void mac_format_void(void);
void append_void(void);
void prepend_void(void);
void backup_file_void(void);
void flip_execute(void);
void flip_pipe(void);
void flip_convert(void);
#endif
#ifdef ENABLE_MULTIBUFFER
void flip_newbuffer(void);
#endif
void discard_buffer(void);
void do_cancel(void);
#endif /* !PROTO_H */

View File

@@ -1,9 +1,9 @@
/**************************************************************************
* rcfile.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2014 Mike Frysinger *
* Copyright (C) 2014-2017 Benno Schulenberg *
* Copyright (C) 2014-2018 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -31,24 +31,26 @@
#ifdef ENABLE_NANORC
#ifndef RCFILE_NAME
#define HOME_RC_NAME ".nanorc"
#define RCFILE_NAME "nanorc"
#else
#define HOME_RC_NAME RCFILE_NAME
#endif
static const rcoption rcopts[] = {
{"boldtext", BOLD_TEXT},
#ifdef ENABLE_LINENUMBERS
{"linenumbers", LINE_NUMBERS},
#endif
#ifdef ENABLE_JUSTIFY
{"brackets", 0},
#endif
{"const", CONSTANT_SHOW}, /* deprecated form, remove in 2018 */
{"constantshow", CONSTANT_SHOW},
#ifdef ENABLED_WRAPORJUSTIFY
{"fill", 0},
#endif
#ifdef ENABLE_HISTORIES
{"historylog", HISTORYLOG},
#endif
#ifdef ENABLE_LINENUMBERS
{"linenumbers", LINE_NUMBERS},
#endif
{"morespace", MORE_SPACE},
#ifdef ENABLE_MOUSE
@@ -67,7 +69,6 @@ static const rcoption rcopts[] = {
{"operatingdir", 0},
#endif
#ifdef ENABLE_HISTORIES
{"poslog", POS_HISTORY}, /* deprecated form, remove in 2018 */
{"positionlog", POS_HISTORY},
#endif
{"preserve", PRESERVE},
@@ -87,16 +88,16 @@ static const rcoption rcopts[] = {
{"tempfile", TEMP_FILE},
{"view", VIEW_MODE},
#ifndef NANO_TINY
{"afterends", AFTER_ENDS},
{"allow_insecure_backup", INSECURE_BACKUP},
{"atblanks", AT_BLANKS},
{"autoindent", AUTOINDENT},
{"backup", BACKUP_FILE},
{"backupdir", 0},
{"backwards", BACKWARDS_SEARCH},
{"casesensitive", CASE_SENSITIVE},
{"cut", CUT_FROM_CURSOR}, /* deprecated form, remove in 2020 */
{"cut", CUT_FROM_CURSOR}, /* deprecated form, remove end of 2018 */
{"cutfromcursor", CUT_FROM_CURSOR},
{"justifytrim", TRIM_BLANKS}, /* deprecated form, remove in 2020 */
{"justifytrim", TRIM_BLANKS}, /* deprecated form, remove end of 2018 */
{"locking", LOCKING},
{"matchbrackets", 0},
{"noconvert", NO_CONVERT},
@@ -117,6 +118,7 @@ static const rcoption rcopts[] = {
{"numbercolor", 0},
{"selectedcolor", 0},
{"statuscolor", 0},
{"errorcolor", 0},
{"keycolor", 0},
{"functioncolor", 0},
#endif
@@ -188,30 +190,25 @@ char *parse_argument(char *ptr)
const char *ptr_save = ptr;
char *last_quote = NULL;
assert(ptr != NULL);
if (*ptr != '"')
return parse_next_word(ptr);
do {
ptr++;
if (*ptr == '"')
while (*ptr != '\0') {
if (*++ptr == '"')
last_quote = ptr;
} while (*ptr != '\0');
}
if (last_quote == NULL) {
if (*ptr == '\0')
ptr = NULL;
else
*ptr++ = '\0';
rcfile_error(N_("Argument '%s' has an unterminated \""), ptr_save);
} else {
*last_quote = '\0';
ptr = last_quote + 1;
return NULL;
}
if (ptr != NULL)
while (isblank((unsigned char)*ptr))
ptr++;
*last_quote = '\0';
ptr = last_quote + 1;
while (isblank((unsigned char)*ptr))
ptr++;
return ptr;
}
@@ -220,19 +217,14 @@ char *parse_argument(char *ptr)
* null-terminate it, and return a pointer to the /next/ word. */
char *parse_next_regex(char *ptr)
{
assert(ptr != NULL);
/* Continue until the end of line, or until a " followed by a
* blank character or the end of line. */
while (*ptr != '\0' && (*ptr != '"' ||
(*(ptr + 1) != '\0' && !isblank((unsigned char)ptr[1]))))
ptr++;
assert(*ptr == '"' || *ptr == '\0');
if (*ptr == '\0') {
rcfile_error(
N_("Regex strings must begin and end with a \" character"));
rcfile_error(N_("Regex strings must begin and end with a \" character"));
return NULL;
}
@@ -270,13 +262,10 @@ bool nregcomp(const char *regex, int compile_flags)
* line at ptr, and add it to the global linked list of color syntaxes. */
void parse_syntax(char *ptr)
{
char *nameptr;
/* A pointer to what should be the name of the syntax. */
char *nameptr = ptr;
opensyntax = FALSE;
assert(ptr != NULL);
/* Check that the syntax name is not empty. */
if (*ptr == '\0' || (*ptr == '"' &&
(*(ptr + 1) == '\0' || *(ptr + 1) == '"'))) {
@@ -284,17 +273,19 @@ void parse_syntax(char *ptr)
return;
}
nameptr = ++ptr;
ptr = parse_next_word(ptr);
/* Check that the name starts and ends with a double quote. */
if (*(nameptr - 1) != '\x22' || nameptr[strlen(nameptr) - 1] != '\x22') {
rcfile_error(N_("A syntax name must be quoted"));
/* Check that quotes around the name are either paired or absent. */
if ((*nameptr == '\x22') ^ (nameptr[strlen(nameptr) - 1] == '\x22')) {
rcfile_error(N_("Unpaired quote in syntax name"));
return;
}
/* Strip the end quote. */
nameptr[strlen(nameptr) - 1] = '\0';
/* If the name is quoted, strip the quotes. */
if (*nameptr == '\x22') {
nameptr++;
nameptr[strlen(nameptr) - 1] = '\0';
}
/* Redefining the "none" syntax is not allowed. */
if (strcmp(nameptr, "none") == 0) {
@@ -309,7 +300,6 @@ void parse_syntax(char *ptr)
live_syntax->headers = NULL;
live_syntax->magics = NULL;
live_syntax->linter = NULL;
live_syntax->formatter = NULL;
#ifdef ENABLE_COMMENT
live_syntax->comment = mallocstrcpy(NULL, GENERAL_COMMENT_CHARACTER);
#endif
@@ -323,14 +313,9 @@ void parse_syntax(char *ptr)
opensyntax = TRUE;
#ifdef DEBUG
fprintf(stderr, "Starting a new syntax type: \"%s\"\n", nameptr);
#endif
/* The default syntax should have no associated extensions. */
if (strcmp(live_syntax->name, "default") == 0 && *ptr != '\0') {
rcfile_error(
N_("The \"default\" syntax does not accept extensions"));
rcfile_error(N_("The \"default\" syntax does not accept extensions"));
return;
}
@@ -340,22 +325,17 @@ void parse_syntax(char *ptr)
}
#endif /* ENABLE_COLOR */
/* Check whether the given executable function is "universal" (meaning
* any horizontal movement or deletion) and thus is present in almost
* all menus. */
/* Return TRUE when the given function is present in almost all menus. */
bool is_universal(void (*func)(void))
{
if (func == do_left || func == do_right ||
return (func == do_left || func == do_right ||
func == do_home || func == do_end ||
#ifndef NANO_TINY
func == do_prev_word_void || func == do_next_word_void ||
#endif
func == do_delete || func == do_backspace ||
func == do_cut_text_void || func == do_uncut_text ||
func == do_tab || func == do_enter || func == do_verbatim_input)
return TRUE;
else
return FALSE;
func == do_tab || func == do_enter || func == do_verbatim_input);
}
/* Bind or unbind a key combo, to or from a function. */
@@ -365,12 +345,6 @@ void parse_binding(char *ptr, bool dobind)
sc *s, *newsc = NULL;
int menu;
assert(ptr != NULL);
#ifdef DEBUG
fprintf(stderr, "Starting the rebinding code...\n");
#endif
if (*ptr == '\0') {
rcfile_error(N_("Missing key name"));
return;
@@ -411,12 +385,13 @@ void parse_binding(char *ptr, bool dobind)
if (dobind) {
funcptr = ptr;
ptr = parse_next_word(ptr);
ptr = parse_argument(ptr);
if (funcptr[0] == '\0') {
rcfile_error(N_("Must specify a function to bind the key to"));
goto free_things;
}
} else if (ptr == NULL)
goto free_things;
}
menuptr = ptr;
@@ -429,14 +404,25 @@ void parse_binding(char *ptr, bool dobind)
}
if (dobind) {
newsc = strtosc(funcptr);
/* If the thing to bind starts with a double quote, it is a string,
* otherwise it is the name of a function. */
if (*funcptr == '"') {
newsc = nmalloc(sizeof(sc));
newsc->func = (functionptrtype)implant;
newsc->expansion = mallocstrcpy(NULL, funcptr + 1);
#ifndef NANO_TINY
newsc->toggle = 0;
#endif
} else
newsc = strtosc(funcptr);
if (newsc == NULL) {
rcfile_error(N_("Cannot map name \"%s\" to a function"), funcptr);
goto free_things;
}
}
menu = strtomenu(menuptr);
menu = name_to_menu(menuptr);
if (menu < 1) {
rcfile_error(N_("Cannot map name \"%s\" to a menu"), menuptr);
goto free_things;
@@ -448,20 +434,21 @@ void parse_binding(char *ptr, bool dobind)
/* Tally up the menus where the function exists. */
for (f = allfuncs; f != NULL; f = f->next)
if (f->scfunc == newsc->scfunc)
if (f->func == newsc->func)
mask = mask | f->menus;
#ifndef NANO_TINY
/* Handle the special case of the toggles. */
if (newsc->scfunc == do_toggle_void)
if (newsc->func == do_toggle_void)
mask = MMAIN;
#endif
#ifdef ENABLE_NANORC
/* Handle the special case of a key defined as a string. */
if (newsc->func == (functionptrtype)implant)
mask = MMOST | MHELP;
#endif
/* Now limit the given menu to those where the function exists. */
if (is_universal(newsc->scfunc))
menu = menu & MMOST;
else
menu = menu & mask;
menu = menu & (is_universal(newsc->func) ? MMOST : mask);
if (!menu) {
rcfile_error(N_("Function '%s' does not exist in menu '%s'"), funcptr, menuptr);
@@ -487,9 +474,9 @@ void parse_binding(char *ptr, bool dobind)
if (dobind) {
#ifndef NANO_TINY
/* If this is a toggle, copy its sequence number. */
if (newsc->scfunc == do_toggle_void) {
if (newsc->func == do_toggle_void) {
for (s = sclist; s != NULL; s = s->next)
if (s->scfunc == do_toggle_void && s->toggle == newsc->toggle)
if (s->func == do_toggle_void && s->toggle == newsc->toggle)
newsc->ordinal = s->ordinal;
} else
newsc->ordinal = 0;
@@ -514,7 +501,7 @@ bool is_good_file(char *file)
if (access(file, R_OK) != 0)
return FALSE;
/* If the thing exists, it may not be a directory nor a device. */
/* If the thing exists, it may be neither a directory nor a device. */
if (stat(file, &rcinfo) != -1 && (S_ISDIR(rcinfo.st_mode) ||
S_ISCHR(rcinfo.st_mode) || S_ISBLK(rcinfo.st_mode))) {
rcfile_error(S_ISDIR(rcinfo.st_mode) ? _("\"%s\" is a directory") :
@@ -547,10 +534,6 @@ static void parse_one_include(char *file)
nanorc = file;
lineno = 0;
#ifdef DEBUG
fprintf(stderr, "Parsing file \"%s\"\n", file);
#endif
parse_rcfile(rcstream, TRUE);
}
@@ -591,7 +574,8 @@ short color_to_short(const char *colorname, bool *bright)
if (strncasecmp(colorname, "bright", 6) == 0) {
*bright = TRUE;
colorname += 6;
}
} else
*bright = FALSE;
if (strcasecmp(colorname, "green") == 0)
return COLOR_GREEN;
@@ -609,13 +593,45 @@ short color_to_short(const char *colorname, bool *bright)
return COLOR_MAGENTA;
else if (strcasecmp(colorname, "black") == 0)
return COLOR_BLACK;
else if (strcasecmp(colorname, "normal") == 0)
return USE_THE_DEFAULT;
rcfile_error(N_("Color \"%s\" not understood.\n"
"Valid colors are \"green\", \"red\", \"blue\",\n"
"\"white\", \"yellow\", \"cyan\", \"magenta\" and\n"
"\"black\", with the optional prefix \"bright\"\n"
"for foreground colors."), colorname);
return -1;
rcfile_error(N_("Color \"%s\" not understood"), colorname);
return BAD_COLOR;
}
/* Parse the color name (or pair of color names) in the given string.
* Return FALSE when any color name is invalid; otherwise return TRUE. */
bool parse_color_names(char *combostr, short *fg, short *bg, int *attributes)
{
char *comma = strchr(combostr, ',');
bool bright;
*attributes = A_NORMAL;
if (comma != NULL) {
*bg = color_to_short(comma + 1, &bright);
if (bright) {
rcfile_error(N_("A background color cannot be bright"));
return FALSE;
}
if (*bg == BAD_COLOR)
return FALSE;
*comma = '\0';
} else
*bg = USE_THE_DEFAULT;
if (comma != combostr) {
*fg = color_to_short(combostr, &bright);
if (*fg == BAD_COLOR)
return FALSE;
if (bright)
*attributes = A_BOLD;
} else
*fg = USE_THE_DEFAULT;
return TRUE;
}
/* Parse the color string in the line at ptr, and add it to the current
@@ -624,13 +640,12 @@ short color_to_short(const char *colorname, bool *bright)
void parse_colors(char *ptr, int rex_flags)
{
short fg, bg;
bool bright = FALSE;
int attributes;
char *item;
if (!opensyntax) {
rcfile_error(
N_("A '%s' command requires a preceding 'syntax' command"),
"color");
rcfile_error(N_("A '%s' command requires a preceding 'syntax' command"),
"color");
return;
}
@@ -641,7 +656,7 @@ void parse_colors(char *ptr, int rex_flags)
item = ptr;
ptr = parse_next_word(ptr);
if (!parse_color_names(item, &fg, &bg, &bright))
if (!parse_color_names(item, &fg, &bg, &attributes))
return;
if (*ptr == '\0') {
@@ -665,8 +680,7 @@ void parse_colors(char *ptr, int rex_flags)
}
if (*ptr != '"') {
rcfile_error(
N_("Regex strings must begin and end with a \" character"));
rcfile_error(N_("Regex strings must begin and end with a \" character"));
ptr = parse_next_regex(ptr);
continue;
}
@@ -689,7 +703,7 @@ void parse_colors(char *ptr, int rex_flags)
newcolor->fg = fg;
newcolor->bg = bg;
newcolor->bright = bright;
newcolor->attributes = attributes;
newcolor->rex_flags = rex_flags;
newcolor->start_regex = mallocstrcpy(NULL, item);
@@ -747,31 +761,19 @@ void parse_colors(char *ptr, int rex_flags)
}
}
/* Parse the color name, or pair of color names, in combostr. */
bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright)
/* Parse the argument of an interface color option. */
colortype *parse_interface_color(char *combostr)
{
char *comma = strchr(combostr, ',');
colortype *trio = nmalloc(sizeof(colortype));
if (comma != NULL) {
*bg = color_to_short(comma + 1, bright);
if (*bright) {
rcfile_error(N_("A background color cannot be bright"));
return FALSE;
}
*comma = '\0';
} else
*bg = -1;
if (comma != combostr) {
*fg = color_to_short(combostr, bright);
/* If the specified foreground color is bad, ignore the regexes. */
if (*fg == -1)
return FALSE;
} else
*fg = -1;
return TRUE;
if (parse_color_names(combostr, &trio->fg, &trio->bg, &trio->attributes)) {
free(combostr);
return trio;
} else {
free(combostr);
free(trio);
return NULL;
}
}
/* Read regex strings enclosed in double quotes from the line pointed at
@@ -810,8 +812,7 @@ void grab_and_store(const char *kind, char *ptr, regexlisttype **storage)
regexlisttype *newthing;
if (*ptr != '"') {
rcfile_error(
N_("Regex strings must begin and end with a \" character"));
rcfile_error(N_("Regex strings must begin and end with a \" character"));
return;
}
@@ -838,11 +839,9 @@ void grab_and_store(const char *kind, char *ptr, regexlisttype **storage)
}
}
/* Gather and store the string after a comment/linter/formatter command. */
/* Gather and store the string after a comment/linter command. */
void pick_up_name(const char *kind, char *ptr, char **storage)
{
assert(ptr != NULL);
if (!opensyntax) {
rcfile_error(
N_("A '%s' command requires a preceding 'syntax' command"), kind);
@@ -856,17 +855,17 @@ void pick_up_name(const char *kind, char *ptr, char **storage)
/* If the argument starts with a quote, find the terminating quote. */
if (*ptr == '"') {
char *look = ++ptr;
look += strlen(ptr);
char *look = ptr + strlen(ptr);
while (*look != '"') {
if (--look < ptr) {
if (--look == ptr) {
rcfile_error(N_("Argument of '%s' lacks closing \""), kind);
return;
}
}
*look = '\0';
ptr++;
}
*storage = mallocstrcpy(*storage, ptr);
@@ -879,17 +878,18 @@ static void check_vitals_mapped(void)
{
subnfunc *f;
int v;
#define VITALS 5
void (*vitals[VITALS])(void) = { do_exit, do_exit, do_cancel, do_cancel, do_cancel };
int inmenus[VITALS] = { MMAIN, MHELP, MWHEREIS, MREPLACE, MGOTOLINE };
#define VITALS 3
void (*vitals[VITALS])(void) = { do_exit, do_exit, do_cancel };
int inmenus[VITALS] = { MMAIN, MHELP, MYESNO };
for (v = 0; v < VITALS; v++) {
for (f = allfuncs; f != NULL; f = f->next) {
if (f->scfunc == vitals[v] && f->menus & inmenus[v]) {
const sc *s = first_sc_for(inmenus[v], f->scfunc);
if (f->func == vitals[v] && f->menus & inmenus[v]) {
const sc *s = first_sc_for(inmenus[v], f->func);
if (!s) {
fprintf(stderr, _("Fatal error: no keys mapped for function "
"\"%s\". Exiting.\n"), f->desc);
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);
@@ -934,7 +934,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
#ifdef ENABLE_COLOR
/* Handle extending first... */
if (strcasecmp(keyword, "extendsyntax") == 0) {
if (strcasecmp(keyword, "extendsyntax") == 0 && !syntax_only) {
syntaxtype *sint;
char *syntaxname = ptr;
@@ -991,13 +991,12 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
parse_colors(ptr, NANO_REG_EXTENDED | REG_ICASE);
else if (strcasecmp(keyword, "linter") == 0)
pick_up_name("linter", ptr, &live_syntax->linter);
else if (strcasecmp(keyword, "formatter") == 0)
#ifdef ENABLE_SPELLER
pick_up_name("formatter", ptr, &live_syntax->formatter);
#else
;
#endif
else if (syntax_only)
else if (syntax_only && (strcasecmp(keyword, "set") == 0 ||
strcasecmp(keyword, "unset") == 0 ||
strcasecmp(keyword, "bind") == 0 ||
strcasecmp(keyword, "unbind") == 0 ||
strcasecmp(keyword, "include") == 0 ||
strcasecmp(keyword, "extendsyntax") == 0))
rcfile_error(N_("Command \"%s\" not allowed in included file"),
keyword);
else if (strcasecmp(keyword, "include") == 0)
@@ -1043,10 +1042,6 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
continue;
}
#ifdef DEBUG
fprintf(stderr, " Option name = \"%s\"\n", rcopts[i].name);
fprintf(stderr, " Flag = %ld\n", rcopts[i].flag);
#endif
/* First handle unsetting. */
if (set == -1) {
if (rcopts[i].flag != 0)
@@ -1075,28 +1070,29 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
ptr = parse_argument(ptr);
option = mallocstrcpy(NULL, option);
#ifdef DEBUG
fprintf(stderr, " Option argument = \"%s\"\n", option);
#endif
/* Make sure the option argument is a valid multibyte string. */
if (!is_valid_mbstring(option)) {
#ifdef ENABLE_UTF8
/* When in a UTF-8 locale, ignore arguments with invalid sequences. */
if (using_utf8() && mbstowcs(NULL, option, 0) == (size_t)-1) {
rcfile_error(N_("Argument is not a valid multibyte string"));
continue;
}
#endif
#ifdef ENABLE_COLOR
if (strcasecmp(rcopts[i].name, "titlecolor") == 0)
specified_color_combo[TITLE_BAR] = option;
color_combo[TITLE_BAR] = parse_interface_color(option);
else if (strcasecmp(rcopts[i].name, "numbercolor") == 0)
specified_color_combo[LINE_NUMBER] = option;
color_combo[LINE_NUMBER] = parse_interface_color(option);
else if (strcasecmp(rcopts[i].name, "selectedcolor") == 0)
specified_color_combo[SELECTED_TEXT] = option;
color_combo[SELECTED_TEXT] = parse_interface_color(option);
else if (strcasecmp(rcopts[i].name, "statuscolor") == 0)
specified_color_combo[STATUS_BAR] = option;
color_combo[STATUS_BAR] = parse_interface_color(option);
else if (strcasecmp(rcopts[i].name, "errorcolor") == 0)
color_combo[ERROR_MESSAGE] = parse_interface_color(option);
else if (strcasecmp(rcopts[i].name, "keycolor") == 0)
specified_color_combo[KEY_COMBO] = option;
color_combo[KEY_COMBO] = parse_interface_color(option);
else if (strcasecmp(rcopts[i].name, "functioncolor") == 0)
specified_color_combo[FUNCTION_TAG] = option;
color_combo[FUNCTION_TAG] = parse_interface_color(option);
else
#endif
#ifdef ENABLE_OPERATINGDIR
@@ -1106,10 +1102,10 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
#endif
#ifdef ENABLED_WRAPORJUSTIFY
if (strcasecmp(rcopts[i].name, "fill") == 0) {
if (!parse_num(option, &wrap_at)) {
if (!parse_num(option, &fill)) {
rcfile_error(N_("Requested fill size \"%s\" is invalid"),
option);
wrap_at = -CHARS_FROM_EOL;
fill = -COLUMNS_FROM_EOL;
} else
UNSET(NO_WRAP);
free(option);
@@ -1138,19 +1134,17 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
#endif
#ifdef ENABLE_JUSTIFY
if (strcasecmp(rcopts[i].name, "punct") == 0) {
punct = option;
if (has_blank_mbchars(punct)) {
if (has_blank_mbchars(option)) {
rcfile_error(N_("Non-blank characters required"));
free(punct);
punct = NULL;
}
free(option);
} else
punct = option;
} else if (strcasecmp(rcopts[i].name, "brackets") == 0) {
brackets = option;
if (has_blank_mbchars(brackets)) {
if (has_blank_mbchars(option)) {
rcfile_error(N_("Non-blank characters required"));
free(brackets);
brackets = NULL;
}
free(option);
} else
brackets = option;
} else if (strcasecmp(rcopts[i].name, "quotestr") == 0)
quotestr = option;
else
@@ -1175,8 +1169,7 @@ void parse_rcfile(FILE *rcstream, bool syntax_only)
tabsize = -1;
}
free(option);
} else
assert(FALSE);
}
}
#ifdef ENABLE_COLOR
@@ -1203,9 +1196,6 @@ void parse_one_nanorc(void)
if (!is_good_file(nanorc))
return;
#ifdef DEBUG
fprintf(stderr, "Going to parse file \"%s\"\n", nanorc);
#endif
rcstream = fopen(nanorc, "rb");
/* If opening the file succeeded, parse it. Otherwise, only
@@ -1232,9 +1222,8 @@ void do_rcfiles(void)
{
const char *xdgconfdir;
/* First process the system-wide nanorc, if there is one. */
nanorc = mallocstrcpy(nanorc, SYSCONFDIR "/nanorc");
/* Process the system-wide nanorc. */
parse_one_nanorc();
/* When configured with --disable-wrapping-as-root, turn wrapping off
@@ -1247,9 +1236,9 @@ void do_rcfiles(void)
get_homedir();
xdgconfdir = getenv("XDG_CONFIG_HOME");
/* Now try the to find a nanorc file in the user's home directory
* or in the XDG configuration directories. */
if (have_nanorc(homedir, "/." RCFILE_NAME))
/* Now try the to find a nanorc file in the user's home directory or in
* the XDG configuration directories, and process the first one found. */
if (have_nanorc(homedir, "/" HOME_RC_NAME))
parse_one_nanorc();
else if (have_nanorc(xdgconfdir, "/nano/" RCFILE_NAME))
parse_one_nanorc();
@@ -1260,6 +1249,16 @@ void do_rcfiles(void)
check_vitals_mapped();
#ifdef __linux__
/* On a Linux console, don't start nano when there are rcfile errors,
* because otherwise these error messages get wiped. */
if (on_a_vt && rcfile_with_errors) {
fprintf(stderr, _("If needed, use nano with the -I option "
"to adjust your nanorc settings.\n"));
exit(1);
}
#endif
free(nanorc);
}

View File

@@ -1,8 +1,8 @@
/**************************************************************************
* search.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2015-2017 Benno Schulenberg *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2015-2018 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -28,8 +28,8 @@
static bool came_full_circle = FALSE;
/* Have we reached the starting line again while searching? */
static bool regexp_compiled = FALSE;
/* Have we compiled any regular expressions? */
static bool have_compiled_regexp = FALSE;
/* Whether we have compiled a regular expression for the search. */
/* Compile the given regular expression and store it in search_regexp.
* Return TRUE if the expression is valid, and FALSE otherwise. */
@@ -50,152 +50,121 @@ bool regexp_init(const char *regexp)
return FALSE;
}
regexp_compiled = TRUE;
have_compiled_regexp = TRUE;
return TRUE;
}
/* Decompile the compiled regular expression we used in the last
* search, if any. */
void regexp_cleanup(void)
/* Free a compiled regular expression, if one was compiled; and schedule a
* full screen refresh when the mark is on, in case the cursor has moved. */
void tidy_up_after_search(void)
{
if (regexp_compiled) {
regexp_compiled = FALSE;
if (have_compiled_regexp) {
regfree(&search_regexp);
have_compiled_regexp = FALSE;
}
}
/* Report on the status bar that the given string was not found. */
void not_found_msg(const char *str)
{
char *disp = display_string(str, 0, (COLS / 2) + 1, FALSE);
size_t numchars = actual_x(disp, strnlenpt(disp, COLS / 2));
statusline(HUSH, _("\"%.*s%s\" not found"), numchars, disp,
(disp[numchars] == '\0') ? "" : "...");
free(disp);
}
/* Abort the current search or replace. Clean up by displaying the main
* shortcut list, updating the screen if the mark was on before, and
* decompiling the compiled regular expression we used in the last
* search, if any. */
void search_replace_abort(void)
{
#ifndef NANO_TINY
if (openfile->mark)
refresh_needed = TRUE;
#endif
regexp_cleanup();
}
/* Set up the system variables for a search or replace. If use_answer
* is TRUE, only set backupstring to answer. Return -2 to run the
* opposite program (search -> replace, replace -> search), return -1 if
* the search should be canceled (due to Cancel, a blank search string,
* Go to Line, or a failed regcomp()), return 0 on success, and return 1
* on rerun calling program.
*
* replacing is TRUE if we call from do_replace(), and FALSE if called
* from do_search(). */
int search_init(bool replacing, bool use_answer)
/* 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)
{
int i = 0;
char *buf;
static char *backupstring = NULL;
/* The search string we'll be using. */
functionptrtype func;
char *thedefault;
/* What will be searched for when the user typed nothing. */
/* If use_answer is TRUE, set backupstring to answer and get out. */
if (use_answer) {
backupstring = mallocstrcpy(backupstring, answer);
return 0;
}
/* We display the search prompt below. If the user types a partial
* search string and then Replace or a toggle, we will return to
* do_search() or do_replace() and be called again. In that case,
* we should put the same search string back up. */
/* When starting a new search, clear the current answer. */
if (!keep_the_answer)
answer = mallocstrcpy(answer, NULL);
/* 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);
buf = charalloc(strlen(disp) + 7);
thedefault = charalloc(strlen(disp) + 7);
/* We use (COLS / 3) here because we need to see more on the line. */
sprintf(buf, " [%s%s]", disp,
sprintf(thedefault, " [%s%s]", disp,
(strlenpt(last_search) > COLS / 3) ? "..." : "");
free(disp);
} else
buf = mallocstrcpy(NULL, "");
thedefault = mallocstrcpy(NULL, "");
/* This is now one simple call. It just does a lot. */
i = do_prompt(FALSE, FALSE,
inhelp ? MFINDINHELP : (replacing ? MREPLACE : MWHEREIS),
backupstring, &search_history,
/* TRANSLATORS: This is the main search prompt. */
edit_refresh, "%s%s%s%s%s%s", _("Search"),
/* TRANSLATORS: The next three modify the search prompt. */
ISSET(CASE_SENSITIVE) ? _(" [Case Sensitive]") : "",
ISSET(USE_REGEXP) ? _(" [Regexp]") : "",
ISSET(BACKWARDS_SEARCH) ? _(" [Backwards]") : "", replacing ?
while (TRUE) {
functionptrtype func;
/* Ask the user what to search for (or replace). */
int i = do_prompt(FALSE, FALSE,
inhelp ? MFINDINHELP : (replacing ? MREPLACE : MWHEREIS),
answer, &search_history,
/* TRANSLATORS: This is the main search prompt. */
edit_refresh, "%s%s%s%s%s%s", _("Search"),
/* TRANSLATORS: The next four modify the search prompt. */
ISSET(CASE_SENSITIVE) ? _(" [Case Sensitive]") : "",
ISSET(USE_REGEXP) ? _(" [Regexp]") : "",
ISSET(BACKWARDS_SEARCH) ? _(" [Backwards]") : "", replacing ?
#ifndef NANO_TINY
/* TRANSLATORS: The next two modify the search prompt. */
openfile->mark ? _(" (to replace) in selection") :
openfile->mark ? _(" (to replace) in selection") :
#endif
_(" (to replace)") : "", buf);
_(" (to replace)") : "", thedefault);
/* Release buf now that we don't need it anymore. */
free(buf);
free(backupstring);
backupstring = NULL;
/* If the search was cancelled, or we have a blank answer and
* nothing was searched for yet during this session, get out. */
if (i == -1 || (i == -2 && *last_search == '\0')) {
statusbar(_("Cancelled"));
return -1;
}
/* If Enter was pressed, see what we got. */
if (i == 0 || i == -2) {
/* If an answer was given, remember it. */
if (*answer != '\0') {
last_search = mallocstrcpy(last_search, answer);
#ifdef ENABLE_HISTORIES
update_history(&search_history, answer);
#endif
/* If the search was cancelled, or we have a blank answer and
* nothing was searched for yet during this session, get out. */
if (i == -1 || (i == -2 && *last_search == '\0')) {
statusbar(_("Cancelled"));
tidy_up_after_search();
free(thedefault);
return;
}
/* If Enter was pressed, prepare to do a replace or a search. */
if (i == 0 || i == -2) {
/* If an actual answer was typed, remember it. */
if (*answer != '\0') {
last_search = mallocstrcpy(last_search, answer);
#ifdef ENABLE_HISTORIES
update_history(&search_history, 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();
}
tidy_up_after_search();
free(thedefault);
return;
}
func = func_from_key(&i);
/* If we're here, one of the five toggles was pressed, or
* a shortcut was executed. */
if (func == case_sens_void) {
TOGGLE(CASE_SENSITIVE);
} else if (func == backwards_void) {
TOGGLE(BACKWARDS_SEARCH);
} else if (func == regexp_void) {
TOGGLE(USE_REGEXP);
} else if (func == flip_replace) {
replacing = !replacing;
} else {
if (func == flip_goto)
do_gotolinecolumn(openfile->current->lineno,
openfile->placewewant + 1, TRUE, TRUE);
tidy_up_after_search();
free(thedefault);
return;
}
if (ISSET(USE_REGEXP) && !regexp_init(last_search))
return -1;
else
return 0; /* We have a valid string or regex. */
}
func = func_from_key(&i);
if (func == case_sens_void) {
TOGGLE(CASE_SENSITIVE);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
} else if (func == backwards_void) {
TOGGLE(BACKWARDS_SEARCH);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
} else if (func == regexp_void) {
TOGGLE(USE_REGEXP);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
} else if (func == flip_replace) {
backupstring = mallocstrcpy(backupstring, answer);
return -2; /* Call the opposite search function. */
} else if (func == do_gotolinecolumn_void) {
do_gotolinecolumn(openfile->current->lineno,
openfile->placewewant + 1, TRUE, TRUE);
return 3;
}
return -1;
}
/* Look for needle, starting at (current, current_x). begin is the line
@@ -235,7 +204,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
lastkbcheck = time(NULL);
/* Consume all waiting keystrokes until a Cancel. */
while (input) {
while (input != ERR) {
if (func_from_key(&input) == do_cancel) {
statusbar(_("Cancelled"));
enable_waiting();
@@ -250,24 +219,19 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
statusbar(_("Searching..."));
}
/* Search for the needle in the current line. */
if (!skipone)
found = strstrwrapper(line->data, needle, from);
/* Ignore the initial match at the starting position: continue
* searching from the next character, or invalidate the match. */
if (skipone || (!whole_word_only && !came_full_circle &&
found == begin->data + begin_x)) {
/* When starting a new search, skip the first character, then
* (in either case) search for the needle in the current line. */
if (skipone) {
skipone = FALSE;
if (ISSET(BACKWARDS_SEARCH) && from != line->data) {
from = line->data + move_mbleft(line->data, from - line->data);
continue;
found = strstrwrapper(line->data, needle, from);
} else if (!ISSET(BACKWARDS_SEARCH) && *from != '\0') {
from += move_mbright(from, 0);
continue;
found = strstrwrapper(line->data, needle, from);
}
found = NULL;
}
} else
found = strstrwrapper(line->data, needle, from);
if (found != NULL) {
/* When doing a regex search, compute the length of the match. */
@@ -333,7 +297,8 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
enable_waiting();
/* Ensure that the found occurrence is not beyond the starting x. */
if (came_full_circle && ((!ISSET(BACKWARDS_SEARCH) && found_x > begin_x) ||
if (came_full_circle && ((!ISSET(BACKWARDS_SEARCH) && (found_x > begin_x ||
(modus == REPLACING && found_x == begin_x))) ||
(ISSET(BACKWARDS_SEARCH) && found_x < begin_x)))
return 0;
@@ -357,17 +322,7 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
/* Ask what to search for and then go looking for it. */
void do_search(void)
{
int i = search_init(FALSE, FALSE);
if (i == -1) /* Cancelled, or some other exit reason. */
search_replace_abort();
else if (i == -2) /* Do a replace instead. */
do_replace();
else if (i == 1) /* Toggled something. */
do_search();
if (i == 0)
go_looking();
search_init(FALSE, FALSE);
}
/* Search forward for a string. */
@@ -384,22 +339,6 @@ void do_search_backward(void)
do_search();
}
#ifndef NANO_TINY
/* Search in the backward direction for the next occurrence. */
void do_findprevious(void)
{
SET(BACKWARDS_SEARCH);
do_research();
}
/* Search in the forward direction for the next occurrence. */
void do_findnext(void)
{
UNSET(BACKWARDS_SEARCH);
do_research();
}
#endif /* !NANO_TINY */
/* Search for the last string without prompting. */
void do_research(void)
{
@@ -422,6 +361,33 @@ void do_research(void)
currmenu = MWHEREIS;
go_looking();
tidy_up_after_search();
}
/* Search in the backward direction for the next occurrence. */
void do_findprevious(void)
{
SET(BACKWARDS_SEARCH);
do_research();
}
/* Search in the forward direction for the next occurrence. */
void do_findnext(void)
{
UNSET(BACKWARDS_SEARCH);
do_research();
}
/* Report on the status bar that the given string was not found. */
void not_found_msg(const char *str)
{
char *disp = display_string(str, 0, (COLS / 2) + 1, FALSE);
size_t numchars = actual_x(disp, strnlenpt(disp, COLS / 2));
statusline(HUSH, _("\"%.*s%s\" not found"), numchars, disp,
(disp[numchars] == '\0') ? "" : "...");
free(disp);
}
/* Search for the global string 'last_search'. Inform the user when
@@ -436,7 +402,7 @@ void go_looking(void)
came_full_circle = FALSE;
didfind = findnextstr(last_search, FALSE, JUSTFIND, NULL, FALSE,
didfind = findnextstr(last_search, FALSE, JUSTFIND, NULL, TRUE,
openfile->current, openfile->current_x);
/* If we found something, and we're back at the exact same spot
@@ -452,7 +418,6 @@ void go_looking(void)
#endif
edit_redraw(was_current, CENTERING);
search_replace_abort();
}
/* Calculate the size of the replacement text, taking possible
@@ -546,7 +511,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
ssize_t numreplaced = -1;
size_t match_len;
bool replaceall = FALSE;
bool skipone = FALSE;
bool skipone = ISSET(BACKWARDS_SEARCH);
int modus = REPLACING;
#ifndef NANO_TINY
filestruct *was_mark = openfile->mark;
@@ -719,30 +684,22 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
/* Replace a string. */
void do_replace(void)
{
if (ISSET(VIEW_MODE))
print_view_warning();
else {
UNSET(BACKWARDS_SEARCH);
search_init(TRUE, FALSE);
}
}
/* Ask the user what the already given search string should be replaced with. */
void ask_for_replacement(void)
{
filestruct *edittop_save, *begin;
size_t firstcolumn_save, begin_x;
ssize_t numreplaced;
int i;
if (ISSET(VIEW_MODE)) {
print_view_warning();
return;
}
i = search_init(TRUE, FALSE);
if (i == -1) /* Cancelled, or some other exit reason. */
search_replace_abort();
else if (i == -2) /* Do a search instead. */
do_search();
else if (i == 1) /* Toggled something. */
do_replace();
if (i != 0)
return;
i = do_prompt(FALSE, FALSE, MREPLACEWITH, NULL, &replace_history,
int i = do_prompt(FALSE, FALSE, MREPLACEWITH, NULL, &replace_history,
/* TRANSLATORS: This is a prompt. */
edit_refresh, _("Replace with"));
@@ -756,7 +713,6 @@ void do_replace(void)
if (i == -1 || i > 0) {
if (i == -1)
statusbar(_("Cancelled"));
search_replace_abort();
return;
}
@@ -778,8 +734,6 @@ void do_replace(void)
if (numreplaced >= 0)
statusline(HUSH, P_("Replaced %zd occurrence",
"Replaced %zd occurrences", numreplaced), numreplaced);
search_replace_abort();
}
/* Go to the specified line and x position. */
@@ -802,8 +756,6 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
bool interactive)
{
if (interactive) {
functionptrtype func;
/* Ask for the line and column. */
int i = do_prompt(FALSE, FALSE, MGOTOLINE,
use_answer ? answer : NULL, NULL,
@@ -816,12 +768,11 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
return;
}
func = func_from_key(&i);
if (func == gototext_void) {
if (func_from_key(&i) == flip_goto) {
UNSET(BACKWARDS_SEARCH);
/* Retain what the user typed so far and switch to searching. */
search_init(TRUE, TRUE);
do_search();
search_init(FALSE, TRUE);
return;
}
/* If a function was executed, we're done here. */
@@ -877,11 +828,11 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
filestruct *line = openfile->current;
filestruct *currentline = openfile->current;
size_t leftedge = leftedge_for(xplustabs(), openfile->current);
rows_from_tail = (editwinrows / 2) -
go_forward_chunks(editwinrows / 2, &line, &leftedge);
rows_from_tail = (editwinrows / 2) - go_forward_chunks(
editwinrows / 2, &currentline, &leftedge);
} else
#endif
rows_from_tail = openfile->filebot->lineno -

1512
src/text.c

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/**************************************************************************
* utils.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2016-2017 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -48,7 +48,7 @@ void get_homedir(void)
/* Only set homedir if some home directory could be determined,
* otherwise keep homedir NULL. */
if (homenv != NULL && strcmp(homenv, "") != 0)
if (homenv != NULL && *homenv != '\0')
homedir = mallocstrcpy(NULL, homenv);
}
}
@@ -325,15 +325,18 @@ const char *strstrwrapper(const char *haystack, const char *needle,
else
return haystack + regmatches[0].rm_so;
}
if (ISSET(CASE_SENSITIVE)) {
if (ISSET(BACKWARDS_SEARCH))
return revstrstr(haystack, needle, start);
else
return strstr(start, needle);
} else if (ISSET(BACKWARDS_SEARCH))
return mbrevstrcasestr(haystack, needle, start);
}
return mbstrcasestr(start, needle);
if (ISSET(BACKWARDS_SEARCH))
return mbrevstrcasestr(haystack, needle, start);
else
return mbstrcasestr(start, needle);
}
/* This is a wrapper for the perror() function. The wrapper temporarily
@@ -378,10 +381,11 @@ char *mallocstrncpy(char *dest, const char *src, size_t n)
if (src == NULL)
src = "";
if (src != dest)
free(dest);
dest = charalloc(n);
#ifndef NANO_TINY
if (src == dest)
fprintf(stderr, "\r*** Copying a string to itself -- please report a bug ***");
#endif
dest = charealloc(dest, n);
strncpy(dest, src, n);
return dest;
@@ -455,7 +459,7 @@ size_t strnlenpt(const char *text, size_t maxlen)
return 0;
while (*text != '\0') {
int charlen = parse_mbchar(text, NULL, &width);
size_t charlen = parse_mbchar(text, NULL, &width);
if (maxlen <= charlen)
break;
@@ -586,21 +590,3 @@ size_t get_totsize(const filestruct *begin, const filestruct *end)
return totsize;
}
#ifdef DEBUG
/* Dump the given buffer to stderr. */
void dump_filestruct(const filestruct *inptr)
{
if (inptr == openfile->fileage)
fprintf(stderr, "Dumping file buffer to stderr...\n");
else if (inptr == cutbuffer)
fprintf(stderr, "Dumping cutbuffer to stderr...\n");
else
fprintf(stderr, "Dumping a buffer to stderr...\n");
while (inptr != NULL) {
fprintf(stderr, "(%zd) %s\n", inptr->lineno, inptr->data);
inptr = inptr->next;
}
}
#endif /* DEBUG */

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
## Here is an example for assembler.
syntax "asm" "\.(S|s|asm)$"
syntax asm "\.(S|s|asm)$"
magic "assembler source"
comment "//"

View File

@@ -1,6 +1,6 @@
## Here is an example for Autoconf.
syntax "autoconf" "\.(ac|m4)$"
syntax autoconf "\.(ac|m4)$"
comment "#"
# Keywords:

View File

@@ -1,6 +1,7 @@
## Here is an example for awk.
syntax "awk" "\.awk$"
syntax awk "\.awk$"
header "^#!.*awk"
magic "awk script"
comment "#"

View File

@@ -1,6 +1,6 @@
## Here is an example for C/C++.
syntax "c" "\.(c(c|pp|xx|\+\+)?|C)$" "\.(h(h|pp|xx)?|H)$" "\.ii?$"
syntax c "\.([ch](pp|xx)?|C|cc|c\+\+|H|hh|ii?)$"
magic "^(C|C\+\+) (source|program)"
comment "//"

View File

@@ -1,6 +1,6 @@
## Colouring for Changelogs.
syntax "changelog" "Change[Ll]og.*"
syntax changelog "Change[Ll]og[^/]*$"
# Author lines.
color green "^(19|20).*$"

View File

@@ -1,6 +1,6 @@
## Syntax highlighting for CMake files.
syntax "cmake" "(CMakeLists\.txt|\.cmake)$"
syntax cmake "(CMakeLists\.txt|\.cmake)$"
comment "#"
icolor green "^[[:space:]]*[A-Z0-9_]+"

View File

@@ -1,6 +1,6 @@
## Here is an example for CSS files.
syntax "css" "\.css$"
syntax css "\.css$"
comment "/*|*/"
color brightred "."

View File

@@ -1,6 +1,6 @@
## Here is an example for apt's sources.list.
syntax "sources.list" "sources\.list(~|\.old|\.save)?$" "sources\.list\.d/.*\.list(~|\.old|\.save)?$"
syntax sources.list "sources\.list(\.d/.*\.list)?(~|\.old|\.save)?$"
comment "#"
# Coloring the deb lines, working from tail to head. First the

View File

@@ -1,7 +1,7 @@
## An example of a default syntax. The default syntax is used for
## files that do not match any other syntax.
syntax "default"
syntax default
comment "#"
# Comments.
@@ -11,7 +11,7 @@ color cyan "^[[:space:]]*#.*"
color ,red " + +"
# Nano's name, including version.
color brightred "(GNU )?nano [1-9]\.[0-9]\.[^[:space:][:punct:]]+"
color brightred "(GNU )?[Nn]ano [1-3]\.[0-9][-.[:alnum:]]*\>"
# Email addresses.
color magenta "<[[:alnum:].%_+-]+@[[:alnum:].-]+\.[[:alpha:]]{2,}>"

View File

@@ -1,6 +1,6 @@
## Here is an example for Emacs Lisp.
syntax "elisp" "\.el$"
syntax elisp "\.el$"
magic "Lisp/Scheme program"
comment ";"

View File

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

View File

@@ -1,7 +1,7 @@
## Here is an example for Gentoo ebuilds/eclasses,
## and (further down) one for Portage control files.
syntax "ebuild" "\.e(build|class|blit)$"
syntax ebuild "\.e(build|class|blit)$"
comment "#"
## All the standard portage functions:
@@ -48,7 +48,7 @@ color ,green "[[:space:]]+$"
color ,green " "
syntax "/etc/portage" "\.(accept_keywords|env|keywords|mask|unmask|use)(/.+)?$"
syntax /etc/portage "\.(accept_keywords|env|keywords|mask|unmask|use)(/.+)?$"
comment "#"
## Base text:

View File

@@ -1,11 +1,8 @@
## Here is an example for Go.
syntax "go" "\.go$"
syntax go "\.go$"
comment "//"
# Set up a formatter since spelling is probably useless...
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)\>"
@@ -24,9 +21,11 @@ color brightcyan "\<(package|import)\>"
color brightcyan "//[[:space:]]*\+build[[:space:]]+(([a-zA-Z_0-9]+[[:space:]]*)+,[[:space:]]*)*[a-zA-Z_0-9]+"
# Literals.
color red "\<[0-9]+(\.[0-9]*)?([Ee][+-]?[0-9]+)?i?\>"
color red "\B\.[0-9]+([Ee][+-]?[0-9]+)?i?\>"
color red "\<(0[0-7]*|[1-9][0-9]*|0[xX][0-9a-fA-F]+)\>"
color red "\<([1-9][0-9]*|0[0-7]*|0[xX][0-9A-Fa-f]+)\>"
color red "\<[0-9]+\.[0-9]*([eE][+-]?[0-9]+)?i?\>"
color red "\<[0-9]+[eE][+-]?[0-9]+i?\>"
color red "\B\.[0-9]+([eE][+-]?[0-9]+)?i?\>"
color red "\<[0-9]+i\>"
# Strings and characters; slightly fuzzy.
color red "\<(true|false|nil|iota|_)\>"

View File

@@ -1,6 +1,6 @@
## Here is an example for groff.
syntax "groff" "\.m[ems]$" "\.rof" "\.tmac$" "^tmac."
syntax groff "(/tmac\.[^/]+$|\.(m[ems]|rof|tmac)$)"
comment ".\""
# The argument of .ds or .nr

View File

@@ -1,6 +1,6 @@
## Here is an example for Guile Scheme.
syntax "guile" "\.scm$"
syntax guile "\.scm$"
header "^#!.*guile"
comment ";"

View File

@@ -1,6 +1,6 @@
## Here is an example for HTML.
syntax "html" "\.html?$"
syntax html "\.html?$"
magic "HTML document"
comment "<!--|-->"

View File

@@ -1,6 +1,6 @@
## Here is an example for Java.
syntax "java" "\.java$"
syntax java "\.java$"
magic "Java "
comment "//"

View File

@@ -1,6 +1,6 @@
## Syntax highlighting for Javascript.
syntax "javascript" "\.js$"
syntax javascript "\.js$"
comment "//"
# Declarational stuff.

View File

@@ -4,7 +4,7 @@
# Original author: Aapo Rantalainen
# License: GPLv3 or newer
syntax "json" "\.json$"
syntax json "\.json$"
# No comments are permitted in JSON.
comment ""

View File

@@ -3,14 +3,17 @@
## Original author: Matthew Wild <mwild1 (at) gmail.com>
## License: GPL 3 or later
syntax "lua" "\.lua$"
syntax lua "\.lua$"
magic "Lua script"
linter "luacheck --no-color"
comment "--"
color brightwhite "\[\[.*\]\]"
# Operators
color brightyellow ":|\*|/|%|\+|-|\^|>|>=|<|<=|~=|=|\.\.|\<(not|and|or)\>"
color brightyellow ":|\*|/|%|\+|-|\^|>|>=|<|<=|~=|=|\.\.|#|\<(not|and|or)\>"
# Don't partially color ... as an operator
color normal "\.\.\."
# Statements
color brightblue "\<(do|end|while|repeat|until|if|elseif|then|else|for|in|function|local|return|break)\>"
@@ -20,7 +23,7 @@ color brightyellow "\<(_G|_VERSION|assert|collectgarbage|dofile|error|getfenv|ge
# Standard library
color brightyellow "\<coroutine\.(create|isyieldable|resume|running|status|wrap|yield)\>"
color brightyellow "\<debug\.(debug|(get|set)(fenv|hook|info|local|metatable|(up|user)value)|getregistry|traceback|upvalue(id|join))\>"
color brightyellow "\<debug\.(debug|(get|set)(fenv|hook|local|metatable|(up|user)value)|getinfo|getregistry|traceback|upvalue(id|join))\>"
color brightyellow "\<io\.(close|flush|input|lines|output|p?open|read|tmpfile|type|write|std(in|out|err))\>"
color brightyellow "\<math\.(abs|acos|asin|atan2?|ceil|cosh?|deg|exp|floor|fmod|frexp|huge|ldexp|log10|log)\>"
color brightyellow "\<math\.((max|min)(integer)?|modf?|pi|pow|rad|random(seed)?|sinh?|sqrt|tan|tointeger|type|ult)\>"
@@ -49,9 +52,9 @@ color brightmagenta "\(|\)|\[|\]|\{|\}"
# Shebang
color brightcyan "^#!.*"
# Strings
color red ""(\\.|[^"\])*"|'(\\.|[^'\])*'"
# Simple comments and multiline comments
color green "--.*"
color green start="--\[\[" end="\]\]"
# Strings
color red ""(\\.|[^"\])*"|'(\\.|[^'\])*'"

View File

@@ -1,14 +1,24 @@
## Here is an example for Makefiles.
syntax "makefile" "Makefile[^/]*$" "\.(make|mk)$"
syntax makefile "(/((GNU)?m|M)akefile[^/]*$|\.(make|mk)$)"
magic "makefile script"
comment "#"
color red "[:=]"
color magenta "\<(if|ifeq|else|endif)\>"
# Assignments.
color red " (:?:|\+|\?)?= "
# Keywords.
color magenta "^(if|ifn?def|ifn?eq|else|endif|(-|s)?include)\>"
color magenta "^((override +)?(un)?define|endef|(un)?export|private|vpath)\>"
# Variable expansions.
color blue "\$+[{(][a-zA-Z0-9_-]+[})]"
# Targets.
color brightblue "^[^ ]+:"
# Comments.
color green "(^|[[:space:]]+)#.*"
## Trailing whitespace.
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -1,6 +1,6 @@
## Here is an example for manpages.
syntax "man" "\.[1-9]x?$"
syntax man "\.[1-9]x?$"
magic "troff or preprocessor input"
comment ".\""

View File

@@ -1,6 +1,6 @@
## Here is an example for Magicpoint presentations.
syntax "mgp" "\.mgp$"
syntax mgp "\.mgp$"
header "^%include.*"
comment "#"

View File

@@ -1,6 +1,6 @@
## Here is an example for quoted emails (under e.g. mutt).
syntax "mutt"
syntax mutt
# Quoted lines.
color green "^>.*"

View File

@@ -1,11 +1,11 @@
## This is meant for highlighting key combos in a nano help text.
# It should not apply to any normal file, so no fileregex.
syntax "nanohelp"
syntax nanohelp
# Key combos:
color cyan "\^[]4-8A-Z^\_◀▶▲▼]" "[◀▶▲▼]" "(\^|M-)Space" "\<M-." "\<F1?[0-9]"
color cyan "\<(Tab|Enter|Ins|Del|Bsp|Up|Down|Left|Right|Home|End|PgUp|PgDn)\>"
color cyan "\^[]4-8A-Z^\_◀▶▲▼]" "[◀▶▲▼]" "\<M-." "\<F1?[0-9]"
color cyan "\<(Tab|Sh-Tab|Enter|Ins|Del|Space|Bsp|Up|Down|Left|Right|Home|End|PgUp|PgDn)\>"
# Quoted indicators:
color brightred "'(\^|M-)'"

View File

@@ -1,26 +1,26 @@
## Here is an example for nanorc files.
syntax "nanorc" "\.?nanorc$"
syntax nanorc "\.?nanorc$"
comment "#"
# Possible errors and parameters
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|formatter|i?color|extendsyntax).*$"
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|i?color|extendsyntax).*$"
# Keywords
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cutfromcursor|fill[[:space:]]+-?[[:digit:]]+|historylog|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize[[:space:]]+[1-9][0-9]*|tabstospaces|tempfile|trimblanks|unix|view|wordbounds)\>"
icolor yellow "^[[:space:]]*set[[:space:]]+((function|key|number|selected|status|title)color)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|selectedcolor|speller|statuscolor|titlecolor|whitespace|wordchars)[[:space:]]+"
icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^([[:alpha:]]|[]0-9\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+[[:alpha:]]+[[:space:]]+(all|main|search|replace(with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([[:alpha:]]|[]0-9\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+(all|main|search|replace(with)?|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
icolor brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|comment|linter|formatter)[[:space:]]+.*$"
icolor brightgreen "^[[:space:]]*(linter|formatter)[[:space:]]+[[:alpha:]]+"
icolor green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|formatter|extendsyntax)\>"
icolor brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|backwards|boldtext|casesensitive|constantshow|cutfromcursor|fill[[:space:]]+-?[[:digit:]]+|historylog|linenumbers|locking|morespace|mouse|multibuffer|noconvert|nohelp|nopauses|nonewlines|nowrap|positionlog|preserve|quickblank|quiet|rebinddelete|rebindkeypad|regexp|showcursor|smarthome|smooth|softwrap|suspend|tabsize[[:space:]]+[1-9][0-9]*|tabstospaces|tempfile|trimblanks|unix|view|wordbounds)\>"
icolor yellow "^[[:space:]]*set[[:space:]]+((error|function|key|number|selected|status|title)color)[[:space:]]+(bright)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>"
icolor brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|punct|quotestr|selectedcolor|speller|statuscolor|titlecolor|whitespace|wordchars)[[:space:]]+"
icolor brightgreen "^[[:space:]]*bind[[:space:]]+((\^([[:alpha:]]|[]@\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+([[:alpha:]]+|".*")[[:space:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
icolor brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([[:alpha:]]|[]@\^_]|Space)|M-([[:alpha:]]|[]!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-6])|Ins|Del)[[:space:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
icolor brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|comment|linter)[[:space:]]+.*$"
icolor brightgreen "^[[:space:]]*(syntax|linter)[[:space:]]+[^[:blank:]]+"
icolor green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|extendsyntax)\>"
# Strings
color brightmagenta "".+"([[:space:]]|$)"
# Colors
icolor yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan)?(,(white|black|red|blue|green|yellow|magenta|cyan))?\>"
icolor yellow "^[[:space:]]*i?color[[:space:]]*(bright)?(white|black|red|blue|green|yellow|magenta|cyan|normal)?(,(white|black|red|blue|green|yellow|magenta|cyan|normal))?\>"
icolor magenta "^[[:space:]]*i?color\>" "\<(start|end)="
# Comments

View File

@@ -1,6 +1,6 @@
## Here is an example for nftables.
syntax "nftables" "\.(nft|nftables)$"
syntax nftables "\.(nft|nftables)$"
header "^#!.*(nft|nftables)"
comment "#"

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