Compare commits

..

96 Commits

Author SHA1 Message Date
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
70 changed files with 18673 additions and 20280 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.

118
ChangeLog
View File

@@ -1,3 +1,121 @@
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:
----------------------------------

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

@@ -2,6 +2,10 @@ Improvements in GNU nano
========================
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.
@@ -34,24 +38,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').

19
NEWS
View File

@@ -1,3 +1,22 @@
2018.06.02 - GNU nano 2.9.8 "Espresso" brings the ability to filter the
buffer (or the marked region) through an external command
(^R^X and prefix the command with the pipe symbol, "|"), is
better at detecting and maintaining paragraphs, is able to
justify //-style comments, fixes a crash when the binding
of a key to a string lacks a closing quote, gives feedback
about the number of lines written also when prepending or
appending, and fixes a couple of bugs with the linter.
2018.05.15 - GNU nano 2.9.7 "Hvide Sande" adds the option '--afterends'
for making Ctrl+Right (the nextword function) stop at word
ends instead of beginnings, accepts multibyte letters for
the Yes/No/All answers, does emergency saves of changed
buffers in the unlikely event that nano crashes, adds the
until-now missing bindable function 'linenumbers', and
renames the toggles 'constupdate' to 'constantshow' and
'cuttoend' to 'cutfromcursor', for consistency with the
corresponding options -- adjust your nanorc files soon.
2018.04.27 - GNU nano 2.9.6 "Gomance" fixes a crash in word completion,
makes --enable-altrcname work again, improves the fluidity
of scrolling when using the touchpad, tweaks the syntaxes

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

7
TODO
View File

@@ -8,9 +8,6 @@ Somewhat urgent:
- 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:
- Add support for right-to-left text (RTL), through FriBidi?
@@ -21,8 +18,10 @@ Vague musings:
brackets inside comments?
For version 2.9:
- Make undo/redo work also for indenting. [DONE]
- 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]

View File

@@ -2,7 +2,7 @@
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="214bf852d8dab02bf62900e61facef2c9f48f2f4"
gnulib_hash="90f289f249a266b1afb9c63e182f5d979d17df5f"
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.6], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [2.9.8], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.14])

View File

@@ -91,7 +91,7 @@
<h3><a name="1.3"></a>1.3. Why the name change from TIP?</h3>
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program &quot;establishes a full duplex terminal connection to a remote host&quot;, and was included with many older Unix systems (and newer ones like Solaris). The conflict was not noticed at first because there is no 'tip' utility included with most GNU/Linux distributions (where nano was developed).</p></blockquote>
<h3><a name="1.4"></a>1.4. What is the current version of nano?</h3>
<blockquote><p>The current version of nano <i>should</i> be <b>2.9.6</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<blockquote><p>The current version of nano <i>should</i> be <b>2.9.8</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%">

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.6" "April 2018"
.TH NANO 1 "version 2.9.8" "June 2018"
.SH NAME
nano \- Nano's ANOther editor, an enhanced free Pico clone
@@ -106,7 +106,7 @@ 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
@@ -122,11 +122,11 @@ Use the blank line below the title bar as extra editing space.
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.
.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
@@ -187,8 +187,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
@@ -250,6 +251,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
@@ -309,6 +313,10 @@ not by default distinguish modified from unmodified arrow keys.
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.6
@set UPDATED April 2018
@set VERSION 2.9.8
@set UPDATED June 2018
@dircategory Editors
@direntry
@@ -23,7 +23,7 @@
@titlepage
@title GNU @command{nano}
@subtitle a small and friendly text editor
@subtitle version 2.9.6
@subtitle version 2.9.8
@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.6.
This manual documents the GNU @command{nano} editor, version 2.9.8.
@menu
* Introduction::
@@ -198,7 +198,7 @@ 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
@@ -218,11 +218,10 @@ Use the blank line below the title bar as extra editing space.
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.
@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
@@ -299,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
@@ -355,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.
@@ -392,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
@@ -591,59 +595,59 @@ The following global toggles are available:
@table @code
@item Backup Files toggle
@item Backup Files
@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
@item Multiple File Buffers
@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
@item No Conversion From DOS/Mac Format
@kbd{Meta-N} toggles the @option{-N} (@option{--noconvert}) command-line option.
@item More Space For Editing toggle
@item More Space For Editing
@kbd{Meta-O} toggles the @option{-O} (@option{--morespace}) command-line option.
@item Whitespace Display toggle
@kbd{Meta-P} toggles the whitespace-display mode (@pxref{Whitespace}).
@item Whitespace Display
@kbd{Meta-P} toggles the displaying of whitespace (@pxref{Whitespace}).
@item Tabs To Spaces toggle
@item Tabs To Spaces
@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
@@ -689,6 +693,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.
@@ -699,7 +706,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
@@ -726,7 +735,7 @@ Set the characters treated as closing brackets when justifying
paragraphs. This may not include blank characters. Only closing
punctuation (see @code{set punct}), optionally followed by the specified
closing brackets, can end sentences. The default value is
@t{"')>]@}"}.
@t{""')>]@}"}.
@item set casesensitive
Do case-sensitive searches by default.
@@ -797,13 +806,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.
@@ -839,12 +848,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
@@ -909,6 +916,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
@@ -950,7 +958,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}
@@ -981,12 +989,12 @@ 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.
Use the given @var{program} to automatically reformat the text in
the current buffer --- useful for a programming language like Go.
(This overrides the speller and linter functions.)
@item comment "@var{string}"
@@ -1153,11 +1161,14 @@ Shows the current cursor position: the line, column, and character positions.
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, or formatter 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.
@@ -1307,6 +1318,10 @@ Toggles between searching for text and targeting a line number.
@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.
@@ -1347,8 +1362,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.
(The form @code{constupdate} is deprecated.)
@item morespace
Toggles the presence of the blank line that 'separates' the title bar from the file text.
@@ -1359,6 +1375,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.
@@ -1369,11 +1388,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.
@@ -1438,7 +1460,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.
@@ -1457,14 +1479,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
@@ -1505,6 +1528,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.6" "April 2018"
.TH NANORC 5 "version 2.9.8" "June 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
@@ -88,7 +93,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
@@ -158,7 +163,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
@@ -198,12 +203,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
@@ -240,9 +243,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.
@@ -273,6 +276,7 @@ And either "\fIfgcolor\fR" or ",\fIbgcolor\fR" may be left out.
.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
@@ -307,7 +311,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
@@ -319,17 +323,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
@@ -338,16 +342,16 @@ 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.
Use the given \fIprogram\fR to automatically reformat the text in
the current buffer -- 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
@@ -357,7 +361,7 @@ 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
@@ -368,10 +372,10 @@ 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,
@@ -380,10 +384,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.
@@ -506,14 +510,17 @@ Shows the current cursor position: the line, column, and character positions.
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, or formatter 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.
@@ -663,6 +670,10 @@ Toggles between searching for text and targeting a line number.
.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.
@@ -703,8 +714,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.
(The form 'constupdate' is deprecated.)
.TP
.B morespace
Toggles the presence of the blank line that 'separates' the title bar from the file text.
@@ -715,6 +727,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
@@ -725,11 +740,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.

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.6" "April 2018"
.TH RNANO 1 "version 2.9.8" "June 2018"
.SH NAME
rnano \- a restricted nano

View File

@@ -15,11 +15,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 +37,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,7 +48,6 @@
## 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
@@ -89,13 +93,13 @@
## 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.
# set nowrap
@@ -107,7 +111,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 +126,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
@@ -174,6 +173,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

950
po/bg.po

File diff suppressed because it is too large Load Diff

1132
po/ca.po

File diff suppressed because it is too large Load Diff

996
po/cs.po

File diff suppressed because it is too large Load Diff

1210
po/da.po

File diff suppressed because it is too large Load Diff

964
po/de.po

File diff suppressed because it is too large Load Diff

1035
po/eo.po

File diff suppressed because it is too large Load Diff

1018
po/es.po

File diff suppressed because it is too large Load Diff

1125
po/eu.po

File diff suppressed because it is too large Load Diff

1007
po/fi.po

File diff suppressed because it is too large Load Diff

2456
po/fr.po

File diff suppressed because it is too large Load Diff

956
po/ga.po

File diff suppressed because it is too large Load Diff

952
po/gl.po

File diff suppressed because it is too large Load Diff

1085
po/hr.po

File diff suppressed because it is too large Load Diff

953
po/hu.po

File diff suppressed because it is too large Load Diff

1053
po/id.po

File diff suppressed because it is too large Load Diff

968
po/it.po

File diff suppressed because it is too large Load Diff

996
po/ja.po

File diff suppressed because it is too large Load Diff

947
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1019
po/nb.po

File diff suppressed because it is too large Load Diff

1024
po/nl.po

File diff suppressed because it is too large Load Diff

1008
po/nn.po

File diff suppressed because it is too large Load Diff

953
po/pl.po

File diff suppressed because it is too large Load Diff

961
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

968
po/ro.po

File diff suppressed because it is too large Load Diff

952
po/ru.po

File diff suppressed because it is too large Load Diff

952
po/sl.po

File diff suppressed because it is too large Load Diff

1008
po/sr.po

File diff suppressed because it is too large Load Diff

1048
po/sv.po

File diff suppressed because it is too large Load Diff

1071
po/tr.po

File diff suppressed because it is too large Load Diff

1020
po/uk.po

File diff suppressed because it is too large Load Diff

997
po/vi.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -168,12 +168,12 @@ char *do_browser(char *path)
} else if (func == do_search_forward) {
do_filesearch();
} else if (func == do_research) {
do_fileresearch(TRUE);
do_fileresearch(FORWARD);
#ifndef NANO_TINY
} else if (func == do_findprevious) {
do_fileresearch(FALSE);
do_fileresearch(BACKWARD);
} else if (func == do_findnext) {
do_fileresearch(TRUE);
do_fileresearch(FORWARD);
#endif
} else if (func == do_left) {
if (selected > 0)
@@ -659,42 +659,40 @@ 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. */
/* Prepare the prompt and ask the user what to search for. 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(void)
{
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", _("Search"), 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,

View File

@@ -2,7 +2,7 @@
* files.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2015-2017 Benno Schulenberg *
* 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 *
@@ -1109,6 +1109,24 @@ void do_insertfile(void)
answer = chosen;
i = 0;
}
#endif
#ifndef NANO_TINY
if (func == flip_pipe) {
/* Remove or add the pipe character at the answer's head. */
if (answer[0] == '|') {
charmove(answer, answer + 1, strlen(answer) + 1);
if (statusbar_x > 0)
statusbar_x--;
} else {
answer = charealloc(answer, strlen(answer) + 2);
charmove(answer + 1, answer, strlen(answer) + 1);
answer[0] = '|';
statusbar_x++;
}
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))
@@ -1915,16 +1933,16 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
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();
@@ -1941,29 +1959,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:

View File

@@ -2,7 +2,7 @@
* global.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* 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 *
@@ -152,6 +152,8 @@ char *word_chars = NULL;
char *answer = NULL;
/* The answer string used by the statusbar prompt. */
size_t statusbar_x = HIGHEST_POSITIVE;
/* The cursor position in answer. */
ssize_t tabsize = -1;
/* The width of a tab in spaces. The default is set in main(). */
@@ -311,6 +313,9 @@ void backup_file_void(void)
void flip_execute(void)
{
}
void flip_pipe(void)
{
}
#endif
#ifdef ENABLE_MULTIBUFFER
void flip_newbuffer(void)
@@ -650,6 +655,8 @@ void shortcut_init(void)
const char *prepend_gist = N_("Toggle prepending");
const char *backup_gist = N_("Toggle backing up of the original file");
const char *execute_gist = N_("Execute external command");
const char *pipe_gist =
N_("Pipe the current buffer (or marked region) to the command");
#endif
#ifdef ENABLE_MULTIBUFFER
const char *newbuffer_gist = N_("Toggle the use of a new buffer");
@@ -1034,7 +1041,11 @@ void shortcut_init(void)
add_to_funcs(flip_newbuffer, MINSERTFILE|MEXTCMD,
N_("New Buffer"), WITHORSANS(newbuffer_gist), TOGETHER, NOVIEW);
#endif
#ifndef NANO_TINY
if (!ISSET(RESTRICTED))
add_to_funcs(flip_pipe, MEXTCMD,
N_("Pipe Text"), WITHORSANS(pipe_gist), TOGETHER, NOVIEW);
#endif
#ifdef ENABLE_BROWSER
/* The file browser is only available when not in restricted mode. */
if (!ISSET(RESTRICTED))
@@ -1329,8 +1340,12 @@ void shortcut_init(void)
#endif
#ifdef ENABLE_MULTIBUFFER
/* Only when not in restricted mode, allow multiple buffers. */
if (!ISSET(RESTRICTED))
if (!ISSET(RESTRICTED)) {
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, flip_newbuffer, 0);
#ifndef NANO_TINY
add_to_sclist(MEXTCMD, "M-\\", 0, flip_pipe, 0);
#endif
}
#endif
#ifdef ENABLE_BROWSER
/* Only when not in restricted mode, allow entering the file browser. */
@@ -1638,6 +1653,8 @@ sc *strtosc(const char *input)
s->func = backup_file_void;
else if (!strcasecmp(input, "flipexecute"))
s->func = flip_execute;
else if (!strcasecmp(input, "flippipe"))
s->func = flip_pipe;
#endif
#ifdef ENABLE_MULTIBUFFER
else if (!strcasecmp(input, "flipnewbuffer"))
@@ -1659,7 +1676,8 @@ sc *strtosc(const char *input)
s->func = do_toggle_void;
if (!strcasecmp(input, "nohelp"))
s->toggle = NO_HELP;
else if (!strcasecmp(input, "constupdate"))
else if (!strcasecmp(input, "constantshow") ||
!strcasecmp(input, "constupdate")) /* Deprecated. Remove end of 2018. */
s->toggle = CONSTANT_SHOW;
else if (!strcasecmp(input, "morespace"))
s->toggle = MORE_SPACE;
@@ -1667,6 +1685,10 @@ sc *strtosc(const char *input)
s->toggle = SMOOTH_SCROLL;
else if (!strcasecmp(input, "softwrap"))
s->toggle = SOFTWRAP;
#ifdef ENABLE_LINENUMBERS
else if (!strcasecmp(input, "linenumbers"))
s->toggle = LINE_NUMBERS;
#endif
else if (!strcasecmp(input, "whitespacedisplay"))
s->toggle = WHITESPACE_DISPLAY;
#ifdef ENABLE_COLOR
@@ -1677,7 +1699,8 @@ sc *strtosc(const char *input)
s->toggle = SMART_HOME;
else if (!strcasecmp(input, "autoindent"))
s->toggle = AUTOINDENT;
else if (!strcasecmp(input, "cuttoend"))
else if (!strcasecmp(input, "cutfromcursor") ||
!strcasecmp(input, "cuttoend")) /* Deprecated. Remove end of 2018. */
s->toggle = CUT_FROM_CURSOR;
#ifdef ENABLE_WRAPPING
else if (!strcasecmp(input, "nowrap"))

View File

@@ -2,7 +2,7 @@
* move.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* 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 *
@@ -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).
@@ -538,7 +556,8 @@ void do_scroll_up(void)
if (openfile->current_y == editwinrows - 1)
do_up();
edit_scroll(BACKWARD);
if (editwinrows > 1)
edit_scroll(BACKWARD);
}
/* Scroll down one line or chunk without scrolling the cursor. */

View File

@@ -2,7 +2,7 @@
* nano.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* 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 *
@@ -551,14 +551,15 @@ void say_there_is_no_help(void)
}
#endif
/* Make nano exit gracefully. */
/* Exit normally: restore the terminal state and save history files. */
void finish(void)
{
/* Blank the statusbar and (if applicable) the shortcut list,
* and move the cursor to the last line of the screen. */
/* Blank the statusbar and (if applicable) the shortcut list. */
blank_statusbar();
blank_bottombars();
wrefresh(bottomwin);
/* Switch on the cursor and exit from curses mode. */
curs_set(1);
endwin();
@@ -582,7 +583,8 @@ void finish(void)
exit(0);
}
/* Make nano die gracefully. */
/* Die gracefully -- by restoring the terminal state and saving any buffers
* that were modified. */
void die(const char *msg, ...)
{
va_list ap;
@@ -740,9 +742,7 @@ void mouse_init(void)
}
#endif /* ENABLE_MOUSE */
/* Print one usage string to the screen. This cuts down on duplicate
* strings to translate, and leaves out the parts that shouldn't be
* translatable (i.e. the flag names). */
/* Print the usage line for the given option to the screen. */
void print_opt(const char *shortflag, const char *longflag, const char *desc)
{
printf(" %s\t", shortflag);
@@ -755,9 +755,7 @@ void print_opt(const char *shortflag, const char *longflag, const char *desc)
else if (strlenpt(longflag) < 16)
printf("\t");
if (desc != NULL)
printf("%s", _(desc));
printf("\n");
printf("%s\n", _(desc));
}
/* Explain how to properly use nano and its command-line options. */
@@ -771,14 +769,13 @@ void usage(void)
printf(_("When a filename is '-', nano reads data from standard input.\n\n"));
printf(_("Option\t\tGNU long option\t\tMeaning\n"));
#ifndef NANO_TINY
print_opt("-A", "--smarthome",
/* TRANSLATORS: The next forty or so strings are option descriptions
* for the --help output. Try to keep them at most 40 characters. */
N_("Enable smart home key"));
/* TRANSLATORS: The next forty or so strings are option descriptions
* for the --help output. Try to keep them at most 40 characters. */
print_opt("-A", "--smarthome", N_("Enable smart home key"));
if (!ISSET(RESTRICTED)) {
print_opt("-B", "--backup", N_("Save backups of existing files"));
print_opt(_("-C <dir>"), _("--backupdir=<dir>"),
N_("Directory for saving unique backup files"));
N_("Directory for saving unique backup files"));
}
#endif
print_opt("-D", "--boldtext", N_("Use bold instead of reverse video text"));
@@ -788,7 +785,7 @@ void usage(void)
#ifdef ENABLE_MULTIBUFFER
if (!ISSET(RESTRICTED))
print_opt("-F", "--multibuffer",
N_("Read a file into a new buffer by default"));
N_("Read a file into a new buffer by default"));
#endif
#ifndef NANO_TINY
print_opt("-G", "--locking", N_("Use (vim-style) lock files"));
@@ -796,32 +793,33 @@ void usage(void)
#ifdef ENABLE_HISTORIES
if (!ISSET(RESTRICTED))
print_opt("-H", "--historylog",
N_("Log & read search/replace string history"));
N_("Log & read search/replace string history"));
#endif
#ifdef ENABLE_NANORC
if (!ISSET(RESTRICTED))
print_opt("-I", "--ignorercfiles", N_("Don't look at nanorc files"));
#endif
print_opt("-K", "--rebindkeypad",
N_("Fix numeric keypad key confusion problem"));
N_("Fix numeric keypad key confusion problem"));
print_opt("-L", "--nonewlines",
N_("Don't add newlines to the ends of files"));
N_("Don't add newlines to the ends of files"));
#ifdef ENABLED_WRAPORJUSTIFY
print_opt("-M", "--trimblanks",
N_("Trim tail spaces when hard-wrapping"));
N_("Trim tail spaces when hard-wrapping"));
#endif
#ifndef NANO_TINY
print_opt("-N", "--noconvert",
N_("Don't convert files from DOS/Mac format"));
N_("Don't convert files from DOS/Mac format"));
#endif
print_opt("-O", "--morespace", N_("Use one more line for editing"));
#ifdef ENABLE_HISTORIES
if (!ISSET(RESTRICTED))
print_opt("-P", "--positionlog",
N_("Log & read location of cursor position"));
N_("Log & read location of cursor position"));
#endif
#ifdef ENABLE_JUSTIFY
print_opt(_("-Q <str>"), _("--quotestr=<str>"), N_("Quoting string"));
print_opt(_("-Q <regex>"), _("--quotestr=<regex>"),
N_("Regular expression to match quoting"));
#endif
if (!ISSET(RESTRICTED))
print_opt("-R", "--restricted", N_("Restricted mode"));
@@ -829,26 +827,26 @@ void usage(void)
print_opt("-S", "--smooth", N_("Scroll by line instead of half-screen"));
#endif
print_opt(_("-T <#cols>"), _("--tabsize=<#cols>"),
N_("Set width of a tab to #cols columns"));
N_("Set width of a tab to #cols columns"));
print_opt("-U", "--quickblank", N_("Do quick statusbar blanking"));
print_opt("-V", "--version", N_("Print version information and exit"));
#ifndef NANO_TINY
print_opt("-W", "--wordbounds",
N_("Detect word boundaries more accurately"));
N_("Detect word boundaries more accurately"));
print_opt(_("-X <str>"), _("--wordchars=<str>"),
N_("Which other characters are word parts"));
N_("Which other characters are word parts"));
#endif
#ifdef ENABLE_COLOR
if (!ISSET(RESTRICTED))
print_opt(_("-Y <name>"), _("--syntax=<name>"),
N_("Syntax definition to use for coloring"));
N_("Syntax definition to use for coloring"));
#endif
#ifndef NANO_TINY
print_opt("-a", "--atblanks", N_("When soft-wrapping, do it at whitespace"));
#endif
print_opt("-c", "--constantshow", N_("Constantly show cursor position"));
print_opt("-d", "--rebinddelete",
N_("Fix Backspace/Delete confusion problem"));
N_("Fix Backspace/Delete confusion problem"));
#ifdef ENABLE_BROWSER
if (!ISSET(RESTRICTED))
print_opt("-g", "--showcursor", N_("Show cursor in file browser"));
@@ -867,17 +865,17 @@ void usage(void)
print_opt("-n", "--noread", N_("Do not read the file (only write it)"));
#ifdef ENABLE_OPERATINGDIR
print_opt(_("-o <dir>"), _("--operatingdir=<dir>"),
N_("Set operating directory"));
N_("Set operating directory"));
#endif
print_opt("-p", "--preserve", N_("Preserve XON (^Q) and XOFF (^S) keys"));
#ifdef ENABLED_WRAPORJUSTIFY
print_opt(_("-r <#cols>"), _("--fill=<#cols>"),
N_("Set hard-wrapping point at column #cols"));
N_("Set hard-wrapping point at column #cols"));
#endif
#ifdef ENABLE_SPELLER
if (!ISSET(RESTRICTED))
print_opt(_("-s <prog>"), _("--speller=<prog>"),
N_("Enable alternate speller"));
N_("Enable alternate speller"));
#endif
print_opt("-t", "--tempfile", N_("Auto save on exit, don't prompt"));
#ifndef NANO_TINY
@@ -888,6 +886,9 @@ void usage(void)
print_opt("-w", "--nowrap", N_("Don't hard-wrap long lines"));
#endif
print_opt("-x", "--nohelp", N_("Don't show the two help lines"));
#ifndef NANO_TINY
print_opt("-y", "--afterends", N_("Make Ctrl+Right stop at word ends"));
#endif
if (!ISSET(RESTRICTED))
print_opt("-z", "--suspend", N_("Enable suspension"));
#ifndef NANO_TINY
@@ -1107,7 +1108,7 @@ bool scoop_stdin(void)
endwin();
tcsetattr(0, TCSANOW, &oldterm);
fprintf(stderr, _("Reading from stdin, ^C to abort\n"));
fprintf(stderr, _("Reading from standard input; type ^D or ^D^D to finish.\n"));
#ifndef NANO_TINY
/* Enable interpretation of the special control keys so that
@@ -1142,6 +1143,7 @@ bool scoop_stdin(void)
open_buffer("", TRUE);
read_file(stream, 0, "stdin", TRUE);
openfile->edittop = openfile->fileage;
fprintf(stderr, ".\n");
/* Reconnect the tty as the input source. */
thetty = open("/dev/tty", O_RDONLY);
@@ -1210,6 +1212,18 @@ void signal_init(void)
sigaction(SIGTSTP, &act, NULL);
#endif
}
#if !defined(NANO_TINY) && !defined(DEBUG)
if (getenv("NANO_NOCATCH") == NULL) {
/* Trap SIGSEGV and SIGABRT to save any changed buffers and reset
* the terminal to a usable state. Reset these handlers to their
* defaults as soon as their signal fires. */
act.sa_handler = handle_crash;
act.sa_flags |= SA_RESETHAND;
sigaction(SIGSEGV, &act, NULL);
sigaction(SIGABRT, &act, NULL);
}
#endif
}
/* Handler for SIGHUP (hangup) and SIGTERM (terminate). */
@@ -1218,6 +1232,14 @@ RETSIGTYPE handle_hupterm(int signal)
die(_("Received SIGHUP or SIGTERM\n"));
}
#if !defined(NANO_TINY) && !defined(DEBUG)
/* Handler for SIGSEGV (segfault) and SIGABRT (abort). */
RETSIGTYPE handle_crash(int signal)
{
die(_("Sorry! Nano crashed! Code: %d. Please report a bug.\n"), signal);
}
#endif
/* Handler for SIGTSTP (suspend). */
RETSIGTYPE do_suspend(int signal)
{
@@ -1519,6 +1541,30 @@ int get_keycode(const char *keyname, const int standard)
return standard;
}
#ifdef ENABLE_LINENUMBERS
/* Ensure that the margin can accomodate the buffer's highest line number. */
void confirm_margin(void)
{
int needed_margin = digits(openfile->filebot->lineno) + 1;
/* When not requested or space is too tight, suppress line numbers. */
if (!ISSET(LINE_NUMBERS) || needed_margin > COLS - 4)
needed_margin = 0;
if (needed_margin != margin) {
margin = needed_margin;
editwincols = COLS - margin;
#ifndef NANO_TINY
/* Ensure that firstcolumn is the starting column of its chunk. */
ensure_firstcolumn_is_aligned();
#endif
/* The margin has changed -- schedule a full refresh. */
refresh_needed = TRUE;
}
}
#endif /* ENABLE_LINENUMBERS */
/* Say that an unbound key was struck, and if possible which one. */
void unbound_key(int code)
{
@@ -1982,6 +2028,7 @@ int main(int argc, char **argv)
{"autoindent", 0, NULL, 'i'},
{"cutfromcursor", 0, NULL, 'k'},
{"unix", 0, NULL, 'u'},
{"afterends", 0, NULL, 'y'},
{"softwrap", 0, NULL, '$'},
#endif
{NULL, 0, NULL, 0}
@@ -2040,15 +2087,9 @@ int main(int argc, char **argv)
while ((optchr =
getopt_long(argc, argv,
"ABC:DEFGHIKLMNOPQ:RST:UVWX:Y:abcdefghijklmno:pqr:s:tuvwxz$",
"ABC:DEFGHIKLMNOPQ:RST:UVWX:Y:abcdefghijklmno:pqr:s:tuvwxyz$",
long_options, NULL)) != -1) {
switch (optchr) {
case 'b':
case 'e':
case 'f':
case 'j':
/* Pico compatibility flags. */
break;
#ifndef NANO_TINY
case 'A':
SET(SMART_HOME);
@@ -2165,6 +2206,9 @@ int main(int argc, char **argv)
case 'g':
SET(SHOW_CURSOR);
break;
case 'h':
usage();
exit(0);
#ifndef NANO_TINY
case 'i':
SET(AUTOINDENT);
@@ -2173,6 +2217,11 @@ int main(int argc, char **argv)
SET(CUT_FROM_CURSOR);
break;
#endif
#ifdef ENABLE_LINENUMBERS
case 'l':
SET(LINE_NUMBERS);
break;
#endif
#ifdef ENABLE_MOUSE
case 'm':
SET(USE_MOUSE);
@@ -2235,6 +2284,11 @@ int main(int argc, char **argv)
case 'x':
SET(NO_HELP);
break;
#ifndef NANO_TINY
case 'y':
SET(AFTER_ENDS);
break;
#endif
case 'z':
SET(SUSPEND);
break;
@@ -2243,14 +2297,11 @@ int main(int argc, char **argv)
SET(SOFTWRAP);
break;
#endif
#ifdef ENABLE_LINENUMBERS
case 'l':
SET(LINE_NUMBERS);
case 'b': /* Pico compatibility flags. */
case 'e':
case 'f':
case 'j':
break;
#endif
case 'h':
usage();
exit(0);
default:
printf(_("Type '%s -h' for a list of available options.\n"), argv[0]);
exit(1);
@@ -2413,21 +2464,18 @@ int main(int argc, char **argv)
#endif
#ifdef ENABLE_JUSTIFY
/* If punct wasn't specified, set its default value. */
/* Set the default value for things that weren't specified. */
if (punct == NULL)
punct = mallocstrcpy(NULL, "!.?");
/* If brackets wasn't specified, set its default value. */
if (brackets == NULL)
brackets = mallocstrcpy(NULL, "\"')>]}");
/* If quotestr wasn't specified, set its default value. */
if (quotestr == NULL)
quotestr = mallocstrcpy(NULL, "^([ \t]*[#:>|}])+");
quoterc = regcomp(&quotereg, quotestr, NANO_REG_EXTENDED);
quotestr = mallocstrcpy(NULL, "^([ \t]*([#:>|}]|/{2}))+");
/* Compile the quoting regex, and free it when it's good; otherwise,
* retrieve and store the error message, to be shown when justifying. */
quoterc = regcomp(&quotereg, quotestr, NANO_REG_EXTENDED);
if (quoterc == 0) {
/* We no longer need quotestr, just quotereg. */
free(quotestr);
quotestr = NULL;
} else {
@@ -2611,25 +2659,15 @@ int main(int argc, char **argv)
if (rcfile_with_errors != NULL)
statusline(ALERT, _("Mistakes in '%s'"), rcfile_with_errors);
#ifdef ENABLE_HELP
if (*openfile->filename == '\0' && openfile->totsize == 0 &&
openfile->next == openfile && !ISSET(NO_HELP))
statusbar(_("Welcome to nano. For basic help, type Ctrl+G."));
#endif
while (TRUE) {
#ifdef ENABLE_LINENUMBERS
int needed_margin = digits(openfile->filebot->lineno) + 1;
/* Suppress line numbers when there is not enough room for them. */
if (!ISSET(LINE_NUMBERS) || needed_margin > COLS - 4)
needed_margin = 0;
if (needed_margin != margin) {
margin = needed_margin;
editwincols = COLS - margin;
#ifndef NANO_TINY
/* Ensure that firstcolumn is the starting column of its chunk. */
ensure_firstcolumn_is_aligned();
#endif
/* The margin has changed -- schedule a full refresh. */
refresh_needed = TRUE;
}
confirm_margin();
#endif
if (currmenu != MMAIN)
display_main_list();
@@ -2649,6 +2687,7 @@ int main(int argc, char **argv)
} else
edit_refresh();
errno = 0;
focusing = TRUE;
/* Forget any earlier statusbar x position. */

View File

@@ -178,7 +178,7 @@ typedef enum {
#ifdef ENABLE_COMMENT
COMMENT, UNCOMMENT, PREFLIGHT,
#endif
CUT, CUT_TO_EOF, PASTE, INSERT, OTHER
CUT, CUT_TO_EOF, PASTE, INSERT, COUPLE_BEGIN, COUPLE_END, OTHER
} undo_type;
/* Structure types. */
@@ -543,7 +543,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. */

View File

@@ -2,7 +2,7 @@
* prompt.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2016 Benno Schulenberg *
* 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,8 +25,6 @@
static char *prompt = NULL;
/* The prompt string used for statusbar questions. */
static size_t statusbar_x = HIGHEST_POSITIVE;
/* The cursor position in answer. */
#ifdef ENABLE_MOUSE
/* Handle a mouse click on the statusbar prompt or the shortcut list. */
@@ -292,17 +290,28 @@ void do_statusbar_cut_text(void)
void do_statusbar_next_word(void)
{
bool seen_space = !is_word_mbchar(answer + statusbar_x, FALSE);
bool seen_word = !seen_space;
/* Move forward until we reach the start of a word. */
/* 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[statusbar_x] != '\0') {
statusbar_x = move_mbright(answer, statusbar_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 + statusbar_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 + statusbar_x, FALSE))
seen_space = TRUE;
else if (seen_space)
break;
}
}
update_the_statusbar();
@@ -659,14 +668,18 @@ int do_prompt(bool allow_tabs, bool allow_files,
int do_yesno_prompt(bool all, const char *msg)
{
int response = -2, width = 16;
/* TRANSLATORS: For the next three strings, specify the single-byte
* starting letters of the translations for "Yes", "No", and "All".
* Of each string, the first letter is shown in the help lines. */
/* 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");
while (response == -2) {
#ifdef ENABLE_NLS
char letter[MAXCHARLEN + 1];
int index = 0;
#endif
int kbinput;
if (!ISSET(NO_HELP)) {
@@ -684,16 +697,16 @@ 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);
}
@@ -710,16 +723,29 @@ 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. */
#ifdef ENABLE_NLS
if (strchr(yesstr, kbinput) != NULL)
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
#endif /* ENABLE_NLS */
if (strchr("Yy", kbinput) != NULL)
response = 1;
else if (strchr("Nn", kbinput) != NULL)

View File

@@ -124,6 +124,7 @@ extern char *quoteerr;
extern char *word_chars;
extern char *answer;
extern size_t statusbar_x;
extern ssize_t tabsize;
@@ -380,7 +381,7 @@ 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);
@@ -426,6 +427,9 @@ 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
@@ -438,6 +442,9 @@ void enable_signals(void);
void disable_flow_control(void);
void enable_flow_control(void);
void terminal_init(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);
@@ -544,7 +551,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);
@@ -706,6 +713,7 @@ void append_void(void);
void prepend_void(void);
void backup_file_void(void);
void flip_execute(void);
void flip_pipe(void);
#endif
#ifdef ENABLE_MULTIBUFFER
void flip_newbuffer(void);

View File

@@ -3,7 +3,7 @@
* *
* 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 *
@@ -39,9 +39,6 @@
static const rcoption rcopts[] = {
{"boldtext", BOLD_TEXT},
#ifdef ENABLE_LINENUMBERS
{"linenumbers", LINE_NUMBERS},
#endif
#ifdef ENABLE_JUSTIFY
{"brackets", 0},
#endif
@@ -51,6 +48,9 @@ static const rcoption rcopts[] = {
#endif
#ifdef ENABLE_HISTORIES
{"historylog", HISTORYLOG},
#endif
#ifdef ENABLE_LINENUMBERS
{"linenumbers", LINE_NUMBERS},
#endif
{"morespace", MORE_SPACE},
#ifdef ENABLE_MOUSE
@@ -88,6 +88,7 @@ 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},
@@ -95,9 +96,9 @@ static const rcoption rcopts[] = {
{"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},
@@ -399,7 +400,8 @@ void parse_binding(char *ptr, bool dobind)
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;
@@ -509,7 +511,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") :
@@ -1145,19 +1147,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

View File

@@ -2,7 +2,7 @@
* search.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999-2011, 2013-2018 Free Software Foundation, Inc. *
* Copyright (C) 2015-2017 Benno Schulenberg *
* 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 *

View File

@@ -5,7 +5,8 @@
* Copyright (C) 2014-2015 Mark Majeres *
* Copyright (C) 2016 Mike Scalora *
* Copyright (C) 2016 Sumedh Pendurkar *
* Copyright (C) 2015-2017 Benno Schulenberg *
* Copyright (C) 2018 Marco Diego Aurélio Mesquita *
* 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 *
@@ -209,7 +210,7 @@ void do_cutword(bool backward)
if (backward)
do_prev_word(ISSET(WORD_BOUNDS), FALSE);
else
do_next_word(ISSET(WORD_BOUNDS), FALSE);
do_next_word(FALSE, ISSET(WORD_BOUNDS), FALSE);
/* Set the mark at the start of that word. */
openfile->mark = openfile->current;
@@ -699,8 +700,8 @@ void do_undo(void)
openfile->current_x = u->begin;
switch (u->type) {
case ADD:
/* TRANSLATORS: The next twelve strings describe actions
* that are undone or redone. It are all nouns, not verbs. */
/* TRANSLATORS: The next thirteen strings describe actions
* that are undone or redone. They are all nouns, not verbs. */
undidmsg = _("text add");
if (u->xflags == WAS_FINAL_LINE && !ISSET(NO_NEWLINES))
remove_magicline();
@@ -800,6 +801,15 @@ void do_undo(void)
cutbuffer = oldcutbuffer;
cutbottom = oldcutbottom;
break;
case COUPLE_BEGIN:
undidmsg = _("filtering");
break;
case COUPLE_END:
openfile->current_undo = openfile->current_undo->next;
do_undo();
do_undo();
do_undo();
return;
case INDENT:
handle_indent_action(u, TRUE, TRUE);
undidmsg = _("indent");
@@ -962,6 +972,15 @@ void do_redo(void)
free_filestruct(u->cutbuffer);
u->cutbuffer = NULL;
break;
case COUPLE_BEGIN:
openfile->current_undo = u;
do_redo();
do_redo();
do_redo();
return;
case COUPLE_END:
redidmsg = _("filtering");
break;
case INDENT:
handle_indent_action(u, FALSE, TRUE);
redidmsg = _("indent");
@@ -1010,27 +1029,34 @@ void do_enter(void)
filestruct *newnode = make_new_node(openfile->current);
size_t extra = 0;
#ifndef NANO_TINY
filestruct *sampleline = openfile->current;
bool allblanks = FALSE;
if (ISSET(AUTOINDENT)) {
extra = indent_length(openfile->current->data);
#ifdef ENABLE_JUSTIFY
/* When doing automatic long-line wrapping and the next line is
* in this same paragraph, use its indentation as the model. */
if (!ISSET(NO_WRAP) && sampleline->next != NULL &&
inpar(sampleline->next) && !begpar(sampleline->next, 0))
sampleline = sampleline->next;
#endif
extra = indent_length(sampleline->data);
/* If we are breaking the line in the indentation, limit the new
* indentation to the current x position. */
/* When breaking in the indentation, limit the automatic one. */
if (extra > openfile->current_x)
extra = openfile->current_x;
else if (extra == openfile->current_x)
allblanks = TRUE;
}
#endif
#endif /* NANO_TINY */
newnode->data = charalloc(strlen(openfile->current->data +
openfile->current_x) + extra + 1);
strcpy(&newnode->data[extra], openfile->current->data +
openfile->current_x);
#ifndef NANO_TINY
if (ISSET(AUTOINDENT)) {
/* Copy the whitespace from the current line to the new one. */
strncpy(newnode->data, openfile->current->data, extra);
/* Copy the whitespace from the sample line to the new one. */
strncpy(newnode->data, sampleline->data, extra);
/* If there were only blanks before the cursor, trim them. */
if (allblanks)
openfile->current_x = 0;
@@ -1052,9 +1078,11 @@ void do_enter(void)
}
#endif
/* Insert the newly created line after the current one and renumber. */
splice_node(openfile->current, newnode);
renumber(newnode);
/* Put the cursor on the new line, after any automatic whitespace. */
openfile->current = newnode;
openfile->current_x = extra;
openfile->placewewant = xplustabs();
@@ -1079,10 +1107,29 @@ RETSIGTYPE cancel_command(int signal)
nperror("kill");
}
/* Execute command in a shell. Return TRUE on success. */
/* Send the text that starts at the given line to file descriptor fd. */
void send_data(const filestruct *line, int fd)
{
FILE *tube = fdopen(fd, "w");
if (tube == NULL)
return;
/* Send each line, except a final empty line. */
while (line != NULL && (line->next != NULL || line->data[0] != '\0')) {
fprintf(tube, "%s%s", line->data, line->next == NULL ? "" : "\n");
line = line->next;
}
fclose(tube);
}
/* Execute the given command in a shell. Return TRUE on success. */
bool execute_command(const char *command)
{
int fd[2];
int from_fd[2], to_fd[2];
/* The pipes through which text will written and read. */
const bool should_pipe = (command[0] == '|');
FILE *stream;
const char *shellenv;
struct sigaction oldaction, newaction;
@@ -1090,8 +1137,9 @@ bool execute_command(const char *command)
bool setup_failed = FALSE;
/* Whether setting up the temporary SIGINT handler failed. */
/* Create a pipe to read the command's output from. */
if (pipe(fd) == -1) {
/* Create a pipe to read the command's output from, and, if needed,
* a pipe to feed the command's input through. */
if (pipe(from_fd) == -1 || (should_pipe && pipe(to_fd) == -1)) {
statusbar(_("Could not create pipe"));
return FALSE;
}
@@ -1103,29 +1151,77 @@ bool execute_command(const char *command)
/* Fork a child process to run the command in. */
if ((pid = fork()) == 0) {
/* Child: close the unused read end of the pipe. */
close(fd[0]);
/* Child: close the unused read end of the output pipe. */
close(from_fd[0]);
/* Connect the write end of the pipe to the process' output streams. */
dup2(fd[1], fileno(stdout));
dup2(fd[1], fileno(stderr));
/* Connect the write end of the output pipe to the process' output streams. */
dup2(from_fd[1], fileno(stdout));
dup2(from_fd[1], fileno(stderr));
/* If the parent sends text, connect the read end of the
* feeding pipe to the child's input stream. */
if (should_pipe) {
dup2(to_fd[0], fileno(stdin));
close(to_fd[1]);
}
/* Run the given command inside the preferred shell. */
execl(shellenv, tail(shellenv), "-c", command, NULL);
execl(shellenv, tail(shellenv), "-c", should_pipe ? &command[1] : command, NULL);
/* If the exec call returns, there was an error. */
exit(1);
}
/* Parent: close the unused write end of the pipe. */
close(fd[1]);
close(from_fd[1]);
if (pid == -1) {
statusbar(_("Could not fork"));
close(fd[0]);
close(from_fd[0]);
return FALSE;
}
/* If the command starts with "|", pipe buffer or region to the command. */
if (should_pipe) {
filestruct *was_cutbuffer = cutbuffer;
cutbuffer = NULL;
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER)) {
switch_to_prev_buffer();
if (openfile->mark)
do_cut_text(TRUE, FALSE);
} else
#endif
{
add_undo(COUPLE_BEGIN);
if (openfile->mark == NULL) {
openfile->current = openfile->fileage;
openfile->current_x = 0;
}
add_undo(CUT);
do_cut_text(FALSE, openfile->mark == NULL);
update_undo(CUT);
}
if (fork() == 0) {
close(to_fd[0]);
send_data(cutbuffer != NULL ? cutbuffer : openfile->fileage, to_fd[1]);
close(to_fd[1]);
exit(0);
}
close(to_fd[0]);
close(to_fd[1]);
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER))
switch_to_next_buffer();
#endif
free_filestruct(cutbuffer);
cutbuffer = was_cutbuffer;
}
/* Re-enable interpretation of the special control keys so that we get
* SIGINT when Ctrl-C is pressed. */
enable_signals();
@@ -1142,12 +1238,15 @@ bool execute_command(const char *command)
}
}
stream = fdopen(fd[0], "rb");
stream = fdopen(from_fd[0], "rb");
if (stream == NULL)
statusline(ALERT, _("Failed to open pipe: %s"), strerror(errno));
else
read_file(stream, 0, "pipe", TRUE);
if (should_pipe && !ISSET(MULTIBUFFER))
add_undo(COUPLE_END);
if (wait(NULL) == -1)
nperror("wait");
@@ -1197,7 +1296,7 @@ void discard_until(const undo *thisitem, openfilestruct *thefile, bool keep)
thefile->last_saved = (undo *)0xbeeb;
}
/* Add a new undo struct to the top of the current pile. */
/* Add a new undo struct of the given type to the top of the current pile. */
void add_undo(undo_type action)
{
undo *u = openfile->current_undo;
@@ -1217,23 +1316,9 @@ void add_undo(undo_type action)
fprintf(stderr, " >> Adding an undo... action = %d\n", action);
#endif
/* Allocate and initialize a new undo type. */
/* Allocate and initialize a new undo item. */
u = (undo *) nmalloc(sizeof(undo));
u->type = action;
#ifdef ENABLE_WRAPPING
if (u->type == SPLIT_BEGIN) {
/* Some action, most likely an ADD, was performed that invoked
* do_wrap(). Rearrange the undo order so that this previous
* action is after the SPLIT_BEGIN undo. */
u->next = openfile->undotop->next;
openfile->undotop->next = u;
} else
#endif
{
u->next = openfile->undotop;
openfile->undotop = u;
openfile->current_undo = u;
}
u->strdata = NULL;
u->cutbuffer = NULL;
u->cutbottom = NULL;
@@ -1245,9 +1330,23 @@ void add_undo(undo_type action)
u->xflags = 0;
u->grouping = NULL;
#ifdef ENABLE_WRAPPING
/* If some action caused automatic long-line wrapping, insert the
* SPLIT_BEGIN item underneath that action's undo item. Otherwise,
* just add the new item to the top of the undo stack. */
if (u->type == SPLIT_BEGIN) {
u->next = openfile->undotop->next;
openfile->undotop->next = u;
} else
#endif
{
u->next = openfile->undotop;
openfile->undotop = u;
openfile->current_undo = u;
}
/* Record the info needed to be able to undo each possible action. */
switch (u->type) {
/* We need to start copying data into the undo buffer
* or we won't be able to restore it later. */
case ADD:
/* If a new magic line will be added, an undo should remove it. */
if (openfile->current == openfile->filebot)
@@ -1263,6 +1362,8 @@ void add_undo(undo_type action)
openfile->current->data[0] != '\0')
u->xflags = WAS_FINAL_BACKSPACE;
case DEL:
/* When not at the end of a line, store the deleted character,
* else purposely fall into the line-joining code. */
if (openfile->current->data[openfile->current_x] != '\0') {
char *char_buf = charalloc(MAXCHARLEN + 1);
int char_len = parse_mbchar(&openfile->current->data[u->begin],
@@ -1273,7 +1374,6 @@ void add_undo(undo_type action)
u->mark_begin_x += char_len;
break;
}
/* Else purposely fall into the line-joining code. */
case JOIN:
if (openfile->current->next) {
if (u->type == BACK) {
@@ -1314,6 +1414,8 @@ void add_undo(undo_type action)
u->lineno += cutbottom->lineno - cutbuffer->lineno;
break;
case INSERT:
case COUPLE_BEGIN:
case COUPLE_END:
break;
case INDENT:
case UNINDENT:
@@ -1474,6 +1576,8 @@ fprintf(stderr, " >> Updating an undo... action = %d\n", action);
case INSERT:
u->mark_begin_lineno = openfile->current->lineno;
u->mark_begin_x = openfile->current_x;
case COUPLE_BEGIN:
case COUPLE_END:
break;
default:
statusline(ALERT, "Wrong undo update type -- please report a bug");
@@ -1645,7 +1749,7 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
/* The length of the current character, in bytes. */
/* Find the last blank that does not overshoot the target column. */
while (*line != '\0' && column <= goal) {
while (*line != '\0' && ((ssize_t)column <= goal)) {
if (is_blank_mbchar(line) || (snap_at_nl && *line == '\n')) {
lastblank = index;
@@ -1659,7 +1763,7 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
}
/* If the whole line displays shorter than goal, we're done. */
if (column <= goal)
if ((ssize_t)column <= goal)
return index;
#ifdef ENABLE_HELP
@@ -1883,92 +1987,58 @@ size_t quote_length(const char *line)
return matches.rm_eo;
}
/* a_line and b_line are lines of text. The quotation part of a_line is
* the first a_quote characters. Check that the quotation part of
* b_line is the same. */
bool quotes_match(const char *a_line, size_t a_quote, const char *b_line)
/* The maximum depth of recursion. This must be an even number. */
#define RECURSION_LIMIT 222
/* Return TRUE when the given line is the beginning of a paragraph (BOP). */
bool begpar(const filestruct *const line, int depth)
{
return (a_quote == quote_length(b_line) &&
strncmp(a_line, b_line, a_quote) == 0);
}
size_t quote_len, indent_len, prev_dent_len;
/* We assume a_line and b_line have no quote part. Then, we return
* whether b_line could follow a_line in a paragraph. */
bool indents_match(const char *a_line, size_t a_indent, const char
*b_line, size_t b_indent)
{
return (b_indent <= a_indent && strncmp(a_line, b_line, b_indent) == 0);
}
/* Is foo the beginning of a paragraph?
*
* A line of text consists of a "quote part", followed by an
* "indentation part", followed by text. The functions quote_length()
* and indent_length() calculate these parts.
*
* A line is "part of a paragraph" if it has a part not in the quote
* part or the indentation.
*
* A line is "the beginning of a paragraph" if it is part of a
* paragraph and
* 1) it is the top line of the file, or
* 2) the line above it is not part of a paragraph, or
* 3) the line above it does not have precisely the same quote
* part, or
* 4) the indentation of this line is not an initial substring of
* the indentation of the previous line, or
* 5) this line has no quote part and some indentation, and
* autoindent isn't turned on.
* The reason for number 5) is that if autoindent isn't turned on,
* then an indented line is expected to start a paragraph, as in
* books. Thus, nano can justify an indented paragraph only if
* autoindent is turned on. */
bool begpar(const filestruct *const foo)
{
size_t quote_len, indent_len, temp_id_len;
if (foo == NULL)
return FALSE;
/* Case 1). */
if (foo == openfile->fileage)
/* If this is the very first line of the buffer, it counts as a BOP
* even when it contains no text. */
if (line == openfile->fileage)
return TRUE;
quote_len = quote_length(foo->data);
indent_len = indent_length(foo->data + quote_len);
/* Not part of a paragraph. */
if (foo->data[quote_len + indent_len] == '\0')
/* If recursion is going too deep, just say it's not a BOP. */
if (depth > RECURSION_LIMIT)
return FALSE;
/* Case 3). */
if (!quotes_match(foo->data, quote_len, foo->prev->data))
quote_len = quote_length(line->data);
indent_len = indent_length(line->data + quote_len);
/* If this line contains no text, it is not a BOP. */
if (line->data[quote_len + indent_len] == '\0')
return FALSE;
/* If the quote part of the preceding line differs, this is a BOP. */
if (quote_len != quote_length(line->prev->data) ||
strncmp(line->data, line->prev->data, quote_len) != 0)
return TRUE;
temp_id_len = indent_length(foo->prev->data + quote_len);
prev_dent_len = indent_length(line->prev->data + quote_len);
/* Case 2) or 5) or 4). */
if (foo->prev->data[quote_len + temp_id_len] == '\0' ||
(quote_len == 0 && indent_len > 0 && !ISSET(AUTOINDENT)) ||
!indents_match(foo->prev->data + quote_len, temp_id_len,
foo->data + quote_len, indent_len))
/* If the preceding line contains no text, this is a BOP. */
if (line->prev->data[quote_len + prev_dent_len] == '\0')
return TRUE;
return FALSE;
/* If the indentation of the preceding line equals the indentation
* of this line, this is not a BOP. */
if (prev_dent_len == indent_len && strncmp(line->prev->data + quote_len,
line->data + quote_len, indent_len) == 0)
return FALSE;
/* Otherwise, this is a BOP if the preceding line is not. */
return !begpar(line->prev, depth + 1);
}
/* Is foo inside a paragraph? */
bool inpar(const filestruct *const foo)
/* Return TRUE when the given line is part of a paragraph. */
bool inpar(const filestruct *const line)
{
size_t quote_len;
size_t quote_len = quote_length(line->data);
if (foo == NULL)
return FALSE;
quote_len = quote_length(foo->data);
return (foo->data[quote_len + indent_length(foo->data +
quote_len)] != '\0');
return (line->data[quote_len +
indent_length(line->data + quote_len)] != '\0');
}
/* Move the next par_len lines, starting with first_line, into the
@@ -2045,15 +2115,11 @@ void backup_lines(filestruct *first_line, size_t par_len)
* beginning of the next paragraph if we're not. Afterwards, save the
* quote length and paragraph length in *quote and *par. Return TRUE if
* we found a paragraph, and FALSE if there was an error or we didn't
* find a paragraph.
*
* See the comment at begpar() for more about when a line is the
* beginning of a paragraph. */
* find a paragraph. */
bool find_paragraph(size_t *const quote, size_t *const par)
{
size_t quote_len;
/* Length of the initial quotation of the paragraph we search
* for. */
/* Length of the initial quotation of the paragraph we search for. */
size_t par_len;
/* Number of lines in the paragraph we search for. */
filestruct *current_save;
@@ -2085,7 +2151,7 @@ bool find_paragraph(size_t *const quote, size_t *const par)
* paragraph, in which case we should move back to the last line
* of the next paragraph. */
if (openfile->current_x == 0) {
if (!inpar(openfile->current->prev))
if (!openfile->current->prev || !inpar(openfile->current->prev))
return FALSE;
if (openfile->current != openfile->fileage)
openfile->current = openfile->current->prev;
@@ -2094,7 +2160,7 @@ bool find_paragraph(size_t *const quote, size_t *const par)
/* If the current line isn't the first line of the paragraph, move
* back to the first line of the paragraph. */
if (!begpar(openfile->current))
if (!begpar(openfile->current, 0))
do_para_begin(FALSE);
/* Now current is the first line of the paragraph. Set quote_len to
@@ -2119,8 +2185,8 @@ bool find_paragraph(size_t *const quote, size_t *const par)
return TRUE;
}
/* If full_justify is TRUE, justify the entire file. Otherwise, justify
* the current paragraph. */
/* Justify the current paragraph, and justify the entire file when
* full_justify is TRUE. */
void do_justify(bool full_justify)
{
filestruct *first_par_line = NULL;
@@ -2157,27 +2223,21 @@ void do_justify(bool full_justify)
openfile->current = openfile->fileage;
while (TRUE) {
size_t i;
/* Generic loop variable. */
filestruct *curr_first_par_line;
filestruct *firstline;
/* The first line of the current paragraph. */
filestruct *sampleline;
/* The line from which the indentation is copied -- either
* the first and only or the second line of the paragraph. */
size_t quote_len;
/* Length of the initial quotation of the current paragraph. */
size_t indent_len;
/* Length of the initial indentation of the current paragraph. */
/* Length of the quote part of the current paragraph. */
size_t lead_len;
/* Length of the quote part plus the indentation part. */
size_t par_len;
/* Number of lines in the current paragraph. */
ssize_t break_pos;
/* Where we will break lines. */
char *indent_string;
/* The first indentation that doesn't match the initial
* indentation of the current paragraph. This is put at the
* beginning of every line broken off the first justified
* line of the paragraph. Note that this works because a
* paragraph can only contain two indentations at most: the
* initial one, and a different one starting on a line after
* the first. See the comment at begpar() for more about
* when a line is part of a paragraph. */
char *lead_string;
/* The quote+indent stuff that is copied from the sample line. */
/* Find the first line of the paragraph to be justified. That
* is the start of this paragraph if we're in one, or the start
@@ -2219,74 +2279,45 @@ void do_justify(bool full_justify)
first_par_line = openfile->current;
}
/* Set curr_first_par_line to the first line of the current
* paragraph. */
curr_first_par_line = openfile->current;
/* Remember the first line of the current paragraph. */
firstline = openfile->current;
/* Initialize indent_string to a blank string. */
indent_string = mallocstrcpy(NULL, "");
/* The sample line is either the only line or the second line. */
sampleline = (par_len == 1 ? firstline : firstline->next);
/* Find the first indentation in the paragraph that doesn't
* match the indentation of the first line, and save it in
* indent_string. If all the indentations are the same, save
* the indentation of the first line in indent_string. */
{
const filestruct *indent_line = openfile->current;
bool past_first_line = FALSE;
for (i = 0; i < par_len; i++) {
indent_len = quote_len +
indent_length(indent_line->data + quote_len);
if (indent_len != strlen(indent_string)) {
indent_string = mallocstrncpy(indent_string,
indent_line->data, indent_len + 1);
indent_string[indent_len] = '\0';
if (past_first_line)
break;
}
if (indent_line == openfile->current)
past_first_line = TRUE;
indent_line = indent_line->next;
}
}
/* Copy the leading part (quoting + indentation) of the sample line. */
lead_len = quote_len + indent_length(sampleline->data + quote_len);
lead_string = mallocstrncpy(NULL, sampleline->data, lead_len + 1);
lead_string[lead_len] = '\0';
/* Now tack all the lines of the paragraph together, skipping
* the quoting and indentation on all lines after the first. */
for (i = 0; i < par_len - 1; i++) {
while (par_len > 1) {
filestruct *next_line = openfile->current->next;
size_t line_len = strlen(openfile->current->data);
size_t next_line_len = strlen(openfile->current->next->data);
size_t next_line_len = strlen(next_line->data);
indent_len = quote_len +
indent_length(openfile->current->next->data + quote_len);
next_line_len -= indent_len;
openfile->totsize -= indent_len;
lead_len = quote_len + indent_length(next_line->data + quote_len);
/* We're just about to tack the next line onto this one. If
* this line isn't empty, make sure it ends in a space. */
if (line_len > 0 && openfile->current->data[line_len - 1] != ' ') {
line_len++;
openfile->current->data =
charealloc(openfile->current->data, line_len + 1);
openfile->current->data[line_len - 1] = ' ';
charealloc(openfile->current->data, line_len + 2);
openfile->current->data[line_len++] = ' ';
openfile->current->data[line_len] = '\0';
openfile->totsize++;
}
openfile->current->data = charealloc(openfile->current->data,
line_len + next_line_len + 1);
strcat(openfile->current->data, next_line->data + indent_len);
line_len + next_line_len - lead_len + 1);
strcat(openfile->current->data, next_line->data + lead_len);
#ifndef NANO_TINY
/* If needed, adjust the coordinates of the mark. */
if (openfile->mark == next_line) {
openfile->mark = openfile->current;
openfile->mark_x += line_len - indent_len;
openfile->mark_x += line_len - lead_len;
}
#endif
/* Don't destroy edittop! */
@@ -2294,12 +2325,7 @@ void do_justify(bool full_justify)
openfile->edittop = openfile->current;
unlink_node(next_line);
/* If we've removed the next line, we need to go through
* this line again. */
i--;
openfile->totsize--;
openfile->totsize -= lead_len + 1;
par_len--;
}
@@ -2311,49 +2337,40 @@ void do_justify(bool full_justify)
while (par_len > 0 && strlenpt(openfile->current->data) > fill) {
size_t line_len = strlen(openfile->current->data);
indent_len = strlen(indent_string);
/* If this line is too long, try to wrap it to the next line
* to make it short enough. */
break_pos = break_line(openfile->current->data + indent_len,
fill - strnlenpt(openfile->current->data, indent_len), FALSE);
break_pos = break_line(openfile->current->data + lead_len,
fill - strnlenpt(openfile->current->data, lead_len), FALSE);
/* We can't break the line, or don't need to, so get out. */
if (break_pos == -1 || break_pos + indent_len == line_len)
/* If we can't break the line, or don't need to, we're done. */
if (break_pos == -1 || break_pos + lead_len == line_len)
break;
/* Move forward to the character after the indentation and
* just after the space. */
break_pos += indent_len + 1;
/* Adjust the breaking position for the leading part and
* move it beyond the found whitespace character. */
break_pos += lead_len + 1;
/* If this paragraph is non-quoted, and autoindent isn't
* turned on, set the indentation length to zero so that the
* indentation is treated as part of the line. */
if (quote_len == 0 && !ISSET(AUTOINDENT))
indent_len = 0;
/* Insert a new line after the current one. */
/* Insert a new line after the current one and allocate it. */
splice_node(openfile->current, make_new_node(openfile->current));
openfile->current->next->data = charalloc(lead_len + 1 +
line_len - break_pos);
/* Copy the text after where we're going to break the
* current line to the next line. */
openfile->current->next->data = charalloc(indent_len + 1 +
line_len - break_pos);
strncpy(openfile->current->next->data, indent_string,
indent_len);
strcpy(openfile->current->next->data + indent_len,
openfile->current->data + break_pos);
/* Copy the leading part and the text after the breaking point
* into the next line. */
strncpy(openfile->current->next->data, lead_string, lead_len);
strcpy(openfile->current->next->data + lead_len,
openfile->current->data + break_pos);
openfile->totsize += indent_len + 1;
openfile->totsize += lead_len + 1;
par_len++;
#ifndef NANO_TINY
/* Adjust the mark coordinates to compensate for the change
/* If needed, compensate the mark coordinates for the change
* in the current line. */
if (openfile->mark == openfile->current &&
openfile->mark_x > break_pos) {
openfile->mark = openfile->current->next;
openfile->mark_x -= break_pos - indent_len;
openfile->mark_x -= break_pos - lead_len;
}
#endif
/* When requested, snip all trailing blanks. */
@@ -2373,7 +2390,7 @@ void do_justify(bool full_justify)
par_len--;
}
free(indent_string);
free(lead_string);
/* Go to the next line, if possible. If there is no next line,
* move to the end of the current line. */
@@ -2384,7 +2401,7 @@ void do_justify(bool full_justify)
/* Renumber the now-justified paragraph, since both refreshing the
* edit window and finding a paragraph need correct line numbers. */
renumber(curr_first_par_line);
renumber(firstline);
/* We've just finished justifying the paragraph. If we're not
* justifying the entire file, break out of the loop.
@@ -3043,6 +3060,7 @@ void do_linter(void)
}
blank_bottombars();
currmenu = MLINTER;
statusbar(_("Invoking linter, please wait"));
construct_argument_list(&lintargs, openfile->syntax->linter, openfile->filename);
@@ -3190,18 +3208,18 @@ void do_linter(void)
struct stat lintfileinfo;
if (stat(curlint->filename, &lintfileinfo) != -1 &&
openfile->current_stat->st_ino != lintfileinfo.st_ino) {
openfilestruct *tmpof = openfile;
(openfile->current_stat == NULL ||
openfile->current_stat->st_ino != lintfileinfo.st_ino)) {
#ifdef ENABLE_MULTIBUFFER
const openfilestruct *started_at = openfile;
#ifdef ENABLE_MULTIBUFFER
while (tmpof != openfile->next) {
if (tmpof->current_stat->st_ino == lintfileinfo.st_ino)
break;
tmpof = tmpof->next;
}
#endif
if (tmpof->current_stat->st_ino != lintfileinfo.st_ino) {
#ifdef ENABLE_MULTIBUFFER
openfile = openfile->next;
while (openfile != started_at && (openfile->current_stat == NULL ||
openfile->current_stat->st_ino != lintfileinfo.st_ino))
openfile = openfile->next;
if (openfile->current_stat == NULL ||
openfile->current_stat->st_ino != lintfileinfo.st_ino) {
char *msg = charalloc(1024 + strlen(curlint->filename));
int i;
@@ -3250,10 +3268,9 @@ void do_linter(void)
}
free(dontwantfile);
}
#ifdef ENABLE_MULTIBUFFER
} else
openfile = tmpof;
}
}
#endif
}
@@ -3261,6 +3278,9 @@ void do_linter(void)
goto_line_posx(curlint->lineno, curlint->colno - 1);
titlebar(NULL);
adjust_viewport(CENTERING);
#ifdef ENABLE_LINENUMBERS
confirm_margin();
#endif
edit_refresh();
statusbar(curlint->msg);
bottombars(MLINTER);
@@ -3459,7 +3479,7 @@ void do_wordlinechar_count(void)
* count whenever we're on a word just before moving. */
while (openfile->current != openfile->filebot ||
openfile->current->data[openfile->current_x] != '\0') {
if (do_next_word(TRUE, FALSE))
if (do_next_word(FALSE, TRUE, FALSE))
words++;
}

View File

@@ -984,7 +984,7 @@ int convert_sequence(const int *seq, size_t length, int *consumed)
}
break;
#ifndef NANO_TINY
case '9': /* To accomodate iTerm2 in "xterm mode". */
case '9': /* To accommodate iTerm2 in "xterm mode". */
case '3':
switch (seq[4]) {
case 'A': /* Esc [ 1 ; 3 A == Alt-Up on xterm. */
@@ -1944,7 +1944,7 @@ char *display_string(const char *buf, size_t column, size_t span, bool isdata)
continue;
}
/* Represent an invalid sequence with the Replacement Character. */
/* Represent an invalid starter byte with the Replacement Character. */
converted[index++] = '\xEF';
converted[index++] = '\xBF';
converted[index++] = '\xBD';
@@ -2159,6 +2159,7 @@ void statusline(message_type importance, const char *msg, ...)
/* Curses mode is turned off. If we use wmove() now, it will muck
* up the terminal settings. So we just use vfprintf(). */
if (isendwin()) {
fprintf(stderr, "\n");
vfprintf(stderr, msg, ap);
va_end(ap);
return;
@@ -3502,15 +3503,15 @@ void do_credits(void)
"",
NULL, /* "Brought to you by:" */
"Chris Allegretta",
"Benno Schulenberg",
"David Lawrence Ramsey",
"Jordi Mallach",
"David Benbennick",
"Rocco Corsi",
"Mike Frysinger",
"Adam Rogoyski",
"Rob Siemborski",
"Rocco Corsi",
"David Lawrence Ramsey",
"David Benbennick",
"Mark Majeres",
"Mike Frysinger",
"Benno Schulenberg",
"Ken Tyler",
"Sven Guckes",
"Bill Soudan",

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

@@ -7,7 +7,7 @@ comment "#"
icolor brightred "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|linter|formatter|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 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:]]|[]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:]]*$)"

View File

@@ -4,7 +4,7 @@
## NOTE: Rules are applied in order: later rules re-colorize matching text.
syntax rust "\.rs"
syntax rust "\.(rlib|rs)$"
comment "//"
# Function definitions

View File

@@ -1,6 +1,6 @@
## Syntax highlighting for RPM spec files.
syntax spec "\.(spec$|spec\.*)"
syntax spec "\.spec(\.[^/]+)?$"
comment "#"
# Main tags.