Compare commits

...

283 Commits

Author SHA1 Message Date
Benno Schulenberg
4d54231967 po: regenerate POT file and PO files 2017-07-21 10:02:20 +02:00
Benno Schulenberg
8f2ac1b7f6 bump version numbers and add a news item for the 2.8.6 release 2017-07-21 09:51:22 +02:00
David Lawrence Ramsey
ee8681d7cc tweaks: only compensate for a partially-offscreen line in softwrap mode
A line can only be partially offscreen when doing softwrapping.
2017-07-20 12:27:40 +02:00
Benno Schulenberg
a1fba43452 pasting: restore the cap on the number of chunks to move backward
This fixes https://savannah.gnu.org/bugs/?51514.
2017-07-20 09:41:27 +02:00
Benno Schulenberg
0e4cbd4bfd softwrap: when possible, go back a whole bunch of chunks at a time
This improves https://savannah.gnu.org/bugs/?51479 for the +-1 case.
2017-07-19 09:47:56 +02:00
David Lawrence Ramsey
ce68f81b2b softwrap: remove unneeded caps on the number of chunks to move 2017-07-19 09:45:22 +02:00
Benno Schulenberg
255f5478e4 startup: in default mode, display the tail of the file as Pico does
When not using --smooth (nor 'set smooth'), and a line near or beyond
the end-of-file is addressed with the + command-line argument, then
center the cursor, just like Pico does -- so in the default mode,
nano is again more like Pico.

This partially addresses https://savannah.gnu.org/bugs/?51489.
2017-07-18 21:32:20 +02:00
Benno Schulenberg
2a7c9b7f62 files: don't bother counting rows when opening a fresh buffer
Counting the added number of rows is only relevant when inserting
a file into the current buffer.  So don't waste time counting when
it's not needed.

This fixes https://savannah.gnu.org/bugs/?51479.
2017-07-17 21:18:48 +02:00
Benno Schulenberg
1146381765 tweaks: drop a bunch of useless asserts 2017-07-17 19:17:57 +02:00
David Lawrence Ramsey
8b1f283a73 moving: fix the cursor jumping back and forth with non-smooth paging
Since commit 8490f4ac, get_edge_and_target() depends on an up-to-date
current_x.  So: make sure current_x is updated when we move to the
top left of the screen to start a non-smooth PageUp or PageDown.

This fixes https://savannah.gnu.org/bugs/?51480.
2017-07-17 11:45:57 +02:00
Benno Schulenberg
43a5c87682 suspension: prevent entering an invalid byte upon resume (with S-Lang)
For some reason, when returning from suspension, SLang will produce
either a clipped error code (0xFF instead of 0xFFFF, when returning
from an externally induced suspension), or it will clip the code of
first subsequent keystroke to a single byte (when returning from a
normal, in-editor suspension: ^Z).

Side-step this by ignoring the clipped error code, and by using an
undefined control code as the first fake keystroke.  Ignoring the
clipped error code is not possible when using a single-byte locale,
otherwise the user would not be able to type the character with
code 0xFF (although it could still be entered with Esc Esc 255).

This fixes https://savannah.gnu.org/bugs/?51477.
2017-07-16 13:55:59 +02:00
Benno Schulenberg
e4a69f8b94 docs: move the descriptions of 'header' and 'magic' next to 'syntax'
And reword them too, so that it is clearer what the mechanism is
for determining which syntax to use for a file.
2017-07-15 12:32:57 +02:00
Benno Schulenberg
8b3213cadb tweaks: chuck some debugging stuff 2017-07-15 11:49:56 +02:00
Benno Schulenberg
14c5f03e38 tweaks: rename another constant, to be more precise 2017-07-14 16:18:41 +02:00
Benno Schulenberg
1e2d9a697a tweaks: rename a constant, to match the corresponding option 2017-07-14 16:14:02 +02:00
Benno Schulenberg
63c428ad08 options: rename --cut to --cutfromcursor, to be clearer
Rename the corresponding rc-file option too, of course.
2017-07-14 16:06:52 +02:00
Benno Schulenberg
f55b65bd99 syntax: nanorc: don't color the argument of 'linter' as if invalid
Color it bright green instead, like valid numeric arguments of
'fill' and 'tabsize'.  Also color the argument of 'formatter'.
2017-07-14 15:32:56 +02:00
Benno Schulenberg
f4c3670f64 docs: reword the explanation of the 'syntax' command 2017-07-14 15:21:30 +02:00
Benno Schulenberg
6d121cc81f docs: improve some spacing, especially of the synopsis in the PDF
And in the bargain improve some mark-up here and there.
2017-07-14 13:38:32 +02:00
Benno Schulenberg
e57b755665 docs: use the @command and @option mark-up more consistently 2017-07-14 10:44:59 +02:00
Benno Schulenberg
fb5478338f syntax: texinfo: cover also some special cases like @U, @OE and @TeX 2017-07-14 10:29:36 +02:00
Benno Schulenberg
961294f533 docs: add some more mark-up to the Info document
And rewrap the feature toggles, so that a title does not start
a sentence.
2017-07-13 22:17:29 +02:00
Benno Schulenberg
46cec27b26 docs: use real cross references in the Info document
And refer backward instead of forward.
2017-07-13 21:43:27 +02:00
Benno Schulenberg
baa73d69e3 docs: improve cross references and mark-up in the Info document 2017-07-13 19:49:44 +02:00
Benno Schulenberg
6855b79267 tweaks: swap ^X and ^L in the help lines of the help viewer
I like it better that ^X stays in the same position compared to the
main screen: the lower left corner.
2017-07-13 16:47:12 +02:00
Benno Schulenberg
934a2192dc screen: retain the same help-line tags when the window is resized
This fixes https://savannah.gnu.org/bugs/?51457.
2017-07-13 11:42:49 +02:00
Benno Schulenberg
5df47bfef6 display: avoid a jumpy cursor by redrawing bottom bars only when needed
The help lines need to be redrawn one step after a justification
(whether it has been undone or not, to replace "Unjustify" with
"Uncut" again for ^U), and after switching buffers (to update a
possibly changed tag for ^T).

This fixes https://savannah.gnu.org/bugs/?51455.
2017-07-13 11:10:51 +02:00
David Lawrence Ramsey
fb51d617fd text: adjust the comments in do_indent() and do_unindent()
Make them reflect the split into two functions, the direct use of
tabsize, and the difference in behavior between indent and unindent.
2017-07-12 17:24:46 +02:00
David Lawrence Ramsey
7e9799d42b text: remove the last usage of cols in do_indent() and do_unindent()
Since all indentation and unindentation is by a tab, or by a tab's
worth of spaces, use tabsize directly.
2017-07-12 17:23:46 +02:00
David Lawrence Ramsey
d02c1993d8 text: normalize the indentation in do_indent() and do_unindent()
Also remove one unneeded blank line.
2017-07-12 16:58:23 +02:00
David Lawrence Ramsey
42f5a84c6f text: remove indent-related code from do_unindent() 2017-07-12 16:57:20 +02:00
David Lawrence Ramsey
109ad0915d text: remove unindent-related code from do_indent() 2017-07-12 16:56:36 +02:00
David Lawrence Ramsey
ee52f45b01 text: remove unneeded references to cols from the indentation routines
The parameter 'cols', that indicates how many columns to indent or
unindent, is changed to be always positive, so the check for being
negative can go.  And it could never be zero anyway.
2017-07-12 16:51:21 +02:00
David Lawrence Ramsey
2367f3d8e6 text: make do_unindent() an exact copy of do_indent()
This is the first step toward splitting them into two dedicated
functions, instead of letting do_indent() handle both cases.
2017-07-12 16:45:41 +02:00
Benno Schulenberg
684fc8f84a tweaks: remove two superfluous includes
The precalculation of the multiline regexes no longer looks at the
keyboard every second, and the backup code makes use of futimens()
nowadays.
2017-07-11 18:07:40 +02:00
Benno Schulenberg
092174dad5 tweaks: move an include to the file that actually makes use of it
Well, it will compile even without that include.  :|
I don't know why, since it does use va_list.
2017-07-11 18:06:33 +02:00
Benno Schulenberg
78bc8b698c tweaks: avoid a clang warning about an expression being treated as NULL
When compiling with 'clang', it would say: warning: expression which
evaluates to zero treated as a null pointer constant of type 'char *'.
2017-07-10 10:34:16 +02:00
Benno Schulenberg
d58ef8d579 gnulib: update to its current state 2017-07-10 10:26:59 +02:00
David Lawrence Ramsey
4f3249de56 display: when converting tabs, don't go beyond the screen width
This fixes https://savannah.gnu.org/bugs/?51427.
2017-07-10 09:34:55 +02:00
Benno Schulenberg
ecc7c26641 tweaks: rename a variable, to have more contrast 2017-07-09 21:11:01 +02:00
Benno Schulenberg
fbbf501f8f tweaks: rename four functions, to be more distinct 2017-07-09 21:07:38 +02:00
Benno Schulenberg
ac7a071893 options: recognize -a and --atblanks on the command line
In nano, -a is only effective when also -$ is given, so this will
not conflict with Pico since Pico does not know the -$ option.
2017-07-07 13:07:10 +02:00
Benno Schulenberg
09723b07a8 tweaks: fix compilation with --enable-tiny 2017-07-07 13:07:10 +02:00
David Lawrence Ramsey
dd667ce92c softwrap: don't flag EOL too early, nor break continuous text too early
This should eliminate all cases where the newline is pushed off the edge
of the screen in non-atblanks softwrap mode.  Also, it allows the use of
the last column of the screen in atblanks softwrap mode when a piece of
text does not contain any blanks.

This avoids the unreachable end-of-line reported on the mailing list:
http://lists.gnu.org/archive/html/nano-devel/2017-06/msg00011.html.
2017-07-07 13:07:10 +02:00
Benno Schulenberg
482fb352b8 tweaks: elide unneeded calls of get_last_chunk_leftedge()
And then elide the function entirely as it's called just once.
2017-07-07 13:07:10 +02:00
Benno Schulenberg
8766e7bdcb tweaks: reshuffle some things to condense the code 2017-07-07 13:07:10 +02:00
David Lawrence Ramsey
bb4d0d548a new feature: allow lines to be softwrapped at whitespace
Extend get_softwrap_breakpoint() to break softwrapped lines on
whitespace when a flag is set.  This flag is controlled by the new
rcfile option "atblanks".  The '>' characters marking two-column
characters at the edge of the screen are disabled when it's on.

If get_softwrap_breakpoint() can't find whitespace in screen range, it
will break the line on the screen edge.  (In this case, a blank can be
on the last column of the screen, but text can't, so that a blank on the
last column doesn't become invisible and possibly break the display.)

This fulfills https://savannah.gnu.org/bugs/index.php?49959.
Requested-by: Nicholas Boel <axxisd@gmail.com>
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey
aa04ad4f83 replacing: make spotlight() account for varying chunk width
spotlight() now displays softwrapped lines chunk by chunk instead of all
at once.  Since softwrapped lines are no longer of constant width, the
latter approach would fail if softwrapping breaks the spotlighted text.

Instead of taking a string, spotlight() now takes the starting and ending
columns of that string.  Also, its handling of softwrapped lines is now
split off into a separate function, spotlight_softwrapped().
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey
a4c2eaa2e6 moving: make vertical movement account for varying chunk width
Use actual_last_column() to properly adjust the cursor if placewewant
is past the end of a softwrapped chunk.
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey
4d7735c8f9 softwrap: in do_mouse(), keep the cursor before a softwrap breakpoint
Add the new function actual_last_column() to accomplish this.
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey
8490f4acab softwrap: make the changes to actually allow the chunk width to vary
get_chunk_row() and get_chunk_leftedge() now become wrappers around
get_chunk(); the latter is only used directly in place_the_cursor()
when we need to get both the row and the leftedge.  get_chunk() now
uses the proper formula to implement varying chunk width.

Since chunk width now varies, place_the_cursor() sets the x position
relative to the leftedge in a different way that works regardless
of chunk width, update_softwrapped_line() loops until it gets all
softwrap breakpoints instead of calculating the full length in
advance and getting one full row at a time, the chunk iterators
now count leftedges instead of rows, and fix_firstcolumn() does a
full recalculation of the chunk that firstcolumn is on instead of
simply shifting it back.

Also, in update_softwrapped_line(), when a line's softwrap breakpoint
is before the last column of the edit window, a ">" is now added to
the end of it.

The workaround in place_the_cursor() for when two-column characters
straddle the edge of the screen is removed, as it's no longer needed
now that chunks end before such characters.

Furthermore, do_home() and do_end() use xplustabs() instead of
placewewant again when calculating the leftedge, since placewewant
refers to a column that may or may not be available (if it's not,
the cursor will be placed wrongly).  Make get_edge_and_target() use
xplustabs() instead of placewewant for the same reason; this also lets
us simplify get_edge_and_target(), since xplustabs() will never be
greater than strlenpt().  Finally, since do_end() now has to calculate
rightedge as well as rightedge_x, use the former to implement the same
time-saving optimizations as in do_home().

The cursor is not yet adjusted when we try to go directly to a column
past the end of a softwrap breakpoint, and placewewant handling in the
vertical movement code is not yet adjusted for varying chunk lengths,
but fixes for these are forthcoming.

This fixes https://savannah.gnu.org/bugs/?49440.
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey
e375995d98 softwrap: add new functions for chunks of varying width
get_chunk_row() replaces the formula "column / editwincols".

get_chunk_leftedge() replaces "(column / editwincols) * editwincols".

get_last_chunk_row() replaces "strlenpt() / editwincols".

get_last_chunk_leftedge() replaces "(strlenpt() / editwincols) * editwincols".

This prepares us for any changes in those formulas, and for more such
functions later.
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey
35f6a1767a softwrap: prepare for allowing the chunk width to vary
The new function find_softwrap_breakpoint() returns the column number
of the last position in screen range where we can wrap the given text
without breaking a two-column character in half (as was done until now).
The returned column number is the leftedge of the next softwrapped chunk.

If the end of the text is reached while searching for a wrapping point,
the parameter end_of_line is set to TRUE.

The new function get_chunk() uses find_softwrap_breakpoint() to find the
row and leftedge corresponding to a given column of a given line.
2017-07-07 13:07:10 +02:00
David Lawrence Ramsey
5bc4abeefe text: update placewewant properly when indenting/unindenting
If the position of the cursor changes horizontally,
placewewant should change with it.

This fixes https://savannah.gnu.org/bugs/?51407.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-07-07 12:09:14 +02:00
Benno Schulenberg
ac726f08fa startup: don't try parsing color names that were not specified
Dereferencing a NULL pointer is never a good idea.

This fixes https://savannah.gnu.org/bugs/?51405.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-07-07 11:55:10 +02:00
David Lawrence Ramsey
30986db708 docs: mention that boldtext can be overridden also for function tags 2017-07-07 10:27:18 +02:00
Benno Schulenberg
1439016c20 tweaks: recognize the empty string as comment inhibitor, instead of NULL 2017-07-07 10:15:17 +02:00
Benno Schulenberg
79971a309f docs: remove the mention of backslashes for the argument of 'comment'
Also remove the backslashes from the two syntaxes that contained them.

This completes the fix for https://savannah.gnu.org/bugs/?51370.
2017-07-07 10:15:17 +02:00
Benno Schulenberg
a7901dd1e0 rcfile: don't require backslashing in the argument of 'comment'
Eradicate the need for backslashes, so that the start of the nanorc
manual becomes true, where it says that quotes inside strings don't
need to be escaped.  In the bargain achieve that the empty string
always switches commenting off.

This fixes https://savannah.gnu.org/bugs/?51370,
and fixes https://savannah.gnu.org/bugs/?51394.
2017-07-07 10:15:17 +02:00
Benno Schulenberg
1695463347 tweaks: correct two conditions for conditional compilation 2017-07-06 21:47:11 +02:00
Benno Schulenberg
f46544f67b tweaks: chuck two useless asserts, and elide a call to strncasecmp() 2017-07-06 10:31:35 +02:00
Benno Schulenberg
9462ba8217 tweaks: simplify the parsing of color combinations 2017-07-06 09:46:17 +02:00
Benno Schulenberg
23f5515fbb build: for Solaris, tell the linker to use a threading lib
This fixes https://savannah.gnu.org/bugs/?51348.
Reported-by: Henrik Karlsson <henrik.karlsson@pulsen.se>
Tested-by: John Wiersba <jrw32982@yahoo.com>
2017-07-05 21:18:52 +02:00
Benno Schulenberg
747310562c tweaks: avoid a failure with black diamonds in a PDF 2017-07-03 17:40:37 +02:00
Benno Schulenberg
1ae97076cd docs: make the guillemot and the middle dot appear correctly in HTML
For the man page, encode them properly, and for the Info stuff,
just set the right document encoding.

This fixes https://savannah.gnu.org/bugs/?51369.
2017-07-03 13:03:54 +02:00
Benno Schulenberg
09f516a58b syntax: man, groff: fix the string that introduces a comment
The comment marker is not «."» but «.\"», which requires three
backslashes to specify.  Also adjust the documentation.
2017-07-03 11:07:21 +02:00
David Lawrence Ramsey
025232b25b docs: mention the default values for comment and whitespace directives
Also, use proper mark-up for the examples.
2017-07-03 10:43:09 +02:00
David Lawrence Ramsey
7c41c8641f tweaks: remove unneeded braces, and mark empty parameter list as void
This matches the style in the rest of the code.
2017-07-03 09:52:13 +02:00
David Lawrence Ramsey
6295cca03b tweaks: correct a parameter type, and correct two empty initializations
This avoids some warnings when compiled with -pedantic:

    ISO C forbids comparison of ‘void *’ with function pointer
    ISO C forbids empty initializer braces
2017-07-03 09:40:55 +02:00
Benno Schulenberg
1c05090a4a syntax: gentoo: make it clearer that the file contains two syntaxes 2017-07-02 20:27:04 +02:00
Benno Schulenberg
14bd52ced8 display: wipe stale messages from the status bar straightaway
When blank_statusbar() has been called, make sure it is effective.

This fixes https://savannah.gnu.org/bugs/?51358.
2017-07-02 19:57:11 +02:00
Benno Schulenberg
7d46eff738 display: when back in the main loop, always redraw the help lines
(Well, redraw them when they're switched on, of course.)  Redraw
them so that they are shown correctly if their content changed.

This fixes https://savannah.gnu.org/bugs/?51356.
and fixes https://savannah.gnu.org/bugs/?51357.
2017-07-02 19:57:11 +02:00
Benno Schulenberg
84b6525914 tweaks: adjust an error message so it fits all possible cases
The thing after a 'comment' directive is just a string, not the
name of a program nor a command.
2017-07-02 19:55:28 +02:00
David Lawrence Ramsey
2abe7c03fe text: make sure commenting is disabled when comment "" was specified
When the active syntax contains a comment command that specifies the
empty string, this should override the default comment of "#" and
should disable the Meta-3 keystroke.

To achieve this, the comment string is now set by default to "#" for
all syntaxes, so that it will be set when no comment command is given
(including for the "none" syntax), and is unset only by explicitly
specifying «comment ""» in a syntax file.

This fixes https://savannah.gnu.org/bugs/?51355.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-07-02 19:44:56 +02:00
Benno Schulenberg
bf72cdd814 tweaks: rename two variables, to make a little sense
And rename a third variable, to match another in its style.
2017-07-02 12:05:12 +02:00
Benno Schulenberg
8e3f40155c input: recognize the Ctrl+Arrow key sequences from Haiku's Terminal 2017-07-02 11:58:43 +02:00
Benno Schulenberg
4239e5fe1a tweaks: put declarations always first, so it will compile on Haiku 2017-07-02 11:53:59 +02:00
David Lawrence Ramsey
d1ee41f319 usage: a dash doesn't have to come first among the filenames 2017-06-30 10:25:49 +02:00
Benno Schulenberg
b93767b54f screen: defeat a VTE/Konsole bug also for the case of --constantshow
When also --nohelp is active and the terminal is so narrow that the
message that --constantshow displays on the bottom row does not fit,
this causes the cursor to be pushed "offscreen".  Some terminal
emulators don't handle this case correctly, and leave the cursor
in an invisible or mistaken position.  Compensate for this by
moving the cursor back to the start of the row.

This fixes https://savannah.gnu.org/bugs/?51335.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-06-30 10:08:17 +02:00
Benno Schulenberg
8fbf10428c tweaks: avoid an unused-variable warning for the tiny version
The extra variable is not needed, because when having read from
standard input, the filename will simply be empty.  It will not
be empty for any other file that was read.
2017-06-30 09:58:40 +02:00
Benno Schulenberg
3719d8e208 docs: be more precise about when a dash is given instead of a filename
The dash doesn't have to be the first non-option argument: it can
be anywhere among the filenames -- there can even be multiple ones
(but don't mention this explicitly).
2017-06-29 20:56:58 +02:00
Benno Schulenberg
50cbde8b23 syntax: nanorc: don't color numeric arguments specially
Negative arguments of 'fill' are bright green since a few commits.
So now color all valid numeric arguments in that same style -- the
yellow was hard to see on a dark background anyway.

Also, color a zero tabsize as invalid.
2017-06-29 19:45:39 +02:00
David Lawrence Ramsey
9ffd3c0222 docs: consistently describe the -U/-c and -r/-w overrides 2017-06-29 17:48:50 +02:00
David Lawrence Ramsey
2704b3874b syntax: nanorc: properly color a "fill" option with a negative value 2017-06-29 17:25:09 +02:00
Benno Schulenberg
139f9c2fe5 files: warn more conspicuously when the file on disk has changed
This partially adresses https://savannah.gnu.org/bugs/?50998.
2017-06-29 10:59:51 +02:00
Benno Schulenberg
580fa53aba tweaks: spell an option correctly in NEWS 2017-06-29 10:59:05 +02:00
David Lawrence Ramsey
2380ee20c5 tweaks: fix a typo in NEWS 2017-06-29 10:56:14 +02:00
Benno Schulenberg
c0a52372f1 docs: drop the cluttering Info-style links from the HTML manual
Especially: get rid of the "Up: (dir)" link that points nowhere.

Also, add a horizontal line before the final Table of Contents.
2017-06-27 19:55:12 +02:00
Benno Schulenberg
fd8ce7af8e po: regenerate POT file and PO files 2017-06-25 11:09:38 +02:00
Benno Schulenberg
c5a0c9b6b2 tweaks: baptize the previous release 2017-06-25 10:59:40 +02:00
Benno Schulenberg
6520aa0079 bump version numbers and add a news item for the 2.8.5 release 2017-06-25 10:37:17 +02:00
Benno Schulenberg
3d8b9895b8 gnulib: update to its current state 2017-06-25 10:05:27 +02:00
Benno Schulenberg
9026e04c73 startup: don't use position history when reading from standard input 2017-06-23 13:44:01 +02:00
Benno Schulenberg
92befae93d startup: don't mark the buffer as modified when in view mode 2017-06-23 10:43:52 +02:00
Benno Schulenberg
dbbc14e0ac tweaks: be consistent in the spelling of title bar and status bar 2017-06-23 10:33:19 +02:00
Benno Schulenberg
8b80ec3e1a startup: allow negative line and column numbers on the command line
They can be given at the prompt, so it's better to accept them on the
command line too.
2017-06-23 10:25:12 +02:00
Benno Schulenberg
a71a2f9a0c startup: don't mark the buffer as modified when nothing was read 2017-06-23 09:51:58 +02:00
Benno Schulenberg
56ce5f2ba8 tweaks: rename a function and a variable, to better match what they do
Also improve some comments.
2017-06-23 09:50:48 +02:00
Benno Schulenberg
5ebdd3fe6e tweaks: reduce the scope of three variables, and rename them besides 2017-06-23 09:00:15 +02:00
Benno Schulenberg
426e6d37c5 startup: don't try placing the cursor when reading standard input failed
And rename the function while there anyway.
2017-06-23 08:30:24 +02:00
Benno Schulenberg
4dd9aadf8a startup: allow positioning the cursor also when reading standard input
A recent change (8dffb00f) removed this ability.  This change restores
it, and also allows reading from standard input multiple times -- maybe
not useful, but it works.
2017-06-20 11:22:57 +02:00
Benno Schulenberg
5ecd81bd19 tweaks: rename a variable, and frob a couple of comments
Also, conditionalize a statement that is only effective when
multiple file buffers are available.
2017-06-18 21:37:42 +02:00
Benno Schulenberg
b4a955512e docs: spell "title bar" and "status bar" correctly 2017-06-18 20:09:30 +02:00
Benno Schulenberg
33c7a4ca95 tweaks: adjust indentation after preceding changes
Also, shorten two variable names.
2017-06-18 11:29:09 +02:00
Benno Schulenberg
40d34862fd tweaks: reduce the scope of two variables, and rename them too
This reduction is possible since the routine no longer loops when
it encounters a +NUMBER argument.
2017-06-18 11:06:58 +02:00
Benno Schulenberg
bee670424e tweaks: elide a variable 2017-06-18 11:00:21 +02:00
Benno Schulenberg
8dffb00fd9 startup: always open with the file that was mentioned first
Also when a dash is the first "file" mentioned on the command line,
nano should show this buffer at startup and not the next.

This fixes https://savannah.gnu.org/bugs/?51207.
2017-06-18 10:49:51 +02:00
Benno Schulenberg
403e87c0a0 docs: avoid a double "see" for cross references in the HTML manual
This fixes https://savannah.gnu.org/bugs/?51208.
2017-06-08 16:25:23 +02:00
Benno Schulenberg
942bb39547 startup: don't crash when opening standard input would fail
This fixes https://savannah.gnu.org/bugs/?51206.
2017-06-08 11:28:49 +02:00
Benno Schulenberg
52b7a41ea4 tweaks: elide a function that should not be a separate one
Reading from standard input is a purely sequential affair --
no need to split it into two functions.
2017-06-07 21:28:34 +02:00
Benno Schulenberg
6807e06a74 tweaks: frob a few comments, and elide and #ifndef 2017-06-06 22:22:48 +02:00
Benno Schulenberg
84cd0abd6f tweaks: avoid compiler warning about implicit type 2017-06-04 12:59:05 +02:00
Benno Schulenberg
6a70d2b6e2 tweaks: rename two functions and a variable, and invert its logic 2017-06-04 12:34:21 +02:00
Benno Schulenberg
16482f99b8 tweaks: unglobalize the nodelay_mode variable 2017-06-04 12:15:26 +02:00
Benno Schulenberg
621eb904b3 bindings: in the tiny version exclude word jumping from the prompts
In the tiny version, Ctrl+Left and Ctrl+Right are available only
in the editor itself and in the file browser.

This fixes https://savannah.gnu.org/bugs/?51173.
2017-06-04 11:13:03 +02:00
Benno Schulenberg
84ff9ebb91 display: don't let a SIGCONT write anything to the screen
The old praxis of calling total_refresh() upon a SIGCONT was confusing,
because the screen would look as if nano had returned from suspension,
but in fact the shell was still active.

Instead of calling total_refresh(), put a no-op key into ncurses' buffer,
so that, when nano actually does return out of suspension (through 'fg'),
this key will be read and discarded, upon which nano will go sit and wait
for the next key, just before which it calls doupdate().  The latter is
all we need to get the entire screen restored.

This also fixes https://savannah.gnu.org/bugs/?51131 for "tiny".
2017-06-02 21:00:13 +02:00
Benno Schulenberg
a2038a9b2b input: give an appropriate message when there are too many errors
This fixes a secondary part of https://savannah.gnu.org/bugs/?51124.
2017-05-31 15:11:11 +02:00
Benno Schulenberg
a969adf804 suspension: fake a SIGWINCH when coming back out of the background
When receiving a SIGCONT, don't call regenerate_screen() directly
but act as if a SIGWINCH occurred.  Also insert a dummy key, and
thus let the relevant input routine redraw the relevant subwindows.

Use KEY_F0 as the dummy key, as both Ncurses and Slang know it, and
it should normally do nothing at all.

This fixes https://savannah.gnu.org/bugs/?51124.
2017-05-31 14:57:56 +02:00
Benno Schulenberg
59b0f81bfa display: redraw title bar and edit window only when needed
When we are in the file browser, browser_refresh() will take care of
redrawing the title bar and the file list, so total_refresh() should
leave those two subwindows alone in that case.

This fixes https://savannah.gnu.org/bugs/?51147.
2017-05-31 12:44:02 +02:00
Benno Schulenberg
6ad3d3d6c0 display: show the cursor position also when searching took a while
Achieve this by making the suppression flag global, so that we can
just reset it instead of making an improper call of do_cursorpos().

This fixes the secondary part of https://savannah.gnu.org/bugs/?51134.
2017-05-29 22:15:38 +02:00
Benno Schulenberg
ca70885564 tweaks: don't bother calculating the position when we won't show it
Also, remove a useless assert.
2017-05-29 21:51:47 +02:00
Benno Schulenberg
cfa20c3f42 display: don't show the cursor while we are busy calculating its position
This fixes https://savannah.gnu.org/bugs/?51134.
2017-05-29 21:47:38 +02:00
Benno Schulenberg
4781d4d351 tweaks: reshuffle some stuff, to put related things closer together 2017-05-24 10:23:20 +02:00
Benno Schulenberg
ef1a3b08ae suspension: remove a duplicate setting of the HUP and TERM handler
This has been done already during signal_init().
2017-05-24 10:15:42 +02:00
Benno Schulenberg
4063fce6a0 syntax: default: allow leading whitespace before a hash comment 2017-05-23 20:07:15 +02:00
Benno Schulenberg
3db2beefd3 po: regenerate POT file and PO files 2017-05-21 10:57:12 +02:00
Benno Schulenberg
5907f8801b bump version numbers and add a news item for the 2.8.4 release 2017-05-21 10:21:03 +02:00
Benno Schulenberg
c68398f18f syntax: php: color "static" again as "function", like it used to be 2017-05-21 10:11:42 +02:00
Benno Schulenberg
d653aeab93 syntax: default: color also hash comments and email addresses 2017-05-19 21:09:15 +02:00
Benno Schulenberg
491e02f532 tweaks: reorder three items in the Info document 2017-05-19 21:09:02 +02:00
Benno Schulenberg
f1a47a2aae tweaks: reshuffle a few things to reduce duplication
It is no longer necessary to assign up() and down() separately for
the help viewer because by now the movement keys have been sorted
in order of ascending stride also in the main menu.

The two string definitions are relocated just to reduce the number
of #ifdefs.
2017-05-19 17:57:39 +02:00
Benno Schulenberg
7b23878b42 tweaks: do actual screen refreshes in a single call, when possible 2017-05-19 16:31:08 +02:00
Benno Schulenberg
5cdadc3eb1 tweaks: avoid an unused-variable warning when using --disable-comment 2017-05-19 11:55:37 +02:00
Benno Schulenberg
8f89e23adb tweaks: adjust the indentation after the preceding change
Also, change two error messages a bit.
2017-05-19 11:47:13 +02:00
Benno Schulenberg
8302ff700b tweaks: remove the no-op x$disable tests 2017-05-19 11:47:13 +02:00
Benno Schulenberg
a32d21c759 build: correct the inverted logic for the nanorc man page
All this "not is no" has me turning around in circles
at least ten times before I know which side is which.

This fixes https://savannah.gnu.org/bugs/?51061
Reported-by: Vicente Olivert Riera <vincent.riera@imgtec.com>
2017-05-19 11:46:18 +02:00
Benno Schulenberg
f8214440c2 gnulib: update to its current state 2017-05-18 20:09:04 +02:00
Benno Schulenberg
c1b08302df po: update translations and regenerate POT file and PO files 2017-05-18 14:27:00 +02:00
Benno Schulenberg
afd8a4e804 bump version numbers and add a news item for the 2.8.3 release 2017-05-18 11:53:19 +02:00
Benno Schulenberg
88b740179a tweaks: rewrap a couple of old items in NEWS, and fix an article
Also fix a URL that mistaken points to a specific bug.
2017-05-18 11:02:16 +02:00
Benno Schulenberg
9ce41543ed startup: don't call delwin() with NULL, to avoid crashing on Solaris
Apparently the curses on SunOS is less forgiving than the one on GNU.
Or rather: delwin(NULL) should just return an error, it shouldn't crash.

This fixes https://savannah.gnu.org/bugs/?51053.
Reported-by: John Wiersba <jrw32982@yahoo.com>
Solved-by: John Wiersba <jrw32982@yahoo.com>
2017-05-18 10:26:11 +02:00
Benno Schulenberg
e4775c2060 syntax: php: color also variable names, and color more reserved words
Most of the keywords listed on the following URL are now highlighted:
  http://php.net/manual/en/reserved.keywords.php

Also color single-quoted strings, and require that //-type comments
are preceded by whitespace or are alone on a line.

With-feedback-from: M <taur@mail.com>
2017-05-18 10:03:43 +02:00
Benno Schulenberg
cd7c3483b4 build: for Solaris, tell the linker where to find clock_gettime()
This fixes https://savannah.gnu.org/bugs/?50972.
Reported-by: John Wiersba <jrw32982@yahoo.com>
2017-05-17 10:53:21 +02:00
Benno Schulenberg
8075e454a9 history: don't save the cursor position for temporary help files
It's useless, because the position doesn't get restored, and it
cannot be restored because the name is different every time.
2017-05-17 10:48:04 +02:00
Benno Schulenberg
93b1c1bea6 files: don't ask "save anyway" when user orders to discard the buffer
This extra question was included upon Chris' request, but I find it
confusing and angering.
2017-05-16 22:14:45 +02:00
Benno Schulenberg
aa14526cb3 tweaks: exclude from the tiny version five error-betraying messages 2017-05-16 22:13:10 +02:00
Benno Schulenberg
d29d49aece tweaks: remove an old fault-catching message 2017-05-16 20:09:03 +02:00
Benno Schulenberg
e8f90789e9 tweaks: exclude from the tiny version two messages that will never occur 2017-05-16 20:00:42 +02:00
Benno Schulenberg
c830b8f51c syntax: php: recognize also the .phtml and .php7 extensions
(And in the bargain sort or group some of the keywords.)

This addresses https://savannah.gnu.org/patch/?9342.
Suggested-by: M <taur@mail.com>
2017-05-15 10:57:57 +02:00
Benno Schulenberg
28beb3f9c5 replacing: don't let placewewant influence the placement of the cursor
When spotlighting the string to be replaced, placewewant isn't valid,
so tell place_the_cursor() to ignore its value to avoid the cursor
getting mistakenly placed at the beginning of the next row.

This fixes https://savannah.gnu.org/bugs/?50997.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-05-11 22:28:34 +02:00
Benno Schulenberg
08fd5b349b moving: limit the target column when it is beyond the last chunk
When the column given in gotoline() is beyond the last available
column in the row of the last chunk, then set placewewant to the
actual end of the chunk, to prevent surprising jumps to the left
when moving up or down from there.

This fixes https://savannah.gnu.org/bugs/?50995.
2017-05-11 21:00:37 +02:00
Benno Schulenberg
6971db773b tweaks: swap a comparison, to be clearer 2017-05-11 10:28:43 +02:00
Benno Schulenberg
c620fc6aa9 build: use backticks to avoid a warning during autoreconf 2017-05-09 20:23:04 +02:00
Benno Schulenberg
7e09f2c64a syntax: makefile: color comments only at start of line or after whitespace 2017-05-09 17:37:05 +02:00
Benno Schulenberg
968c07fc81 build: use the "force" mechanism to always run the revision rule
Whenever 'make' is run, it should check whether the revision has
changed, and if so, it should update src/revision.h.

This portable FORCE mechanism should have been the replacement for
the phony target that was removed in a33a4f00, five commits ago.

This fixes https://savannah.gnu.org/bugs/?50956 in a better way.
2017-05-09 17:30:49 +02:00
Benno Schulenberg
858e75e4cf tweaks: transform the token DISABLE_NANORC to ENABLE_NANORC
Also, allow rebinding the word and block jumping functions
in the tiny version when nanorc files are reenabled.
2017-05-09 11:59:34 +02:00
Benno Schulenberg
a05180ed2d tweaks: transform the token DISABLE_TABCOMP to ENABLE_TABCOMP 2017-05-09 11:31:54 +02:00
Benno Schulenberg
00533854c0 tweaks: fix compilation with --enable-tiny ...-help and ...-multibuffer
(This should have been part of 9ea5eef2, four commits ago.)
2017-05-08 22:01:34 +02:00
Benno Schulenberg
dc3610fc8e tweaks: transform the token DISABLE_BROWSER to ENABLE_BROWSER
Also, allow Ctrl+Left/Right with --enable-tiny --enable-browser.
2017-05-08 21:56:50 +02:00
Benno Schulenberg
a33a4f00e5 build: don't use a dummy dependency, as it breaks non-GNU makes
This fixes https://savannah.gnu.org/bugs/?50956.
Reported-by: John Wiersba <jrw32982@yahoo.com>
2017-05-08 21:27:07 +02:00
Benno Schulenberg
509b091c47 tweaks: rename three empty functions, and reshuffle some others
Also remove a superfluous check for 'do_replace' -- it never gets
bound in the Search/Replace menus.
2017-05-08 14:33:18 +02:00
Benno Schulenberg
9ea5eef200 bindings: allow toggling a new buffer when multiple buffers are enabled
When configured with --enable-tiny --enable-multibuffer,
/do/ include the new-buffer toggle in the Read-File menu.
2017-05-08 13:36:57 +02:00
Benno Schulenberg
e701bb01aa tweaks: remove five dummy function definitions from the tiny version 2017-05-08 13:04:26 +02:00
Benno Schulenberg
a3102cd4cf syntax: xml: recognize an XML file also by its first line
Some .rdf files are XML, but the .rdf extension seems to be used
also for other things.  So... use the 'header' mechanism.
2017-05-07 20:02:20 +02:00
Benno Schulenberg
da67883508 syntax: nanohelp: color also ^6 as a shortcut keystroke
(Hadn't seen that one because of my additional bindings.)
2017-05-07 20:00:52 +02:00
David Lawrence Ramsey
03c3e2b7c0 tweaks: fix several whitespace irregularities
Add missing spaces, remove excess spaces, and
replace groups of indentation spaces with tabs.
2017-05-07 18:20:01 +02:00
Benno Schulenberg
4953dcec20 tweaks: add another warning for an impossible condition 2017-05-05 22:00:04 +02:00
Benno Schulenberg
f5155786e1 tweaks: adjust whitespace and comments after the preceding change 2017-05-05 21:54:23 +02:00
Benno Schulenberg
a9abc3d95f chars: optimize moving a character left in the non-UTF-8 case
When not in a UTF-8 locale, each character is just a single byte.
2017-05-05 21:40:00 +02:00
Benno Schulenberg
09cabcad5d chars: probe for a valid UTF-8 starter byte, instead of overstepping
Instead of always stepping back four bytes and then tentatively
moving forward again (which is wasteful when most codes are just
one or two bytes long), inspect the preceding bytes one by one
and begin the move forward at the first valid starter byte.

This reduces the backwards searching time by close to 40 percent.
2017-05-05 21:36:45 +02:00
Benno Schulenberg
f162a6a2ab chars: valid UTF-8 codes are at most 4 bytes long, so look only that far
This reduces the backwards searching time by a good 20 percent.
2017-05-05 21:34:23 +02:00
Benno Schulenberg
5a3de7f117 tweaks: avoid an empty function call in tiny version with line numbers 2017-05-05 12:39:20 +02:00
Benno Schulenberg
7b5cc1dcda display: keep the cursor put, also when toggling nohelp or morespace
Also when toggling the help lines back on or the extra editing space
back off, keep the cursor near the bottom of the screen if it /was/
there, instead of centering it -- if smooth scrolling is on, that is.

This supplements the fix for https://savannah.gnu.org/bugs/?50933.
2017-05-05 12:37:45 +02:00
David Lawrence Ramsey
2b38547875 display: ensure smooth scrolling when the edit window is resized
When the editing space gets narrower, either by toggling line numbers on
or making nano's window smaller, and when the cursor is near the bottom,
it can be pushed offscreen.  In that case, don't get it back onscreen by
centering the current line but by putting it on the bottom row.  This
makes for a smoother experience.

This fixes http://savannah.gnu.org/bugs/?50933.
2017-05-05 12:31:02 +02:00
Benno Schulenberg
492166a3f7 po: update translations and regenerate POT file and PO files 2017-05-04 11:19:50 +02:00
Benno Schulenberg
e1e15fd0f4 bump version numbers and add a news item for the 2.8.2 release 2017-05-04 10:24:54 +02:00
Benno Schulenberg
9c2bc68847 help: after a search, show the cursor only when something was found
And hide the cursor again as soon as the user scrolls.
Achieve this through making the 'didfind' variable global.

Also, remove a superfluous call of wnoutrefresh(), as bottombars()
already does that.

This fixes https://savannah.gnu.org/bugs/?50918.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
2017-05-03 17:02:49 +02:00
Benno Schulenberg
3d1ef8e07f bindings: show Home and End in browser help text, instead of M-| and M-? 2017-05-02 17:56:08 +02:00
Benno Schulenberg
5033cfd81a tweaks: transform the token DISABLE_MOUSE to ENABLE_MOUSE
Also, trim some comments and avoid an unused-variable warning.
2017-05-01 20:53:07 +02:00
Benno Schulenberg
9c3a149b14 tweaks: transform the token DISABLE_MULTIBUFFER to ENABLE_MULTIBUFFER 2017-05-01 20:20:34 +02:00
Benno Schulenberg
a9c4682c25 tweaks: rename another function, to better describe what it does
Also, reshuffle two initializations to go sit with the other ones.
2017-05-01 17:54:48 +02:00
Benno Schulenberg
6566177743 tweaks: add a warning for a condition that should never occur 2017-05-01 17:42:55 +02:00
Benno Schulenberg
443e1484e5 tweaks: reshuffle help-text initialization, to elide a save-and-restore 2017-05-01 17:32:50 +02:00
Benno Schulenberg
ac9550d4c2 tweaks: remove two superfluous calls of wnoutrefresh()
The bottomwin has just been refreshed by update_the_statusbar(),
and it should not be the responsibility of the prompt routines
to keep the edit window up to date, as they don't write anything
there.
2017-05-01 17:14:20 +02:00
Benno Schulenberg
1423e57199 tweaks: rename a function, to better suit what it does
Things have morphed over time and display_buffer() no longer actually
displays the buffer -- it just displays the title bar, precalculates
the multiline color info, and schedules a refresh of the edit window.
2017-05-01 16:53:13 +02:00
Benno Schulenberg
c095ece497 gnulib: update to its current state in git 2017-05-01 15:07:33 +02:00
Benno Schulenberg
9366131c51 tweaks: reshuffle some more stuff, and rename two more variables 2017-05-01 13:22:37 +02:00
Benno Schulenberg
009cd30695 tweaks: rename three variables, elide another, and reshuffle some stuff
Also, avoid an unused-variable warning when configured with
--enable-tiny --enable-help --enable-multibuffer.
2017-05-01 12:10:17 +02:00
Benno Schulenberg
c42d6d378a tweaks: check for an empty needle in a central place
Searching for an empty string should be impossible, it should never
happen, but it is bit too hard to verify this at the moment.
2017-04-30 20:32:01 +02:00
Benno Schulenberg
1a79b3d514 tweaks: remove a superfluous strlen() call from the reverse searches
If the length of the haystack is smaller than the length of the needle,
this means that also the length of the tail will be smaller -- because
pointer will be bigger than or equal to haystack -- so the pointer gets
readjusted to be a needle length before the end of the haystack, which
means that it ends up /before/ the haystack: thus the while loop will
never run.

On average, this saves some 200 nanoseconds per line.
2017-04-30 19:51:36 +02:00
Benno Schulenberg
7d3d3dec9a tweaks: use the logic from revstrstr() also in mbrevstrcasestr()
Because it is slightly faster.
2017-04-30 19:51:14 +02:00
Benno Schulenberg
6240805c41 tweaks: rename one variable again
It is not an index, it is not an offset from anything,
it is a direct pointer.
2017-04-30 17:50:12 +02:00
Benno Schulenberg
17cf7d1c62 syntax: nanohelp: change the hue of the keystrokes to match sample.nanorc
And because I think it looks slightly better.
2017-04-30 17:37:07 +02:00
Benno Schulenberg
3275c4e514 display: initialize the colors only when starting to draw the content
This avoids https://savannah.gnu.org/bugs/?49912 while at the same time
avoiding to draw the edit window twice in a row -- the first drawing
would use a wrong margin, which results in a visible and irritating
shift left or right of the content upon the second drawing.

This fixes https://savannah.gnu.org/bugs/?50877.
2017-04-30 17:29:17 +02:00
Benno Schulenberg
395c8e9e25 help: allocate enough space for the descriptions, so we don't crash
We should measure the length of each /translated/ shortcut description,
not of the original English one.

This fixes https://savannah.gnu.org/bugs/?50899.
2017-04-30 13:00:02 +02:00
Benno Schulenberg
a8a60b29e6 startup: warn about a strange character size only in the UTF-8 case
This addresses https://savannah.gnu.org/bugs/?50897.
Reported-by: Hannu Nyman <hannu.nyman@iki.fi>
2017-04-30 11:15:03 +02:00
Benno Schulenberg
c1ebfa04ae docs: in the FAQ, extend the answer to the pasting problem 2017-04-28 22:13:02 +02:00
Benno Schulenberg
6967fae35d tweaks: use the logic from revstrstr() also in revstrcasestr()
This elides a counter and a comparison from the central loop,
and thus makes the search a tiny bit faster.
2017-04-28 22:12:53 +02:00
Benno Schulenberg
a37435141a tweaks: rename some more of these 'rev_start' variables 2017-04-28 22:09:38 +02:00
Benno Schulenberg
329021e24a tweaks: rename two variables, because this 'rev_start' is irksome
And one-letter variables I cannot "see" -- they are too small.
2017-04-28 21:02:24 +02:00
Benno Schulenberg
b06407fbd7 tweaks: drop a bunch of asserts 2017-04-28 16:07:27 +02:00
Benno Schulenberg
8edaa38a1e tweaks: condense two bits of code, and drop two asserts 2017-04-28 15:57:51 +02:00
Benno Schulenberg
1f55c8819b tweaks: swap the names of two variables, to make more sense
An iterator should not be called "start_col", because it is only the
starting column at the very beginning.

Also, start_col (after the rename) can never be /larger/ than column.
2017-04-28 15:48:50 +02:00
Benno Schulenberg
03ecbf3d55 tweaks: remove a superfluous check
The mbwidth() function itself checks whether UTF-8 is being used
and does the right thing.
2017-04-28 15:47:53 +02:00
Benno Schulenberg
81aebeb2a9 bindings: allow using <Backspace> to scroll back up in the help viewer
Backspace is a more logical counterpart of Space than minus.
2017-04-26 15:14:28 +02:00
Benno Schulenberg
7b442ea4cb tweaks: be more precise about what --disable-extra does
Also, harmonize some configure-option descriptions,
add a slash after a subdir, and fix a typo.
2017-04-26 13:54:48 +02:00
Benno Schulenberg
a846a2c19f docs: add an item to the FAQ, about pasting from Windows to a remote nano
Also, add two missing configure options, and frob some other things.
2017-04-26 12:49:10 +02:00
Benno Schulenberg
a832fffb1f browser: make ^End work properly by fixing a paste error
It complained of "Unbound key" until now.
2017-04-26 10:05:18 +02:00
Benno Schulenberg
99fa20645c tweaks: avoid an unused-variable warning
That is: nest the conditions consistently.
And in the bargain rename the variable.
2017-04-25 20:57:22 +02:00
Benno Schulenberg
26fe2118c4 docs: update the list of who authored what
Also, mention that help texts can now be searched through, update
a copyright notice, and update and simplify a copyright year.
2017-04-25 20:32:05 +02:00
Benno Schulenberg
46430999d5 build: make --enable-help properly depend on --enable-multibuffer
And in the process transform the token DISABLE_HELP to ENABLE_HELP.
2017-04-25 18:27:55 +02:00
Benno Schulenberg
9cff7a1689 help: use a dedicated syntax to color shortcuts in a help text
This avoids applying the default syntax, or the syntax specified
with --syntax, to a ^G help text.
2017-04-25 17:21:46 +02:00
Benno Schulenberg
ae15fc9bb2 bindings: allow using '/' to start a search in the help viewer
And allow 'N' for searching the next occurrence.  Add the
same keystrokes to the file browser too, for consistency.
2017-04-25 17:21:38 +02:00
Benno Schulenberg
b3b3dd5792 help: remove the final blank line, so <End> does the same as all <Down>
Since the help text is searchable, an <End> would go to the end of the
text but would leave a blank line above the statusbar -- a blank line
that wasn't there before, and that is not reached when simply holding
down <Down> all the way from the top.
2017-04-25 17:21:33 +02:00
Benno Schulenberg
7e1648fdb0 help: set tabsize to the default width while showing a help text
So that the shortcut explanations get properly aligned.
2017-04-25 17:21:28 +02:00
Benno Schulenberg
e05dfda2be help: don't cycle forward in the buffers when exiting from help
When nano has multiple files open, closing a help buffer should
not switch to the next buffer in the ring but to the preceding one,
because it was from there that the help screen was invoked.
2017-04-25 17:21:25 +02:00
Benno Schulenberg
fe012dad91 help: when searching, do it forward, without case, and without regexes
Also, save and restore all the flags in a single swoop.
2017-04-25 17:21:21 +02:00
Benno Schulenberg
3787494c15 help: don't crash when nano was started with --noread
There is no need to restore NOREAD_MODE after unsetting it, because
any files mentioned on the command line have already been /not/ read.
2017-04-25 17:21:16 +02:00
Benno Schulenberg
8de4b7aaeb tweaks: rename a variable, use a faster comparison, and reshuffle a bit 2017-04-25 17:21:13 +02:00
Benno Schulenberg
9de0f158e2 help: keep the same position also after M-\ or M-/ has been used 2017-04-25 17:21:09 +02:00
Benno Schulenberg
3d62d32cbe help: keep the text at the same position when the screen is resized
However, prefer moving the starting point of the text backwards over
moving it forward, so that of the same paragraph more text is shown
instead of less.  But scroll an empty line out of view -- no text is
"lost" then.
2017-04-25 17:21:06 +02:00
Benno Schulenberg
f9fea02fc5 help: suppress nano's name and number to make it clearer this is help
The top-left corner changing is far more conspicuous than the top right.
2017-04-25 17:21:02 +02:00
Rishabh Dave
90bd25c1bb new feature: add a search facility to the help viewer
Allow the user to search in a help text with ^W and M-W.

Achieve this by not writing the help text directly to the screen
but first writing it to a temporary file and then opening this file
in a new buffer, and treating it specially: the normal file-reading
feedback is suppressed, the titlebar shows the headline of the text,
the cursor is hidden, and the menu is limited to just the up and down
movements and searching.

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

Signed-off-by: Rishabh Dave <rishabhddave@gmail.com>
2017-04-25 17:20:34 +02:00
Benno Schulenberg
ca6d7b6a46 input: avoid crashing when resizing the window during verbatim input
This fixes https://savannah.gnu.org/bugs/?50872.
2017-04-25 13:01:21 +02:00
Benno Schulenberg
d6313c2f8c tweaks: fix two typos 2017-04-24 20:29:41 +02:00
Benno Schulenberg
861d81edba scrolling: don't bother to limit the number of lines to step back
The go_back_chunks() function will do this clipping.

This fixes https://savannah.gnu.org/bugs/?50866.
2017-04-24 19:48:55 +02:00
Benno Schulenberg
ac1444578c docs: harmonize the nanorc man page and Info document a bit
And make the strings after "start=" and  "end=" more readable.
2017-04-21 11:29:19 +02:00
Benno Schulenberg
9a4c384afa docs: reword the main paragraph of the man page
Mention some things that really set nano apart from Pico.
Plus some other small tweaks here and there.
2017-04-19 20:31:04 +02:00
Benno Schulenberg
040bd93cc4 tweaks: distinguish (in the comments) between buffers and linestructs
Call something a buffer when it refers to a linked list of linestructs,
and call something a linestruct when it is a struct that describes a
single line.
2017-04-19 17:48:52 +02:00
Benno Schulenberg
e935fd4f88 tweaks: reshuffle a couple of lines to avoid a duplicate call
Trim a superfluous assert too.
2017-04-19 16:32:16 +02:00
Benno Schulenberg
a43eee6aec tweaks: fix compilation with --enable-tiny --enable-color --enable-speller
Also avoid an unused-variable warning, and trim a useless assert.
2017-04-19 14:30:36 +02:00
Benno Schulenberg
1fbe7596f8 options: allow -U (--quickblank) to be used in the tiny version
It takes almost no code and is a useful little improvement over Pico.
2017-04-19 13:47:40 +02:00
Benno Schulenberg
3c875f9b59 tweaks: complete the exclusion of backups and such from the tiny version
File formats, appending and prepending, and backups are not available
when --enable-tiny is used, so prevent all relevant pieces of code from
getting compiled.  And correct two misspelled ENABLE_TINY to NANO_TINY.
2017-04-19 13:30:43 +02:00
Benno Schulenberg
700c5c9399 tweaks: rename a parameter, to be more imperative 2017-04-17 12:01:03 +02:00
Benno Schulenberg
74f128859b tweaks: rename a constant, to match the corresponding option 2017-04-17 11:51:48 +02:00
Benno Schulenberg
953fbf8efe tweaks: elide a function that is used just once
And in the bargain avoid a duplicate call of strlenpt(prompt).
2017-04-17 11:44:04 +02:00
Benno Schulenberg
3dc6ccbe86 tweaks: rename a function, to be more accurate
Because nothing gets reset to zero or to some initial value.
2017-04-17 11:29:29 +02:00
Benno Schulenberg
b98545f455 display: push the titlebar to the screen as soon as it has been drawn
To avoid an ncurses hiccup (miscoloring) when running on musl.

This fixes https://savannah.gnu.org/bugs/?50787.
Reported-by: Avi Halachmi <avihpit@yahoo.com>
2017-04-17 10:53:38 +02:00
Benno Schulenberg
5a741a0205 tweaks: remove some superfluous placements of the cursor
The cursor needs to be placed in its proper spot in the edit window
/only/ when nano is about to accept input from the user and needs to
show where this input will go.

(This might cause a scrolling issue to appear, because reset_cursor()
does not just place the cursor, it also recomputes current_y, which
is used in several places to determine whether and how much to scroll.
If it so happens, we'll deal with that fallout later.)
2017-04-17 10:35:05 +02:00
Benno Schulenberg
6723ac6fcc tweaks: add three warnings for conditions that should never occur 2017-04-17 10:17:47 +02:00
David Lawrence Ramsey
bbc718633e docs: mention that also numbercolor overrides boldtext 2017-04-16 19:30:40 +02:00
Benno Schulenberg
b7166d5c06 po: update translations and regenerate POT file and PO files 2017-04-12 10:19:50 +02:00
Benno Schulenberg
1e8f6fd7a9 bump version numbers and add a news item for the 2.8.1 release 2017-04-12 10:11:45 +02:00
Benno Schulenberg
0b93fff802 docs: correct an answer to a question in the FAQ 2017-04-11 21:10:07 +02:00
Benno Schulenberg
1c74517629 docs: remove the self-referencing stuff and the changelog from the FAQ
Furthermore, change an item header into a question, swap two items,
and tweak the formatting a bit.
2017-04-11 20:41:17 +02:00
Benno Schulenberg
9f696ef9af copyright: update the year in --version, and use the standard hyphen 2017-04-11 13:57:29 +02:00
Benno Schulenberg
5aa12a2b3d tweaks: group ^D and ^H together in the help lines
This also groups ^I and ^M together, and cutwordleft and cutwordright
(when they are bound).  It furthermore makes that less pairs are now
mixed and instead consist of either two Ctrl or two Meta combos.  In
short: it looks better in the default config.  The only sacrifice is
that Verbatim is now split off from the other "inserting" keys.
2017-04-11 13:23:43 +02:00
Benno Schulenberg
2439e1e451 linting: treat a tab as one "column", not eight
This fixes https://savannah.gnu.org/bugs/?47131.
2017-04-10 20:32:36 +02:00
Benno Schulenberg
dab70d06ed linting: when no is said to a file, remove all corresponding entries
When the user chooses not to open a file that some message refers to,
remove all messages for that file from the linting results, so the user
does not get asked about that same file again.

This fixes https://savannah.gnu.org/bugs/?47130.
2017-04-10 19:55:46 +02:00
Benno Schulenberg
8993c36366 tweaks: reduce the number of additions that actual_x() performs
Replace them by a single subtraction.
2017-04-10 19:25:40 +02:00
David Lawrence Ramsey
5c51d4ea46 tweaks: avoid a compilation warning 2017-04-10 16:26:52 +02:00
David Lawrence Ramsey
02376103eb bindings: use arrows instead of words for search history too
When UTF-8 is available, use actual arrows instead of untranslated words
to indicate the cursor keys in the search history, as is done elsewhere.
2017-04-10 16:19:37 +02:00
Benno Schulenberg
999d99c6e4 tweaks: delete a function that hasn't been used since 2005 2017-04-09 13:33:25 +02:00
Benno Schulenberg
6e73805a0d tweaks: delete unnecessary function prototypes
These functions are used only in the file in which they are declared,
and they are declared before they are used.
2017-04-09 13:28:27 +02:00
Benno Schulenberg
754c62c5cc copyright: update the years, use ranges, and explain this usage
The interval 2013-2017 for the Free Software Foundation is valid
because in those years there were releases with changes by either
Chris or David, and the GNU maintainers guide advises to mention
a new year in all files of a package, not just in the ones that
actually changed, and be done with it for the rest of the year.
2017-04-09 12:09:23 +02:00
Benno Schulenberg
9f2c80db24 moving: when determining where we are on the screen, use placewewant
To make dynamic Home and End work properly when double-width characters
straddle a chunk boundary, use the spot where the cursor is really shown
instead of the "actual x" position of the current character, because the
latter might be on the preceding row.

This fixes https://savannah.gnu.org/bugs/?50737.
2017-04-09 11:36:39 +02:00
Benno Schulenberg
4c987bc3e0 tweaks: adjust a couple of comments 2017-04-07 21:40:33 +02:00
Benno Schulenberg
e75c933cb0 tweaks: fix two typos in the NEWS file
Also, use single quotes for rcfile options more consistently.
2017-04-07 21:23:00 +02:00
Benno Schulenberg
28767d8fec tweaks: fix some inconsistencies in an old Changelog 2017-04-07 21:22:55 +02:00
Benno Schulenberg
bf00e3f606 tweaks: put M-A before ^6, to look better above M-6 in the help lines
Also, M-A is far more mnemonic for setting the mark than ^6 or ^^,
so it's better to try and teach the user that.
2017-04-07 20:07:37 +02:00
David Lawrence Ramsey
23ae7bfbbf input: support escape sequences for ^Home and ^End
Make nano recognize the escape sequences for Ctrl-Home, Ctrl-End,
Shift-Ctrl-Home, and Shift-Ctrl-End on xterm, rxvt, and Eterm.
2017-04-06 21:25:41 +02:00
Benno Schulenberg
cb0806b2a0 bindings: make ^Home and ^End go to top and tail of buffer
On some terminal emulators, Ctrl+Home and Ctrl+End produce special
keycodes, distinct from plain Home and End.  Make the users of those
emulators (and of the Linux console) glad by making ^Home and ^End
do the obvious thing, and the combinations with Shift too.
2017-04-06 21:19:00 +02:00
Benno Schulenberg
005ee8eda6 editing: avoid creating blank lines when using autoindent
When Enter is pressed while the cursor is exactly on the current
indent width, remove the blank characters on that line to avoid
creating a line that consists only of trailing whitespace.

(When Enter is pressed somewhere in the middle of the blanks,
however, the whitespace is preserved.)

Suggested-by: Florian Zeitz <florob@babelmonkeys.de>
2017-04-06 20:34:04 +02:00
Benno Schulenberg
f3e2ad945d display: with softwrap, show the cursor where the eye expects it
When a multi-column character straddles a chunk boundary, and the
preferred column (placewewant) for the cursor is zero, cheat: show
the cursor not where the character starts but on the beginning of
the next row.  This makes the cursor move smoothly in the leftmost
column of the screen when using <Up> and <Down> and such, instead
of jumping around.

In this way the scrolling logic won't get confused and the screen
will scroll properly when stepping beyond the top or bottom row.

This fixes https://savannah.gnu.org/bugs/?50687.
2017-04-06 19:51:07 +02:00
Benno Schulenberg
6ec65d5500 display: check the correct character for being double-width
This fixes https://savannah.gnu.org/bugs/?50741.
2017-04-06 17:39:58 +02:00
Benno Schulenberg
de0adb8e3e tweaks: keep the help text aligned, also with the narrow arrows 2017-04-05 18:02:03 +02:00
Mike Frysinger
cc91ee603c configure: ignore the REG_ENHANCED test when we use gnulib
If we're using the bundled gnulib regex module, then assume REG_ENHANCED
is not supported (since gnulib doesn't support it).

This fixes https://savannah.gnu.org/bugs/?50714.
2017-04-04 21:21:37 +02:00
Benno Schulenberg
c84324bc7a gnulib: update to current state 2017-04-04 21:11:31 +02:00
Benno Schulenberg
8fc72eb32b bindings: use arrows instead of words to designate the cursor keys
When UTF-8 is available, use actual arrows instead of untranslated words
to indicate the cursor keys.  This was already done for the combinations
with Ctrl but not yet for the plain cursor keys.
2017-04-04 20:53:08 +02:00
Benno Schulenberg
6b5aff4878 tweaks: put unshifted shortcuts ^6 and M-6 first, instead of ^^ and M-^
The unshifted shortcuts are easier to type, and also less confusing in
my eyes.  Putting them first means they get shown in the help lines,
and get listed first in the ^G help text.

(I would also like to put ^- first instead of ^_ (because the latter
is hard to see when using the default inverse video for shortcuts),
but on several terminal emulators Ctrl+- reduces the font size.)
2017-04-04 20:41:09 +02:00
Benno Schulenberg
fb534bada6 bindings: make ^Up/^Down go to first/last row in the file browser
Making ^Up and ^Down go to top and bottom row in the file browser
complements and completes the behavior of ^Left and ^Right.
2017-04-04 20:26:21 +02:00
Benno Schulenberg
b5bc1b5094 tweaks: again use memory on the stack instead of malloc() and free()
Also, don't bother copying the found bracket -- just compare it in situ
and thus elide a variable.
2017-04-04 19:20:33 +02:00
Benno Schulenberg
aedc3ddd49 tweaks: replace a function call or a macro with a hard number
Verify at startup that the number is not too small.
2017-04-04 19:17:02 +02:00
Benno Schulenberg
754aa8ba79 tweaks: elide a variable and a pair of braces 2017-04-04 19:15:15 +02:00
Benno Schulenberg
53cea142e0 tweaks: use memory on the stack instead of calling malloc() and free()
Rename some variables in the process, and remove two cluttering asserts.
2017-04-04 19:14:14 +02:00
Benno Schulenberg
7e18100197 tweaks: close the backup file also when we skip making a backup
(We still leak the backupname in that case, but I can't be bothered
with that now.)

Also elide a variable, trim some comments, and rewrap some lines.
2017-04-04 12:50:49 +02:00
Benno Schulenberg
0abf225129 files: check also for write errors when prepending, not just read errors 2017-04-04 12:21:43 +02:00
Kamil Dudka
70bcf752dc backup: prevent a symlink attack by operating on the file descriptor
Use futimens() instead of utime() to change the timestamps on a backup
file.  Otherwise, a non-privileged user could create an arbitrary symlink
with the name of the backup file and in this way fool a privileged user
to call utime() on the attacker-chosen file.

Import the relevant gnulib module to make sure futimens() is available.
2017-04-04 11:28:01 +02:00
Mike Frysinger
8f2b5bbf3d configure: fix up word boundary regex logic now that we have gnulib
If we're using the bundled gnulib regex module, then assume word boundary
support is available to avoid issues with the regcomp test.  This also
unifies the different code paths a bit.

This fixes https://savannah.gnu.org/bugs/?50705.
2017-04-04 11:08:58 +02:00
David Lawrence Ramsey
f9a8d6ff4e scrolling: properly compensate for the onscreen chunks
If edittop is partially offscreen before we scroll, and it gets
scrolled more offscreen, we do need to compensate for the chunks
between firstcolumn and leftedge -- that is: the chunks between
the top row and the cursor row.

This fixes https://savannah.gnu.org/bugs/?50691.
2017-04-04 10:55:24 +02:00
David Lawrence Ramsey
c3830517cc display: show '<' and '>' placeholders for characters that get split
When a two-column character cannot be shown because it straddles the
boundary between two chunks of a line, show the '>' placeholder for
its left "half", and '<' for its right "half".

This mitigates https://savannah.gnu.org/bugs/?49440.
2017-04-03 21:51:46 +02:00
Benno Schulenberg
6d70ab11d6 docs: mention another difference with Pico in the Info document 2017-04-02 13:26:53 +02:00
Benno Schulenberg
5f359179b2 docs: trim the TODO file a bit, and put the more important items first
Remove some things we're never going to do: allowing to replace
newlines, a regression framework, characterset conversions, or
jumping to various screen lines.
2017-04-02 13:09:52 +02:00
77 changed files with 23228 additions and 21920 deletions

10
AUTHORS
View File

@@ -8,8 +8,8 @@ Chris Allegretta <chrisa@asty.org>
David Lawrence Ramsey <pooka109@gmail.com>
* Former stable series maintainer. Multiple buffer support,
operating dir (-o) option, bug fixes for display routines,
wrapping code, spelling fixes, const mode, parts of the
UTF-8 support, and various other fixes.
wrapping code, spelling fixes, constantshow mode, parts of
UTF-8 support, softwrap overhaul, and various other fixes.
Jordi Mallach <jordi@gnu.org>
* Debian package maintainer, fellow bug squasher.
@@ -39,7 +39,8 @@ Mike Frysinger <vapier@gentoo.org>
* Gentoo package maintainer. Whitespace display mode,
--enable-utf8/--disable-utf8 configure options for ncurses,
many new color regexes and improvements to existing color
regexes in syntax/*.nanorc, and miscellaneous bug fixes.
regexes in syntax/*.nanorc, the move from svn to git, the
conversion to gnulib, and miscellaneous bug fixes.
Mark Majeres <mark@engine12.com>
* A functional undo/redo system, and coloring nano's interface.
@@ -56,6 +57,9 @@ Faissal Bensefia <faissaloo@gmail.com>
Sumedh Pendurkar <sumedh.pendurkar@gmail.com>
* The word-completion feature.
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

326
ChangeLog
View File

@@ -1,3 +1,329 @@
Changes between v2.8.5 and v2.8.6:
----------------------------------
Benno Schulenberg (58):
build: for Solaris, tell the linker to use a threading lib
bump version numbers and add a news item for the 2.8.6 release
display: avoid a jumpy cursor by redrawing bottom bars only when needed
display: when back in the main loop, always redraw the help lines
display: wipe stale messages from the status bar straightaway
docs: add some more mark-up to the Info document
docs: be more precise about when a dash is given instead of a filename
docs: drop the cluttering Info-style links from the HTML manual
docs: improve cross references and mark-up in the Info document
docs: improve some spacing, especially of the synopsis in the PDF
docs: make the guillemot and the middle dot appear correctly in HTML
docs: move the descriptions of 'header' and 'magic' next to 'syntax'
docs: remove the mention of backslashes for the argument of 'comment'
docs: reword the explanation of the 'syntax' command
docs: use real cross references in the Info document
docs: use the @command and @option mark-up more consistently
files: don't bother counting rows when opening a fresh buffer
files: warn more conspicuously when the file on disk has changed
gnulib: update to its current state
input: recognize the Ctrl+Arrow key sequences from Haiku's Terminal
options: recognize -a and --atblanks on the command line
options: rename --cut to --cutfromcursor, to be clearer
pasting: restore the cap on the number of chunks to move backward
rcfile: don't require backslashing in the argument of 'comment'
screen: defeat a VTE/Konsole bug also for the case of --constantshow
screen: retain the same help-line tags when the window is resized
softwrap: when possible, go back a whole bunch of chunks at a time
startup: don't try parsing color names that were not specified
startup: in default mode, display the tail of the file as Pico does
suspension: prevent entering an invalid byte upon resume (with S-Lang)
syntax: gentoo: make it clearer that the file contains two syntaxes
syntax: man, groff: fix the string that introduces a comment
syntax: nanorc: don't color numeric arguments specially
syntax: nanorc: don't color the argument of 'linter' as if invalid
syntax: texinfo: cover also some special cases like @U, @OE and @TeX
tweaks: adjust an error message so it fits all possible cases
tweaks: avoid a clang warning about an expression being treated as NULL
tweaks: avoid a failure with black diamonds in a PDF
tweaks: avoid an unused-variable warning for the tiny version
tweaks: chuck some debugging stuff
tweaks: chuck two useless asserts, and elide a call to strncasecmp()
tweaks: correct two conditions for conditional compilation
tweaks: drop a bunch of useless asserts
tweaks: elide unneeded calls of get_last_chunk_leftedge()
tweaks: fix compilation with --enable-tiny
tweaks: move an include to the file that actually makes use of it
tweaks: put declarations always first, so it will compile on Haiku
tweaks: recognize the empty string as comment inhibitor, instead of NULL
tweaks: remove two superfluous includes
tweaks: rename a constant, to match the corresponding option
tweaks: rename another constant, to be more precise
tweaks: rename a variable, to have more contrast
tweaks: rename four functions, to be more distinct
tweaks: rename two variables, to make a little sense
tweaks: reshuffle some things to condense the code
tweaks: simplify the parsing of color combinations
tweaks: spell an option correctly in NEWS
tweaks: swap ^X and ^L in the help lines of the help viewer
David Lawrence Ramsey (29):
display: when converting tabs, don't go beyond the screen width
docs: consistently describe the -U/-c and -r/-w overrides
docs: mention that boldtext can be overridden also for function tags
docs: mention the default values for comment and whitespace directives
moving: fix the cursor jumping back and forth with non-smooth paging
moving: make vertical movement account for varying chunk width
new feature: allow lines to be softwrapped at whitespace
replacing: make spotlight() account for varying chunk width
softwrap: add new functions for chunks of varying width
softwrap: don't flag EOL too early, nor break continuous text too early
softwrap: in do_mouse(), keep the cursor before a softwrap breakpoint
softwrap: make the changes to actually allow the chunk width to vary
softwrap: prepare for allowing the chunk width to vary
softwrap: remove unneeded caps on the number of chunks to move
syntax: nanorc: properly color a "fill" option with a negative value
text: adjust the comments in do_indent() and do_unindent()
text: make do_unindent() an exact copy of do_indent()
text: make sure commenting is disabled when comment "" was specified
text: normalize the indentation in do_indent() and do_unindent()
text: remove indent-related code from do_unindent()
text: remove the last usage of cols in do_indent() and do_unindent()
text: remove unindent-related code from do_indent()
text: remove unneeded references to cols from the indentation routines
text: update placewewant properly when indenting/unindenting
tweaks: correct a parameter type, and correct two empty initializations
tweaks: fix a typo in NEWS
tweaks: only compensate for a partially-offscreen line in softwrap mode
tweaks: remove unneeded braces, and mark empty parameter list as void
usage: a dash doesn't have to come first among the filenames
Changes between v2.8.4 and v2.8.5:
----------------------------------
Benno Schulenberg (35):
bindings: in the tiny version exclude word jumping from the prompts
bump version numbers and add a news item for the 2.8.5 release
display: don't let a SIGCONT write anything to the screen
display: don't show the cursor while we are busy calculating its position
display: redraw title bar and edit window only when needed
display: show the cursor position also when searching took a while
docs: avoid a double "see" for cross references in the HTML manual
docs: spell "title bar" and "status bar" correctly
gnulib: update to its current state
input: give an appropriate message when there are too many errors
startup: allow negative line and column numbers on the command line
startup: allow positioning the cursor also when reading standard input
startup: always open with the file that was mentioned first
startup: don't crash when opening standard input would fail
startup: don't mark the buffer as modified when in view mode
startup: don't mark the buffer as modified when nothing was read
startup: don't try placing the cursor when reading standard input failed
startup: don't use position history when reading from standard input
suspension: fake a SIGWINCH when coming back out of the background
suspension: remove a duplicate setting of the HUP and TERM handler
syntax: default: allow leading whitespace before a hash comment
tweaks: adjust indentation after preceding changes
tweaks: avoid compiler warning about implicit type
tweaks: be consistent in the spelling of title bar and status bar
tweaks: don't bother calculating the position when we won't show it
tweaks: elide a function that should not be a separate one
tweaks: elide a variable
tweaks: frob a few comments, and elide and #ifndef
tweaks: reduce the scope of three variables, and rename them besides
tweaks: reduce the scope of two variables, and rename them too
tweaks: rename a function and a variable, to better match what they do
tweaks: rename a variable, and frob a couple of comments
tweaks: rename two functions and a variable, and invert its logic
tweaks: reshuffle some stuff, to put related things closer together
tweaks: unglobalize the nodelay_mode variable
Changes between v2.8.3 and v2.8.4:
----------------------------------
Benno Schulenberg (11):
build: correct the inverted logic for the nanorc man page
bump version numbers and add a news item for the 2.8.4 release
gnulib: update to its current state
syntax: default: color also hash comments and email addresses
syntax: php: color "static" again as "function", like it used to be
tweaks: adjust the indentation after the preceding change
tweaks: avoid an unused-variable warning when using --disable-comment
tweaks: do actual screen refreshes in a single call, when possible
tweaks: remove the no-op x$disable tests
tweaks: reorder three items in the Info document
tweaks: reshuffle a few things to reduce duplication
Changes between v2.8.2 and v2.8.3:
----------------------------------
Benno Schulenberg (34):
bindings: allow toggling a new buffer when multiple buffers are enabled
build: don't use a dummy dependency, as it breaks non-GNU makes
build: for Solaris, tell the linker where to find clock_gettime()
build: use backticks to avoid a warning during autoreconf
build: use the "force" mechanism to always run the revision rule
bump version numbers and add a news item for the 2.8.3 release
chars: optimize moving a character left in the non-UTF-8 case
chars: probe for a valid UTF-8 starter byte, instead of overstepping
chars: valid UTF-8 codes are at most 4 bytes long, so look only that far
display: keep the cursor put, also when toggling nohelp or morespace
files: don't ask "save anyway" when user orders to discard the buffer
history: don't save the cursor position for temporary help files
moving: limit the target column when it is beyond the last chunk
replacing: don't let placewewant influence the placement of the cursor
startup: don't call delwin() with NULL, to avoid crashing on Solaris
syntax: makefile: color comments only at start of line or after whitespace
syntax: nanohelp: color also ^6 as a shortcut keystroke
syntax: php: color also variable names, and color more reserved words
syntax: php: recognize also the .phtml and .php7 extensions
syntax: xml: recognize an XML file also by its first line
tweaks: add another warning for an impossible condition
tweaks: adjust whitespace and comments after the preceding change
tweaks: avoid an empty function call in tiny version with line numbers
tweaks: exclude from the tiny version five error-betraying messages
tweaks: exclude from the tiny version two messages that will never occur
tweaks: fix compilation with --enable-tiny ...-help and ...-multibuffer
tweaks: remove an old fault-catching message
tweaks: remove five dummy function definitions from the tiny version
tweaks: rename three empty functions, and reshuffle some others
tweaks: rewrap a couple of old items in NEWS, and fix an article
tweaks: swap a comparison, to be clearer
tweaks: transform the token DISABLE_BROWSER to ENABLE_BROWSER
tweaks: transform the token DISABLE_NANORC to ENABLE_NANORC
tweaks: transform the token DISABLE_TABCOMP to ENABLE_TABCOMP
David Lawrence Ramsey (2):
display: ensure smooth scrolling when the edit window is resized
tweaks: fix several whitespace irregularities
Changes between v2.8.1 and v2.8.2:
----------------------------------
Benno Schulenberg (64):
bindings: allow using <Backspace> to scroll back up in the help viewer
bindings: allow using '/' to start a search in the help viewer
bindings: show Home and End in browser help text, instead of M-| and M-?
browser: make ^End work properly by fixing a paste error
build: make --enable-help properly depend on --enable-multibuffer
bump version numbers and add a news item for the 2.8.2 release
display: initialize the colors only when starting to draw the content
display: push the titlebar to the screen as soon as it has been drawn
docs: add an item to the FAQ, about pasting from Windows to a remote nano
docs: harmonize the nanorc man page and Info document a bit
docs: in the FAQ, extend the answer to the pasting problem
docs: reword the main paragraph of the man page
docs: update the list of who authored what
gnulib: update to its current state in git
help: after a search, show the cursor only when something was found
help: allocate enough space for the descriptions, so we don't crash
help: don't crash when nano was started with --noread
help: don't cycle forward in the buffers when exiting from help
help: keep the same position also after M-\ or M-/ has been used
help: keep the text at the same position when the screen is resized
help: remove the final blank line, so <End> does the same as all <Down>
help: set tabsize to the default width while showing a help text
help: suppress nano's name and number to make it clearer this is help
help: use a dedicated syntax to color shortcuts in a help text
help: when searching, do it forward, without case, and without regexes
input: avoid crashing when resizing the window during verbatim input
options: allow -U (--quickblank) to be used in the tiny version
scrolling: don't bother to limit the number of lines to step back
startup: warn about a strange character size only in the UTF-8 case
syntax: nanohelp: change the hue of the keystrokes to match sample.nanorc
tweaks: add a warning for a condition that should never occur
tweaks: add three warnings for conditions that should never occur
tweaks: avoid an unused-variable warning
tweaks: be more precise about what --disable-extra does
tweaks: check for an empty needle in a central place
tweaks: complete the exclusion of backups and such from the tiny version
tweaks: condense two bits of code, and drop two asserts
tweaks: distinguish (in the comments) between buffers and linestructs
tweaks: drop a bunch of asserts
tweaks: elide a function that is used just once
tweaks: fix compilation with --enable-tiny --enable-color --enable-speller
tweaks: fix two typos
tweaks: remove a superfluous check
tweaks: remove a superfluous strlen() call from the reverse searches
tweaks: remove some superfluous placements of the cursor
tweaks: remove two superfluous calls of wnoutrefresh()
tweaks: rename a constant, to match the corresponding option
tweaks: rename a function, to be more accurate
tweaks: rename a function, to better suit what it does
tweaks: rename another function, to better describe what it does
tweaks: rename a parameter, to be more imperative
tweaks: rename a variable, use a faster comparison, and reshuffle a bit
tweaks: rename one variable again
tweaks: rename some more of these 'rev_start' variables
tweaks: rename three variables, elide another, and reshuffle some stuff
tweaks: rename two variables, because this 'rev_start' is irksome
tweaks: reshuffle a couple of lines to avoid a duplicate call
tweaks: reshuffle help-text initialization, to elide a save-and-restore
tweaks: reshuffle some more stuff, and rename two more variables
tweaks: swap the names of two variables, to make more sense
tweaks: transform the token DISABLE_MOUSE to ENABLE_MOUSE
tweaks: transform the token DISABLE_MULTIBUFFER to ENABLE_MULTIBUFFER
tweaks: use the logic from revstrstr() also in mbrevstrcasestr()
tweaks: use the logic from revstrstr() also in revstrcasestr()
David Lawrence Ramsey (1):
docs: mention that also numbercolor overrides boldtext
Rishabh Dave (1):
new feature: add a search facility to the help viewer
Changes between v2.8.0 and v2.8.1:
----------------------------------
Benno Schulenberg (33):
bindings: make ^Home and ^End go to top and tail of buffer
bindings: make ^Up/^Down go to first/last row in the file browser
bindings: use arrows instead of words to designate the cursor keys
bump version numbers and add a news item for the 2.8.1 release
copyright: update the year in --version, and use the standard hyphen
copyright: update the years, use ranges, and explain this usage
display: check the correct character for being double-width
display: with softwrap, show the cursor where the eye expects it
docs: correct an answer to a question in the FAQ
docs: mention another difference with Pico in the Info document
docs: remove the self-referencing stuff and the changelog from the FAQ
docs: trim the TODO file a bit, and put the more important items first
editing: avoid creating blank lines when using autoindent
files: check also for write errors when prepending, not just read errors
gnulib: update to current state
linting: treat a tab as one "column", not eight
linting: when no is said to a file, remove all corresponding entries
moving: when determining where we are on the screen, use placewewant
tweaks: adjust a couple of comments
tweaks: again use memory on the stack instead of malloc() and free()
tweaks: close the backup file also when we skip making a backup
tweaks: delete a function that hasn't been used since 2005
tweaks: delete unnecessary function prototypes
tweaks: elide a variable and a pair of braces
tweaks: fix some inconsistencies in an old Changelog
tweaks: fix two typos in the NEWS file
tweaks: group ^D and ^H together in the help lines
tweaks: keep the help text aligned, also with the narrow arrows
tweaks: put M-A before ^6, to look better above M-6 in the help lines
tweaks: put unshifted shortcuts ^6 and M-6 first, instead of ^^ and M-^
tweaks: reduce the number of additions that actual_x() performs
tweaks: replace a function call or a macro with a hard number
tweaks: use memory on the stack instead of calling malloc() and free()
David Lawrence Ramsey (5):
bindings: use arrows instead of words for search history too
display: show '<' and '>' placeholders for characters that get split
input: support escape sequences for ^Home and ^End
scrolling: properly compensate for the onscreen chunks
tweaks: avoid a compilation warning
Kamil Dudka (1):
backup: prevent a symlink attack by operating on the file descriptor
Mike Frysinger (2):
configure: fix up word boundary regex logic now that we have gnulib
configure: ignore the REG_ENHANCED test when we use gnulib
Changes between v2.7.5 and v2.8.0:
----------------------------------

View File

@@ -5975,7 +5975,7 @@ GNU nano 1.1.8 - 2002.03.30
do_insertfile()
- Handle cancel from ExtCmd properly. (David Benbennick)
read_file()
- Abort if we read a file of 0 lines (num_lines == 0), fixes BUG #70.
- Abort if we read a file of 0 lines (num_lines == 0). Fixes bug #70.
- Reverse tests to stop segfault on editing a new file of 0 lines.
(David Benbennick)
- Change input var to one char instead of array. (David Benbennick)
@@ -6108,8 +6108,8 @@ GNU nano 1.1.7 - 2002.03.05
- Added Noconvert option to man page. (DLR)
- nano.c:
justify_format(), do_justify()
- Various fixes for starting blank spaces, spaces after
punctuation, & segfault with quoting strings. (David Benbennick)
- Various fixes for starting blank spaces, spaces after
punctuation, & segfault with quoting strings. (David Benbennick)
do_justify()
- Don't continue to justify string if it's indented more
(quoting wise) than the beginning of the justification.
@@ -6139,8 +6139,8 @@ GNU nano 1.1.7 - 2002.03.05
- NANO_SMALL test was backwards. (Ken Tyler)
- winio.c:
strlenpt()
- Changed main function to strnlenpt() for new justify changes,
original function now just a stub.
- Changed main function to strnlenpt() for new justify changes,
original function now just a stub.
- nanorc.sample
- Mention unset in the sample nanorc.
- po/ca.po, po/es.po:
@@ -6208,7 +6208,7 @@ nano-1.1.6 - 2002.01.25
- Temporarily unset REVERSE_SEARCH if it's set. (Rocco Corsi)
do_suspend()
- Call tcsetattr() to restore the old terminal settings, so
tcsh can use ^C after suspend for example (fixes BUG #68).
tcsh can use ^C after suspend for example. Fixes bug #68.
do_wrap()
- Move "right" increment to part where new line is created,
should change (fix?) some wrapping problems with autoindent.
@@ -6368,10 +6368,10 @@ nano-1.1.4 - 2001.12.11
- nano.c:
main()
- Add Esc-[-[IGL] keys for FreeBSD Console (PgUp,PgDn,Insert).
- Added better Hurd support for function keys (Alt-V,U,9,@,F).
- Added better Hurd support for function keys (Alt-V,U,9,@,F).
signal_init()
- do SIG_IGN for the SIGTSTP sigaction regardless of whether
we have _POSIX_VDISABLE or not (more Hurd fixes)
- do SIG_IGN for the SIGTSTP sigaction regardless of whether
we have _POSIX_VDISABLE or not (more Hurd fixes)
help_init()
- Typo fixes and additions to the new help texts.
do_curpos()
@@ -6487,10 +6487,10 @@ nano-1.1.2 - 2001.10.03
- Take control-space out of -tiny build, unneeded.
- cut.c:
cut_marked_segment()
- Add magic line when cutting a selection including filebot
(discovered by DLR, fixed by DLR & Chris, fixes BUG #66).
- Add magic line when cutting a selection including filebot.
Fixes bug #66. (discovered by DLR, fixed by DLR & Chris)
do_cut_text()
- Don't recenter the line when cutting one line (DLR) (Bug #65).
- Don't recenter the line when cutting one line. Fixes bug #65. (DLR)
- faq.html:
- Notes about the Free Translation Project.
- Debian additions.
@@ -6681,14 +6681,14 @@ nano-1.1.0 - 2001.07.15
add_to_cutbuffer()
- Remove useless statements. (Rocco)
cut_marked_segment()
- Add bizarre copy of bot node, else *BSD goes ballistic (fixes
BUG #60).
- Add bizarre copy of bot node, else *BSD goes ballistic. Fixes
bug #60.
- Added 'destructive' argument. Allows the selected text to be
added to the cutbuffer without changing the contents of the
file. This allows writing selection to separate files.
do_cut_text()
- If the line is empty when using -k and wasn't already added,
create a dummy line and add it to the cutbuffer (fixes bug #61)
create a dummy line and add it to the cutbuffer. Fixes bug #61.
- Reset marked_cut if we blow away the cutbuffer.
- Moved the case of current == mark_beginbuf into cut_marked
segment, so do_writeout could call it when writing selection to
@@ -6719,7 +6719,7 @@ nano-1.1.0 - 2001.07.15
- move.c:
page_up()
- Rewritten with a loop to make screen updates work when
mark is set (fixes bug #59).
mark is set. Fixes bug #59.
do_home(), do_end()
- Don't keep cutbuffer.
- nano.1:
@@ -6756,7 +6756,7 @@ nano-1.1.0 - 2001.07.15
- Optimizations, remove "$" goes-to-last-line, less messages. (Rocco)
do_replace()
- If we manage to make it in somehow with VIEW_MODE on, abort
nicely (fixes BUG #59).
nicely. Fixes bug #59.
- utils.c
strcasestr()
- Replaced by mutt's mutt_stristr function, because the thought
@@ -6844,13 +6844,13 @@ nano-1.0.0 - 2001.03.22
- move.c:
page_down()
- Check for totlines < editwinrows in check for superfluous
edit update (fixed BUG #57).
edit update. Fixes bug #57.
- search.c:
print_replaced()
- s/occurence/occurrence typos. (Jordi)
search_init()
- If using Pico mode and regex and same answer is entered, use
last_search string instead of answer (fixes BUG #56).
last_search string instead of answer. Fixes bug #56.
- nano.texi:
- Meta-Z correction and grammar in --enable-tiny desc. (Neil Parks)
@@ -6868,7 +6868,7 @@ nano-0.9.99pre3 - 2001.02.19
- ALL_LINGUAS: added hu and ca.
- cut.c:
do_cut_text()
- marked text cut fixes (Rocco) (Fixes bug #54).
- Marked text cut fixes. Fixes bug #54. (Rocco)
- nano.c:
do_delete()
- Added check for current->next == fileptr, as we have a magic
@@ -7016,7 +7016,7 @@ General -
for now.
- Moved keypad() calls for PDCurses from main() to window_init()
so the keypad continues to work after a Meta-X, for example.
Fixed bug #51.
Fixes bug #51.
- faq.html:
- Fix typos and small mistakes. (Jordi)
- files.c:
@@ -7038,7 +7038,7 @@ General -
- move.c:
page_down()
- Don't do an edit_update when there is only one page of text
(fileage == edittop && filebot == editbot). Fixes Bug #50.
(fileage == edittop && filebot == editbot). Fixes bug #50.
- nano.c:
main()
- Reorder the getopt options to be more or less alphabetical
@@ -7080,7 +7080,7 @@ General
uncutting marked text at filebot. (Ryan Krebs)
- files.c:
read_file()
- If we encounter an error and insert is not set, run new_file().
- If we encounter an error and insert is not set, run new_file()
(bug discovered by Ben Roberts).
write_file()
- Change open call flags, basically copy joe's way of doing it so
@@ -7097,8 +7097,8 @@ General
modify_control_key. Removed #ifdef _POSIX_VDISABLE check
around Control-S,Q,Z handlers because we need it now for
the Alt-Alt-x code.
- Added --view option to getopt_long() call. Bug discovered
by Rocco Corsi.
- Added --view option to getopt_long() call (bug discovered by
Rocco Corsi).
help_init()
- Fix off by one error that was making ^G help in normal mode and
^_ in Pico mode not be displayed in the help (bug discovered by
@@ -7292,7 +7292,7 @@ nano 0.9.20 - 2000.11.18
- nano.c:
keypad_on()
- New function, toggles turning the keypad on and off in edit and
bottomwin(). Added call to this in finish(), fixes bug #45.
bottomwin(). Added call to this in finish(). Fixes bug #45.
- search.c
findnextstr()
- New arg for begin_x variable, basically a rewrite that
@@ -7359,7 +7359,7 @@ nano 0.9.18 - 2000.09.18
- cut.c:
do_cut_text()
- Don't immediately abort if we're on filebot and the marker is
set (fixes bug #42).
set. Fixes bug #42.
- files.c:
open_file()
- Fix for bug #44. (Rocco Corsi)
@@ -7372,9 +7372,9 @@ nano 0.9.18 - 2000.09.18
available, allows nano to work with cygwin.
- Added gettext calls to enable/disable strings. (Jordi)
- Revamped a great deal of the F-key and keypad key handling,
because we not longer use keypad() (see below).
because we no longer use keypad() (see below).
- Removed keypad() call because nano was not working with the
keypad in many terms, which is very bad.
keypad on many terminals, which is very bad.
- Made insert key call do_insertfile().
do_toggle()
- Rewrote function to allow NOHELP toggle to work on systems
@@ -7450,7 +7450,7 @@ nano-0.9.17 - 2000.09.04
findnextstr():
- Added reset for placewewant. (Ben Roberts)
- Fixed check for string that only occurs on the same line failing
(discovered by Ken Tyler).
(bug discovered by Ken Tyler).
nano-0.9.16 - 2000.08.09
- cut.c:
@@ -7481,7 +7481,7 @@ nano-0.9.15 - 2000.08.03
with --with-slang or --without-slang
- nano.c:
splice_node()
- New function, abstracts linking in nodes. Fixes bug #36.
- New function, abstracts linking in nodes. Fixes bug #36.
null_at()
- New function, nulls a string at a given index and realigns it.
delete_buffer()
@@ -7555,7 +7555,7 @@ nano-0.9.13 - 2000.07.23
- More intelligent emergency-save filename selection. (Rob)
do_spell():
- Changed exit semantics a bit so that aspell wouldn't get
all screwy (bug discovered by Joshua Jensen.
all screwy (bug discovered by Joshua Jensen).
- files.c:
read_file():
- Added init of buf variable, hopefully this will stop the
@@ -7606,8 +7606,8 @@ nano-0.9.12 - 2000.07.07
- Magic Line code in read_file (Rob)
- nano.c:
- Removed dual alt_speller variables, oops! (Rocco Corsi)
- Removed unnecessary do_oldspell function. (Rocco Corsi). Added
SMALL_NANO #ifdef around actual spell function.
- Removed unnecessary do_oldspell function. (Rocco Corsi)
- Added SMALL_NANO #ifdef around actual spell function.
- Moved page_up() to move.c where is belongs.
- Corrected FIXME in do_enter with explanation. (Rob)
- Fixed FIXME in do_justify, resulted in creation of

View File

@@ -1,6 +1,13 @@
Improvements in GNU nano
========================
Since 2.8.0:
- Softwrapping can be done at whitespace (with --soft --atblanks).
- The ^G help texts have become searchable (with ^W and M-W).
- Ctrl+Home and Ctrl+End jump to start and end of file.
- In softwrap mode the cursor now moves per visual row instead of
per logical line, and the screen will scroll per row.
Since 2.7.0:
- The keystroke ^] to complete a fragment to an existing full word.
- The ability to display line numbers in front of the text (M-#).

123
NEWS
View File

@@ -1,3 +1,54 @@
2017.07.21 - GNU nano 2.8.6 "Kekulé" offers a new feature: the ability
to do softwrapping between words -- at whitespace --
instead of always at the edge of the screen. This can
be activated with -a or --atblanks or 'set atblanks'
together with the softwrap option. This release further
fixes a handful of rare display glitches, fixes a build
failure on AIX, harmonizes the quoting rules in the rc
files, and renames the option 'cut' to 'cutfromcursor'
(please update your nanorc files before 2020).
2017.06.25 - GNU nano 2.8.5 "Farouche" avoids a crash when waking from
a suspension that was induced from the outside, allows
negative line and column numbers on the command line,
avoids some flickering when resizing the screen while
in the file browser, opens files in the order they were
mentioned on the command line, and does not pretend to
have woken from suspension when receiving a SIGCONT.
2017.05.21 - GNU nano 2.8.4 "Our Version of Events" includes the nanorc
man page again.
2017.05.18 - GNU nano 2.8.3 "Hirsch" fixes a misplacement of the spotlight
during interactive replacing, avoids build failures on AIX
and Solaris, fixes a crash on Solaris, speeds up backwards
searching, improves PHP syntax highlighting, and no longer
asks “save anyway?” when the user ^Q discards the buffer.
2017.05.04 - GNU nano 2.8.2 "Krats" adds another new feature: it makes
the ^G help texts searchable with ^W. Apart from that,
it fixes a crash when resizing the window in the middle
of verbatim input, avoids an unlikely crash when used
without UTF-8 support in some locales, avoids redrawing
the screen twice when switching between buffers while
line numbers are active, and works around a coloring
bug on musl. Plus tweaks to the documentation; plus
translation updates for fifteen languages.
2017.04.12 - GNU nano 2.8.1 "Ellert" fixes build failures on MacOS and
on musl, fixes scrolling problems in softwrap mode when
double-width characters on row boundaries are involved,
shows double-width characters as ">" and "<" when split
across two rows, moves the cursor more predictably (at
the cost of sometimes putting it on the second "half"
of a character), avoids creating lines that consist of
only blanks when using autoindent, makes ^Home and ^End
go to the start and end of the file (on terminals that
support those keystrokes), places the cursor better when
linting, lets the linter ask only once whether to open
an included file, and adds bindings for ^Up and ^Down
in the file browser. Don't sit on your hands.
2017.03.31 - GNU nano 2.8.0 "Axat" makes it easier to move around in
softwrapped lines: the Up and Down keys now step from
visual row to visual row instead of jumping between
@@ -8,7 +59,7 @@
of always per logical line. On an entirely different
front: nano now makes use of gnulib, to make it build
on more platforms. In short: there were many internal
changes, not many user-visible ones (apart form the
changes, not many user-visible ones (apart from the
new softwrap navigation). The conversion to gnulib
was done by Mike Frysinger, the softwrap overhaul by
David Ramsey.
@@ -51,8 +102,8 @@
related to using line numbers in softwrap mode, allows to
use the PageUp and PageDown keys together with Shift on
VTE-based terminals, stops the help lines from flickering
during interactive replacing, makes a "set fill" override
an earlier "set nowrap", properly restores the selected
during interactive replacing, makes a 'set fill' override
an earlier 'set nowrap', properly restores the selected
region after an external spell check, and improves a few
other tidbits. If you should find any more bugs, please
run 'man nano | grep bugs' and report them there.
@@ -93,7 +144,7 @@
input (M-V followed by a six-digit hexadecimal number which
must start with 0 or 10), avoids a crash when resizing the
window during Verbatim input, doesn't drop a keystroke after
having been suspended, and replaces the beginning-of-line
having been suspended, and replaces the beginning-of-line
anchor (^) just once per line. There are also several tiny
improvements in screen rendering and key handling. Come get
your hair tousled!
@@ -242,13 +293,12 @@
handling of --tempfile mode, and better handling of
command line arguments when also attempting to specify
+<line number>. As always, please file any bugs you
find at the Savannah page for nano, at
https://savannah.gnu.org/bugs/index.php?42639 and
thanks for using nano.
find via https://savannah.gnu.org/bugs/?group=nano
and thanks for using nano.
2014.06.02 - GNU nano 2.3.4 won't leave you high, won't leave you dry. This
release contains only a small number of fixes, but in
particular allows nano to compile on non-UTF-8 curses
2014.06.02 - GNU nano 2.3.4 won't leave you high, won't leave you dry.
This release contains only a small number of fixes, but
in particular allows nano to compile on non-UTF-8 curses
implementations (i.e. libncursesw). Other small fixes to
the undo implementation and the default syntax config are
also included. As always, Share and Enjoy!
@@ -293,11 +343,11 @@
has been added on top of the existing file extension
and header support already available. Secondly, cursor
position can be saved between editing sessions with
the -P or --poslog command-line flag, or via "set poslog"
the -P or --poslog command-line flag, or via 'set poslog'
in your .nanorc. Also included are some fixes for
compilation with g++, and better handling of issues
writing the backup file, which should reduce the need
for the "set allow_insecure_backup" nanorc option.
for the 'set allow_insecure_backup' nanorc option.
Don't stop, get it get it, don't stop, get it get it.
@@ -317,7 +367,7 @@
being used out of crontab). For very strange situations
(such as where you cannot change the permissions on the
file you're writing), there is a new rc file option
"allow_insecure_backup" to be even more permissive and
'allow_insecure_backup' to be even more permissive and
allow the write to proceed. Also included are some
syntax highlighting updates, and that is about it.
Keep fighting the good fight children.
@@ -508,16 +558,16 @@
an internal error occurs in the undo code, and fixes for
various combinations of configure-time options and
compiler flags. Also included is new support for
changing the rc file name at configure time, and
using GNU-style regexes for word-boundaries on systems
which do not support them natively, as well as the ever
popular translation updates. Rock the tarball.
changing the rc file name at configure time, and using
GNU-style regexes for word-boundaries on systems which
do not support them natively, as well as the ever popular
translation updates. Rock the tarball.
2008.08.09 - GNU nano 2.1.4 "I told you so!" is released. This release
includes fixes for several severe issues with the new
undo/redo code. Also the behavior of writing
files when using backup mode has changed as well: if writing
the backup file fails, nano will not attempt to write the
undo/redo code. Also the behavior of writing files when
using backup mode has changed as well: if writing the
backup file fails, nano will not attempt to write the
current file. This should help folks who enjoy "extreme
text editing", i.e. editing files on file systems which
are likely to run out of space; see Savannah bug #24000.
@@ -541,7 +591,7 @@
compiling on AIX, and a segfault when making the terminal
window too small. Rest in Peace Tim and George!
2008.04.01 - GNU nano 2.1.1 wont get fooled again. This release contains
2008.04.01 - GNU nano 2.1.1 won't get fooled again. This release contains
fixes for the new user-rebindable keys (in particular
bracket match which was mis-bound), and various
problems with translations and configure-related
@@ -706,7 +756,7 @@
focuses mostly on bugfixes, which include better
handling of the cursor at the statusbar prompt, support
for certain combinations of Shift and keypad keys in
both normal and --rebind-keypad mode, a fix for a minor
both normal and --rebindkeypad mode, a fix for a minor
display problem after some searches, a real fix for a
long-standing segfault when displaying overly long
lines, and a real fix for nano's not hanging up properly
@@ -1223,28 +1273,27 @@
Have fun with it.
2001.03.22 - GNU Nano 1.0 is released! The autoindent wrapping bug
has been fixed, as well as strange bug when using Pico
has been fixed, as well as a strange bug when using Pico
mode and regex search. There have also been some minor
spelling and documentation updates. As stated on the
website, there are currently no known bugs with nano,
but some will pop up eventually and they will be
addressed in subsequent releases. We hope you enjoy
this first stable release of nano, and as always,
feedback is welcome! nano@nano-editor.org.
feedback is welcome! <nano@nano-editor.org>
2001.02.19 - Nano 0.9.99pre3 brings a lot of changes! The most
important being that nano is now officially a GNU
program. Some changes have been made for GNU
compatibility (like the default list of shortcuts, "^G
Get Help" is now Listed and "^_ Goto Line" is not). The
Yes/No/All keys have finally been internationalized
also. All in all, quite a few changes, considering nano
is supposed to be in a code freeze. But there are the
usual helping of bugfixes, a nasty bug when cutting text
in -k mode and some compatibility issues with older
ncurses libraries have also been fixed. All in all, a
lot to see.
2001.02.19 - Nano 0.9.99pre3 brings a lot of changes! The most important
being that nano is now officially a GNU program. Some
changes have been made for GNU compatibility (like in the
default list of shortcuts: "^G Get Help" is now listed
and "^_ Goto Line" is not). The Yes/No/All keys have
finally been internationalized also. All in all, quite
a few changes, considering nano is supposed to be in
a code freeze. But there are the usual helping of
bugfixes, a nasty bug when cutting text in -k mode and
some compatibility issues with older ncurses libraries
have also been fixed. All in all, a lot to see.
2001.01.31 - Nano 0.9.99pre2 is released. Not surprisingly, all that is
new is bugfixes, bugfixes, bugfixes. There were a few
@@ -1253,7 +1302,7 @@
is now a preliminary (read: needs testing) fix for
resizing the editor in any mode other than normal edit
mode. Other fixes include some more tab completion
segfaults, and an silly segfault that occurred when
segfaults, and a silly segfault that occurred when
successfully writing a file on the 2nd try (i.e. after
an initial write error). Slowly but surely, on toward
1.0 we travel.

11
README
View File

@@ -65,5 +65,12 @@ Bug Reports
Current Status
GNU nano has reached its seventh milestone, 2.6.x. Since 2.5.0, it
is a "rolling" release: bug fixing and development go hand in hand.
Since version 2.5.0, GNU nano has abandoned the distinction between
a stable and a development branch: it is now on a "rolling" release
-- fixing bugs and adding new features go hand in hand.
Copyright Years
When in any file of this package a copyright notice mentions a
year range (such as 1999-2011), it is a shorthand for a list of
all the years in that interval.

45
TODO
View File

@@ -1,29 +1,12 @@
A list of desired features
--------------------------
Vague musings:
- FriBidi support?
- Make matching bracket searches sophisticated enough to skip over
brackets inside comments?
- Allow indentation of marked text by spaces as well as tabs?
- Allow indentation to add just enough columns to reach the nearest
multiple of tabsize, rather than always adding tabsize columns?
- Allow conversion between different character sets.
- Allow setting marks (saved positions, not to be confused with the mark
set via Ctrl-^) at various lines and/or columns in the buffer, and
allow movement between them with a single keystroke?
- Allow searching for and replacing newlines?
See also https://savannah.gnu.org/bugs/?47053.
- New regression framework built on expect?
- Add the ability to move to different lines of the screen with a single
keystroke, e.g. M-` (M-~) to go to the top line, M-& (M-7) to go to
the center line, and M-' (M-") to go to the last line?
Somewhat urgent:
- Allow text searches in the help viewer.
See https://savannah.gnu.org/bugs/?28994.
- Make undo/redo work also for justifying and indenting.
- Detect when text is being pasted, so that we can handle it faster.
See https://savannah.gnu.org/bugs/?40060.
- Allow to define and execute a macro: a stored sequence of keystrokes.
See https://savannah.gnu.org/bugs/?50314.
- Allow color syntaxes to apply to more than just color, so that we can
e.g. specify a different alternate spell checker depending on which
file type we have open.
@@ -31,6 +14,20 @@ Somewhat urgent:
the command's output -- that is: generalize the spell-check flow.
See also https://savannah.gnu.org/bugs/?28993.
Vague musings:
- FriBidi support?
- Allow setting marks (saved positions, not to be confused with the
mark set via Ctrl-^) at various lines and/or columns in the buffer,
and allow movement between them with a single keystroke?
- Make matching bracket searches sophisticated enough to skip over
brackets inside comments?
- Allow indentation of marked text by spaces as well as tabs?
- Allow indentation to add just enough columns to reach the nearest
multiple of tabsize, rather than always adding tabsize columns?
For version 2.8:
- Allow text searches in the help viewer. [DONE]
For version 2.4:
- Handle window resizes better. After we've resized, we should stay
wherever we were before we resized, as Pico does. [DONE]
@@ -63,14 +60,13 @@ For version 2.0:
For version 1.2:
- Single-line scroll up/down? [DONE]
- Color syntax highlighting? (Certainly seems like there's a demand for
it.) [DONE]
- .nanorc [DONE]
- Color syntax highlighting? (There seems to be a demand for it.) [DONE]
- Support for a .nanorc file. [DONE]
- Backup making (filename~)? [DONE]
- Search/replace string history. [DONE]
- Implement Pico's -j and -g flags, as they are pretty easy to do. [DONE]
- Make mouse support work with clicking on the shortcuts (-m). [DONE]
- Implement -o (chroot of sorts). [DONE]
- Implement -o (--operatingdir, a chroot of sorts). [DONE]
- Allow -r to take a negative argument, meaning right margin instead of
left (allows resizing that way), formerly -W arg. [DONE]
@@ -81,7 +77,6 @@ For version 1.0:
- Allow nano to be resized in X. [DONE]
- On PageUp/Down, put the cursor on the first line (like Pico), not the
center line. [DONE]
- Rewrite edit_refresh, if at all possible. [DONE]
- Implement justify function. [DONE]
- Cut to end of line. [DONE]
- Built-in speller command. [DONE]

View File

@@ -2,9 +2,10 @@
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="4084b3a1094372b960ce4a97634e08f4538c8bdd"
gnulib_hash="c7711db84f251d9e580d9fa53a070fa97ae89095"
modules="
futimens
getdelim
getline
getopt-gnu

View File

@@ -1,7 +1,7 @@
# Configuration for GNU nano - a small and user-friendly text editor
#
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
# 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc.
# Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc.
# Copyright (C) 2014, 2017 Mike Frysinger
#
# GNU nano is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
@@ -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.8.0], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [2.8.6], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.14])
@@ -63,9 +63,14 @@ AC_CHECK_HEADERS(libintl.h limits.h pwd.h termios.h sys/param.h)
dnl Checks for options.
AC_ARG_ENABLE(browser,
AS_HELP_STRING([--disable-browser], [Disable built-in file browser]))
if test "x$enable_browser" = xno; then
AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in file browser.])
AS_HELP_STRING([--disable-browser], [Disable the built-in file browser]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_browser" != xyes; then
enable_browser=no
fi
fi
if test "x$enable_browser" != xno; then
AC_DEFINE(ENABLE_BROWSER, 1, [Define this to enable the built-in file browser.])
fi
AC_ARG_ENABLE(color,
@@ -85,7 +90,7 @@ else
fi
AC_ARG_ENABLE(comment,
AS_HELP_STRING([--disable-comment], [Disable comment/uncomment functions]))
AS_HELP_STRING([--disable-comment], [Disable the comment/uncomment function]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_comment" = xyes; then
AC_MSG_ERROR([--enable-comment cannot work with --enable-tiny])
@@ -93,22 +98,37 @@ if test "x$enable_tiny" = xyes; then
enable_comment=no
fi
fi
if test "x$disable_comment" != xyes; then
if test "x$enable_comment" != xno; then
AC_DEFINE(ENABLE_COMMENT, 1, [Define this to enable the comment/uncomment function.])
fi
if test "x$enable_comment" != xno; then
AC_DEFINE(ENABLE_COMMENT, 1, [Define this to enable the comment/uncomment function.])
fi
AC_ARG_ENABLE(extra,
AS_HELP_STRING([--disable-extra], [Disable extra features, currently only easter eggs]))
AS_HELP_STRING([--disable-extra], [Disable the Easter egg]))
if test "x$enable_extra" = xno; then
AC_DEFINE(DISABLE_EXTRA, 1, [Define this to disable extra stuff.])
fi
AC_ARG_ENABLE(help,
AS_HELP_STRING([--disable-help], [Disable help functions]))
if test "x$enable_help" = xno; then
AC_DEFINE(DISABLE_HELP, 1, [Define this to disable the help text display.])
AS_HELP_STRING([--disable-help], [Disable the built-in help texts]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_help" = xyes; then
if test "x$enable_multibuffer" != xyes; then
AC_MSG_ERROR([--enable-help needs --enable-multibuffer to work])
fi
else
enable_help=no
fi
fi
if test "x$enable_multibuffer" = xno; then
if test "x$enable_help" = xyes; then
AC_MSG_ERROR([--enable-help cannot work with --disable-multibuffer])
else
# Disabling multibuffer silently disables the help texts.
enable_help=no
fi
fi
if test "x$enable_help" != xno; then
AC_DEFINE(ENABLE_HELP, 1, [Define this to enable the Ctrl+G help texts.])
fi
AC_ARG_ENABLE(histories,
@@ -118,7 +138,7 @@ if test "x$enable_histories" = xno; then
fi
AC_ARG_ENABLE(justify,
AS_HELP_STRING([--disable-justify], [Disable justify/unjustify functions]))
AS_HELP_STRING([--disable-justify], [Disable the justify/unjustify functions]))
if test "x$enable_justify" = xno; then
AC_DEFINE(DISABLE_JUSTIFY, 1, [Define this to disable the justify routines.])
fi
@@ -133,52 +153,69 @@ if test "x$enable_tiny" = xyes; then
enable_linenumbers=no
fi
fi
if test "x$disable_linenumbers" != xyes; then
if test "x$enable_linenumbers" != xno; then
AC_DEFINE(ENABLE_LINENUMBERS, 1, [Define this to enable line numbering.])
fi
if test "x$enable_linenumbers" != xno; then
AC_DEFINE(ENABLE_LINENUMBERS, 1, [Define this to enable line numbering.])
fi
AC_ARG_ENABLE(mouse,
AS_HELP_STRING([--disable-mouse], [Disable mouse support (and -m flag)]))
if test "x$enable_mouse" = xno; then
AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable the mouse support.])
AS_HELP_STRING([--disable-mouse], [Disable mouse support]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_mouse" != xyes; then
enable_mouse=no
fi
fi
if test "x$enable_mouse" != xno; then
AC_DEFINE(ENABLE_MOUSE, 1, [Define this to enable mouse support.])
fi
AC_ARG_ENABLE(multibuffer,
AS_HELP_STRING([--disable-multibuffer], [Disable multiple file buffers]))
if test "x$enable_multibuffer" = xno; then
AC_DEFINE(DISABLE_MULTIBUFFER, 1, [Define this to disable multiple file buffers.])
if test "x$enable_tiny" = xyes; then
if test "x$enable_multibuffer" != xyes; then
enable_multibuffer=no
fi
fi
if test "x$enable_multibuffer" != xno; then
AC_DEFINE(ENABLE_MULTIBUFFER, 1, [Define this to enable multiple file buffers.])
fi
AC_ARG_ENABLE(nanorc,
AS_HELP_STRING([--disable-nanorc], [Disable use of .nanorc files]))
if test "x$enable_nanorc" = xno; then
AC_DEFINE(DISABLE_NANORC, 1, [Define this to disable the use of .nanorc files.])
else
AS_HELP_STRING([--disable-nanorc], [Disable the use of .nanorc files]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_nanorc" != xyes; then
enable_nanorc=no
fi
fi
if test "x$enable_nanorc" != xno; then
AC_DEFINE(ENABLE_NANORC, 1, [Define this to enable the use of .nanorc files.])
nanorc_support=yes
fi
AC_ARG_ENABLE(operatingdir,
AS_HELP_STRING([--disable-operatingdir], [Disable setting of operating directory (chroot of sorts)]))
AS_HELP_STRING([--disable-operatingdir], [Disable the setting of an operating directory]))
if test "x$enable_operatingdir" = xno; then
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of the operating directory (chroot of sorts).])
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of an operating directory (a chroot of sorts).])
fi
AC_ARG_ENABLE(speller,
AS_HELP_STRING([--disable-speller], [Disable spell checker functions]))
AS_HELP_STRING([--disable-speller], [Disable the spell-checker functions]))
if test "x$enable_speller" = xno; then
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell checker functions.])
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell-checker functions.])
fi
AC_ARG_ENABLE(tabcomp,
AS_HELP_STRING([--disable-tabcomp], [Disable tab completion functions]))
if test "x$enable_tabcomp" = xno; then
AC_DEFINE(DISABLE_TABCOMP, 1, [Define this to disable the tab completion functions for filenames and search strings.])
AS_HELP_STRING([--disable-tabcomp], [Disable the tab-completion functions]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_tabcomp" != xyes; then
enable_tabcomp=no
fi
fi
if test "x$enable_tabcomp" != xno; then
AC_DEFINE(ENABLE_TABCOMP, 1, [Define this to have tab completion for filenames and search strings.])
fi
AC_ARG_ENABLE(wordcomp,
AS_HELP_STRING([--disable-wordcomp], [Disable the word completion function]))
AS_HELP_STRING([--disable-wordcomp], [Disable the word-completion function]))
if test "x$enable_tiny" = xyes; then
if test "x$enable_wordcomp" = xyes; then
AC_MSG_ERROR([--enable-wordcomp cannot work with --enable-tiny])
@@ -186,16 +223,14 @@ if test "x$enable_tiny" = xyes; then
enable_wordcomp=no
fi
fi
if test "x$disable_wordcomp" != xyes; then
if test "x$enable_wordcomp" != xno; then
AC_DEFINE(ENABLE_WORDCOMPLETION, 1, [Define this to enable the word completion function.])
fi
if test "x$enable_wordcomp" != xno; then
AC_DEFINE(ENABLE_WORDCOMPLETION, 1, [Define this to enable the word-completion function.])
fi
AC_ARG_ENABLE(wrapping,
AS_HELP_STRING([--disable-wrapping], [Disable all wrapping of text (and -w flag)]))
AS_HELP_STRING([--disable-wrapping], [Disable all hard-wrapping of text]))
if test "x$enable_wrapping" = xno; then
AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable all text wrapping.])
AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable all hard text wrapping.])
fi
AC_ARG_ENABLE(wrapping-as-root,
@@ -207,7 +242,7 @@ fi
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug], [Enable debugging (disabled by default)]))
if test "x$enable_debug" = xyes; then
AC_DEFINE(DEBUG, 1, [Define this to enable debug messages and assert warnings.])
AC_DEFINE(DEBUG, 1, [Define this to enable debug messages and abortion on failing asserts.])
else
AC_DEFINE(NDEBUG, 1, [Shut up assert warnings :-)])
fi
@@ -216,23 +251,17 @@ AC_ARG_ENABLE(tiny,
AS_HELP_STRING([--enable-tiny], [Disable features for the sake of size]))
if test "x$enable_tiny" = xyes; then
AC_DEFINE(NANO_TINY, 1, [Define this to make the nano executable as small as possible.])
if test "x$enable_browser" != xyes; then
AC_DEFINE(DISABLE_BROWSER, 1, [Define this to disable the built-in file browser.])
fi
if test "x$enable_color" != xyes; then
AC_DEFINE(DISABLE_COLOR, 1, [Define this to disable syntax highlighting.])
color_support=no
else
if test "x$enable_nanorc" != xyes; then
AC_MSG_ERROR([--enable-color with --enable-tiny cannot work without --enable-nanorc])
AC_MSG_ERROR([--enable-color needs --enable-nanorc to work])
fi
fi
if test "x$enable_extra" != xyes; then
AC_DEFINE(DISABLE_EXTRA, 1, [Define this to disable extra stuff.])
fi
if test "x$enable_help" != xyes; then
AC_DEFINE(DISABLE_HELP, 1, [Define this to disable the help text display.])
fi
if test "x$enable_histories" != xyes; then
AC_DEFINE(DISABLE_HISTORIES, 1, [Define this to disable search and position histories.])
fi
@@ -242,23 +271,11 @@ if test "x$enable_tiny" = xyes; then
if test "x$enable_libmagic" != xyes; then
enable_libmagic=no
fi
if test "x$enable_mouse" != xyes; then
AC_DEFINE(DISABLE_MOUSE, 1, [Define this to disable the mouse support.])
fi
if test "x$enable_multibuffer" != xyes; then
AC_DEFINE(DISABLE_MULTIBUFFER, 1, [Define this to disable multiple file buffers.])
fi
if test "x$enable_nanorc" != xyes; then
AC_DEFINE(DISABLE_NANORC, 1, [Define this to disable the use of .nanorc files.])
fi
if test "x$enable_operatingdir" != xyes; then
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of the operating directory (chroot of sorts).])
AC_DEFINE(DISABLE_OPERATINGDIR, 1, [Define this to disable the setting of an operating directory (a chroot of sorts).])
fi
if test "x$enable_speller" != xyes; then
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell checker functions.])
fi
if test "x$enable_tabcomp" != xyes; then
AC_DEFINE(DISABLE_TABCOMP, 1, [Define this to disable the tab completion functions for files and search strings.])
AC_DEFINE(DISABLE_SPELLER, 1, [Define this to disable the spell-checker functions.])
fi
if test "x$enable_wrapping" != xyes; then
AC_DEFINE(DISABLE_WRAPPING, 1, [Define this to disable all text wrapping.])
@@ -545,13 +562,13 @@ else
fi
AC_CHECK_LIB([$CURSES_LIB_NAME], [use_default_colors],
[AC_DEFINE(HAVE_USE_DEFAULT_COLORS, 1, [Define this if your curses library has the use_default_colors() command.])],
[AC_DEFINE(HAVE_USE_DEFAULT_COLORS, 1, [Define this if your curses library has the use_default_colors() function.])],
[], [$CURSES_LIB])
AC_CHECK_LIB([$CURSES_LIB_NAME], [set_escdelay],
[AC_DEFINE(HAVE_SET_ESCDELAY, 1, [Define this if your curses library has the set_escdelay() function.])],
[], [$CURSES_LIB])
AC_CHECK_LIB([$CURSES_LIB_NAME], [key_defined],
[AC_DEFINE(HAVE_KEY_DEFINED, 1, [Define this if your curses library has the key_defined() command.])],
[AC_DEFINE(HAVE_KEY_DEFINED, 1, [Define this if your curses library has the key_defined() function.])],
[], [$CURSES_LIB])
dnl Parse any configure options.
@@ -587,36 +604,43 @@ else
fi
fi
AC_CACHE_CHECK([for enhanced regular expression flag], nano_cv_flag_reg_extended,
AC_CACHE_CHECK([for enhanced regular expression flag], nano_cv_flag_reg_enhanced,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <regex.h>]],
[[
#ifndef REG_ENHANCED
error: No REG_ENHANCED support!
#endif
]])],
[nano_cv_flag_reg_extended="REG_EXTENDED | REG_ENHANCED"],
[nano_cv_flag_reg_extended="REG_EXTENDED"])])
[nano_cv_flag_reg_enhanced=yes],
[nano_cv_flag_reg_enhanced=no])])
dnl The bundled gnulib regex module doesn't support REG_ENHANCED.
if test "$ac_use_included_regex" = "yes"; then
nano_cv_flag_reg_enhanced="no"
fi
if test "$nano_cv_flag_reg_enhanced" = "yes"; then
nano_reg_extended="REG_EXTENDED | REG_ENHANCED"
else
nano_reg_extended="REG_EXTENDED"
fi
AC_DEFINE_UNQUOTED(NANO_REG_EXTENDED, $nano_cv_flag_reg_extended,
AC_DEFINE_UNQUOTED(NANO_REG_EXTENDED, $nano_reg_extended,
[Flag(s) to use to get the full range of extended regular expressions])
# Check for word-boundary support (/< and />).
AC_MSG_CHECKING([for GNU-style word boundary regex support])
AC_ARG_WITH(wordbounds,
AS_HELP_STRING([--with-wordbounds], [Use GNU-style word boundary delimiters]),
[ case "$with_wordbounds" in
no)
AC_MSG_RESULT(no)
;;
*)
AC_MSG_RESULT(yes)
# We explicitly don't check if the user forced the option, because
# this is needed for cross compilers and we can't test the target.
AC_DEFINE(GNU_WORDBOUNDS, 1, [Define this if the system supports GNU-style word boundaries in regexes.]) gnu_wordbounds=yes,
;;
esac
], [
AC_TRY_RUN([
[with_wordbounds=$withval], [with_wordbounds=auto])
if test "$with_wordbounds" != "no"; then
dnl If we're using the bundled gnulib regex module, we know it's supported.
if test "$ac_use_included_regex" = "yes"; then
with_wordbounds="yes"
fi
dnl We explicitly don't check if the user forced the option, because
dnl this is needed for cross compilers and we can't test the target.
if test "$with_wordbounds" != "yes"; then
AC_TRY_RUN([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
@@ -627,18 +651,29 @@ int main(void)
size_t nmatch;
regmatch_t pmatch;
if (regcomp(&r, "\\\\>", $nano_cv_flag_reg_extended|REG_NOSUB))
if (regcomp(&r, "\\\\>", $nano_reg_extended|REG_NOSUB))
return 1;
if (regexec(&r, "word boundary", nmatch, &pmatch, 0))
return 1;
return 0;
}],
AC_MSG_RESULT(yes)
AC_DEFINE(GNU_WORDBOUNDS, 1, [Define this if the system supports GNU-style word boundaries in regexes.]) gnu_wordbounds=yes,
AC_MSG_RESULT(no),
AC_MSG_WARN([*** Can't check for GNU-style word boundary support when cross-compiling])
)
])
with_wordbounds="yes",
with_wordbounds="no",
with_wordbounds="cross")
fi
fi
case $with_wordbounds in
yes)
AC_MSG_RESULT(yes)
AC_DEFINE(GNU_WORDBOUNDS, 1, [Define this if the system supports GNU-style word boundaries in regexes.])
;;
no)
AC_MSG_RESULT(no)
;;
cross)
AC_MSG_WARN([*** Can't check for GNU-style word boundary support when cross-compiling])
;;
esac
if test x$color_support = xyes; then
# if test x$CURSES_LIB_NAME = xcurses; then
@@ -660,7 +695,7 @@ int main(void)
int testcolor = COLOR_WHITE;
return 0;
}],
AC_DEFINE(NEED_XOPEN_SOURCE_EXTENDED, 1, [Define this if you need the _XOPEN_SOURCE_EXTENDED macro for color support])
AC_DEFINE(NEED_XOPEN_SOURCE_EXTENDED, 1, [Define this if you need the _XOPEN_SOURCE_EXTENDED macro for color support.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(not sure)
AC_MSG_WARN([*** Couldn't successfully compile basic color test with or without _XOPEN_SOURCE_EXTENDED])
@@ -678,7 +713,7 @@ int main(void)
COLS = 25;
return 0;
}],
AC_DEFINE(REDEFINING_MACROS_OK, 1, [Define this if you know your curses library allows LINES and COLS to be redefined to deal with a resizing bug])
AC_DEFINE(REDEFINING_MACROS_OK, 1, [Define this if you know your curses library allows LINES and COLS to be redefined to deal with a resizing bug.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no),
AC_MSG_WARN([*** Can't check for macro redefinability when cross-compiling]))

View File

@@ -28,6 +28,6 @@ info_TEXINFOS = nano.texi
BUILT_SOURCES += nano.html
dist_html_DATA += nano.html
AM_MAKEINFOHTMLFLAGS = --no-split
AM_MAKEINFOHTMLFLAGS = --no-split -c HEADERS=0
EXTRA_DIST = $(BUILT_SOURCES) $(info_TEXINFOS)

View File

@@ -9,20 +9,21 @@
<h1>The GNU nano editor FAQ</h1>
<h2>Table of Contents</h2>
<h2><a href="#1">1. General</a></h2>
<blockquote><p><a href="#1.1">1.1 About this FAQ</a><br>
<a href="#1.2">1.2. How do I contribute to it?</a><br>
<a href="#1.3">1.3. What is GNU nano?</a><br>
<a href="#1.4">1.4. What is the history behind nano?</a><br>
<a href="#1.5">1.5. Why the name change from TIP?</a><br>
<a href="#1.6">1.6. What is the current version of nano?</a><br>
<a href="#1.7">1.7. I want to read the manpage without having to download the program!</a></p></blockquote>
<blockquote><p>
<a href="#1.1">1.1. What is GNU nano?</a><br>
<a href="#1.2">1.2. What is the history behind nano?</a><br>
<a href="#1.3">1.3. Why the name change from TIP?</a><br>
<a href="#1.4">1.4. What is the current version of nano?</a><br>
<a href="#1.5">1.5. I want to read the manpage without having to download the program!</a></p></blockquote>
<h2><a href="#2">2. Where to get GNU nano.</a></h2>
<blockquote><p><a href="#2.1">2.1. FTP and WWW sites that carry nano.</a><br>
<blockquote><p>
<a href="#2.1">2.1. FTP and WWW sites that carry nano.</a><br>
<a href="#2.2">2.2. RedHat and derivatives (.rpm) packages.</a><br>
<a href="#2.3">2.3. Debian (.deb) packages.</a><br>
<a href="#2.4">2.4. By GIT (for the brave).</a></p></blockquote>
<h2><a href="#3">3. Installation and Configuration</a></h2>
<blockquote><p><a href="#3.1">3.1. How do I install the RPM or DEB package?</a><br>
<blockquote><p>
<a href="#3.1">3.1. How do I install the RPM or DEB package?</a><br>
<a href="#3.2">3.2. Compiling from source: WHAT THE HECK DO I DO NOW?</a><br>
<a href="#3.3">3.3. Why does everything go into /usr/local?</a><br>
<a href="#3.5">3.5. nano should automatically run strip on the binary when installing it!</a><br>
@@ -32,44 +33,44 @@
<a href="#3.9a">3.9a. How do I make a .nanorc file that nano will read when I start it?</a><br>
<a href="#3.9b">3.9b. How about in Win32?</a></p></blockquote>
<h2><a href="#4">4. Running</a></h2>
<blockquote><p><a href="#4.1">4.1. How do I open a file with a name beginning with '+' from the command line?</a><br>
<blockquote><p>
<a href="#4.1">4.1. How do I open a file with a name beginning with '+' from the command line?</a><br>
<a href="#4.2">4.2. Ack! My Backspace/Delete/Enter/Meta/double bucky key doesn't seem to work! What can I do?</a><br>
<a href="#4.3">4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</a><br>
<a href="#4.4">4.4. Ack! When I hold down a Meta key combination for a while, the character of the held key gets inserted now and then. What gives?</a><br>
<a href="#4.5">4.5. How do I type the F13-F16 keys shown in the help browser? My keyboard only has F1-F12!</a><br>
<a href="#4.5">4.5. How do I type the F13-F16 keys listed in the help viewer? My keyboard only has F1-F12!</a><br>
<a href="#4.6">4.6. nano crashes when I type &lt;insert keystroke here&gt;!</a><br>
<a href="#4.7">4.7. nano crashes when I resize my window. How can I fix that?</a><br>
<a href="#4.8">4.8. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</a><br>
<a href="#4.8a">4.8a. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</a><br>
<a href="#4.8b">4.8b. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?<a><br>
<a href="#4.9">4.9. I've compiled nano with color support, but I don't see any color when I run it!</a><br>
<a href="#4.10">4.10. How do I make nano my default editor (in Pine, mutt, etc.)?</a><br>
<a href="#4.11">4.11. How do I select text for or paste text from the clipboard in an X terminal when I'm running nano in one and nano's mouse support is turned on?</a><br>
<a href="#4.12">4.12. On startup I get a message that says "Detected a legacy nano history file". Now older nano versions can't find my search history!</a></p></blockquote>
<h2><a href="#5">5. Internationalization</a></h2>
<blockquote><p><a href="#5.1">5.1. There's no translation for my language!</a><br>
<blockquote><p>
<a href="#5.1">5.1. There's no translation for my language!</a><br>
<a href="#5.2">5.2. I don't like the translation for &lt;x&gt; in my language. How can I fix it?</a><br>
<a href="#5.3">5.3. What is the status of Unicode support?</a></p></blockquote>
<h2><a href="#6">6. Advocacy and Licensing</a></h2>
<blockquote><p><a href="#6.1">6.1. Why should I use nano instead of Pico?</a><br>
<blockquote><p>
<a href="#6.1">6.1. Why should I use nano instead of Pico?</a><br>
<a href="#6.2">6.2. Why should I use Pico instead of nano?</a><br>
<a href="#6.3">6.3. What is so bad about the older Pine license?</a><br>
<a href="#6.4">6.4. Okay, well, what mail program should I use then?</a></p></blockquote>
<h2><a href="#7">7. Miscellaneous</a></h2>
<blockquote><p><a href="#7.1">7.1. nano-related mailing lists.</a><br>
<a href="#7.2">7.2. I want to send the development team a big load of cash (or just a thank you).</a><br>
<a href="#7.3">7.3. How do I submit a bug report or patch?</a><br>
<blockquote><p>
<a href="#7.1">7.1. Where can I ask questions or send suggestions?</a><br>
<a href="#7.2">7.2. How do I submit a bug report or patch?</a><br>
<a href="#7.3">7.3. I want to send the development team a big load of cash (or just a thank you).</a><br>
<a href="#7.4">7.4. How do I join the development team?</a><br>
<a href="#7.5">7.5. Can I have write access to the GIT tree?</a></p></blockquote>
<h2><a href="#8">8. ChangeLog</a></h2>
<hr width="100%">
<h1><a name="1"></a>1. General</h1>
<h2><a name="1.1"></a>1.1 About this FAQ</h2>
<blockquote><p>This FAQ was originally written and maintained by Chris Allegretta &lt;<a href="mailto:chrisa@asty.org">chrisa@asty.org</a>&gt;, who also happens to be the creator of nano. It was then maintained by David Lawrence Ramsey &lt;<a href="mailto:pooka109@gmail.com">pooka109@gmail.com</a>&gt;. Maybe someone else will volunteer to maintain this FAQ someday, who knows...</p></blockquote>
<h2><a name="1.2"></a>1.2. How do I contribute to it?</h2>
<blockquote><p>Your best bet is to send it to the nano email address, <a href="mailto:nano@nano-editor.org">nano@nano-editor.org</a> and if it is useful enough it will be included in future versions.</p></blockquote>
<h2><a name="1.3"></a>1.3. What is GNU nano?</h2>
<h2><a name="1.1"></a>1.1. What is GNU nano?</h2>
<blockquote><p>GNU nano is designed to be a free replacement for the Pico text editor, part of the Pine email suite from <a href="http://www.washington.edu/pine/">The University of Washington</a>. It aims to &quot;emulate Pico as closely as possible and then include extra functionality&quot;.</p></blockquote>
<h2><a name="1.4"></a>1.4. What is the history behind nano?</h2>
<h2><a name="1.2"></a>1.2. What is the history behind nano?</h2>
<blockquote><p>Funny you should ask!</p>
<p><b>In the beginning...</b></p>
<p>For years Pine was THE program used to read email on a Unix system. The Pico text editor is the portion of the program one would use to compose his or her mail messages. Many beginners to Unix flocked to Pico and Pine because of their well organized, easy to use interfaces. With the proliferation of GNU/Linux in the mid to late 90's, many University students became intimately familiar with the strengths (and weaknesses) of Pine and Pico.</p>
@@ -79,11 +80,11 @@
<p>It was in late 1999 when Chris Allegretta (our hero) was yet again complaining to himself about the less-than-perfect license Pico was distributed under, the 1000 makefiles that came with it and how just a few small improvements could make it the Best Editor in the World (TM). Having been a convert from Slackware to Debian, he missed having a simple binary package that included Pine and Pico, and had grown tired of downloading them himself.</p>
<p>Finally something snapped inside and Chris coded and hacked like a madman for many hours straight one weekend to make a (barely usable) Pico clone, at the time called TIP (Tip Isn't Pico). The program could not be invoked without a filename, could not save files, had no help text display, spell checker, and so forth. But over time it improved, and with the help of a few great coders it matured to the (hopefully) stable state it is in today.</p>
<p>In February 2001, nano was declared an official GNU program by Richard Stallman. nano also reached its first production release on March 22, 2001.</p></blockquote>
<h2><a name="1.5"></a>1.5. Why the name change from TIP?</h2>
<h2><a name="1.3"></a>1.3. Why the name change from TIP?</h2>
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program &quot;establishes a full duplex terminal connection to a remote host&quot;, and was included with many older Unix systems (and newer ones like Solaris). The conflict was not noticed at first because there is no 'tip' utility included with most GNU/Linux distributions (where nano was developed).</p></blockquote>
<h2><a name="1.6"></a>1.6. What is the current version of nano?</h2>
<blockquote><p>The current version of nano <i>should</i> be <b>2.8.0</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<h2><a name="1.7"></a>1.7. I want to read the man page without having to download the program!</h2>
<h2><a name="1.4"></a>1.4. What is the current version of nano?</h2>
<blockquote><p>The current version of nano <i>should</i> be <b>2.8.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>
<h2><a name="1.5"></a>1.5. I want to read the man page without having to download the program!</h2>
<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%">
@@ -138,27 +139,29 @@
<pre>
<b>--disable-browser</b> Disable the built-in file browser
<b>--disable-color</b> Disable color and syntax highlighting
<b>--disable-extra</b> Disable extra features (currently only an easter egg)
<b>--disable-help</b> Disable help functions
<b>--disable-comment</b> Disable the comment/uncomment function
<b>--disable-extra</b> Disable the easter egg
<b>--disable-help</b> Disable the built-in help texts
<b>--disable-histories</b> Disable the saving of search strings and cursor positions
<b>--disable-justify</b> Disable justify/unjustify functions
<b>--disable-justify</b> Disable the justify/unjustify functions
<b>--disable-libmagic</b> Disable the use of libmagic for determining a file's syntax
<b>--disable-linenumbers</b> Disable line numbering
<b>--disable-mouse</b> Disable mouse support
<b>--disable-multibuffer</b> Disable having multiple file buffers open
<b>--disable-multibuffer</b> Disable the opening of multiple file buffers
<b>--disable-nanorc</b> Disable the use of .nanorc files
<b>--disable-operatingdir</b> Disable the setting of an operating directory
<b>--disable-speller</b> Disable spell checker functions
<b>--disable-tabcomp</b> Disable tab completion functions
<b>--disable-wordcomp</b> Disable the word completion function
<b>--disable-speller</b> Disable the spell-checker functions
<b>--disable-tabcomp</b> Disable the tab-completion functions
<b>--disable-wordcomp</b> Disable the word-completion function
<b>--disable-wrapping</b> Disable all hard-wrapping of text</pre>
<p>There's also the <b>--enable-tiny</b> option which disables everything above, as well as some larger chunks of the program (like the marker code that you use with Control-^ to select text). Also, if you know you aren't going to be using other languages, you can use <b>--disable-nls</b> to disable internationalization and save a few K to a few dozen K depending on whether you have locale support on your system. And finally, there's always good old <b>strip</b> to strip all debugging code and code that exists in libraries on your system.</p>
<p>With <b>--disable-wrapping-as-root</b> you can disable any hard-wrapping by default when the user is root, useful to prevent accidentally changing long lines in system configuration files.</p>
</blockquote>
<h2><a name="3.7"></a>3.7. Tell me more about this multibuffer stuff!</h2>
<blockquote><p>To use multiple file buffers, you must not have configured nano with <b>--disable-multibuffer</b> nor with <b>--enable-tiny</b> (use <b>nano -V</b> to check the compilation options). Then when you want to insert a file into its own buffer instead of into the current file, just hit <b>Meta-F</b>, then insert the file as normal with <b>^R</b>. If you always want files to be loaded into their own buffers, use the <b>--multibuffer</b> or <b>-F</b> flag when you invoke nano.</p>
<blockquote><p>To use multiple file buffers, you must not have configured nano with <b>--disable-multibuffer</b> nor with <b>--enable-tiny</b> (use <b>nano -V</b> to check the compilation options). Then when you want to insert a file into its own buffer instead of into the current file, just hit <b>Meta-F</b> after typing <b>^R</b>. If you always want files to be loaded into their own buffers, use the <b>--multibuffer</b> or <b>-F</b> flag when you invoke nano.</p>
<p>You can move between the buffers you have open with the <b>Meta-&lt;</b> and <b>Meta-&gt;</b> keys, or more easily without holding Shift: <b>Meta-,</b> and <b>Meta-.</b> (clear as mud, right? =-). When you have more than one file buffer open, the ^X shortcut will say &quot;Close&quot;, instead of the normal &quot;Exit&quot; when only one buffer is open.</p></blockquote>
<h2><a name="3.8"></a>3.8. Tell me more about this verbatim input stuff!</h2>
<blockquote><p>When you want to insert a literal character into the file you're editing, such as a control character that nano usually treats as a command, first press <b>Meta-V</b> (if you're not at a prompt, you'll get the message &quot;Verbatim Input&quot; on the statusbar), then press the key(s) that generate the character you want.</p>
<blockquote><p>When you want to insert a literal character into the file you're editing, such as a control character that nano usually treats as a command, first press <b>Meta-V</b> (if you're not at a prompt, you'll get the message &quot;Verbatim Input&quot; on the status bar), then press the key(s) that generate the character you want.</p>
<p>Alternatively, if you've enabled Unicode support (see section <a href="#5.3">5.3</a>), you can press <b>Meta-V</b> and then type a six-digit hexadecimal code (from 000000 to 10FFFF, case-insensitive), and the character with the corresponding value will be inserted. The statubar will change to &quot;Unicode Input: ......&quot; when you do this.</p></blockquote>
<h2><a name="3.9a"></a>3.9a. How do I make a .nanorc file that will be read when I start nano?</h2>
<blockquote><p>It's not hard at all! But, your nano must <b>not</b> have been compiled with <b>--disable-nanorc</b>. Then simply copy the <b>sample.nanorc</b> that came with the nano source or your nano package (most likely in /usr/doc/nano) to .nanorc in your home directory. If you didn't get one, the syntax of the file is simple. Flags are turned on and off by using the words <b>set</b> and <b>unset</b> plus the long option name for the feature. For example, &quot;set nowrap&quot; or &quot;set smarthome&quot;.</p></blockquote>
@@ -183,17 +186,19 @@
<h2><a name="4.3"></a>4.3. Ack! My numeric keypad's keys don't work properly when NumLock is off! What can I do?</h2>
<blockquote><p>You can use the <b>-K</b> or <b>--rebindkeypad</b> option on the command line, or add the line <b>set rebindkeypad</b> to your .nanorc. However, nano's mouse support won't work properly if you do any of these things.</p></blockquote>
<h2><a name="4.4"></a>4.4. Ack! When I hold down a Meta key combination for a while, the character of the held key gets inserted now and then. What gives?</h2>
<blockquote><p>This is a bug in the terminal, not in nano. When a key is repeating faster than nano can process it, the keyboard buffer becomes full and starts dropping incoming keystrokes. Unfortunately, it doesn't just drop whole keystrokes; it can also drop parts of multibyte key combinations, resulting in nano's receiving a wrong key.</p></blockquote>
<h2><a name="4.5"></a>4.5. How do I type the F13-F16 keys shown in the help browser? My keyboard only has F1-F12!</h2>
<blockquote><p>This was a bug in how nano handled consecutive escape sequences. It should be fixed since version 2.6.0.</p></blockquote>
<h2><a name="4.5"></a>4.5. How do I type the F13-F16 keys listed in the help viewer? My keyboard only has F1-F12!</h2>
<blockquote><p>It depends on the terminal type you're using. On some terminals, such as the FreeBSD console, xterm, konsole, and gnome-terminal, Shift-F1 to Shift-F4 will generate F13 to F16. On other terminals, such as the Linux console, rxvt, and Eterm, Shift-F3 to Shift-F6 will generate F13 to F16.</p></blockquote>
<h2><a name="4.6"></a>4.6. nano crashes when I type &lt;insert keystroke here&gt;!</h2>
<blockquote><p>If you aren't trying some bizarre keystroke combination with some bizarre $TERM entry, chances are you have found a bug. You are welcome to submit it to the <a href="mailto:nano-devel@gnu.org">nano-devel</a> list or in the <a href="https://savannah.gnu.org/bugs/?group=nano">bug tracker</a> on Savannah.</p></blockquote>
<h2><a name="4.7"></a>4.7. nano crashes when I resize my window. How can I fix that?</h2>
<blockquote><p>Older versions of nano had this problem. Please upgrade to version 2.7.0 or newer.</p></blockquote>
<h2><a name="4.8"></a>4.8. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</h2>
<h2><a name="4.8a"></a>4.8a. When I paste text into a document, each line gets indented further than the last. Why does nano do this, and how can I avoid it?</h2>
<blockquote><p>You have the autoindent feature turned on. Hit Meta-I to turn it off, paste your text, and then hit Meta-I again to turn it back on.</p></blockquote>
<h2><a name="4.8b"></a>4.8b. When I paste from Windows into a remote nano, nano rewraps the lines. What gives?</h2>
<blockquote><p>When pasting from Windows, in some situations linefeeds are sent instead of carriage returns (Enters). And linefeeds are <b>^J</b>s, which make nano justify (rewrap) the current paragraph. To prevent these linefeeds from causing these unwanted justifications, add this line to your .nanorc on the remote Linux box: <b>unbind ^J main</b> or <b>bind ^J enter main</b>, depending on whether the paste contains CR + LF or only LF.</p></blockquote>
<h2><a name="4.9"></a>4.9. I've compiled nano with color support, but I don't see any color when I run it!</h2>
<blockquote><p>If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Several example configurations are in the <b>doc/syntax</b> subdirectory of the nano source, which are normally installed to <b>/usr/local/share/nano</b>. To enable all of them, uncomment the line <b># include "/usr/local/share/nano/*.nanorc"</b> in your nanorc. See also section <a href="#3.9a">3.9a</a>.</p></blockquote>
<blockquote><p>If you want nano to actually use color, you have to specify the color configurations you want it to use in your .nanorc. Several example configurations are in the <b>syntax/</b> subdirectory of the nano source, which are normally installed to <b>/usr/local/share/nano/</b>. To enable all of them, uncomment the line <b># include "/usr/local/share/nano/*.nanorc"</b> in your nanorc. See also section <a href="#3.9a">3.9a</a>.</p></blockquote>
<h2><a name="4.10"></a>4.10. How do I make nano my default editor (in Pine, mutt, etc.)?</h2>
<blockquote><p>You need to make nano your $EDITOR. If you want this to be saved, you should put a line like this in your <b>.bashrc</b> if you use bash (or <b>.zshrc</b> if you believe in zsh):</p>
<p><b>export EDITOR=/usr/local/bin/nano</b></p>
@@ -240,93 +245,22 @@
<hr width="100%">
<h1><a name="7"></a>7. Miscellaneous</h1>
<h2><a name="7.1"></a>7.1. nano-related mailing lists.</h2>
<h2><a name="7.1"></a>7.1. Where can I ask questions or send suggestions?</h2>
<blockquote><p>There are three mailing lists for nano hosted at <a href="http://savannah.gnu.org/">Savannah</a>: info-nano, help-nano and nano-devel. info-nano is a very low traffic list where new versions of nano are announced (surprise!). help-nano is for getting help with the editor without needing to hear all of the development issues surrounding it. nano-devel is a normally low, sometimes high traffic list for discussing the present and future development of nano. Here are links to where you can sign up for a given list:</p>
<p>info-nano - <a href="http://mail.gnu.org/mailman/listinfo/info-nano/">http://mail.gnu.org/mailman/listinfo/info-nano/</a><br>
help-nano - <a href="http://mail.gnu.org/mailman/listinfo/help-nano/">http://mail.gnu.org/mailman/listinfo/help-nano/</a><br>
nano-devel - <a href="http://mail.gnu.org/mailman/listinfo/nano-devel/">http://mail.gnu.org/mailman/listinfo/nano-devel/</a></p></blockquote>
<h2><a name="7.2"></a>7.2. I want to send the development team a big load of cash (or just a thank you).</h2>
<blockquote><p>That's fine. Send it <a href="mailto:nano-devel@gnu.org">our way</a>! Better yet, fix a <a href="https://savannah.gnu.org/bugs/?group=nano">bug</a> in the program or implement a <a href="https://nano-editor.org/dist/latest/TODO">cool feature</a> and send us that instead (though cash is fine too).</p></blockquote>
<h2><a name="7.3"></a>7.3. How do I submit a bug report or patch?</h2>
<h2><a name="7.2"></a>7.3. How do I submit a bug report or patch?</h2>
<blockquote>
<p>The best way to submit bugs is through the <a href="https://savannah.gnu.org/bugs/?group=nano">Savannah bug tracker</a>, as you can check whether the bug you are reporting has already been submitted, and it makes it easier for the maintainers to keep track of them.
<p>You can submit patches for nano via <a href="https://savannah.gnu.org/patch/?group=nano">Savannah's patch manager</a>.</p></blockquote>
<h2><a name="7.3"></a>7.3. I want to send the development team a big load of cash (or just a thank you).</h2>
<blockquote><p>That's fine. Send it <a href="mailto:nano-devel@gnu.org">our way</a>! Better yet, fix a <a href="https://savannah.gnu.org/bugs/?group=nano">bug</a> in the program or implement a <a href="https://nano-editor.org/dist/latest/TODO">cool feature</a> and send us that instead (though cash is fine too).</p></blockquote>
<h2><a name="7.4"></a>7.4. How do I join the development team?</h2>
<blockquote><p>The easiest way is to consistently send in good patches that add some needed functionality, fix a bug or two, and/or make the program more optimized/efficient. Then ask nicely and you will probably be added to the Savannah development list and be given write access after a while. There is a lot of responsibility that goes along with being a team member, so don't think it's just something to add to your resume.</p></blockquote>
<h2><a name="7.5"></a>7.5. Can I have write access to the git tree?</h2>
<blockquote><p>Re-read section <a href="#7.4">7.4</a> and you should know the answer.</p></blockquote>
<hr width="100%">
<h1><a name="8"></a>8. ChangeLog</h1>
<blockquote><p>
2017.01.09 - Delete some obsolete items and update a few others. (Benno)<br>
2016.04.17 - Update docs to refer to GIT instead of subversion. (Mike)<br>
2015.07.18 - More small fixes and updates. (Benno)<br>
2014.04.24 - A bunch of small fixes and updates. (Benno)<br>
2009.11.30 - Update various bits for nano 2.2.x. (DLR)<br>
2009.11.18 - Typo fix. (j.mader@gmail.com)<br>
2008.03.16 - Update docs to refer to subversion instead of CVS, add more words about Alpine, and refer to Savannah for bugs and patches. (Chris)<br>
2007.12.21 - Update maintainer information. (DLR)<br>
2007.12.09 - Add minor punctuation and wording fixes, and update various sections to account for Alpine. (DLR)<br>
2007.08.26 - Update links to the Free Translation Project. (DLR)<br>
2007.07.29 - Update RPM links for nano 2.0.x. (DLR)<br>
2007.04.18 - Add a new section 4.14 to explain how autoindent affects pasted text. (John M. Gabriele, minor tweaks by DLR)<br>
2007.04.04 - Update email address. (DLR)<br>
2007.01.01 - Update section 4.1 to describe how to open files with names beginning with '+' at specified columns as well as lines. (DLR)<br>
2006.11.25 - Add miscellaneous wording and capitalization fixes. (DLR)<br>
2006.10.28 - Update various links for the 2.0 branch of nano. (DLR)<br>
2006.10.06 - Update the question in section 4.13 to match the version of it in the answer section. (DLR)<br>
2006.07.25 - Update section 5.3 again to not state &quot;the latest development version&quot; before 1.3.12, as it's no longer accurate. Also add some minor spacing fixes. (DLR)<br>
2006.06.12 - Update section 5.3, due to the display fix for two-column Unicode characters. (DLR)<br>
2006.06.05 - Add a new section 4.8, and move all section 4 entries after it down one number, to explain how to deal with glibc 2.2.3's crashes involving extended regular expressions. (DLR)<br>
2006.06.04 - Add minor punctuation, wording, and typo fixes. (DLR)<br>
2006.05.27 - Update section 3.8 to mention the new "Unicode Input" prompt, and how Unicode input only works when Unicode support is enabled. (DLR)<br>
2006.05.12 - Remove section 4.4, and move all section 4 entries after it up one number, since it no longer applies. Meta-] and Meta-[ are no longer used to indent and unindent marked text, since they require that the bracket matching key change to Ctrl-], which is used as the telnet escape key (found by Chris). Also, make the link to the nano CVS page a bit more readable. (DLR)<br>
2006.05.08 - Add a new section 4.5, and move all section 4 entries after it down one number, to explain a problem that can occur when holding down keys to generate Meta sequences. Also add a few more capitalization and wording fixes. (Benno Schulenberg, minor tweaks by DLR)<br>
2006.05.01 - Add a new section 4.4, and move all section 4 entries after it down one number, to explain how to deal with problems typing Meta-[. Also add a few capitalization and wording fixes. (DLR)<br>
2006.04.14 - Clarify section 1.4: help menu -> help text display. (DLR, suggested by Benno Schulenberg)<br>
2006.03.16 - Update the Free Translation Project's address, change the character set to UTF-8, and remove broken links to contributed RedHat nano packages. (DLR)<br>
2005.11.21 - Clarify section 5.3 to better explain how to enable Unicode support, and remove the mention of quirks, since they turned out to not be a nano problem. (Mike Frysinger and DLR)<br>
2005.11.19 - Add a new section 5.3 to explain the status of nano's Unicode support. (Mike Frysinger, minor tweaks by DLR)<br>
2005.08.27 - Update email address. (DLR)<br>
2005.08.10 - Add a new section 4.3, and move all section 4 entries after it down one number, to explain how to deal with numeric keypad problems. (DLR)<br>
2005.08.08 - Update section 3.8 to mention that verbatim input mode now takes a six-digit hexadecimal number. (DLR)<br>
2005.07.04 - Update section 4.10 to mention that pasting from the X clipboard via the middle mouse button also works when the Shift key is used. (DLR)<br>
2005.06.15 - Update description of --enable-extra, and add missing line breaks. (DLR)<br>
2005.06.13 - Minor capitalization and wording fixes. (DLR)<br>
2005.06.08 - Updated section 1.1 to mention the current maintainer. (DLR)<br>
2005.03.09 - Added question about opening files with names beginning with '+'s, and added a few more miscellaneous cosmetic fixes. (DLR)<br>
2005.01.03 - Removed now-inaccurate note about verbatim input's not working at prompts, and update its description to mention that it handles hexadecimal values now. (DLR)<br>
2004.11.21 - Listed sh as an example of a Bourne shell. (DLR)<br>
2004.11.05 - Fixed inaccuracy: Pico compatibility mode was made the default in nano 1.1.99pre1, not 1.2.2. Also added question about how to type F13-F16 on terminals lacking keys past F12 (suggested by Chris), question about how to select text for the clipboard in X terminals with nano's mouse support turned on (answer found by Joseph Birthisel), and misc. fixes and link updates. (DLR)<br>
2004.04.07 - Removed NumLock glitch question, as it's no longer needed. (DLR)<br>
2004.01.30 - Fixed inaccuracy: multibuffer mode was first in nano 1.1.0, not 1.1.12. (DLR)<br>
2003.12.31 - Added question about the new verbatim input function, and a few minor fixes. Removed reference to &quot;set pico&quot; (DLR).<br>
2003.07.02 - Added question about nano's not showing color when it's compiled with color support (DLR; suggested by Jordi).<br>
2003.02.23 - Updated RPM links for nano 1.2.x (DLR).<br>
2003.01.16 - Split section 4.5 into 4.5a and 4.5b for search string behavior. Added --enable-all docs.<br>
2002.12.28 - More misc. fixes (David Benbennick, DLR).<br>
2002.10.25 - Misc. fixes and link updates (DLR).<br>
2002.09.10 - Another typo fix (DLR).<br>
2002.05.15 - Typo fix (DLR).<br>
2001.12.26 - Misc. fixes (Aaron S. Hawley, DLR).<br>
2001.10.02 - Update for Free Translation Project.<br>
2001.10.02 - Assorted fixes, Debian additions.<br>
2001.06.30 - Silly typo fix.<br>
2001.05.05 - Spelling fixes by David Lawrence Ramsey.<br>
2001.05.02 - Misc fixes.<br>
2001.03.26 - Typo fix in an URL.<br>
2001.02.17 - Advocacy updates.<br>
2001.02.15 - Added GNU notes for 0.9.99pre3.<br>
2001.02.06 - Typo fixes.<br>
2001.01.14 - Added note about NumLock glitch.<br>
2001.01.10 - Linux -&gt; GNU/Linux.<br>
2001.01.09 - Added &quot;making exe smaller&quot; section.<br>
2000.12.19 - Typo and assorted error fixes.<br>
2000.11.28 - Added blurb about make install-strip.<br>
2000.11.19 - Changed Debian frozen to stable.<br>
2000.11.18 - Previous string display (4.5).<br>
2000.09.27 - Moved addresses to nano-editor.org.<br>
2000.06.31 - Initial framework.</p></blockquote>
</body>
</html>

View File

@@ -1,5 +1,4 @@
.\" Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
.\" 2009, 2010, 2013, 2014 Free Software Foundation, Inc.
.\" Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc.
.\"
.\" This document is dual-licensed. You may distribute and/or modify it
.\" under the terms of either of the following licenses:
@@ -17,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 2.8.0" "March 2017"
.TH NANO 1 "version 2.8.6" "July 2017"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
@@ -28,18 +27,17 @@ nano \- Nano's ANOther editor, an enhanced free Pico clone
.RI [ options "] [[+" line [, column "]]\ " file "]..."
.SH DESCRIPTION
\fBnano\fP is a small, free and friendly editor which aims to replace
Pico, the default editor included in the non-free Pine package. On
top of copying Pico's look and feel, \fBnano\fP also implements some
missing (or disabled by default) features in Pico, such as "search and
replace" and "go to line and column number".
\fBnano\fP is a small and friendly editor. It copies the look and feel
of Pico, but is free software, and implements several features that Pico
lacks, such as: opening multiple files, scrolling per line, undo/redo,
syntax coloring, line numbering, and soft-wrapping overlong lines.
When opening a file, the cursor can be put on a specific line by adding
the line number with a plus sign (\fB+\fR) before the filename, and even
in a specific column by adding it with a comma.
When giving a filename on the command line, the cursor can be put on a
specific line by adding the line number with a plus sign (\fB+\fR) before
the filename, and even in a specific column by adding it with a comma.
If the first file specified is a dash (\fB\-\fR), \fBnano\fR will read
data from standard input.
As a special case: if instead of a filename a dash (\fB\-\fR) is given,
\fBnano\fR will read data from standard input.
.SH EDITING
Entering text and moving around in a file is straightforward: typing the
@@ -61,7 +59,7 @@ Since nano-2.7.0, text can also be selected by holding Shift and moving the
cursor with the arrow keys. Holding down the Alt key too will increase the
stride.
.PP
The two lines at the bottom of the screen show the most important commands;
The two lines at the bottom of the screen show some important commands;
the built-in help (\fB^G\fR) lists all the available ones.
The default key bindings can be changed via the .nanorc file -- see
.BR nanorc (5).
@@ -81,7 +79,7 @@ filename suffixed with a tilde (\fB~\fP).
.TP
.BR \-C\ \fIdirectory\fR ", " \-\-backupdir= \fIdirectory
Make and keep not just one backup file, but make and keep a uniquely
numbered one every time a file is saved -- when backups are enabled.
numbered one every time a file is saved -- when backups are enabled (\fB\-B\fR).
The uniquely numbered files are stored in the specified \fIdirectory\fR.
.TP
.BR \-D ", " \-\-boldtext
@@ -91,10 +89,10 @@ Use bold text instead of reverse video text.
Convert typed tabs to spaces.
.TP
.BR \-F ", " \-\-multibuffer
Enable multiple file buffers (if support for them has been compiled in).
Read a file into a new buffer by default.
.TP
.BR \-G ", " \-\-locking
Enable vim-style file locking when editing files.
Use vim-style file locking when editing files.
.TP
.BR \-H ", " \-\-historylog
Log search and replace strings to \fI~/.nano/search_history\fP, so they can be
@@ -115,7 +113,7 @@ Don't add newlines to the ends of files.
Disable automatic conversion of files from DOS/Mac format.
.TP
.BR \-O ", " \-\-morespace
Use the blank line below the titlebar as extra editing space.
Use the blank line below the title bar as extra editing space.
.TP
.BR \-P ", " \-\-positionlog
For the 200 most recent files, log the last position of the cursor,
@@ -138,7 +136,7 @@ This restricted mode is also accessible by invoking \fBnano\fP
with any name beginning with 'r' (e.g. "rnano").
.TP
.BR \-S ", " \-\-smooth
Enable smooth scrolling. Text will scroll line-by-line, instead of the
Use smooth scrolling: text will scroll line-by-line, instead of the
usual chunk-by-chunk behavior.
.TP
.BR \-T\ \fInumber\fR ", " \-\-tabsize= \fInumber
@@ -146,8 +144,9 @@ Set the size (width) of a tab to \fInumber\fP columns. The value of
\fInumber\fP must be greater than 0. The default value is 8.
.TP
.BR \-U ", " \-\-quickblank
Do quick statusbar blanking. Statusbar messages will disappear after 1
keystroke instead of 25. Note that \fB\-c\fP overrides this.
Do quick status-bar blanking: status-bar messages will disappear after 1
keystroke instead of 25. Note that option \fB\-c\fR (\fB\-\-constantshow\fR)
overrides this.
.TP
.BR \-V ", " \-\-version
Show the current version number and exit.
@@ -165,8 +164,13 @@ should be considered as part of a word. This overrides option
Specify the name of the syntax highlighting to use from among the ones
defined in the \fInanorc\fP files.
.TP
.BR \-a ", " \-\-atblanks
When doing soft line wrapping, wrap lines at whitespace
instead of always at the edge of the screen.
.TP
.BR \-c ", " \-\-constantshow
Constantly show the cursor position. Note that this overrides \fB\-U\fP.
Constantly show the cursor position on the status bar.
Note that this overrides option \fB\-U\fR (\fB\-\-quickblank\fR).
.TP
.BR \-d ", " \-\-rebinddelete
Interpret the Delete key differently so that both Backspace and Delete
@@ -184,7 +188,7 @@ Show a summary of the available command-line options and exit.
Indent new lines to the previous line's indentation. Useful when
editing source code.
.TP
.BR \-k ", " \-\-cut
.BR \-k ", " \-\-cutfromcursor
Make the 'Cut Text' command (normally \fB^K\fR) cut from the current cursor
position to the end of the line, instead of cutting the entire line.
.TP
@@ -222,7 +226,7 @@ Hard-wrap lines at column \fInumber\fP. If this value is 0 or less, wrapping
will occur at the width of the screen less \fInumber\fP columns, allowing
the wrap point to vary along with the width of the screen if the screen
is resized. The default value is \-8. This option conflicts with
\fB\-w\fR -- the last one given takes effect.
\fB\-w\fR (\fB\-\-nowrap\fR) -- the last one given takes effect.
.TP
.BR \-s\ \fIprogram\fR ", " \-\-speller= \fIprogram
Use this alternative spell checker command.
@@ -240,7 +244,7 @@ Just view the file and disallow editing: read-only mode.
.TP
.BR \-w ", " \-\-nowrap
Disable the hard-wrapping of long lines. This option conflicts with
\fB\-r\fR -- the last one given takes effect.
\fB\-r\fR (\fB\-\-fill\fR) -- the last one given takes effect.
.TP
.BR \-x ", " \-\-nohelp
Don't show the two help lines at the bottom of the screen.
@@ -256,7 +260,7 @@ continuing it over multiple screen lines. Since
this option last when using other options (e.g.\& 'nano \-wS$') or pass it
separately (e.g.\& 'nano \-wS \-$').
.TP
.BR \-a ", " \-b ", " \-e ", " \-f ", " \-j
.BR \-b ", " \-e ", " \-f ", " \-j
Ignored, for compatibility with Pico.
.SH TOGGLES
@@ -301,7 +305,7 @@ Please report any other bugs that you encounter via:
\fIhttps://savannah.gnu.org/bugs/?group=nano\fR.
.SH HOMEPAGE
https://nano-editor.org/
\fIhttps://nano-editor.org/\fR
.SH SEE ALSO
.BR nanorc (5)

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,4 @@
.\" Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
.\" 2013, 2014, 2015 Free Software Foundation, Inc.
.\" Copyright (C) 2003-2011, 2013-2017 Free Software Foundation, Inc.
.\"
.\" This document is dual-licensed. You may distribute and/or modify it
.\" under the terms of either of the following licenses:
@@ -17,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 2.8.0" "March 2017"
.TH NANORC 5 "version 2.8.6" "July 2017"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
@@ -58,6 +57,10 @@ 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
NOT enable this option unless you are sure you need it.
.TP
.B set atblanks
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.
.TP
@@ -67,7 +70,7 @@ the file's name.
.TP
.B set backupdir "\fIdirectory\fP"
Make and keep not just one backup file, but make and keep a uniquely
numbered one every time a file is saved --- when backups are enabled
numbered one every time a file is saved -- when backups are enabled
with \fBset backup\fR or \fB\-\-backup\fR or \fB\-B\fR.
The uniquely numbered files are stored in the specified \fIdirectory\fR.
.TP
@@ -75,9 +78,10 @@ The uniquely numbered files are stored in the specified \fIdirectory\fR.
Do backwards searches by default.
.TP
.B set boldtext
Use bold instead of reverse video for the titlebar, statusbar, key combos,
and selected text. This can be overridden for the first three by setting
the options \fBtitlecolor\fP, \fBstatuscolor\fP, and \fBkeycolor\fP.
Use bold instead of reverse video for the title bar, status bar, key combos,
function tags, line numbers, and selected text. This can be overridden for
the first five by setting the options \fBtitlecolor\fP, \fBstatuscolor\fP,
\fBkeycolor\fP, \fBfunctioncolor\fP, and \fBnumbercolor\fP.
.TP
.B set brackets "\fIstring\fP"
Set the characters treated as closing brackets when justifying
@@ -91,14 +95,17 @@ Do case-sensitive searches by default.
.B set constantshow
Constantly display the cursor position in the status bar.
(The old form of this option, '\fBset const\fR', is deprecated.)
This overrides the option \fBquickblank\fR.
.TP
.B set cut
Use cut-to-end-of-line by default, instead of cutting the whole line.
.B set cutfromcursor
Use cut-from-cursor-to-end-of-line by default, instead of cutting the whole line.
(The old form of this option, '\fBset cut\fR', is deprecated.)
.TP
.B set fill \fInumber\fR
Hard-wrap lines at column number \fInumber\fR. If \fInumber\fR is 0 or less,
the maximum line length will be the screen width less \fInumber\fP columns.
The default value is \fB\-8\fR.
The default value is \fB\-8\fR. This option conflicts with
\fBnowrap\fR -- the last one given takes effect.
.TP
.B set functioncolor \fIfgcolor\fR,\fIbgcolor\fR
Specify the color combination to use for the function descriptions
@@ -130,7 +137,7 @@ come before the closing set, and the two sets must be in the same order.
The default value is "\fB(<[{)>]}\fP".
.TP
.B set morespace
Use the blank line below the titlebar as extra editing space.
Use the blank line below the title bar as extra editing space.
.TP
.B set mouse
Enable mouse support, if available for your system. When enabled, mouse
@@ -156,7 +163,8 @@ Don't pause between warnings at startup. This means that only
the last one will be visible (when there are multiple ones).
.TP
.B set nowrap
Don't hard-wrap text at all.
Don't hard-wrap text at all. This option conflicts with
\fBfill\fR -- the last one given takes effect.
.TP
.B set numbercolor \fIfgcolor\fR,\fIbgcolor\fR
Specify the color combination to use for line numbers.
@@ -183,8 +191,8 @@ specfified closing punctuation, optionally followed by closing brackets
(see \fBbrackets\fP), can end sentences. The default value is "\fB!.?\fP".
.TP
.B set quickblank
Do quick statusbar blanking. Statusbar messages will disappear after 1
keystroke instead of 25.
Do quick status-bar blanking: status-bar messages will disappear after 1
keystroke instead of 25. The option \fBconstantshow\fR overrides this.
.TP
.B set quiet
\fBnano\fP will not report errors in the \fInanorc\fP file nor ask them
@@ -234,7 +242,7 @@ Use spelling checker \fIspellprog\fP instead of the built-in one, which
calls \fIspell\fP.
.TP
.B set statuscolor \fIfgcolor\fR,\fIbgcolor\fR
Specify the color combination to use for the statusbar.
Specify the color combination to use for the status bar.
See \fBset titlecolor\fR for more details.
.TP
.B set suspend
@@ -251,7 +259,7 @@ Convert typed tabs to spaces.
Save automatically on exit, don't prompt.
.TP
.B set titlecolor \fIfgcolor\fR,\fIbgcolor\fR
Specify the color combination to use for the titlebar.
Specify the color combination to use for the title bar.
Valid names for the foreground and background colors are:
.BR white ", " black ", " blue ", " green ", " red ", " cyan ", " yellow ", and " magenta .
The name of the foreground color may be prefixed with \fBbright\fR.
@@ -267,7 +275,8 @@ Disallow file modification.
.TP
.B set whitespace "\fIstring\fP"
Set the two characters used to indicate the presence of tabs and
spaces. They must be single-column characters.
spaces. They must be single-column characters. The default pair
for a UTF-8 locale is "\fB\[Fc]\[md]\fR", and for other locales "\fB>.\fR".
.TP
.B set wordbounds
Detect word boundaries differently by treating punctuation
@@ -286,53 +295,58 @@ powerful enough to fully parse a file. Nevertheless, regular
expressions can do a lot and are easy to make, so they are a
good fit for a small editor like \fBnano\fR.
.sp
A separate syntax can be defined for each kind of file
For each kind of file a separate syntax can be defined
via the following commands:
.TP
.BR syntax " ""\fIstr\fR"" [""\fIfileregex\fR"" ...]"
Defines a syntax named \fIstr\fP which can be activated via the
.BR \-Y / \-\-syntax
command-line option, or will be automatically activated if
the current filename matches the extended regular expression
\fIfileregex\fP. All subsequent \fBcolor\fR, \fBicolor\fR,
\fBheader\fR and other such statements will apply to this
\fIstr\fP syntax until a new \fBsyntax\fR command is encountered.
.BR syntax " ""\fIname\fR"" [""\fIfileregex\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
command is encountered.
The \fBnone\fP syntax is reserved; specifying it on the command line is
the same as not having a syntax at all. The \fBdefault\fP syntax is
special: it takes no \fIfileregex\fP, and applies to files that don't
match any syntax's \fIfileregex\fP.
When \fBnano\fR is run, this syntax will be automatically
activated if the current filename matches the extended regular
expression \fIfileregex\fR. Or the syntax can be explicitly
activated by using the \fB-Y\fR or \fB\-\-syntax\fR
command-line option followed by the \fIname\fR.
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
is the same as not having a syntax at all.
.TP
.BR header " ""\fIregex\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"" " ...
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
file, to determine whether this syntax should be used for it.
(This functionality only works when \fBlibmagic\fP is installed on the
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
(this overrides the speller function when defined).
Use the given \fIprogram\fR to run a syntax check on the current file.
(This overrides the speller function.)
.TP
.BI formatter " program " \fR[ "arg " \fR...]
Use the given \fIprogram\fR to automatically reformat text.
Useful in certain programming languages (e.g. Go).
Use the given \fIprogram\fR to automatically reformat text --
useful in a programming language like Go.
(This overrides the speller and linter functions.)
.TP
.BR header " \fIregex\fR " ...
Add one or more regexes which will
be compared against the very first line of the file to be edited,
to determine whether this syntax should be used for that file.
.TP
.BR magic " \fIregex\fR " ...
Add one or more regexes which
will be compared against the result of querying the \fBmagic\fP
database about the file to be edited, to determine whether this
syntax should be used for that file. This
functionality only works when \fBlibmagic\fP is installed on the
system and will be silently ignored otherwise.
.TP
.BI comment " string"
Use the given string for commenting and uncommenting lines. A vertical bar or
pipe character (|) designates bracket-style comments; for example, "/*|*/" for
.BR comment " ""\fIstring\fR"""
Use the given string 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
characters after the pipe are appended at the end of the line. If no pipe
character is present, the entire string is prepended; for example, "#" for
Python files. If empty double quotes are specified, the comment/uncomment
function is disabled; for example, "" for JSON. Double quotes or backslashes
may be escaped with a backslash; for example, ".\\"" for man page source.
character is present, the full string is prepended; for example, "\fB#\fR"
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""" ...
Display all pieces of text that match
@@ -346,32 +360,33 @@ foreground. If your terminal supports transparency, not specifying a
background.
.TP
.B icolor \fIfgcolor\fR,\fIbgcolor\fR """\fIregex\fR""" ...
Same as above, except that the text matching is case insensitive.
Same as above, except that the matching is case insensitive.
.TP
.BR color " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIsr\fR"" " end= """\fIer\fR""
.BR color " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIfromrx\fR"" " end= """\fItorx\fR""
Display all pieces of text whose start matches extended regular expression
\fIsr\fP and whose end matches extended regular expression \fIer\fP with
\fIfromrx\fP and whose end matches extended regular expression \fItorx\fP with
foreground color \fIfgcolor\fP and background color \fIbgcolor\fP,
at least one of which must be specified. This means that, after an
initial instance of \fIsr\fP, all text will be highlighted until the
first instance of \fIer\fP. This allows syntax highlighting to span
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= """\fIsr\fR"" " end= """\fIer\fR""
Same as above, except that the text matching is case insensitive.
.BR icolor " \fIfgcolor\fR,\fIbgcolor\fR " start= """\fIfromrx\fR"" " end= """\fItorx\fR""
Same as above, except that the matching is case insensitive.
.TP
.BR include " ""\fIsyntaxfile\fR"""
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.
.TP
.BI extendsyntax " str directive " \fR[ "arg " \fR...]
Extend the syntax previously defined as \fIstr\fP to include
new information. This allows you to add a new \fBcolor\fP, \fBicolor\fP,
\fBheader\fP, \fBmagic\fP, \fBcomment\fP, \fBlinter\fP, or \fBformatter\fP directive
to an already defined syntax -- useful when you want to
.BI extendsyntax " name command " \fR[ "arg " \fR...]
Extend the syntax previously defined as \fIname\fR with another
\fIcommand\fR. This allows adding a new \fBcolor\fP, \fBicolor\fP,
\fBheader\fP, \fBmagic\fP, \fBcomment\fP, \fBlinter\fP, or \fBformatter\fP
command to an already defined syntax -- useful when you want to
slightly improve a syntax defined in one of the system-installed
files (which are normally not writable)
files (which normally are not writable).
.SH REBINDING KEYS
Key bindings can be changed via the following two commands:
.TP
@@ -665,7 +680,7 @@ Toggles the presence of the two-line list of key bindings at the bottom of the s
Toggles the constant display of the current line, column, and character positions.
.TP
.B morespace
Toggles the presence of the blank line which 'separates' the titlebar from the file text.
Toggles the presence of the blank line that 'separates' the title bar from the file text.
.TP
.B smoothscroll
Toggles smooth scrolling (when moving around with the arrow keys).

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.8.0" "March 2017"
.TH RNANO 1 "version 2.8.6" "July 2017"
.\" Please adjust this date whenever revising the manpage.
.SH NAME

View File

@@ -20,6 +20,10 @@
## versions of nano installed (e.g. your home directory is on NFS).
# set quiet
## 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.
# set autoindent
@@ -44,13 +48,14 @@
## Do case-sensitive searches by default.
# set casesensitive
## Constantly display the cursor position in the statusbar. Note that
## Constantly display the cursor position in the status bar. Note that
## this overrides "quickblank".
# set constantshow
## (The old form, 'const', is deprecated.)
## Use cut-to-end-of-line by default.
# set cut
## Use cut-from-cursor-to-end-of-line by default.
# set cutfromcursor
## (The old form, 'cut', is deprecated.)
## Set the line length for wrapping text and justifying paragraphs.
## If the value is 0 or less, the wrapping point will be the screen
@@ -76,7 +81,7 @@
## come before the latter set, and both must be in the same order.
# set matchbrackets "(<[{)>]}"
## Use the blank line below the titlebar as extra editing space.
## Use the blank line below the title bar as extra editing space.
# set morespace
## Enable mouse support, if available for your system. When enabled,
@@ -124,8 +129,8 @@
## sentences.
# set punct "!.?"
## Do quick statusbar blanking. Statusbar messages will disappear after
## 1 keystroke instead of 26. Note that "const" overrides this.
## Do quick status-bar blanking. Status-bar messages will disappear after
## 1 keystroke instead of 26. Note that "constantshow" overrides this.
# set quickblank
## The email-quote string, used to justify email-quoted paragraphs.

1063
po/bg.po

File diff suppressed because it is too large Load Diff

1077
po/ca.po

File diff suppressed because it is too large Load Diff

1070
po/cs.po

File diff suppressed because it is too large Load Diff

1183
po/da.po

File diff suppressed because it is too large Load Diff

1206
po/de.po

File diff suppressed because it is too large Load Diff

1084
po/eo.po

File diff suppressed because it is too large Load Diff

1104
po/es.po

File diff suppressed because it is too large Load Diff

1067
po/eu.po

File diff suppressed because it is too large Load Diff

1068
po/fi.po

File diff suppressed because it is too large Load Diff

1157
po/fr.po

File diff suppressed because it is too large Load Diff

1076
po/ga.po

File diff suppressed because it is too large Load Diff

1068
po/gl.po

File diff suppressed because it is too large Load Diff

2088
po/hr.po

File diff suppressed because it is too large Load Diff

1276
po/hu.po

File diff suppressed because it is too large Load Diff

1063
po/id.po

File diff suppressed because it is too large Load Diff

1120
po/it.po

File diff suppressed because it is too large Load Diff

1214
po/ja.po

File diff suppressed because it is too large Load Diff

1069
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1074
po/nb.po

File diff suppressed because it is too large Load Diff

1099
po/nl.po

File diff suppressed because it is too large Load Diff

1063
po/nn.po

File diff suppressed because it is too large Load Diff

1070
po/pl.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1144
po/ro.po

File diff suppressed because it is too large Load Diff

1066
po/ru.po

File diff suppressed because it is too large Load Diff

1063
po/sl.po

File diff suppressed because it is too large Load Diff

1122
po/sr.po

File diff suppressed because it is too large Load Diff

1071
po/sv.po

File diff suppressed because it is too large Load Diff

2124
po/tr.po

File diff suppressed because it is too large Load Diff

1071
po/uk.po

File diff suppressed because it is too large Load Diff

1077
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

@@ -4,7 +4,7 @@ AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -DSYSCONFDIR=\"$(sysconfdir)\" \
CLEANFILES = revision.h
if BUILDING_FROM_GIT
SOMETHING = "REVISION \"$(shell git describe --tags 2>/dev/null)\""
SOMETHING = "REVISION \"`git describe --tags 2>/dev/null`\""
else
SOMETHING = "NOTHING \"from tarball\""
endif
@@ -12,12 +12,13 @@ endif
nano.o: revision.h
winio.o: revision.h
revision.h: update_revision
# Always run the commands in this rule. But update the target
# only when the revision actually changed.
revision.h: FORCE
@[ -f $@ ] || touch $@
@echo "#define $(SOMETHING)" | cmp -s $@ - || \
echo "#define $(SOMETHING)" > $@
.PHONY: update_revision
echo "#define $(SOMETHING)" > $@
FORCE:
bin_PROGRAMS = nano
nano_SOURCES = browser.c \
@@ -36,9 +37,10 @@ nano_SOURCES = browser.c \
search.c \
text.c \
utils.c \
winio.c
winio.c
nano_LDADD = @LIBINTL@ $(top_builddir)/lib/libgnu.a
nano_LDADD = @LIBINTL@ $(top_builddir)/lib/libgnu.a \
$(LIB_CLOCK_GETTIME) $(LIBTHREAD)
install-exec-hook:
cd $(DESTDIR)$(bindir) && rm -f rnano && $(LN_S) nano rnano

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* browser.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, *
* 2010, 2011, 2013, 2014, 2015 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2015, 2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -28,7 +27,7 @@
#include <unistd.h>
#include <errno.h>
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
static char **filelist = NULL;
/* The list of files to display in the file browser. */
@@ -123,7 +122,7 @@ char *do_browser(char *path)
kbinput = get_kbinput(edit);
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y;
@@ -152,7 +151,7 @@ char *do_browser(char *path)
continue;
}
#endif /* !DISABLE_MOUSE */
#endif /* ENABLE_MOUSE */
func = parse_browser_input(&kbinput);
@@ -163,7 +162,7 @@ char *do_browser(char *path)
kbinput = KEY_WINCH;
#endif
} else if (func == do_help_void) {
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
do_help_void();
#ifndef NANO_TINY
/* The window dimensions might have changed, so act as if. */
@@ -184,20 +183,29 @@ char *do_browser(char *path)
} else if (func == do_right) {
if (selected < filelist_len - 1)
selected++;
#ifndef NANO_TINY
} else if (func == do_prev_word_void) {
selected -= (selected % width);
} else if (func == do_next_word_void) {
selected += width - 1 - (selected % width);
if (selected >= filelist_len)
selected = filelist_len - 1;
#endif
} else if (func == do_up_void) {
if (selected >= width)
selected -= width;
} else if (func == do_down_void) {
if (selected + width <= filelist_len - 1)
selected += width;
} else if (func == do_prev_block) {
selected = ((selected / (editwinrows * width)) *
editwinrows * width) + selected % width;
} else if (func == do_next_block) {
selected = ((selected / (editwinrows * width)) *
editwinrows * width) + selected % width +
editwinrows * width - width;
if (selected >= filelist_len)
selected = (filelist_len / width) * width + selected % width;
if (selected >= filelist_len)
selected -= width;
} else if (func == do_page_up) {
if (selected < width)
selected = 0;
@@ -480,7 +488,11 @@ functionptrtype parse_browser_input(int *kbinput)
return do_enter;
case 'W':
case 'w':
case '/':
return do_search;
case 'N':
case 'n':
return do_research;
}
}
return func_from_key(kbinput);
@@ -798,4 +810,4 @@ char *strip_last_component(const char *path)
return copy;
}
#endif /* !DISABLE_BROWSER */
#endif /* ENABLE_BROWSER */

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* chars.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, *
* 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -71,13 +70,11 @@ void mbtowc_reset(void)
/* This function is equivalent to isalpha() for multibyte characters. */
bool is_alpha_mbchar(const char *c)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
return 0;
}
@@ -91,13 +88,11 @@ bool is_alpha_mbchar(const char *c)
/* This function is equivalent to isalnum() for multibyte characters. */
bool is_alnum_mbchar(const char *c)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
return 0;
}
@@ -111,13 +106,11 @@ bool is_alnum_mbchar(const char *c)
/* This function is equivalent to isblank() for multibyte characters. */
bool is_blank_mbchar(const char *c)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
return 0;
}
@@ -159,13 +152,11 @@ bool is_cntrl_mbchar(const char *c)
/* This function is equivalent to ispunct() for multibyte characters. */
bool is_punct_mbchar(const char *c)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
return 0;
}
@@ -188,7 +179,7 @@ bool is_word_mbchar(const char *c, bool allow_punct)
return TRUE;
if (word_chars != NULL && *word_chars != '\0') {
char symbol[mb_cur_max() + 1];
char symbol[MAXCHARLEN + 1];
int symlen = parse_mbchar(c, symbol, NULL);
symbol[symlen] = '\0';
@@ -235,12 +226,10 @@ char control_mbrep(const char *c, bool isdata)
* return the number of columns that the character occupies. */
int length_of_char(const char *c, int *width)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
int charlen = mbtowc(&wc, c, MB_CUR_MAX);
int charlen = mbtowc(&wc, c, MAXCHARLEN);
/* If the sequence is invalid... */
if (charlen < 0) {
@@ -266,14 +255,12 @@ int length_of_char(const char *c, int *width)
/* This function is equivalent to wcwidth() for multibyte characters. */
int mbwidth(const char *c)
{
assert(c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
wchar_t wc;
int width;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
return 1;
}
@@ -289,17 +276,6 @@ int mbwidth(const char *c)
return 1;
}
/* Return the maximum length (in bytes) of a character. */
int mb_cur_max(void)
{
#ifdef ENABLE_UTF8
if (use_utf8)
return MB_CUR_MAX;
else
#endif
return 1;
}
/* Convert the Unicode value in chr to a multibyte character, if possible.
* If the conversion succeeds, return the (dynamically allocated) multibyte
* character and its length. Otherwise, return an undefined (dynamically
@@ -310,7 +286,7 @@ char *make_mbchar(long chr, int *chr_mb_len)
#ifdef ENABLE_UTF8
if (use_utf8) {
chr_mb = charalloc(MB_CUR_MAX);
chr_mb = charalloc(MAXCHARLEN);
*chr_mb_len = wctomb(chr_mb, (wchar_t)chr);
/* Reject invalid Unicode characters. */
@@ -333,14 +309,10 @@ char *make_mbchar(long chr, int *chr_mb_len)
* col isn't NULL, add the character's width (in columns) to it. */
int parse_mbchar(const char *buf, char *chr, size_t *col)
{
int length;
assert(buf != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
/* Get the number of bytes in the multibyte character. */
length = mblen(buf, MB_CUR_MAX);
int length = mblen(buf, MAXCHARLEN);
/* When the multibyte sequence is invalid, only take the first byte. */
if (length <= 0) {
@@ -370,12 +342,11 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
} else
*col += mbwidth(buf);
}
return length;
} else
#endif
{
/* A byte character is one byte long. */
length = 1;
/* When requested, store the byte character in chr. */
if (chr != NULL)
*chr = *buf;
@@ -394,33 +365,48 @@ int parse_mbchar(const char *buf, char *chr, size_t *col)
else
(*col)++;
}
}
return length;
return 1;
}
}
/* Return the index in buf of the beginning of the multibyte character
* before the one at pos. */
size_t move_mbleft(const char *buf, size_t pos)
{
size_t before, char_len = 0;
#ifdef ENABLE_UTF8
if (use_utf8) {
size_t before, char_len = 0;
assert(buf != NULL && pos <= strlen(buf));
if (pos < 4)
before = 0;
else {
const char *ptr = buf + pos;
/* There is no library function to move backward one multibyte
* character. So we just start groping for one at the farthest
* possible point. */
if (mb_cur_max() > pos)
before = 0;
else
before = pos - mb_cur_max();
/* Probe for a valid starter byte in the preceding four bytes. */
if ((signed char)*(--ptr) > -65)
before = pos - 1;
else if ((signed char)*(--ptr) > -65)
before = pos - 2;
else if ((signed char)*(--ptr) > -65)
before = pos - 3;
else if ((signed char)*(--ptr) > -65)
before = pos - 4;
else
before = pos - 1;
}
while (before < pos) {
char_len = parse_mbchar(buf + before, NULL, NULL);
before += char_len;
}
/* Move forward again until we reach the original character,
* so we know the length of its preceding the character. */
while (before < pos) {
char_len = parse_mbchar(buf + before, NULL, NULL);
before += char_len;
}
return before - char_len;
return before - char_len;
} else
#endif
return (pos == 0 ? 0 : pos - 1);
}
/* Return the index in buf of the beginning of the multibyte character
@@ -446,12 +432,12 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
while (*s1 != '\0' && *s2 != '\0' && n > 0) {
bool bad1 = FALSE, bad2 = FALSE;
if (mbtowc(&wc1, s1, MB_CUR_MAX) < 0) {
if (mbtowc(&wc1, s1, MAXCHARLEN) < 0) {
mbtowc_reset();
bad1 = TRUE;
}
if (mbtowc(&wc2, s2, MB_CUR_MAX) < 0) {
if (mbtowc(&wc2, s2, MAXCHARLEN) < 0) {
mbtowc_reset();
bad2 = TRUE;
}
@@ -485,12 +471,7 @@ char *mbstrcasestr(const char *haystack, const char *needle)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
size_t needle_len;
if (*needle == '\0')
return (char *)haystack;
needle_len = mbstrlen(needle);
size_t needle_len = mbstrlen(needle);
while (*haystack != '\0') {
if (mbstrncasecmp(haystack, needle, needle_len) == 0)
@@ -506,19 +487,13 @@ char *mbstrcasestr(const char *haystack, const char *needle)
}
/* This function is equivalent to strstr(), except in that it scans the
* string in reverse, starting at rev_start. */
* string in reverse, starting at pointer. */
char *revstrstr(const char *haystack, const char *needle,
const char *pointer)
{
size_t needle_len = strlen(needle);
size_t tail_len = strlen(pointer);
if (needle_len == 0)
return (char *)pointer;
if (strlen(haystack) < needle_len)
return NULL;
if (tail_len < needle_len)
pointer += tail_len - needle_len;
@@ -532,65 +507,53 @@ char *revstrstr(const char *haystack, const char *needle,
}
/* This function is equivalent to strcasestr(), except in that it scans
* the string in reverse, starting at rev_start. */
char *revstrcasestr(const char *haystack, const char *needle, const char
*rev_start)
* the string in reverse, starting at pointer. */
char *revstrcasestr(const char *haystack, const char *needle,
const char *pointer)
{
size_t rev_start_len, needle_len;
size_t needle_len = strlen(needle);
size_t tail_len = strlen(pointer);
if (*needle == '\0')
return (char *)rev_start;
if (tail_len < needle_len)
pointer += tail_len - needle_len;
needle_len = strlen(needle);
if (strlen(haystack) < needle_len)
return NULL;
rev_start_len = strlen(rev_start);
for (; rev_start >= haystack; rev_start--, rev_start_len++) {
if (rev_start_len >= needle_len && strncasecmp(rev_start,
needle, needle_len) == 0)
return (char *)rev_start;
while (pointer >= haystack) {
if (strncasecmp(pointer, needle, needle_len) == 0)
return (char *)pointer;
pointer--;
}
return NULL;
}
/* This function is equivalent to strcasestr() for multibyte strings,
* except in that it scans the string in reverse, starting at rev_start. */
char *mbrevstrcasestr(const char *haystack, const char *needle, const
char *rev_start)
* except in that it scans the string in reverse, starting at pointer. */
char *mbrevstrcasestr(const char *haystack, const char *needle,
const char *pointer)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
size_t rev_start_len, needle_len;
size_t needle_len = mbstrlen(needle);
size_t tail_len = mbstrlen(pointer);
if (*needle == '\0')
return (char *)rev_start;
if (tail_len < needle_len)
pointer += tail_len - needle_len;
needle_len = mbstrlen(needle);
if (mbstrlen(haystack) < needle_len)
if (pointer < haystack)
return NULL;
rev_start_len = mbstrlen(rev_start);
while (TRUE) {
if (rev_start_len >= needle_len &&
mbstrncasecmp(rev_start, needle, needle_len) == 0)
return (char *)rev_start;
if (mbstrncasecmp(pointer, needle, needle_len) == 0)
return (char *)pointer;
/* If we've reached the head of the haystack, we found nothing. */
if (rev_start == haystack)
if (pointer == haystack)
return NULL;
rev_start = haystack + move_mbleft(haystack, rev_start - haystack);
rev_start_len++;
pointer = haystack + move_mbleft(haystack, pointer - haystack);
}
} else
#endif
return revstrcasestr(haystack, needle, rev_start);
return revstrcasestr(haystack, needle, pointer);
}
/* This function is equivalent to strlen() for multibyte strings. */
@@ -620,16 +583,14 @@ size_t mbstrnlen(const char *s, size_t maxlen)
/* This function is equivalent to strchr() for multibyte strings. */
char *mbstrchr(const char *s, const char *c)
{
assert(s != NULL && c != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
bool bad_s_mb = FALSE, bad_c_mb = FALSE;
char symbol[MB_CUR_MAX];
char symbol[MAXCHARLEN];
const char *q = s;
wchar_t ws, wc;
if (mbtowc(&wc, c, MB_CUR_MAX) < 0) {
if (mbtowc(&wc, c, MAXCHARLEN) < 0) {
mbtowc_reset();
wc = (unsigned char)*c;
bad_c_mb = TRUE;
@@ -678,59 +639,54 @@ char *mbstrpbrk(const char *s, const char *accept)
return (char *) strpbrk(s, accept);
}
/* This function is equivalent to strpbrk(), except in that it scans the
* string in reverse, starting at rev_start. */
char *revstrpbrk(const char *s, const char *accept, const char
*rev_start)
/* Locate, in the string that starts at head, the first occurrence of any of
* the characters in the string accept, starting from pointer and searching
* backwards. */
char *revstrpbrk(const char *head, const char *accept, const char *pointer)
{
assert(s != NULL && accept != NULL && rev_start != NULL);
if (*rev_start == '\0') {
if (rev_start == s)
if (*pointer == '\0') {
if (pointer == head)
return NULL;
rev_start--;
pointer--;
}
for (; rev_start >= s; rev_start--) {
if (strchr(accept, *rev_start) != NULL)
return (char *)rev_start;
while (pointer >= head) {
if (strchr(accept, *pointer) != NULL)
return (char *)pointer;
pointer--;
}
return NULL;
}
/* This function is equivalent to strpbrk() for multibyte strings,
* except in that it scans the string in reverse, starting at rev_start. */
char *mbrevstrpbrk(const char *s, const char *accept, const char
*rev_start)
/* The same as the preceding function but then for multibyte strings. */
char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer)
{
assert(s != NULL && accept != NULL && rev_start != NULL);
#ifdef ENABLE_UTF8
if (use_utf8) {
if (*rev_start == '\0') {
if (rev_start == s)
if (*pointer == '\0') {
if (pointer == head)
return NULL;
rev_start = s + move_mbleft(s, rev_start - s);
pointer = head + move_mbleft(head, pointer - head);
}
while (TRUE) {
if (mbstrchr(accept, rev_start) != NULL)
return (char *)rev_start;
if (mbstrchr(accept, pointer) != NULL)
return (char *)pointer;
/* If we've reached the head of the string, we found nothing. */
if (rev_start == s)
if (pointer == head)
return NULL;
rev_start = s + move_mbleft(s, rev_start - s);
pointer = head + move_mbleft(head, pointer - head);
}
} else
#endif
return revstrpbrk(s, accept, rev_start);
return revstrpbrk(head, accept, pointer);
}
#endif /* !NANO_TINY */
#if !defined(DISABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
/* Return TRUE if the string s contains one or more blank characters,
* and FALSE otherwise. */
bool has_blank_chars(const char *s)
@@ -749,7 +705,7 @@ bool has_blank_mbchars(const char *s)
{
#ifdef ENABLE_UTF8
if (use_utf8) {
char symbol[MB_CUR_MAX];
char symbol[MAXCHARLEN];
for (; *s != '\0'; s += move_mbright(s, 0)) {
parse_mbchar(s, symbol, NULL);
@@ -763,7 +719,7 @@ bool has_blank_mbchars(const char *s)
#endif
return has_blank_chars(s);
}
#endif /* !DISABLE_NANORC && (!NANO_TINY || !DISABLE_JUSTIFY) */
#endif /* ENABLE_NANORC && (!NANO_TINY || !DISABLE_JUSTIFY) */
#ifdef ENABLE_UTF8
/* Return TRUE if wc is valid Unicode, and FALSE otherwise. */
@@ -776,7 +732,7 @@ bool is_valid_unicode(wchar_t wc)
}
#endif
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
/* Check if the string s is a valid multibyte string. Return TRUE if it
* is, and FALSE otherwise. */
bool is_valid_mbstring(const char *s)
@@ -788,4 +744,4 @@ bool is_valid_mbstring(const char *s)
#endif
return TRUE;
}
#endif /* !DISABLE_NANORC */
#endif /* ENABLE_NANORC */

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* color.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, *
* 2010, 2011, 2013, 2014, 2015 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2014, 2015, 2016, 2017 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -25,7 +24,6 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <unistd.h>
#ifdef HAVE_MAGIC_H
@@ -55,8 +53,9 @@ void set_colorpairs(void)
for (i = 0; i < NUMBER_OF_ELEMENTS; i++) {
bool bright = FALSE;
if (parse_color_names(specified_color_combo[i],
&foreground, &background, &bright)) {
if (specified_color_combo[i] != NULL &&
parse_color_names(specified_color_combo[i],
&foreground, &background, &bright)) {
if (foreground == -1 && !using_defaults)
foreground = COLOR_WHITE;
if (background == -1 && !using_defaults)
@@ -64,8 +63,7 @@ void set_colorpairs(void)
init_pair(i + 1, foreground, background);
interface_color_pair[i] =
COLOR_PAIR(i + 1) | (bright ? A_BOLD : A_NORMAL);
}
else {
} else {
if (i != FUNCTION_TAG)
interface_color_pair[i] = hilite_attribute;
else
@@ -133,6 +131,8 @@ void color_init(void)
fprintf(stderr, "init_pair(): fg = %hd, bg = %hd\n", foreground, background);
#endif
}
have_palette = TRUE;
}
/* Try to match the given shibboleth string with one of the regexes in

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* cut.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2014 Mark Majeres *
* Copyright (C) 2016 Benno Schulenberg *
* *
@@ -109,8 +108,8 @@ void cut_to_eof(void)
}
#endif /* !NANO_TINY */
/* Move text from the current filestruct into the cutbuffer. If
* copy_text is TRUE, copy the text back into the filestruct afterward.
/* Move text from the current buffer into the cutbuffer. If
* copy_text is TRUE, copy the text back into the buffer afterward.
* If cut_till_eof is TRUE, move all text from the current cursor
* position to the end of the file into the cutbuffer. */
void do_cut_text(bool copy_text, bool cut_till_eof)
@@ -156,7 +155,7 @@ void do_cut_text(bool copy_text, bool cut_till_eof)
/* Move the marked text to the cutbuffer, and turn the mark off. */
cut_marked(&right_side_up);
openfile->mark_set = FALSE;
} else if (ISSET(CUT_TO_END))
} else if (ISSET(CUT_FROM_CURSOR))
/* Move all text up to the end of the line into the cutbuffer. */
cut_to_eol();
else
@@ -202,7 +201,7 @@ void do_cut_text(bool copy_text, bool cut_till_eof)
#endif
}
/* Move text from the current filestruct into the cutbuffer. */
/* Move text from the current buffer into the cutbuffer. */
void do_cut_text_void(void)
{
#ifndef NANO_TINY
@@ -215,8 +214,8 @@ void do_cut_text_void(void)
}
#ifndef NANO_TINY
/* Move text from the current filestruct into the cutbuffer, and copy it
* back into the filestruct afterward. If the mark is set or the cursor
/* Move text from the current buffer into the cutbuffer, and copy it
* back into the buffer afterward. If the mark is set or the cursor
* was moved, blow away previous contents of the cutbuffer. */
void do_copy_text(void)
{
@@ -249,13 +248,13 @@ void do_copy_text(void)
/* Cut from the current cursor position to the end of the file. */
void do_cut_till_eof(void)
{
add_undo(CUT_EOF);
add_undo(CUT_TO_EOF);
do_cut_text(FALSE, TRUE);
update_undo(CUT_EOF);
update_undo(CUT_TO_EOF);
}
#endif /* !NANO_TINY */
/* Copy text from the cutbuffer into the current filestruct. */
/* Copy text from the cutbuffer into the current buffer. */
void do_uncut_text(void)
{
ssize_t was_lineno = openfile->current->lineno;
@@ -271,10 +270,10 @@ void do_uncut_text(void)
add_undo(PASTE);
if (ISSET(SOFTWRAP))
was_leftedge = (xplustabs() / editwincols) * editwincols;
was_leftedge = leftedge_for(xplustabs(), openfile->current);
#endif
/* Add a copy of the text in the cutbuffer to the current filestruct
/* Add a copy of the text in the cutbuffer to the current buffer
* at the current cursor position. */
copy_from_buffer(cutbuffer);
@@ -292,8 +291,8 @@ void do_uncut_text(void)
/* Mark the file as modified. */
set_modified();
/* Update the cursor position to account for the inserted lines. */
reset_cursor();
/* Update current_y to account for the inserted lines. */
place_the_cursor(TRUE);
refresh_needed = TRUE;

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* files.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2015, 2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -22,10 +21,10 @@
#include "proto.h"
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <utime.h>
#include <fcntl.h>
#include <errno.h>
#include <ctype.h>
@@ -63,32 +62,29 @@ bool has_valid_path(const char *filename)
return validity;
}
/* Add an entry to the circular list of openfile structs. */
/* Add an item to the circular list of openfile structs. */
void make_new_buffer(void)
{
openfilestruct *newnode = make_new_opennode();
if (openfile == NULL) {
openfile = make_new_opennode();
/* Make the first open file the only element in the list. */
openfile->prev = openfile;
openfile->next = openfile;
newnode->prev = newnode;
newnode->next = newnode;
} else {
openfilestruct *newnode = make_new_opennode();
/* Add the new open file after the current one in the list. */
newnode->prev = openfile;
newnode->next = openfile->next;
openfile->next->prev = newnode;
openfile->next = newnode;
/* Make the new file the current one. */
openfile = newnode;
/* There is more than one file open: show Close in help lines. */
/* There is more than one file open: show "Close" in help lines. */
exitfunc->desc = close_tag;
}
/* Start initializing the new buffer. */
/* Make the new buffer the current one, and start initializing it. */
openfile = newnode;
openfile->filename = mallocstrcpy(NULL, "");
initialize_buffer_text();
@@ -118,11 +114,9 @@ void make_new_buffer(void)
#endif
}
/* Initialize the text of the current openfile struct. */
/* Initialize the text and pointers of the current openfile struct. */
void initialize_buffer_text(void)
{
assert(openfile != NULL);
openfile->fileage = make_new_node(NULL);
openfile->fileage->data = mallocstrcpy(NULL, "");
@@ -436,8 +430,6 @@ bool open_buffer(const char *filename, bool undoable)
/* rc == -2 means that we have a new file. -1 means that the
* open() failed. 0 means that the open() succeeded. */
assert(filename != NULL);
/* Display newlines in filenames as ^J. */
as_an_at = FALSE;
@@ -471,12 +463,12 @@ bool open_buffer(const char *filename, bool undoable)
if (new_buffer) {
make_new_buffer();
if (has_valid_path(realname)) {
if (!inhelp && has_valid_path(realname)) {
#ifndef NANO_TINY
if (ISSET(LOCKING) && filename[0] != '\0') {
/* When not overriding an existing lock, discard the buffer. */
if (do_lockfile(realname) < 0) {
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
close_buffer();
#endif
free(realname);
@@ -490,7 +482,7 @@ bool open_buffer(const char *filename, bool undoable)
/* If the filename isn't blank, and we are not in NOREAD_MODE,
* open the file. Otherwise, treat it as a new file. */
rc = (filename[0] != '\0' && !ISSET(NOREAD_MODE)) ?
open_file(realname, new_buffer, FALSE, &f) : -2;
open_file(realname, new_buffer, inhelp, &f) : -2;
/* If we have a file, and we're loading into a new buffer, update
* the filename. */
@@ -533,8 +525,6 @@ void replace_buffer(const char *filename)
FILE *f;
int descriptor;
assert(filename != NULL && filename[0] != '\0');
/* Open the file quietly. */
descriptor = open_file(filename, FALSE, TRUE, &f);
@@ -584,39 +574,35 @@ void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
if (!old_no_newlines)
UNSET(NO_NEWLINES);
}
#endif /* !ENABLE_TINY */
#endif /* !NANO_TINY */
#endif /* !DISABLE_SPELLER */
/* Update the screen to account for the current buffer. */
void display_buffer(void)
/* Update the titlebar and the multiline cache to match the current buffer. */
void prepare_for_display(void)
{
/* Update the titlebar, since the filename may have changed. */
titlebar(NULL);
if (!inhelp)
titlebar(NULL);
#ifndef DISABLE_COLOR
/* Make sure we're using the buffer's associated colors. */
color_init();
/* If there are multiline coloring regexes, and there is no
* multiline cache data yet, precalculate it now. */
if (openfile->syntax && openfile->syntax->nmultis > 0 &&
openfile->fileage->multidata == NULL)
precalc_multicolorinfo();
#endif
/* Update the content of the edit window straightaway. */
edit_refresh();
have_palette = FALSE;
#endif
refresh_needed = TRUE;
}
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
/* Switch to a neighbouring file buffer; to the next if to_next is TRUE;
* otherwise, to the previous one. */
void switch_to_prevnext_buffer(bool to_next)
{
assert(openfile != NULL);
/* If only one file buffer is open, say so and get out. */
if (openfile == openfile->next) {
if (openfile == openfile->next && !inhelp) {
statusbar(_("No more open file buffers"));
return;
}
@@ -636,13 +622,19 @@ void switch_to_prevnext_buffer(bool to_next)
openfile->firstcolumn = 0;
#endif
/* Update the screen to account for the current buffer. */
display_buffer();
/* Update titlebar and multiline info to match the current buffer. */
prepare_for_display();
if (inhelp)
return;
/* Ensure that the main loop will redraw the help lines. */
currmenu = MMOST;
/* Indicate the switch on the statusbar. */
statusline(HUSH, _("Switched to %s"),
((openfile->filename[0] == '\0') ?
_("New Buffer") : openfile->filename));
((openfile->filename[0] == '\0') ?
_("New Buffer") : openfile->filename));
#ifdef DEBUG
dump_filestruct(openfile->current);
@@ -666,8 +658,6 @@ void switch_to_next_buffer_void(void)
* open buffers. */
bool close_buffer(void)
{
assert(openfile != NULL);
/* If only one file buffer is open, get out. */
if (openfile == openfile->next)
return FALSE;
@@ -684,13 +674,13 @@ bool close_buffer(void)
/* Close the file buffer we had open before. */
unlink_opennode(openfile->prev);
/* If only one buffer is open now, show Exit in the help lines. */
/* If now just one buffer remains open, show "Exit" in the help lines. */
if (openfile == openfile->next)
exitfunc->desc = exit_tag;
return TRUE;
}
#endif /* !DISABLE_MULTIBUFFER */
#endif /* ENABLE_MULTIBUFFER */
/* Do a quick permissions check by verifying whether the file is appendable.
* Err on the side of permissiveness (reporting TRUE when it might be wrong)
@@ -707,8 +697,6 @@ int is_file_writable(const char *filename)
if (ISSET(VIEW_MODE))
return TRUE;
assert(filename != NULL);
/* Get the specified file's full path. */
full_filename = get_full_path(filename);
@@ -784,7 +772,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
add_undo(INSERT);
if (ISSET(SOFTWRAP))
was_leftedge = (xplustabs() / editwincols) * editwincols;
was_leftedge = leftedge_for(xplustabs(), openfile->current);
#endif
/* Create an empty buffer. */
@@ -909,6 +897,10 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
/* Set the desired x position at the end of what was inserted. */
openfile->placewewant = xplustabs();
/* If we've read a help file, don't give any feedback. */
if (inhelp)
return;
if (!writable)
statusline(ALERT, _("File '%s' is unwritable"), filename);
#ifndef NANO_TINY
@@ -934,7 +926,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable,
(unsigned long)num_lines), (unsigned long)num_lines);
/* If we inserted less than a screenful, don't center the cursor. */
if (less_than_a_screenful(was_lineno, was_leftedge))
if (undoable && less_than_a_screenful(was_lineno, was_leftedge))
focusing = FALSE;
#ifndef NANO_TINY
@@ -956,8 +948,6 @@ int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
int fd;
char *full_filename;
assert(filename != NULL && f != NULL);
/* Get the specified file's full path. */
full_filename = get_full_path(filename);
@@ -1002,7 +992,7 @@ int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
if (*f == NULL) {
statusline(ALERT, _("Error reading %s: %s"), filename, strerror(errno));
close(fd);
} else
} else if (!inhelp)
statusbar(_("Reading File"));
}
@@ -1021,8 +1011,6 @@ char *get_next_filename(const char *name, const char *suffix)
char *buf;
size_t wholenamelen;
assert(name != NULL && suffix != NULL);
wholenamelen = strlen(name) + strlen(suffix);
/* Reserve space for: the name plus the suffix plus a dot plus
@@ -1067,7 +1055,7 @@ void do_insertfile(void)
while (TRUE) {
#ifndef NANO_TINY
if (execute) {
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER))
/* TRANSLATORS: The next four messages are prompts. */
msg = _("Command to execute in new buffer");
@@ -1077,7 +1065,7 @@ void do_insertfile(void)
} else
#endif /* NANO_TINY */
{
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER))
msg = _("File to insert into new buffer [from %s]");
else
@@ -1109,14 +1097,13 @@ void do_insertfile(void)
} else {
ssize_t was_current_lineno = openfile->current->lineno;
size_t was_current_x = openfile->current_x;
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
#if !defined(NANO_TINY) || defined(ENABLE_BROWSER) || defined(ENABLE_MULTIBUFFER)
functionptrtype func = func_from_key(&i);
#endif
given = mallocstrcpy(given, answer);
#ifndef NANO_TINY
#ifndef DISABLE_MULTIBUFFER
if (func == new_buffer_void) {
#ifdef ENABLE_MULTIBUFFER
if (func == flip_newbuffer) {
/* Don't allow toggling when in view mode. */
if (!ISSET(VIEW_MODE))
TOGGLE(MULTIBUFFER);
@@ -1125,13 +1112,13 @@ void do_insertfile(void)
continue;
}
#endif
if (func == flip_execute_void) {
#ifndef NANO_TINY
if (func == flip_execute) {
execute = !execute;
continue;
}
#endif /* !NANO_TINY */
#ifndef DISABLE_BROWSER
#endif
#ifdef ENABLE_BROWSER
if (func == to_files_void) {
char *chosen = do_browse_from(answer);
@@ -1150,7 +1137,7 @@ void do_insertfile(void)
#ifndef NANO_TINY
if (execute) {
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
/* When in multibuffer mode, first open a blank buffer. */
if (ISSET(MULTIBUFFER))
open_buffer("", FALSE);
@@ -1158,7 +1145,7 @@ void do_insertfile(void)
/* Save the command's output in the current buffer. */
execute_command(answer);
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
/* If this is a new buffer, put the cursor at the top. */
if (ISSET(MULTIBUFFER)) {
openfile->current = openfile->fileage;
@@ -1179,7 +1166,7 @@ void do_insertfile(void)
open_buffer(answer, TRUE);
}
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
if (ISSET(MULTIBUFFER)) {
#ifndef DISABLE_HISTORIES
if (ISSET(POS_HISTORY)) {
@@ -1192,17 +1179,17 @@ void do_insertfile(void)
}
#endif /* !DISABLE_HISTORIES */
/* Update stuff to account for the current buffer. */
display_buffer();
prepare_for_display();
} else
#endif /* !DISABLE_MULTIBUFFER */
#endif /* ENABLE_MULTIBUFFER */
{
/* Mark the file as modified if it changed. */
if (openfile->current->lineno != was_current_lineno ||
openfile->current_x != was_current_x)
set_modified();
/* Update the cursor position to account for inserted lines. */
reset_cursor();
/* Update current_y to account for inserted lines. */
place_the_cursor(TRUE);
refresh_needed = TRUE;
}
@@ -1219,7 +1206,7 @@ void do_insertfile_void(void)
{
if (ISSET(RESTRICTED))
show_restricted_warning();
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
else if (ISSET(VIEW_MODE) && !ISSET(MULTIBUFFER))
statusbar(_("Key invalid in non-multibuffer mode"));
#endif
@@ -1390,8 +1377,6 @@ char *safe_tempfile(FILE **f)
int fd;
mode_t original_umask = 0;
assert(f != NULL);
/* If $TMPDIR is set, set tempdir to it, run it through
* get_full_path(), and save the result in full_tempdir. Otherwise,
* leave full_tempdir set to NULL. */
@@ -1432,8 +1417,6 @@ char *safe_tempfile(FILE **f)
/* Initialize full_operating_dir based on operating_dir. */
void init_operating_dir(void)
{
assert(full_operating_dir == NULL);
if (operating_dir == NULL)
return;
@@ -1465,8 +1448,6 @@ bool check_operating_dir(const char *currpath, bool allow_tabcomp)
if (operating_dir == NULL)
return FALSE;
assert(full_operating_dir != NULL);
fullpath = get_full_path(currpath);
/* If fullpath is NULL, it means some directory in the path doesn't
@@ -1541,12 +1522,14 @@ void init_backup_dir(void)
/* Read from inn, write to out. We assume inn is opened for reading,
* and out for writing. We return 0 on success, -1 on read error, or -2
* on write error. */
int copy_file(FILE *inn, FILE *out)
* on write error. inn is always closed by this function, out is closed
* only if close_out is true. */
int copy_file(FILE *inn, FILE *out, bool close_out)
{
int retval = 0;
char buf[BUFSIZ];
size_t charsread;
int (*flush_out_fnc)(FILE *) = (close_out) ? fclose : fflush;
assert(inn != NULL && out != NULL && inn != out);
@@ -1564,7 +1547,7 @@ int copy_file(FILE *inn, FILE *out)
if (fclose(inn) == EOF)
retval = -1;
if (fclose(out) == EOF)
if (flush_out_fnc(out) == EOF)
retval = -2;
return retval;
@@ -1655,13 +1638,12 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
int backup_fd;
FILE *backup_file;
char *backupname;
struct utimbuf filetime;
int copy_status;
static struct timespec filetime[2];
int backup_cflags;
/* Save the original file's access and modification times. */
filetime.actime = openfile->current_stat->st_atime;
filetime.modtime = openfile->current_stat->st_mtime;
filetime[0].tv_sec = openfile->current_stat->st_atime;
filetime[1].tv_sec = openfile->current_stat->st_mtime;
if (f_open == NULL) {
/* Open the original file to copy to the backup. */
@@ -1753,35 +1735,36 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
statusline(HUSH, _("Error writing backup file %s: %s"),
backupname, strerror(errno));
free(backupname);
/* If we can't make a backup, DON'T go on, since whatever caused
* the backup to fail (e.g. disk full) may well cause the real
* file write to fail, in which case we could lose both the
* backup and the original! */
goto cleanup_and_exit;
}
/* We shouldn't worry about chown()ing something if we're not
* root, since it's likely to fail! */
if (geteuid() == NANO_ROOT_UID && fchown(backup_fd,
openfile->current_stat->st_uid, openfile->current_stat->st_gid) == -1
&& !ISSET(INSECURE_BACKUP)) {
/* Only try chowning the backup when we're root. */
if (geteuid() == NANO_ROOT_UID &&
fchown(backup_fd, openfile->current_stat->st_uid,
openfile->current_stat->st_gid) == -1 &&
!ISSET(INSECURE_BACKUP)) {
fclose(backup_file);
if (prompt_failed_backupwrite(backupname))
goto skip_backup;
statusline(HUSH, _("Error writing backup file %s: %s"),
backupname, strerror(errno));
free(backupname);
fclose(backup_file);
goto cleanup_and_exit;
}
if (fchmod(backup_fd, openfile->current_stat->st_mode) == -1
&& !ISSET(INSECURE_BACKUP)) {
/* Set the backup's mode bits. */
if (fchmod(backup_fd, openfile->current_stat->st_mode) == -1 &&
!ISSET(INSECURE_BACKUP)) {
fclose(backup_file);
if (prompt_failed_backupwrite(backupname))
goto skip_backup;
statusline(HUSH, _("Error writing backup file %s: %s"),
backupname, strerror(errno));
free(backupname);
fclose(backup_file);
/* If we can't write to the backup, DONT go on, since
* whatever caused the backup file to fail (e.g. disk
* full) may well cause the real file write to fail, which
* means we could lose both the backup and the original! */
goto cleanup_and_exit;
}
@@ -1790,27 +1773,24 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
#endif
/* Copy the file. */
copy_status = copy_file(f, backup_file);
if (copy_status != 0) {
if (copy_file(f, backup_file, FALSE) != 0) {
fclose(backup_file);
statusline(ALERT, _("Error reading %s: %s"), realname,
strerror(errno));
goto cleanup_and_exit;
}
/* And set its metadata. */
if (utime(backupname, &filetime) == -1 && !ISSET(INSECURE_BACKUP)) {
/* And set the backup's timestamps. */
if (futimens(backup_fd, filetime) == -1 && !ISSET(INSECURE_BACKUP)) {
fclose(backup_file);
if (prompt_failed_backupwrite(backupname))
goto skip_backup;
statusline(HUSH, _("Error writing backup file %s: %s"),
backupname, strerror(errno));
/* If we can't write to the backup, DON'T go on, since
* whatever caused the backup file to fail (e.g. disk full
* may well cause the real file write to fail, which means
* we could lose both the backup and the original! */
goto cleanup_and_exit;
}
fclose(backup_file);
free(backupname);
}
@@ -1867,7 +1847,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
}
}
if (f_source == NULL || copy_file(f_source, f) != 0) {
if (f_source == NULL || copy_file(f_source, f, TRUE) != 0) {
statusline(ALERT, _("Error writing temp file: %s"),
strerror(errno));
unlink(tempname);
@@ -1975,7 +1955,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
goto cleanup_and_exit;
}
if (copy_file(f_source, f) == -1) {
if (copy_file(f_source, f, TRUE) != 0) {
statusline(ALERT, _("Error writing %s: %s"), realname,
strerror(errno));
goto cleanup_and_exit;
@@ -1992,6 +1972,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
/* If we must set the filename, and it changed, adjust things. */
if (!nonamechange && strcmp(openfile->filename, realname) != 0) {
#ifndef DISABLE_COLOR
char *newname;
char *oldname = openfile->syntax ? openfile->syntax->name : "";
filestruct *line = openfile->fileage;
#endif
@@ -2002,7 +1983,7 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
color_update();
color_init();
char *newname = openfile->syntax ? openfile->syntax->name : "";
newname = openfile->syntax ? openfile->syntax->name : "";
/* If the syntax changed, discard and recompute the multidata. */
if (strcmp(oldname, newname) != 0) {
@@ -2051,7 +2032,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
filestruct *top, *bot;
size_t top_x, bot_x;
/* Partition the filestruct so that it contains only the marked text. */
/* Partition the buffer so that it contains only the marked text. */
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, NULL);
filepart = partition_filestruct(top, top_x, bot, bot_x);
@@ -2069,7 +2050,7 @@ bool write_marked_file(const char *name, FILE *f_open, bool tmp,
if (added_magicline)
remove_magicline();
/* Unpartition the filestruct so that it contains all the text again. */
/* Unpartition the buffer so that it contains all the text again. */
unpartition_filestruct(&filepart);
if (old_modified)
@@ -2132,11 +2113,12 @@ int do_writeout(bool exiting)
msg = (method == PREPEND) ? _("Prepend Selection to File") :
(method == APPEND) ? _("Append Selection to File") :
_("Write Selection to File");
else if (method != OVERWRITE)
msg = (method == PREPEND) ? _("File Name to Prepend to") :
_("File Name to Append to");
else
#endif /* !NANO_TINY */
msg = (method == PREPEND) ? _("File Name to Prepend to") :
(method == APPEND) ? _("File Name to Append to") :
_("File Name to Write");
msg = _("File Name to Write");
present_path = mallocstrcpy(present_path, "./");
@@ -2161,24 +2143,15 @@ int do_writeout(bool exiting)
} else {
functionptrtype func = func_from_key(&i);
/* Upon request, abandon the buffer, if user is sure. */
/* Upon request, abandon the buffer. */
if (func == discard_buffer) {
if (openfile->modified)
i = do_yesno_prompt(FALSE,
_("Save modified buffer anyway? "));
else
i = 0;
if (i == 0) {
free(given);
return 2; /* Yes, discard the buffer. */
} else
continue; /* Go back to the filename prompt. */
free(given);
return 2;
}
given = mallocstrcpy(given, answer);
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
if (func == to_files_void) {
char *chosen = do_browse_from(answer);
@@ -2189,7 +2162,7 @@ int do_writeout(bool exiting)
free(answer);
answer = chosen;
} else
#endif /* !DISABLE_BROWSER */
#endif
#ifndef NANO_TINY
if (func == dos_format_void) {
openfile->fmt = (openfile->fmt == DOS_FILE) ? NIX_FILE :
@@ -2202,15 +2175,15 @@ int do_writeout(bool exiting)
} else if (func == backup_file_void) {
TOGGLE(BACKUP_FILE);
continue;
} else
#endif /* !NANO_TINY */
if (func == prepend_void) {
} else if (func == prepend_void) {
method = (method == PREPEND) ? OVERWRITE : PREPEND;
continue;
} else if (func == append_void) {
method = (method == APPEND) ? OVERWRITE : APPEND;
continue;
} else if (func == do_help_void) {
} else
#endif /* !NANO_TINY */
if (func == do_help_void) {
continue;
}
@@ -2297,6 +2270,8 @@ int do_writeout(bool exiting)
openfile->current_stat->st_dev != st.st_dev ||
openfile->current_stat->st_ino != st.st_ino)) {
warn_and_shortly_pause(_("File on disk has changed"));
if (do_yesno_prompt(FALSE, _("File was modified since "
"you opened it; continue saving? ")) < 1)
continue;
@@ -2390,7 +2365,7 @@ char *real_dir_from_tilde(const char *buf)
return retval;
}
#if !defined(DISABLE_TABCOMP) || !defined(DISABLE_BROWSER)
#if defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
/* Our sort routine for file listings. Sort alphabetically and
* case-insensitively, and sort directories before filenames. */
int diralphasort(const void *va, const void *vb)
@@ -2427,7 +2402,7 @@ void free_chararray(char **array, size_t len)
}
#endif
#ifndef DISABLE_TABCOMP
#ifdef ENABLE_TABCOMP
/* Is the given path a directory? */
bool is_dir(const char *buf)
{
@@ -2468,14 +2443,15 @@ char **username_tab_completion(const char *buf, size_t *num_matches,
size_t buf_len)
{
char **matches = NULL;
#ifdef HAVE_PWD_H
const struct passwd *userdata;
#endif
assert(buf != NULL && num_matches != NULL && buf_len > 0);
*num_matches = 0;
#ifdef HAVE_PWD_H
const struct passwd *userdata;
while ((userdata = getpwent()) != NULL) {
if (strncmp(userdata->pw_name, buf + 1, buf_len - 1) == 0) {
/* Cool, found a match. Add it to the list. This makes a
@@ -2634,7 +2610,7 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
char *mzero, *glued;
const char *lastslash = revstrstr(buf, "/", buf + *place);
size_t lastslash_len = (lastslash == NULL) ? 0 : lastslash - buf + 1;
char char1[mb_cur_max()], char2[mb_cur_max()];
char char1[MAXCHARLEN], char2[MAXCHARLEN];
int len1, len2;
/* Get the number of characters that all matches have in common. */
@@ -2751,7 +2727,7 @@ char *input_tab(char *buf, bool allow_files, size_t *place,
return buf;
}
#endif /* !DISABLE_TABCOMP */
#endif /* ENABLE_TABCOMP */
/* Return the filename part of the given path. */
const char *tail(const char *path)
@@ -3007,7 +2983,7 @@ void update_poshistory(char *filename, ssize_t lineno, ssize_t xpos)
poshiststruct *posptr, *theone, *posprev = NULL;
char *fullpath = get_full_path(filename);
if (fullpath == NULL || fullpath[strlen(fullpath) - 1] == '/') {
if (fullpath == NULL || fullpath[strlen(fullpath) - 1] == '/' || inhelp) {
free(fullpath);
return;
}
@@ -3079,7 +3055,7 @@ bool has_old_position(const char *file, ssize_t *line, ssize_t *column)
free(fullpath);
if (posptr == NULL)
return FALSE;
return FALSE;
*line = posptr->lineno;
*column = posptr->xno;

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* global.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2014, 2015, 2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -53,15 +52,32 @@ int margin = 0;
int editwincols = -1;
/* The number of usable columns in the edit window: COLS - margin. */
#ifndef DISABLE_COLOR
bool have_palette = FALSE;
/* Whether the colors for the current syntax have been initialized. */
#endif
bool suppress_cursorpos = FALSE;
/* Should we skip constant position display for current keystroke? */
message_type lastmessage = HUSH;
/* Messages of type HUSH should not overwrite type MILD nor ALERT. */
filestruct *pletion_line = NULL;
/* The line where the last completion was found, if any. */
int controlleft, controlright, controlup, controldown;
bool inhelp = FALSE;
/* Whether we are in the help viewer. */
char *title = NULL;
/* When not NULL: the title of the current help text. */
int didfind = 0;
/* Whether the last search found something. */
int controlleft, controlright, controlup, controldown, controlhome, controlend;
#ifndef NANO_TINY
int shiftcontrolleft, shiftcontrolright, shiftcontrolup, shiftcontroldown;
int shiftcontrolhome, shiftcontrolend;
int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown;
#endif
@@ -82,14 +98,14 @@ char *present_path = NULL;
unsigned flags[4] = {0, 0, 0, 0};
/* Our flag containing the states of all global options. */
WINDOW *topwin;
WINDOW *topwin = NULL;
/* The top portion of the window, where we display the version
* number of nano, the name of the current file, and whether the
* current file has been modified. */
WINDOW *edit;
WINDOW *edit = NULL;
/* The middle portion of the window, i.e. the edit window, where
* we display the current file we're editing. */
WINDOW *bottomwin;
WINDOW *bottomwin = NULL;
/* The bottom portion of the window, where we display statusbar
* messages, the statusbar prompt, and a list of shortcuts. */
int editwinrows = 0;
@@ -133,9 +149,6 @@ char *quoteerr = NULL;
char *word_chars = NULL;
/* Nonalphanumeric characters that also form words. */
bool nodelay_mode = FALSE;
/* Are we checking for a cancel wile doing something? */
char *answer = NULL;
/* The answer string used by the statusbar prompt. */
@@ -214,10 +227,10 @@ regmatch_t regmatches[10];
int hilite_attribute = A_REVERSE;
/* The curses attribute we use to highlight something. */
#ifndef DISABLE_COLOR
char* specified_color_combo[] = {};
char* specified_color_combo[] = {NULL};
/* The color combinations as specified in the rcfile. */
#endif
int interface_color_pair[] = {};
int interface_color_pair[] = {0};
/* The processed color pairs for the interface elements. */
char *homedir = NULL;
@@ -253,10 +266,13 @@ void regexp_void(void)
void backwards_void(void)
{
}
void flip_replace(void)
{
}
void gototext_void(void)
{
}
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
void to_files_void(void)
{
}
@@ -264,6 +280,7 @@ void goto_dir_void(void)
{
}
#endif
#ifndef NANO_TINY
void dos_format_void(void)
{
}
@@ -279,18 +296,18 @@ void prepend_void(void)
void backup_file_void(void)
{
}
void flip_execute(void)
{
}
#endif
#ifdef ENABLE_MULTIBUFFER
void flip_newbuffer(void)
{
}
#endif
void discard_buffer(void)
{
}
void new_buffer_void(void)
{
}
void flip_replace_void(void)
{
}
void flip_execute_void(void)
{
}
/* Add a function to the function list. */
void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *help,
@@ -309,7 +326,7 @@ void add_to_funcs(void (*func)(void), int menus, const char *desc, const char *h
f->menus = menus;
f->desc = desc;
f->viewok = viewok;
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
f->help = help;
f->blank_after = blank_after;
#endif
@@ -475,16 +492,13 @@ void shortcut_init(void)
/* TRANSLATORS: Try to keep this string at most 12 characters. */
const char *whereis_next_tag = N_("WhereIs Next");
#ifndef DISABLE_HELP
#ifndef DISABLE_JUSTIFY
#ifdef ENABLE_HELP
/* TRANSLATORS: The next long series of strings are shortcut descriptions;
* they are best kept shorter than 56 characters, but may be longer. */
const char *nano_justify_msg = N_("Justify the current paragraph");
#endif
const char *nano_cancel_msg = N_("Cancel the current function");
const char *nano_help_msg = N_("Display this help text");
const char *nano_exit_msg =
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
N_("Close the current file buffer / Exit from nano")
#else
N_("Exit from nano")
@@ -496,12 +510,14 @@ void shortcut_init(void)
N_("Insert another file into the current one");
const char *nano_whereis_msg =
N_("Search for a string or a regular expression");
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
const char *nano_browser_whereis_msg = N_("Search for a string");
const char *nano_browser_refresh_msg = N_("Refresh the file list");
#ifndef NANO_TINY
const char *nano_browser_lefthand_msg = N_("Go to lefthand column");
const char *nano_browser_righthand_msg = N_("Go to righthand column");
const char *nano_browser_toprow_msg = N_("Go to first row in this column");
const char *nano_browser_bottomrow_msg = N_("Go to last row in this column");
#endif
#endif
const char *nano_prevpage_msg = N_("Go one screenful up");
@@ -551,7 +567,7 @@ void shortcut_init(void)
const char *nano_scrolldown_msg =
N_("Scroll down one line without scrolling the cursor");
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
const char *nano_prevfile_msg = N_("Switch to the previous file buffer");
const char *nano_nextfile_msg = N_("Switch to the next file buffer");
#endif
@@ -570,6 +586,7 @@ void shortcut_init(void)
N_("Cut from the cursor position to the end of the file");
#endif
#ifndef DISABLE_JUSTIFY
const char *nano_justify_msg = N_("Justify the current paragraph");
const char *nano_fulljustify_msg = N_("Justify the entire file");
#endif
#ifndef NANO_TINY
@@ -604,9 +621,6 @@ void shortcut_init(void)
const char *nano_next_history_msg =
N_("Recall the next search/replace string");
#endif
#ifndef DISABLE_BROWSER
const char *nano_tofiles_msg = N_("Go to file browser");
#endif
#ifndef NANO_TINY
const char *nano_dos_msg = N_("Toggle the use of DOS format");
const char *nano_mac_msg = N_("Toggle the use of Mac format");
@@ -615,11 +629,12 @@ void shortcut_init(void)
const char *nano_backup_msg = N_("Toggle backing up of the original file");
const char *nano_execute_msg = N_("Execute external command");
#endif
const char *nano_discard_buffer_msg = N_("Close buffer without saving it");
#ifndef DISABLE_MULTIBUFFER
const char *nano_multibuffer_msg = N_("Toggle the use of a new buffer");
#ifdef ENABLE_MULTIBUFFER
const char *nano_newbuffer_msg = N_("Toggle the use of a new buffer");
#endif
#ifndef DISABLE_BROWSER
const char *nano_discard_buffer_msg = N_("Close buffer without saving it");
#ifdef ENABLE_BROWSER
const char *nano_tofiles_msg = N_("Go to file browser");
const char *nano_exitbrowser_msg = N_("Exit from the file browser");
const char *nano_firstfile_msg = N_("Go to the first file in the list");
const char *nano_lastfile_msg = N_("Go to the last file in the list");
@@ -635,9 +650,9 @@ void shortcut_init(void)
const char *nano_formatter_msg = N_("Invoke formatter, if available");
#endif
#endif
#endif /* !DISABLE_HELP */
#endif /* ENABLE_HELP */
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
#define IFSCHELP(help) help
#else
#define IFSCHELP(help) ""
@@ -657,7 +672,7 @@ void shortcut_init(void)
/* Remember the entry for Exit, to be able to replace it with Close. */
exitfunc = tailfunc;
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
add_to_funcs(do_exit, MBROWSER,
exit_tag, IFSCHELP(nano_exitbrowser_msg), TOGETHER, VIEW);
#endif
@@ -676,7 +691,7 @@ void shortcut_init(void)
read_file_tag, IFSCHELP(nano_insert_msg), BLANKAFTER,
/* We allow inserting files in view mode if multibuffer mode
* is switched on, so that we can view multiple files. */
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
VIEW);
#else
NOVIEW);
@@ -694,7 +709,7 @@ void shortcut_init(void)
add_to_funcs(do_replace, MMAIN,
replace_tag, IFSCHELP(nano_replace_msg), TOGETHER, NOVIEW);
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
add_to_funcs(do_search, MBROWSER,
whereis_tag, IFSCHELP(nano_browser_whereis_msg), TOGETHER, VIEW);
@@ -702,15 +717,14 @@ void shortcut_init(void)
N_("Go To Dir"), IFSCHELP(nano_gotodir_msg), BLANKAFTER, VIEW);
#endif
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
/* The description ("x") and blank_after (0) are irrelevant,
* because the help viewer does not have a help text. */
add_to_funcs(do_exit, MHELP, exit_tag, "x", 0, VIEW);
add_to_funcs(total_refresh, MHELP, refresh_tag, "x", 0, VIEW);
add_to_funcs(do_exit, MHELP, close_tag, "x", 0, VIEW);
add_to_funcs(do_up_void, MHELP, prev_line_tag, "x", 0, VIEW);
add_to_funcs(do_down_void, MHELP, next_line_tag, "x" , 0, VIEW);
add_to_funcs(do_search, MHELP, whereis_tag, "x", 0, VIEW);
add_to_funcs(do_research, MHELP, whereis_next_tag, "x", 0, VIEW);
#endif
add_to_funcs(do_cut_text_void, MMAIN,
@@ -771,10 +785,10 @@ void shortcut_init(void)
add_to_funcs(backwards_void, MWHEREIS|MREPLACE,
N_("Backwards"), IFSCHELP(nano_reverse_msg), TOGETHER, VIEW);
add_to_funcs(flip_replace_void, MWHEREIS,
add_to_funcs(flip_replace, MWHEREIS,
replace_tag, IFSCHELP(nano_replace_msg), BLANKAFTER, VIEW);
add_to_funcs(flip_replace_void, MREPLACE,
add_to_funcs(flip_replace, MREPLACE,
N_("No Replace"), IFSCHELP(nano_whereis_msg), BLANKAFTER, VIEW);
#ifndef DISABLE_JUSTIFY
@@ -802,7 +816,7 @@ void shortcut_init(void)
N_("Back"), IFSCHELP(nano_back_msg), TOGETHER, VIEW);
add_to_funcs(do_right, MMAIN,
N_("Forward"), IFSCHELP(nano_forward_msg), TOGETHER, VIEW);
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
add_to_funcs(do_left, MBROWSER,
N_("Back"), IFSCHELP(nano_backfile_msg), TOGETHER, VIEW);
add_to_funcs(do_right, MBROWSER,
@@ -819,9 +833,9 @@ void shortcut_init(void)
add_to_funcs(do_end_void, MMAIN,
N_("End"), IFSCHELP(nano_end_msg), BLANKAFTER, VIEW);
add_to_funcs(do_up_void, MMAIN|MBROWSER,
add_to_funcs(do_up_void, MMAIN|MHELP|MBROWSER,
prev_line_tag, IFSCHELP(nano_prevline_msg), TOGETHER, VIEW);
add_to_funcs(do_down_void, MMAIN|MBROWSER,
add_to_funcs(do_down_void, MMAIN|MHELP|MBROWSER,
next_line_tag, IFSCHELP(nano_nextline_msg), TOGETHER, VIEW);
#ifndef NANO_TINY
add_to_funcs(do_scroll_up, MMAIN,
@@ -851,7 +865,7 @@ void shortcut_init(void)
add_to_funcs(do_last_line, MMAIN|MHELP|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE,
N_("Last Line"), IFSCHELP(nano_lastline_msg), BLANKAFTER, VIEW);
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
add_to_funcs(switch_to_prev_buffer_void, MMAIN,
N_("Prev File"), IFSCHELP(nano_prevfile_msg), TOGETHER, VIEW);
add_to_funcs(switch_to_next_buffer_void, MMAIN,
@@ -870,9 +884,6 @@ void shortcut_init(void)
whereis_next_tag, IFSCHELP(nano_whereis_next_msg), TOGETHER, VIEW);
#endif
add_to_funcs(do_verbatim_input, MMAIN,
N_("Verbatim"), IFSCHELP(nano_verbatim_msg), TOGETHER, NOVIEW);
add_to_funcs(do_tab, MMAIN,
N_("Tab"), IFSCHELP(nano_tab_msg), TOGETHER, NOVIEW);
add_to_funcs(do_enter, MMAIN,
@@ -909,6 +920,9 @@ void shortcut_init(void)
N_("Word Count"), IFSCHELP(nano_wordcount_msg), TOGETHER, VIEW);
#endif
add_to_funcs(do_verbatim_input, MMAIN,
N_("Verbatim"), IFSCHELP(nano_verbatim_msg), BLANKAFTER, NOVIEW);
add_to_funcs(total_refresh, MMAIN,
refresh_tag, IFSCHELP(nano_refresh_msg), TOGETHER, VIEW);
@@ -916,7 +930,7 @@ void shortcut_init(void)
N_("Suspend"), IFSCHELP(nano_suspend_msg), BLANKAFTER, VIEW);
#ifndef NANO_TINY
add_to_funcs(do_indent_void, MMAIN,
add_to_funcs(do_indent, MMAIN,
N_("Indent Text"), IFSCHELP(nano_indent_msg), TOGETHER, NOVIEW);
add_to_funcs(do_unindent, MMAIN,
N_("Unindent Text"), IFSCHELP(nano_unindent_msg), BLANKAFTER, NOVIEW);
@@ -974,20 +988,20 @@ void shortcut_init(void)
/* If we're using restricted mode, file insertion is disabled, and
* thus command execution and the multibuffer toggle have no place. */
if (!ISSET(RESTRICTED)) {
add_to_funcs(flip_execute_void, MINSERTFILE,
add_to_funcs(flip_execute, MINSERTFILE,
N_("Execute Command"), IFSCHELP(nano_execute_msg), TOGETHER, NOVIEW);
add_to_funcs(flip_execute_void, MEXTCMD,
add_to_funcs(flip_execute, MEXTCMD,
read_file_tag, IFSCHELP(nano_insert_msg), TOGETHER, NOVIEW);
#ifndef DISABLE_MULTIBUFFER
add_to_funcs(new_buffer_void, MINSERTFILE|MEXTCMD,
N_("New Buffer"), IFSCHELP(nano_multibuffer_msg), TOGETHER, NOVIEW);
#endif
}
#endif /* !NANO_TINY */
#ifdef ENABLE_MULTIBUFFER
if (!ISSET(RESTRICTED))
add_to_funcs(flip_newbuffer, MINSERTFILE|MEXTCMD,
N_("New Buffer"), IFSCHELP(nano_newbuffer_msg), TOGETHER, NOVIEW);
#endif
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
if (!ISSET(RESTRICTED))
add_to_funcs(to_files_void, MWRITEFILE|MINSERTFILE,
N_("To Files"), IFSCHELP(nano_tofiles_msg), TOGETHER, VIEW);
@@ -1006,7 +1020,7 @@ void shortcut_init(void)
add_to_funcs(discard_buffer, MWRITEFILE,
N_("Discard buffer"), IFSCHELP(nano_discard_buffer_msg), BLANKAFTER, NOVIEW);
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
add_to_funcs(do_research, MBROWSER,
whereis_next_tag, IFSCHELP(nano_whereis_next_msg), TOGETHER, VIEW);
add_to_funcs(total_refresh, MBROWSER,
@@ -1015,7 +1029,11 @@ void shortcut_init(void)
add_to_funcs(do_prev_word_void, MBROWSER,
N_("Left Column"), IFSCHELP(nano_browser_lefthand_msg), TOGETHER, VIEW);
add_to_funcs(do_next_word_void, MBROWSER,
N_("Right Column"), IFSCHELP(nano_browser_righthand_msg), BLANKAFTER, VIEW);
N_("Right Column"), IFSCHELP(nano_browser_righthand_msg), TOGETHER, VIEW);
add_to_funcs(do_prev_block, MBROWSER,
N_("Top Row"), IFSCHELP(nano_browser_toprow_msg), TOGETHER, VIEW);
add_to_funcs(do_next_block, MBROWSER,
N_("Bottom Row"), IFSCHELP(nano_browser_bottomrow_msg), BLANKAFTER, VIEW);
#endif
#endif
@@ -1029,8 +1047,8 @@ void shortcut_init(void)
/* Start associating key combos with functions in specific menus. */
add_to_sclist(MMOST, "^G", 0, do_help_void, 0);
add_to_sclist(MMOST, "F1", 0, do_help_void, 0);
add_to_sclist(MMOST & ~MFINDINHELP, "^G", 0, do_help_void, 0);
add_to_sclist(MMOST & ~MFINDINHELP, "F1", 0, do_help_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^X", 0, do_exit, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "F2", 0, do_exit, 0);
add_to_sclist(MMAIN, "^O", 0, do_writeout_void, 0);
@@ -1038,8 +1056,8 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "^R", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN, "F5", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN, "Ins", 0, do_insertfile_void, 0);
add_to_sclist(MMAIN|MBROWSER, "^W", 0, do_search, 0);
add_to_sclist(MMAIN|MBROWSER, "F6", 0, do_search, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^W", 0, do_search, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "F6", 0, do_search, 0);
add_to_sclist(MMAIN, "^\\", 0, do_replace, 0);
add_to_sclist(MMAIN, "M-R", 0, do_replace, 0);
add_to_sclist(MMAIN, "F14", 0, do_replace, 0);
@@ -1068,23 +1086,27 @@ void shortcut_init(void)
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^Y", 0, do_page_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F7", 0, do_page_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgUp", KEY_PPAGE, do_page_up, 0);
add_to_sclist(MHELP|MBROWSER, "Bsp", KEY_BACKSPACE, do_page_up, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "^V", 0, do_page_down, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "F8", 0, do_page_down, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER|MLINTER, "PgDn", KEY_NPAGE, do_page_down, 0);
add_to_sclist(MMAIN|MHELP, "M-\\", 0, do_first_line, 0);
add_to_sclist(MMAIN|MHELP, "^Home", CONTROL_HOME, do_first_line, 0);
add_to_sclist(MMAIN|MHELP, "M-|", 0, do_first_line, 0);
add_to_sclist(MMAIN|MHELP, "M-/", 0, do_last_line, 0);
add_to_sclist(MMAIN|MHELP, "^End", CONTROL_END, do_last_line, 0);
add_to_sclist(MMAIN|MHELP, "M-?", 0, do_last_line, 0);
add_to_sclist(MMAIN|MBROWSER, "M-W", 0, do_research, 0);
add_to_sclist(MMAIN|MBROWSER, "F16", 0, do_research, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "M-W", 0, do_research, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "F16", 0, do_research, 0);
#ifndef NANO_TINY
add_to_sclist(MMAIN, "M-]", 0, do_find_bracket, 0);
add_to_sclist(MMAIN, "^^", 0, do_mark, 0);
add_to_sclist(MMAIN, "M-A", 0, do_mark, 0);
add_to_sclist(MMAIN, "^6", 0, do_mark, 0);
add_to_sclist(MMAIN, "^^", 0, do_mark, 0);
add_to_sclist(MMAIN, "F15", 0, do_mark, 0);
add_to_sclist(MMAIN, "M-^", 0, do_copy_text, 0);
add_to_sclist(MMAIN, "M-6", 0, do_copy_text, 0);
add_to_sclist(MMAIN, "M-}", 0, do_indent_void, 0);
add_to_sclist(MMAIN, "M-^", 0, do_copy_text, 0);
add_to_sclist(MMAIN, "M-}", 0, do_indent, 0);
add_to_sclist(MMAIN, "M-{", 0, do_unindent, 0);
add_to_sclist(MMAIN, "M-U", 0, do_undo, 0);
add_to_sclist(MMAIN, "M-E", 0, do_redo, 0);
@@ -1096,18 +1118,20 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "M-3", 0, do_comment, 0);
#endif
add_to_sclist(MMOST, "^B", 0, do_left, 0);
add_to_sclist(MMOST, "Left", KEY_LEFT, do_left, 0);
add_to_sclist(MMOST, "^F", 0, do_right, 0);
add_to_sclist(MMOST, "Right", KEY_RIGHT, do_right, 0);
#ifdef ENABLE_UTF8
if (using_utf8()) {
add_to_sclist(MMOST, "^\xE2\x86\x90", CONTROL_LEFT, do_prev_word_void, 0);
add_to_sclist(MMOST, "^\xE2\x86\x92", CONTROL_RIGHT, do_next_word_void, 0);
add_to_sclist(MMOST, "\xE2\x86\x90", KEY_LEFT, do_left, 0);
add_to_sclist(MMOST, "\xE2\x86\x92", KEY_RIGHT, do_right, 0);
add_to_sclist(MSOME, "^\xE2\x86\x90", CONTROL_LEFT, do_prev_word_void, 0);
add_to_sclist(MSOME, "^\xE2\x86\x92", CONTROL_RIGHT, do_next_word_void, 0);
} else
#endif
{
add_to_sclist(MMOST, "^Left", CONTROL_LEFT, do_prev_word_void, 0);
add_to_sclist(MMOST, "^Right", CONTROL_RIGHT, do_next_word_void, 0);
add_to_sclist(MMOST, "Left", KEY_LEFT, do_left, 0);
add_to_sclist(MMOST, "Right", KEY_RIGHT, do_right, 0);
add_to_sclist(MSOME, "^Left", CONTROL_LEFT, do_prev_word_void, 0);
add_to_sclist(MSOME, "^Right", CONTROL_RIGHT, do_next_word_void, 0);
}
add_to_sclist(MMOST, "M-Space", 0, do_prev_word_void, 0);
add_to_sclist(MMOST, "^Space", 0, do_next_word_void, 0);
@@ -1116,18 +1140,20 @@ void shortcut_init(void)
add_to_sclist((MMOST & ~MBROWSER), "^E", 0, do_end_void, 0);
add_to_sclist((MMOST & ~MBROWSER), "End", KEY_END, do_end_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^P", 0, do_up_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "Up", KEY_UP, do_up_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "^N", 0, do_down_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "Down", KEY_DOWN, do_down_void, 0);
#ifdef ENABLE_UTF8
if (using_utf8()) {
add_to_sclist(MMAIN, "^\xE2\x86\x91", CONTROL_UP, do_prev_block, 0);
add_to_sclist(MMAIN, "^\xE2\x86\x93", CONTROL_DOWN, do_next_block, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "\xE2\x86\x91", KEY_UP, do_up_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "\xE2\x86\x93", KEY_DOWN, do_down_void, 0);
add_to_sclist(MMAIN|MBROWSER, "^\xE2\x86\x91", CONTROL_UP, do_prev_block, 0);
add_to_sclist(MMAIN|MBROWSER, "^\xE2\x86\x93", CONTROL_DOWN, do_next_block, 0);
} else
#endif
{
add_to_sclist(MMAIN, "^Up", CONTROL_UP, do_prev_block, 0);
add_to_sclist(MMAIN, "^Down", CONTROL_DOWN, do_next_block, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "Up", KEY_UP, do_up_void, 0);
add_to_sclist(MMAIN|MHELP|MBROWSER, "Down", KEY_DOWN, do_down_void, 0);
add_to_sclist(MMAIN|MBROWSER, "^Up", CONTROL_UP, do_prev_block, 0);
add_to_sclist(MMAIN|MBROWSER, "^Down", CONTROL_DOWN, do_next_block, 0);
}
add_to_sclist(MMAIN, "M-7", 0, do_prev_block, 0);
add_to_sclist(MMAIN, "M-8", 0, do_next_block, 0);
@@ -1143,7 +1169,7 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "M-+", 0, do_scroll_down, 0);
add_to_sclist(MMAIN, "M-=", 0, do_scroll_down, 0);
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
add_to_sclist(MMAIN, "M-<", 0, switch_to_prev_buffer_void, 0);
add_to_sclist(MMAIN, "M-,", 0, switch_to_prev_buffer_void, 0);
add_to_sclist(MMAIN, "M->", 0, switch_to_next_buffer_void, 0);
@@ -1163,7 +1189,7 @@ void shortcut_init(void)
#ifndef NANO_TINY
/* Group of "Appearance" toggles. */
add_to_sclist(MMAIN, "M-X", 0, do_toggle_void, NO_HELP);
add_to_sclist(MMAIN, "M-C", 0, do_toggle_void, CONST_UPDATE);
add_to_sclist(MMAIN, "M-C", 0, do_toggle_void, CONSTANT_SHOW);
add_to_sclist(MMAIN, "M-O", 0, do_toggle_void, MORE_SPACE);
add_to_sclist(MMAIN, "M-S", 0, do_toggle_void, SMOOTH_SCROLL);
add_to_sclist(MMAIN, "M-$", 0, do_toggle_void, SOFTWRAP);
@@ -1178,7 +1204,7 @@ void shortcut_init(void)
/* Group of "Editing-behavior" toggles. */
add_to_sclist(MMAIN, "M-H", 0, do_toggle_void, SMART_HOME);
add_to_sclist(MMAIN, "M-I", 0, do_toggle_void, AUTOINDENT);
add_to_sclist(MMAIN, "M-K", 0, do_toggle_void, CUT_TO_END);
add_to_sclist(MMAIN, "M-K", 0, do_toggle_void, CUT_FROM_CURSOR);
#ifndef DISABLE_WRAPPING
add_to_sclist(MMAIN, "M-L", 0, do_toggle_void, NO_WRAP);
#endif
@@ -1186,10 +1212,10 @@ void shortcut_init(void)
/* Group of "Peripheral-feature" toggles. */
add_to_sclist(MMAIN, "M-B", 0, do_toggle_void, BACKUP_FILE);
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
add_to_sclist(MMAIN, "M-F", 0, do_toggle_void, MULTIBUFFER);
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
add_to_sclist(MMAIN, "M-M", 0, do_toggle_void, USE_MOUSE);
#endif
add_to_sclist(MMAIN, "M-N", 0, do_toggle_void, NO_CONVERT);
@@ -1204,7 +1230,7 @@ void shortcut_init(void)
add_to_sclist(MWHEREIS|MREPLACE, "M-C", 0, case_sens_void, 0);
add_to_sclist(MWHEREIS|MREPLACE, "M-R", 0, regexp_void, 0);
add_to_sclist(MWHEREIS|MREPLACE, "M-B", 0, backwards_void, 0);
add_to_sclist(MWHEREIS|MREPLACE, "^R", 0, flip_replace_void, 0);
add_to_sclist(MWHEREIS|MREPLACE, "^R", 0, flip_replace, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^Y", 0, do_first_line, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE, "^V", 0, do_last_line, 0);
#ifndef DISABLE_JUSTIFY
@@ -1214,20 +1240,30 @@ void shortcut_init(void)
add_to_sclist(MWHEREIS, "^T", 0, do_gotolinecolumn_void, 0);
add_to_sclist(MGOTOLINE, "^T", 0, gototext_void, 0);
#ifndef DISABLE_HISTORIES
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^P", 0, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Up", KEY_UP, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "^N", 0, get_history_newer_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE, "Down", KEY_DOWN, get_history_newer_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "^P", 0, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "^N", 0, get_history_newer_void, 0);
#ifdef ENABLE_UTF8
if (using_utf8()) {
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "\xE2\x86\x91", KEY_UP, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "\xE2\x86\x93", KEY_DOWN, get_history_newer_void, 0);
} else
#endif
#ifndef DISABLE_BROWSER
{
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "Up", KEY_UP, get_history_older_void, 0);
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP, "Down", KEY_DOWN, get_history_newer_void, 0);
}
#endif
#ifdef ENABLE_BROWSER
add_to_sclist(MWHEREISFILE, "^Y", 0, do_first_file, 0);
add_to_sclist(MWHEREISFILE, "^V", 0, do_last_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-\\", 0, do_first_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", 0, do_first_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-/", 0, do_last_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", 0, do_last_file, 0);
add_to_sclist(MBROWSER, "Home", KEY_HOME, do_first_file, 0);
add_to_sclist(MBROWSER, "End", KEY_END, do_last_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-|", 0, do_first_file, 0);
add_to_sclist(MBROWSER|MWHEREISFILE, "M-?", 0, do_last_file, 0);
add_to_sclist(MBROWSER, "^Home", CONTROL_HOME, do_first_file, 0);
add_to_sclist(MBROWSER, "^End", CONTROL_END, do_last_file, 0);
add_to_sclist(MBROWSER, "^_", 0, goto_dir_void, 0);
add_to_sclist(MBROWSER, "M-G", 0, goto_dir_void, 0);
add_to_sclist(MBROWSER, "F13", 0, goto_dir_void, 0);
@@ -1235,26 +1271,34 @@ void shortcut_init(void)
#endif
if (ISSET(TEMP_FILE))
add_to_sclist(MWRITEFILE, "^Q", 0, discard_buffer, 0);
#ifndef NANO_TINY
add_to_sclist(MWRITEFILE, "M-D", 0, dos_format_void, 0);
add_to_sclist(MWRITEFILE, "M-M", 0, mac_format_void, 0);
/* In restricted mode, don't allow Appending, Prepending, nor making
* backups, nor executing a command, nor opening a new buffer. */
if (!ISSET(RESTRICTED)) {
/* Don't allow Appending, Prepending, nor Backups in restricted mode. */
add_to_sclist(MWRITEFILE, "M-A", 0, append_void, 0);
add_to_sclist(MWRITEFILE, "M-P", 0, prepend_void, 0);
add_to_sclist(MWRITEFILE, "M-B", 0, backup_file_void, 0);
#ifndef DISABLE_BROWSER
add_to_sclist(MINSERTFILE|MEXTCMD, "^X", 0, flip_execute, 0);
}
#endif
#ifdef ENABLE_MULTIBUFFER
if (!ISSET(RESTRICTED))
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, flip_newbuffer, 0);
#endif
#ifdef ENABLE_BROWSER
/* In restricted mode, don't allow entering the file browser. */
if (!ISSET(RESTRICTED))
add_to_sclist(MWRITEFILE|MINSERTFILE, "^T", 0, to_files_void, 0);
#endif
add_to_sclist(MINSERTFILE|MEXTCMD, "^X", 0, flip_execute_void, 0);
add_to_sclist(MINSERTFILE|MEXTCMD, "M-F", 0, new_buffer_void, 0);
}
add_to_sclist(MHELP|MBROWSER, "^C", 0, do_exit, 0);
/* Allow exiting from the file browser and the help viewer with
* the same key as they were entered. */
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
add_to_sclist(MBROWSER, "^T", 0, do_exit, 0);
#endif
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
add_to_sclist(MHELP, "^G", 0, do_exit, 0);
add_to_sclist(MHELP, "Home", KEY_HOME, do_first_line, 0);
add_to_sclist(MHELP, "End", KEY_END, do_last_line, 0);
@@ -1316,7 +1360,7 @@ const char *flagtostr(int flag)
/* TRANSLATORS: The next seventeen strings are toggle descriptions;
* they are best kept shorter than 40 characters, but may be longer. */
return N_("Help mode");
case CONST_UPDATE:
case CONSTANT_SHOW:
return N_("Constant cursor position display");
case MORE_SPACE:
return N_("Use of one more line for editing");
@@ -1332,7 +1376,7 @@ const char *flagtostr(int flag)
return N_("Smart home key");
case AUTOINDENT:
return N_("Auto indent");
case CUT_TO_END:
case CUT_FROM_CURSOR:
return N_("Cut to end");
case NO_WRAP:
return N_("Hard wrapping of overlong lines");
@@ -1356,7 +1400,7 @@ const char *flagtostr(int flag)
}
#endif /* !NANO_TINY */
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
/* Interpret a function string given in the rc file, and return a
* shortcut struct with the corresponding function filled in. */
sc *strtosc(const char *input)
@@ -1367,7 +1411,7 @@ sc *strtosc(const char *input)
s->toggle = 0;
#endif
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
if (!strcasecmp(input, "help"))
s->scfunc = do_help_void;
else
@@ -1445,25 +1489,17 @@ sc *strtosc(const char *input)
#endif
#ifndef NANO_TINY
else if (!strcasecmp(input, "indent"))
s->scfunc = do_indent_void;
s->scfunc = do_indent;
else if (!strcasecmp(input, "unindent"))
s->scfunc = do_unindent;
else if (!strcasecmp(input, "scrollup"))
s->scfunc = do_scroll_up;
else if (!strcasecmp(input, "scrolldown"))
s->scfunc = do_scroll_down;
else if (!strcasecmp(input, "prevword"))
s->scfunc = do_prev_word_void;
else if (!strcasecmp(input, "nextword"))
s->scfunc = do_next_word_void;
else if (!strcasecmp(input, "cutwordleft"))
s->scfunc = do_cut_prev_word;
else if (!strcasecmp(input, "cutwordright"))
s->scfunc = do_cut_next_word;
else if (!strcasecmp(input, "prevblock"))
s->scfunc = do_prev_block;
else if (!strcasecmp(input, "nextblock"))
s->scfunc = do_next_block;
else if (!strcasecmp(input, "findbracket"))
s->scfunc = do_find_bracket;
else if (!strcasecmp(input, "wordcount"))
@@ -1485,10 +1521,18 @@ sc *strtosc(const char *input)
else if (!strcasecmp(input, "down") ||
!strcasecmp(input, "nextline"))
s->scfunc = do_down_void;
else if (!strcasecmp(input, "prevword"))
s->scfunc = do_prev_word_void;
else if (!strcasecmp(input, "nextword"))
s->scfunc = do_next_word_void;
else if (!strcasecmp(input, "home"))
s->scfunc = do_home_void;
else if (!strcasecmp(input, "end"))
s->scfunc = do_end_void;
else if (!strcasecmp(input, "prevblock"))
s->scfunc = do_prev_block;
else if (!strcasecmp(input, "nextblock"))
s->scfunc = do_next_block;
else if (!strcasecmp(input, "pageup") ||
!strcasecmp(input, "prevpage"))
s->scfunc = do_page_up;
@@ -1499,7 +1543,7 @@ sc *strtosc(const char *input)
s->scfunc = do_first_line;
else if (!strcasecmp(input, "lastline"))
s->scfunc = do_last_line;
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
else if (!strcasecmp(input, "prevbuf"))
s->scfunc = switch_to_prev_buffer_void;
else if (!strcasecmp(input, "nextbuf"))
@@ -1528,7 +1572,7 @@ sc *strtosc(const char *input)
s->scfunc = backwards_void;
else if (!strcasecmp(input, "flipreplace") ||
!strcasecmp(input, "dontreplace")) /* Deprecated. Remove in 2018. */
s->scfunc = flip_replace_void;
s->scfunc = flip_replace;
else if (!strcasecmp(input, "gototext"))
s->scfunc = gototext_void;
#ifndef DISABLE_HISTORIES
@@ -1537,6 +1581,7 @@ sc *strtosc(const char *input)
else if (!strcasecmp(input, "nexthistory"))
s->scfunc = get_history_newer_void;
#endif
#ifndef NANO_TINY
else if (!strcasecmp(input, "dosformat"))
s->scfunc = dos_format_void;
else if (!strcasecmp(input, "macformat"))
@@ -1547,16 +1592,15 @@ sc *strtosc(const char *input)
s->scfunc = prepend_void;
else if (!strcasecmp(input, "backup"))
s->scfunc = backup_file_void;
#ifndef ENABLE_TINY
else if (!strcasecmp(input, "flipexecute"))
s->scfunc = flip_execute_void;
s->scfunc = flip_execute;
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
else if (!strcasecmp(input, "flipnewbuffer") ||
!strcasecmp(input, "newbuffer")) /* Deprecated. Remove in 2018. */
s->scfunc = new_buffer_void;
s->scfunc = flip_newbuffer;
#endif
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
else if (!strcasecmp(input, "tofiles") ||
!strcasecmp(input, "browser"))
s->scfunc = to_files_void;
@@ -1573,7 +1617,7 @@ sc *strtosc(const char *input)
if (!strcasecmp(input, "nohelp"))
s->toggle = NO_HELP;
else if (!strcasecmp(input, "constupdate"))
s->toggle = CONST_UPDATE;
s->toggle = CONSTANT_SHOW;
else if (!strcasecmp(input, "morespace"))
s->toggle = MORE_SPACE;
else if (!strcasecmp(input, "smoothscroll"))
@@ -1591,7 +1635,7 @@ sc *strtosc(const char *input)
else if (!strcasecmp(input, "autoindent"))
s->toggle = AUTOINDENT;
else if (!strcasecmp(input, "cuttoend"))
s->toggle = CUT_TO_END;
s->toggle = CUT_FROM_CURSOR;
#ifndef DISABLE_WRAPPING
else if (!strcasecmp(input, "nowrap"))
s->toggle = NO_WRAP;
@@ -1600,11 +1644,11 @@ sc *strtosc(const char *input)
s->toggle = TABS_TO_SPACES;
else if (!strcasecmp(input, "backupfile"))
s->toggle = BACKUP_FILE;
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
else if (!strcasecmp(input, "multibuffer"))
s->toggle = MULTIBUFFER;
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
else if (!strcasecmp(input, "mouse"))
s->toggle = USE_MOUSE;
#endif
@@ -1645,7 +1689,7 @@ int strtomenu(const char *input)
else if (!strcasecmp(input, "externalcmd") ||
!strcasecmp(input, "extcmd"))
return MEXTCMD;
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
else if (!strcasecmp(input, "help"))
return MHELP;
#endif
@@ -1655,7 +1699,7 @@ int strtomenu(const char *input)
#endif
else if (!strcasecmp(input, "linter"))
return MLINTER;
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
else if (!strcasecmp(input, "browser"))
return MBROWSER;
else if (!strcasecmp(input, "whereisfile"))
@@ -1665,7 +1709,7 @@ int strtomenu(const char *input)
#endif
return -1;
}
#endif /* !DISABLE_NANORC */
#endif /* ENABLE_NANORC */
#ifdef DEBUG
@@ -1676,7 +1720,8 @@ int strtomenu(const char *input)
* function unless debugging is turned on. */
void thanks_for_all_the_fish(void)
{
delwin(topwin);
if (topwin != NULL)
delwin(topwin);
delwin(edit);
delwin(bottomwin);
@@ -1771,7 +1816,7 @@ void thanks_for_all_the_fish(void)
sclist = sclist->next;
free(s);
}
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
free(homedir);
#endif
}

View File

@@ -1,9 +1,9 @@
/**************************************************************************
* help.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, *
* 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 2014, 2015, 2016 Benno Schulenberg *
* Copyright (C) 2000-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2017 Rishabh Dave *
* Copyright (C) 2014-2017 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,165 +25,265 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
static char *help_text = NULL;
/* The text displayed in the help window. */
static const char *start_of_body = NULL;
/* The point in the help text just after the title. */
static char *end_of_intro = NULL;
/* The point in the help text where the introductory paragraphs end
* and the shortcut descriptions begin. */
/* The point in the help text where the shortcut descriptions begin. */
static size_t location;
/* The offset (in bytes) of the topleft of the shown help text. */
char *tempfilename = NULL;
/* Name of the temporary file used for wrapping the help text. */
/* Hard-wrap the help text, write it to the existing temporary file, and
* read that file into a new buffer. */
void wrap_the_help_text(bool redisplaying)
{
int sum = 0;
const char *ptr = start_of_body;
FILE *tempfile = fopen(tempfilename, "w+b");
/* If re-opening the temporary file failed, give up. */
if (tempfile == NULL) {
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
return;
}
/* Write the body of the help_text into the temporary file. */
while (*ptr != '\0') {
int length = help_line_len(ptr);
fwrite(ptr, sizeof(char), length, tempfile);
ptr += length;
/* Hard-wrap the lines in the help text. */
if (*ptr != '\n')
fwrite("\n", sizeof(char), 1, tempfile);
else while (*ptr == '\n')
fwrite(ptr++, sizeof(char), 1, tempfile);
}
fclose(tempfile);
if (redisplaying)
close_buffer();
open_buffer(tempfilename, FALSE);
remove_magicline();
prepare_for_display();
/* Move to the position in the file where we were before. */
while (TRUE) {
sum += strlen(openfile->current->data);
if (sum > location)
break;
openfile->current = openfile->current->next;
}
openfile->edittop = openfile->current;
}
/* Our main help-viewer function. */
void do_help(void)
{
int kbinput = ERR;
bool old_no_help = ISSET(NO_HELP);
size_t line = 0;
/* The line number in help_text of the first displayed help
* line. This variable is zero-based. */
size_t last_line = 0;
/* The line number in help_text of the last help line. This
* variable is zero-based. */
int oldmenu = currmenu;
/* The menu we were called from. */
const char *ptr;
/* The current line of the help text. */
size_t old_line = (size_t)-1;
/* The line we were on before the current line. */
functionptrtype func;
/* The function of the key the user typed in. */
int oldmenu = currmenu;
/* The menu we were called from. */
#ifdef ENABLE_LINENUMBERS
int was_margin = margin;
#endif
ssize_t was_tabsize = tabsize;
#ifndef DISABLE_COLOR
char *was_syntax = syntaxstr;
#endif
char *saved_answer = (answer != NULL) ? strdup(answer) : NULL;
/* The current answer when the user invokes help at the prompt. */
unsigned stash[sizeof(flags) / sizeof(flags[0])];
/* A storage place for the current flag settings. */
filestruct *line;
int length;
FILE *fp;
/* Don't show a cursor in the help screen. */
curs_set(0);
blank_edit();
blank_statusbar();
/* Set help_text as the string to display. */
help_init();
/* Get a temporary file for the help text. If it fails, give up. */
tempfilename = safe_tempfile(&fp);
if (tempfilename == NULL) {
statusline(ALERT, _("Error writing temp file: %s"), strerror(errno));
free(saved_answer);
return;
}
assert(help_text != NULL);
fclose(fp);
if (ISSET(NO_HELP)) {
/* Make sure that the help screen's shortcut list will actually
* be displayed. */
/* Save the settings of all flags. */
memcpy(stash, flags, sizeof(flags));
/* Ensure that the help screen's shortcut list can be displayed. */
if (ISSET(NO_HELP) && LINES > 4) {
UNSET(NO_HELP);
window_init();
}
/* When searching, do it forward, case insensitive, and without regexes. */
UNSET(BACKWARDS_SEARCH);
UNSET(CASE_SENSITIVE);
UNSET(USE_REGEXP);
UNSET(WHITESPACE_DISPLAY);
UNSET(NOREAD_MODE);
SET(MULTIBUFFER);
#ifdef ENABLE_LINENUMBERS
UNSET(LINE_NUMBERS);
margin = 0;
#endif
tabsize = 8;
#ifndef DISABLE_COLOR
syntaxstr = "nanohelp";
#endif
curs_set(0);
/* Compose the help text from all the pieces. */
help_init();
inhelp = TRUE;
location = 0;
bottombars(MHELP);
wnoutrefresh(bottomwin);
/* Extract the title from the head of the help text. */
length = break_line(help_text, MAX_BUF_SIZE, TRUE);
title = charalloc(length * sizeof(char) + 1);
strncpy(title, help_text, length);
title[length] = '\0';
titlebar(title);
/* Skip over the title to point at the start of the body text. */
start_of_body = help_text + length;
while (*start_of_body == '\n')
start_of_body++;
wrap_the_help_text(FALSE);
edit_refresh();
while (TRUE) {
size_t i;
ptr = help_text;
/* Find the line number of the last line of the help text. */
for (last_line = 0; *ptr != '\0'; last_line++) {
ptr += help_line_len(ptr);
if (*ptr == '\n')
ptr++;
}
if (last_line > 0)
last_line--;
/* Redisplay if the text was scrolled or an invalid key was pressed. */
if (line != old_line || kbinput == ERR) {
blank_edit();
ptr = help_text;
/* Advance in the text to the first line to be displayed. */
for (i = 0; i < line; i++) {
ptr += help_line_len(ptr);
if (*ptr == '\n')
ptr++;
}
/* Now display as many lines as the window will hold. */
for (i = 0; i < editwinrows && *ptr != '\0'; i++) {
size_t j = help_line_len(ptr);
mvwaddnstr(edit, i, 0, ptr, j);
ptr += j;
if (*ptr == '\n')
ptr++;
}
}
wnoutrefresh(edit);
old_line = line;
lastmessage = HUSH;
focusing = TRUE;
didfind = 0;
kbinput = get_kbinput(edit);
#ifndef NANO_TINY
if (kbinput == KEY_WINCH) {
kbinput = ERR;
continue; /* Redraw the screen. */
}
#endif
#ifndef DISABLE_MOUSE
if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y;
get_mouseinput(&mouse_x, &mouse_y, TRUE);
continue; /* Redraw the screen. */
}
#endif
func = parse_help_input(&kbinput);
if (func == total_refresh) {
total_redraw();
} else if (func == do_up_void) {
if (line > 0)
line--;
do_up(TRUE);
} else if (func == do_down_void) {
if (line + (editwinrows - 1) < last_line)
line++;
if (openfile->edittop->lineno + editwinrows - 1 <
openfile->filebot->lineno)
do_down(TRUE);
} else if (func == do_page_up) {
if (line > editwinrows - 2)
line -= editwinrows - 2;
else
line = 0;
do_page_up();
} else if (func == do_page_down) {
if (line + (editwinrows - 1) < last_line)
line += editwinrows - 2;
do_page_down();
} else if (func == do_first_line) {
line = 0;
do_first_line();
} else if (func == do_last_line) {
if (line + (editwinrows - 1) < last_line)
line = last_line - (editwinrows - 1);
do_last_line();
} else if (func == do_search) {
do_search();
bottombars(MHELP);
} else if (func == do_research) {
do_research();
currmenu = MHELP;
#ifndef NANO_TINY
} else if (kbinput == KEY_WINCH) {
; /* Nothing to do. */
#endif
#ifdef ENABLE_MOUSE
} else if (kbinput == KEY_MOUSE) {
int dummy_x, dummy_y;
get_mouseinput(&dummy_x, &dummy_y, TRUE);
#endif
} else if (func == do_exit) {
/* Exit from the help viewer. */
close_buffer();
break;
} else
unbound_key(kbinput);
/* If we searched and found something, let the cursor show it. */
if (didfind == 1)
curs_set(1);
else
curs_set(0);
edit_refresh();
location = 0;
line = openfile->fileage;
/* Count how far (in bytes) edittop is into the file. */
while (line != openfile->edittop) {
location += strlen(line->data);
line = line->next;
}
}
if (old_no_help) {
/* Restore the settings of all flags. */
memcpy(flags, stash, sizeof(flags));
#ifdef ENABLE_LINENUMBERS
margin = was_margin;
#endif
tabsize = was_tabsize;
#ifndef DISABLE_COLOR
syntaxstr = was_syntax;
#endif
/* Switch back to the buffer we were invoked from. */
switch_to_prev_buffer_void();
if (ISSET(NO_HELP)) {
blank_bottombars();
wnoutrefresh(bottomwin);
currmenu = oldmenu;
SET(NO_HELP);
window_init();
} else
bottombars(oldmenu);
#ifndef DISABLE_BROWSER
free(title);
title = NULL;
inhelp = FALSE;
#ifdef ENABLE_BROWSER
if (oldmenu == MBROWSER || oldmenu == MWHEREISFILE || oldmenu == MGOTODIR)
browser_refresh();
else
#endif
edit_refresh();
total_refresh();
free(answer);
answer = saved_answer;
remove(tempfilename);
free(tempfilename);
/* We're exiting from the help screen. */
free(help_text);
}
@@ -200,12 +300,6 @@ void help_init(void)
const subnfunc *f;
const sc *s;
#ifndef NANO_TINY
bool old_whitespace = ISSET(WHITESPACE_DISPLAY);
UNSET(WHITESPACE_DISPLAY);
#endif
/* First, set up the initial help text for the current function. */
if (currmenu == MWHEREIS || currmenu == MREPLACE || currmenu == MREPLACEWITH) {
htx[0] = N_("Search Command Help Text\n\n "
@@ -259,7 +353,7 @@ void help_init(void)
htx[1] = NULL;
htx[2] = NULL;
}
#ifndef DISABLE_BROWSER
#ifdef ENABLE_BROWSER
else if (currmenu == MBROWSER) {
htx[0] = N_("File Browser Help Text\n\n "
"The file browser is used to visually browse the "
@@ -297,7 +391,7 @@ void help_init(void)
htx[1] = NULL;
htx[2] = NULL;
}
#endif /* !DISABLE_BROWSER */
#endif /* ENABLE_BROWSER */
#ifndef DISABLE_SPELLER
else if (currmenu == MSPELL) {
htx[0] = N_("Spell Check Help Text\n\n "
@@ -370,7 +464,7 @@ void help_init(void)
* plus one or two \n's. */
for (f = allfuncs; f != NULL; f = f->next)
if (f->menus & currmenu)
allocsize += (16 * mb_cur_max()) + strlen(f->help) + 2;
allocsize += (16 * MAXCHARLEN) + strlen(_(f->help)) + 2;
#ifndef NANO_TINY
/* If we're on the main list, we also count the toggle help text.
@@ -385,7 +479,7 @@ void help_init(void)
}
#endif
/* Allocate space for the help text. */
/* Allocate memory for the help text. */
help_text = charalloc(allocsize + 1);
/* Now add the text we want. */
@@ -418,9 +512,9 @@ void help_init(void)
/* Make the first column narrower (6) than the second (10),
* but allow it to spill into the second, for "M-Space". */
if (scsfound == 1) {
sprintf(ptr, "%s ", s->keystr);
sprintf(ptr, "%s ", s->keystr);
/* Unicode arrows take three bytes instead of one. */
if (s->keystr[1] == '\xE2')
if (s->keystr[0] == '\xE2' || s->keystr[1] == '\xE2')
ptr += 8;
else
ptr += 6;
@@ -465,13 +559,10 @@ void help_init(void)
}
}
}
if (old_whitespace)
SET(WHITESPACE_DISPLAY);
#endif /* !NANO_TINY */
/* If all went well, we didn't overwrite the allocated space. */
assert(strlen(help_text) <= allocsize + 1);
if (strlen(help_text) > allocsize)
statusline(ALERT, "Help text spilled over -- please report a bug");
}
/* Return the function that is bound to the given key, accepting certain
@@ -484,6 +575,13 @@ functionptrtype parse_help_input(int *kbinput)
return do_page_down;
case '-':
return do_page_up;
case 'W':
case 'w':
case '/':
return do_search;
case 'N':
case 'n':
return do_research;
case 'E':
case 'e':
case 'Q':
@@ -525,17 +623,17 @@ size_t help_line_len(const char *ptr)
return 0;
}
#endif /* !DISABLE_HELP */
#endif /* ENABLE_HELP */
/* Start the help viewer. */
void do_help_void(void)
{
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
do_help();
#else
if (currmenu == MMAIN)
say_there_is_no_help();
else
beep();
#endif /* !DISABLE_HELP */
#endif
}

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* move.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2014, 2015, 2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -54,13 +53,8 @@ void get_edge_and_target(size_t *leftedge, size_t *target_column)
{
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
size_t realspan = strlenpt(openfile->current->data);
if (openfile->placewewant < realspan)
realspan = openfile->placewewant;
*leftedge = (realspan / editwincols) * editwincols;
*target_column = openfile->placewewant % editwincols;
*leftedge = leftedge_for(xplustabs(), openfile->current);
*target_column = openfile->placewewant - *leftedge;
} else
#endif
{
@@ -80,6 +74,8 @@ void do_page_up(void)
if (!ISSET(SMOOTH_SCROLL)) {
openfile->current = openfile->edittop;
openfile->placewewant = openfile->firstcolumn;
openfile->current_x = actual_x(openfile->current->data,
openfile->firstcolumn);
openfile->current_y = 0;
}
@@ -94,9 +90,9 @@ void do_page_up(void)
openfile->placewewant = leftedge + target_column;
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
actual_last_column(leftedge, target_column));
/* Scroll the edit window up a page. */
/* Move the viewport so that the cursor stays immobile, if possible. */
adjust_viewport(STATIONARY);
refresh_needed = TRUE;
}
@@ -112,6 +108,8 @@ void do_page_down(void)
if (!ISSET(SMOOTH_SCROLL)) {
openfile->current = openfile->edittop;
openfile->placewewant = openfile->firstcolumn;
openfile->current_x = actual_x(openfile->current->data,
openfile->firstcolumn);
openfile->current_y = 0;
}
@@ -126,18 +124,17 @@ void do_page_down(void)
openfile->placewewant = leftedge + target_column;
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
actual_last_column(leftedge, target_column));
/* Scroll the edit window down a page. */
/* Move the viewport so that the cursor stays immobile, if possible. */
adjust_viewport(STATIONARY);
refresh_needed = TRUE;
}
#ifndef DISABLE_JUSTIFY
/* Move up to the beginning of the last beginning-of-paragraph line
* before the current line. If allow_update is TRUE, update the screen
* afterwards. */
void do_para_begin(bool allow_update)
/* Move to the beginning of the last beginning-of-paragraph line before the
* current line. If update_screen is TRUE, update the screen afterwards. */
void do_para_begin(bool update_screen)
{
filestruct *was_current = openfile->current;
@@ -149,12 +146,11 @@ void do_para_begin(bool allow_update)
openfile->current_x = 0;
if (allow_update)
if (update_screen)
edit_redraw(was_current);
}
/* Move up to the beginning of the last beginning-of-paragraph line
* before the current line, and update the screen afterwards. */
/* Move up to first start of a paragraph before the current line. */
void do_para_begin_void(void)
{
do_para_begin(TRUE);
@@ -162,11 +158,11 @@ void do_para_begin_void(void)
/* Move down to the beginning of the last line of the current paragraph.
* Then move down one line farther if there is such a line, or to the
* end of the current line if not. If allow_update is TRUE, update the
* end of the current line if not. If update_screen is TRUE, update the
* screen afterwards. A line is the last line of a paragraph if it is
* in a paragraph, and the next line either is the beginning line of a
* paragraph or isn't in a paragraph. */
void do_para_end(bool allow_update)
void do_para_end(bool update_screen)
{
filestruct *was_current = openfile->current;
@@ -186,13 +182,11 @@ void do_para_end(bool allow_update)
} else
openfile->current_x = strlen(openfile->current->data);
if (allow_update)
if (update_screen)
edit_redraw(was_current);
}
/* Move down to the beginning of the last line of the current paragraph.
* Then move down one line farther if there is such a line, or to the
* end of the current line if not, and update the screen afterwards. */
/* Move down to just after the first end of a paragraph. */
void do_para_end_void(void)
{
do_para_end(TRUE);
@@ -240,9 +234,9 @@ void do_next_block(void)
}
/* Move to the previous word in the file. If allow_punct is TRUE, treat
* punctuation as part of a word. If allow_update is TRUE, update the
* punctuation as part of a word. If update_screen is TRUE, update the
* screen afterwards. */
void do_prev_word(bool allow_punct, bool allow_update)
void do_prev_word(bool allow_punct, bool update_screen)
{
filestruct *was_current = openfile->current;
bool seen_a_word = FALSE, step_forward = FALSE;
@@ -279,8 +273,7 @@ void do_prev_word(bool allow_punct, bool allow_update)
openfile->current_x = move_mbright(openfile->current->data,
openfile->current_x);
/* If allow_update is TRUE, update the screen. */
if (allow_update) {
if (update_screen) {
focusing = FALSE;
edit_redraw(was_current);
}
@@ -294,10 +287,10 @@ void do_prev_word_void(void)
}
/* Move to the next word in the file. If allow_punct is TRUE, treat
* punctuation as part of a word. If allow_update is TRUE, update the
* punctuation as part of a word. If update_screen is TRUE, update the
* screen afterwards. Return TRUE if we started on a word, and FALSE
* otherwise. */
bool do_next_word(bool allow_punct, bool allow_update)
bool do_next_word(bool allow_punct, bool update_screen)
{
filestruct *was_current = openfile->current;
bool started_on_word = is_word_mbchar(openfile->current->data +
@@ -329,8 +322,7 @@ bool do_next_word(bool allow_punct, bool allow_update)
break;
}
/* If allow_update is TRUE, update the screen. */
if (allow_update) {
if (update_screen) {
focusing = FALSE;
edit_redraw(was_current);
}
@@ -348,7 +340,7 @@ void do_next_word_void(void)
/* Move to the beginning of the current line (or softwrapped chunk).
* If be_clever is TRUE, do a smart home when wanted and possible,
* and do a dynamic home when in softwrap mode and it'spossible.
* and do a dynamic home when in softwrap mode and it's possible.
* If be_clever is FALSE, just do a simple home. */
void do_home(bool be_clever)
{
@@ -357,11 +349,12 @@ void do_home(bool be_clever)
bool moved_off_chunk = TRUE;
#ifndef NANO_TINY
bool moved = FALSE;
size_t leftedge_x = 0;
size_t leftedge = 0, leftedge_x = 0;
if (ISSET(SOFTWRAP))
leftedge_x = actual_x(openfile->current->data,
(was_column / editwincols) * editwincols);
if (ISSET(SOFTWRAP)) {
leftedge = leftedge_for(was_column, openfile->current);
leftedge_x = actual_x(openfile->current->data, leftedge);
}
if (ISSET(SMART_HOME) && be_clever) {
size_t indent_x = indent_length(openfile->current->data);
@@ -387,13 +380,15 @@ void do_home(bool be_clever)
openfile->current_x = 0;
else {
openfile->current_x = leftedge_x;
openfile->placewewant = leftedge;
moved_off_chunk = FALSE;
}
} else if (!moved)
#endif
openfile->current_x = 0;
openfile->placewewant = xplustabs();
if (moved_off_chunk)
openfile->placewewant = 0;
/* If we changed chunk, we might be offscreen. Otherwise,
* update current if the mark is on or we changed "page". */
@@ -422,9 +417,20 @@ void do_end(bool be_clever)
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
size_t rightedge_x = actual_x(openfile->current->data,
((was_column / editwincols) * editwincols) +
(editwincols - 1));
bool last_chunk = FALSE;
size_t leftedge = leftedge_for(was_column, openfile->current);
size_t rightedge = get_softwrap_breakpoint(openfile->current->data,
leftedge, &last_chunk);
size_t rightedge_x;
/* If we're on the last chunk, we're already at the end of the line.
* Otherwise, we're one column past the end of the line. Shifting
* backwards one column might put us in the middle of a multi-column
* character, but actual_x() will fix that. */
if (!last_chunk)
rightedge--;
rightedge_x = actual_x(openfile->current->data, rightedge);
/* If already at the right edge of the screen, move fully to
* the end of the line. Otherwise, move to the right edge. */
@@ -432,13 +438,15 @@ void do_end(bool be_clever)
openfile->current_x = line_len;
else {
openfile->current_x = rightedge_x;
openfile->placewewant = rightedge;
moved_off_chunk = FALSE;
}
} else
#endif
openfile->current_x = line_len;
openfile->placewewant = xplustabs();
if (moved_off_chunk)
openfile->placewewant = xplustabs();
/* If we changed chunk, we might be offscreen. Otherwise,
* update current if the mark is on or we changed "page". */
@@ -476,7 +484,7 @@ void do_up(bool scroll_only)
openfile->placewewant = leftedge + target_column;
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
actual_last_column(leftedge, target_column));
/* When the cursor was on the first line of the edit window (or when just
* scrolling without moving the cursor), scroll the edit window up -- one
@@ -520,7 +528,7 @@ void do_down(bool scroll_only)
openfile->placewewant = leftedge + target_column;
openfile->current_x = actual_x(openfile->current->data,
openfile->placewewant);
actual_last_column(leftedge, target_column));
/* When the cursor was on the last line of the edit window (or when just
* scrolling without moving the cursor), scroll the edit window down -- one
@@ -567,8 +575,8 @@ void do_left(void)
{
size_t was_column = xplustabs();
#ifndef NANO_TINY
size_t was_chunk = (was_column / editwincols);
filestruct *was_current = openfile->current;
size_t was_chunk = chunk_for(was_column, was_current);
#endif
if (openfile->current_x > 0)
@@ -587,7 +595,8 @@ void do_left(void)
* we're now above the first line of the edit window, so scroll up. */
if (ISSET(SOFTWRAP) && openfile->current_y == 0 &&
openfile->current == was_current &&
openfile->placewewant / editwincols != was_chunk) {
chunk_for(openfile->placewewant,
openfile->current) != was_chunk) {
edit_scroll(UPWARD, ISSET(SMOOTH_SCROLL) ? 1 : editwinrows / 2 + 1);
return;
}
@@ -603,8 +612,8 @@ void do_right(void)
{
size_t was_column = xplustabs();
#ifndef NANO_TINY
size_t was_chunk = (was_column / editwincols);
filestruct *was_current = openfile->current;
size_t was_chunk = chunk_for(was_column, was_current);
#endif
if (openfile->current->data[openfile->current_x] != '\0')
@@ -623,7 +632,8 @@ void do_right(void)
* we're now below the first line of the edit window, so scroll down. */
if (ISSET(SOFTWRAP) && openfile->current_y == editwinrows - 1 &&
openfile->current == was_current &&
openfile->placewewant / editwincols != was_chunk) {
chunk_for(openfile->placewewant,
openfile->current) != was_chunk) {
edit_scroll(DOWNWARD, ISSET(SMOOTH_SCROLL) ? 1 : editwinrows / 2 + 1);
return;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* nano.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2014, 2015, 2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -49,8 +48,6 @@
#include <sys/param.h>
#endif
#include <stdarg.h>
/* Suppress warnings for __attribute__((warn_unused_result)). */
#define IGNORE_CALL_RESULT(call) do { if (call) {} } while(0)
@@ -68,6 +65,13 @@
#define charmove(dest, src, n) memmove(dest, src, (n) * sizeof(char))
#define charset(dest, src, n) memset(dest, src, (n) * sizeof(char))
/* In UTF-8 a character is at most six bytes long. */
#ifdef ENABLE_UTF8
#define MAXCHARLEN 6
#else
#define MAXCHARLEN 1
#endif
/* Set a default value for PATH_MAX if there isn't one. */
#ifndef PATH_MAX
#define PATH_MAX 4096
@@ -118,10 +122,10 @@
#include <signal.h>
#include <assert.h>
/* If we aren't using ncurses with mouse support, turn the mouse support
* off, as it's useless then. */
/* If we aren't using an ncurses with mouse support, exclude any
* mouse routines, as they are useless then. */
#ifndef NCURSES_MOUSE_VERSION
#define DISABLE_MOUSE 1
#undef ENABLE_MOUSE
#endif
#if defined(DISABLE_WRAPPING) && defined(DISABLE_JUSTIFY)
@@ -154,11 +158,11 @@ typedef enum {
} update_type;
typedef enum {
ADD, DEL, BACK, CUT, CUT_EOF, REPLACE,
ADD, DEL, BACK, CUT, CUT_TO_EOF, REPLACE,
#ifndef DISABLE_WRAPPING
SPLIT_BEGIN, SPLIT_END,
#endif
#ifndef DISABLE_COMMENT
#ifdef ENABLE_COMMENT
COMMENT, UNCOMMENT, PREFLIGHT,
#endif
JOIN, PASTE, INSERT, ENTER, OTHER
@@ -214,8 +218,10 @@ typedef struct syntaxtype {
/* The command with which to lint this type of file. */
char *formatter;
/* The formatting command (for programming languages mainly). */
#ifdef ENABLE_COMMENT
char *comment;
/* The line comment prefix (and postfix) for this type of file. */
#endif
colortype *color;
/* The colors and their regexes used in this syntax. */
int nmultis;
@@ -398,7 +404,7 @@ typedef struct openfilestruct {
/* The preceding open file, if any. */
} openfilestruct;
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
typedef struct rcoption {
const char *name;
/* The name of the rcfile option. */
@@ -436,7 +442,7 @@ typedef struct subnfunc {
/* In what menus this function applies. */
const char *desc;
/* The function's short description, for example "Where Is". */
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
const char *help;
/* The help-screen text for this function. */
bool blank_after;
@@ -474,7 +480,7 @@ enum
{
DONTUSE,
CASE_SENSITIVE,
CONST_UPDATE,
CONSTANT_SHOW,
NO_HELP,
SUSPEND,
NO_WRAP,
@@ -483,7 +489,7 @@ enum
USE_MOUSE,
USE_REGEXP,
TEMP_FILE,
CUT_TO_END,
CUT_FROM_CURSOR,
BACKWARDS_SEARCH,
MULTIBUFFER,
SMOOTH_SCROLL,
@@ -513,7 +519,8 @@ enum
JUSTIFY_TRIM,
SHOW_CURSOR,
LINE_NUMBERS,
NO_PAUSES
NO_PAUSES,
AT_BLANKS
};
/* Flags for the menus in which a given function should be present. */
@@ -532,9 +539,15 @@ enum
#define MGOTODIR (1<<12)
#define MYESNO (1<<13)
#define MLINTER (1<<14)
#define MFINDINHELP (1<<15)
/* This is an abbreviation for all menus except Help and YesNo. */
#define MMOST (MMAIN|MWHEREIS|MREPLACE|MREPLACEWITH|MGOTOLINE|MWRITEFILE|MINSERTFILE|\
MEXTCMD|MBROWSER|MWHEREISFILE|MGOTODIR|MSPELL|MLINTER)
MEXTCMD|MBROWSER|MWHEREISFILE|MGOTODIR|MFINDINHELP|MSPELL|MLINTER)
#ifndef NANO_TINY
#define MSOME MMOST
#else
#define MSOME MMAIN|MBROWSER
#endif
/* Basic control codes. */
#define TAB_CODE 0x09
@@ -546,10 +559,14 @@ enum
#define CONTROL_RIGHT 0x402
#define CONTROL_UP 0x403
#define CONTROL_DOWN 0x404
#define CONTROL_HOME 0x411
#define CONTROL_END 0x412
#define SHIFT_CONTROL_LEFT 0x405
#define SHIFT_CONTROL_RIGHT 0x406
#define SHIFT_CONTROL_UP 0x407
#define SHIFT_CONTROL_DOWN 0x408
#define SHIFT_CONTROL_HOME 0x413
#define SHIFT_CONTROL_END 0x414
#define SHIFT_ALT_LEFT 0x409
#define SHIFT_ALT_RIGHT 0x40a
#define SHIFT_ALT_UP 0x40b
@@ -559,6 +576,15 @@ enum
#define SHIFT_HOME 0x40f
#define SHIFT_END 0x410
#ifdef USE_SLANG
#ifdef ENABLE_UTF8
#define KEY_BAD 0xFF /* Clipped error code. */
#endif
#define KEY_FLUSH 0x91 /* User-definable control code. */
#else
#define KEY_FLUSH KEY_F0 /* Nonexistent function key. */
#endif
#ifndef NANO_TINY
/* An imaginary key for when we get a SIGWINCH (window resize). */
#define KEY_WINCH -2
@@ -581,6 +607,9 @@ enum
/* The default width of a tab in spaces. */
#define WIDTH_OF_TAB 8
/* The default comment character when a syntax does not specify any. */
#define GENERAL_COMMENT_CHARACTER "#"
/* The maximum number of search/replace history strings saved, not
* counting the blank lines at their ends. */
#define MAX_SEARCH_HISTORY 100

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* prompt.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -58,7 +57,7 @@ int do_statusbar_input(bool *ran_func, bool *finished)
return KEY_WINCH;
#endif
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
/* If we got a mouse click and it was on a shortcut, read in the
* shortcut character. */
if (input == KEY_MOUSE) {
@@ -96,7 +95,7 @@ int do_statusbar_input(bool *ran_func, bool *finished)
kbinput = (int *)nrealloc(kbinput, kbinput_len * sizeof(int));
kbinput[kbinput_len - 1] = input;
}
}
}
/* If we got a shortcut, or if there aren't any other keystrokes waiting
* after the one we read in, we need to insert all the characters in the
@@ -138,9 +137,9 @@ int do_statusbar_input(bool *ran_func, bool *finished)
s->scfunc == do_delete ||
s->scfunc == do_backspace))
;
else if (s->scfunc == do_verbatim_input) {
else if (s->scfunc == do_verbatim_input)
do_statusbar_verbatim_input();
} else if (s->scfunc == do_cut_text_void)
else if (s->scfunc == do_cut_text_void)
do_statusbar_cut_text();
else if (s->scfunc == do_delete)
do_statusbar_delete();
@@ -165,7 +164,7 @@ int do_statusbar_input(bool *ran_func, bool *finished)
return input;
}
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
/* Handle a mouse click on the statusbar prompt or the shortcut list. */
int do_statusbar_mouse(void)
{
@@ -197,7 +196,7 @@ void do_statusbar_output(int *the_input, size_t input_len,
bool filtering)
{
char *output = charalloc(input_len + 1);
char *char_buf = charalloc(mb_cur_max());
char onechar[MAXCHARLEN];
int i, char_len;
/* Copy the typed stuff so it can be treated. */
@@ -213,7 +212,7 @@ void do_statusbar_output(int *the_input, size_t input_len,
output[i] = '\n';
/* Interpret the next multibyte character. */
char_len = parse_mbchar(output + i, char_buf, NULL);
char_len = parse_mbchar(output + i, onechar, NULL);
i += char_len;
@@ -225,12 +224,11 @@ void do_statusbar_output(int *the_input, size_t input_len,
answer = charealloc(answer, strlen(answer) + char_len + 1);
charmove(answer + statusbar_x + char_len, answer + statusbar_x,
strlen(answer) - statusbar_x + 1);
strncpy(answer + statusbar_x, char_buf, char_len);
strncpy(answer + statusbar_x, onechar, char_len);
statusbar_x += char_len;
}
free(char_buf);
free(output);
update_the_statusbar();
@@ -293,7 +291,7 @@ void do_statusbar_delete(void)
/* Zap some or all text from the answer. */
void do_statusbar_cut_text(void)
{
if (!ISSET(CUT_TO_END))
if (!ISSET(CUT_FROM_CURSOR))
statusbar_x = 0;
answer[statusbar_x] = '\0';
@@ -385,35 +383,18 @@ void reinit_statusbar_x(void)
statusbar_x = HIGHEST_POSITIVE;
}
/* Put the cursor in the answer at statusbar_x. */
void reset_statusbar_cursor(void)
{
size_t start_col = strlenpt(prompt) + 2;
size_t xpt = statusbar_xplustabs();
/* Work around a cursor-misplacement bug in VTEs. */
wmove(bottomwin, 0, 0);
wnoutrefresh(bottomwin);
doupdate();
wmove(bottomwin, 0, start_col + xpt -
get_statusbar_page_start(start_col, start_col + xpt));
wnoutrefresh(bottomwin);
}
/* Repaint the statusbar. */
/* Redraw the promptbar and place the cursor at the right spot. */
void update_the_statusbar(void)
{
size_t base, the_page, end_page;
size_t base = strlenpt(prompt) + 2;
size_t the_page, end_page, column;
char *expanded;
base = strlenpt(prompt) + 2;
the_page = get_statusbar_page_start(base, base + strnlenpt(answer, statusbar_x));
end_page = get_statusbar_page_start(base, base + strlenpt(answer) - 1);
/* Color the promptbar over its full width. */
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
blank_statusbar();
mvwaddstr(bottomwin, 0, 0, prompt);
@@ -428,7 +409,14 @@ void update_the_statusbar(void)
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
reset_statusbar_cursor();
/* Work around a cursor-misplacement bug in VTEs. */
wmove(bottomwin, 0, 0);
wrefresh(bottomwin);
/* Place the cursor at statusbar_x in the answer. */
column = base + statusbar_xplustabs();
wmove(bottomwin, 0, column - get_statusbar_page_start(base, column));
wnoutrefresh(bottomwin);
}
/* Get a string of input at the statusbar prompt. */
@@ -442,7 +430,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
int kbinput = ERR;
bool ran_func, finished;
functionptrtype func;
#ifndef DISABLE_TABCOMP
#ifdef ENABLE_TABCOMP
bool tabbed = FALSE;
/* Whether we've pressed Tab. */
#endif
@@ -452,7 +440,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
char *magichistory = NULL;
/* The temporary string typed at the bottom of the history, if
* any. */
#ifndef DISABLE_TABCOMP
#ifdef ENABLE_TABCOMP
int last_kbinput = ERR;
/* The key we pressed before the current key. */
size_t complete_len = 0;
@@ -470,10 +458,6 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
update_the_statusbar();
/* Refresh edit window and statusbar before getting input. */
wnoutrefresh(edit);
wnoutrefresh(bottomwin);
while (TRUE) {
/* Ensure the cursor is shown when waiting for input. */
curs_set(1);
@@ -497,7 +481,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
if (func == do_cancel || func == do_enter)
break;
#ifndef DISABLE_TABCOMP
#ifdef ENABLE_TABCOMP
if (func != do_tab)
tabbed = FALSE;
@@ -518,7 +502,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
answer = input_tab(answer, allow_files, &statusbar_x,
&tabbed, refresh_func, listed);
} else
#endif /* !DISABLE_TABCOMP */
#endif /* ENABLE_TABCOMP */
#ifndef DISABLE_HISTORIES
if (func == get_history_older_void) {
if (history_list != NULL) {
@@ -582,7 +566,7 @@ functionptrtype acquire_an_answer(int *actual, bool allow_tabs,
update_the_statusbar();
#if !defined(DISABLE_HISTORIES) && !defined(DISABLE_TABCOMP)
#if !defined(DISABLE_HISTORIES) && defined(ENABLE_TABCOMP)
last_kbinput = kbinput;
#endif
}
@@ -622,8 +606,9 @@ int do_prompt(bool allow_tabs, bool allow_files,
int retval;
functionptrtype func = NULL;
bool listed = FALSE;
/* Save a possible current statusbar x position. */
/* Save a possible current statusbar x position and prompt. */
size_t was_statusbar_x = statusbar_x;
char *saved_prompt = prompt;
bottombars(menu);
@@ -632,9 +617,9 @@ int do_prompt(bool allow_tabs, bool allow_files,
#ifndef NANO_TINY
redo_theprompt:
#endif
prompt = charalloc((COLS * mb_cur_max()) + 1);
prompt = charalloc((COLS * MAXCHARLEN) + 1);
va_start(ap, msg);
vsnprintf(prompt, COLS * mb_cur_max(), msg, ap);
vsnprintf(prompt, COLS * MAXCHARLEN, msg, ap);
va_end(ap);
/* Reserve five columns for colon plus angles plus answer, ":<aa>". */
prompt[actual_x(prompt, (COLS < 5) ? 0 : COLS - 5)] = '\0';
@@ -646,7 +631,7 @@ int do_prompt(bool allow_tabs, bool allow_files,
refresh_func);
free(prompt);
prompt = NULL;
prompt = saved_prompt;
#ifndef NANO_TINY
if (retval == KEY_WINCH)
@@ -672,7 +657,7 @@ int do_prompt(bool allow_tabs, bool allow_files,
fprintf(stderr, "answer = \"%s\"\n", answer);
#endif
#ifndef DISABLE_TABCOMP
#ifdef ENABLE_TABCOMP
/* If we've done tab completion, there might still be a list of
* filename matches on the edit window. Clear them off. */
if (listed)
@@ -753,7 +738,7 @@ int do_yesno_prompt(bool all, const char *msg)
if (func == do_cancel)
response = -1;
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
else if (kbinput == KEY_MOUSE) {
int mouse_x, mouse_y;
/* We can click on the Yes/No/All shortcuts to select an answer. */
@@ -775,7 +760,7 @@ int do_yesno_prompt(bool all, const char *msg)
response = -2;
}
}
#endif /* !DISABLE_MOUSE */
#endif /* ENABLE_MOUSE */
else {
/* Look for the kbinput in the Yes, No (and All) strings. */
if (strchr(yesstr, kbinput) != NULL)

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* proto.h -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* *
* GNU nano is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
@@ -25,6 +24,7 @@
#include "nano.h"
/* All external variables. See global.c for their descriptions. */
#ifndef NANO_TINY
extern volatile sig_atomic_t the_window_resized;
#endif
@@ -43,19 +43,34 @@ extern bool as_an_at;
extern int margin;
extern int editwincols;
#ifndef DISABLE_COLOR
extern bool have_palette;
#endif
extern bool suppress_cursorpos;
extern message_type lastmessage;
extern filestruct *pletion_line;
extern bool inhelp;
extern char *title;
extern int didfind;
extern int controlleft;
extern int controlright;
extern int controlup;
extern int controldown;
extern int controlhome;
extern int controlend;
#ifndef NANO_TINY
extern int shiftcontrolleft;
extern int shiftcontrolright;
extern int shiftcontrolup;
extern int shiftcontroldown;
extern int shiftcontrolhome;
extern int shiftcontrolend;
extern int shiftaltleft;
extern int shiftaltright;
extern int shiftaltup;
@@ -106,8 +121,6 @@ extern char *quoteerr;
extern char *word_chars;
extern bool nodelay_mode;
extern char *answer;
extern ssize_t tabsize;
@@ -162,17 +175,13 @@ extern char *homedir;
typedef void (*functionptrtype)(void);
/* All functions in browser.c. */
#ifndef DISABLE_BROWSER
char *do_browser(char *path);
/* Most functions in browser.c. */
#ifdef ENABLE_BROWSER
char *do_browse_from(const char *inpath);
void read_the_list(const char *path, DIR *dir);
functionptrtype parse_browser_input(int *kbinput);
void browser_refresh(void);
void browser_select_dirname(const char *needle);
int filesearch_init(void);
void findnextfile(const char *needle);
void filesearch_abort(void);
void do_filesearch(void);
void do_fileresearch(void);
void do_first_file(void);
@@ -188,18 +197,13 @@ bool using_utf8(void);
char *addstrings(char* str1, size_t len1, char* str2, size_t len2);
bool is_byte(int c);
bool is_alpha_mbchar(const char *c);
bool is_alnum_mbchar(const char *c);
bool is_blank_mbchar(const char *c);
bool is_ascii_cntrl_char(int c);
bool is_cntrl_char(int c);
bool is_cntrl_mbchar(const char *c);
bool is_punct_mbchar(const char *c);
bool is_word_mbchar(const char *c, bool allow_punct);
char control_rep(const signed char c);
char control_mbrep(const char *c, bool isdata);
int length_of_char(const char *c, int *width);
int mbwidth(const char *c);
int mb_cur_max(void);
char *make_mbchar(long chr, int *chr_mb_len);
int parse_mbchar(const char *buf, char *chr, size_t *col);
size_t move_mbleft(const char *buf, size_t pos);
@@ -208,11 +212,9 @@ int mbstrcasecmp(const char *s1, const char *s2);
int mbstrncasecmp(const char *s1, const char *s2, size_t n);
char *mbstrcasestr(const char *haystack, const char *needle);
char *revstrstr(const char *haystack, const char *needle,
const char *pointer);
char *revstrcasestr(const char *haystack, const char *needle, const char
*rev_start);
char *mbrevstrcasestr(const char *haystack, const char *needle, const
char *rev_start);
const char *index);
char *mbrevstrcasestr(const char *haystack, const char *needle,
const char *index);
size_t mbstrlen(const char *s);
size_t mbstrnlen(const char *s, size_t maxlen);
#if !defined(NANO_TINY) || !defined(DISABLE_JUSTIFY)
@@ -220,19 +222,16 @@ char *mbstrchr(const char *s, const char *c);
#endif
#ifndef NANO_TINY
char *mbstrpbrk(const char *s, const char *accept);
char *revstrpbrk(const char *s, const char *accept, const char
*rev_start);
char *mbrevstrpbrk(const char *s, const char *accept, const char
*rev_start);
char *revstrpbrk(const char *head, const char *accept, const char *index);
char *mbrevstrpbrk(const char *head, const char *accept, const char *index);
#endif
#if !defined(DISABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
bool has_blank_chars(const char *s);
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || !defined(DISABLE_JUSTIFY))
bool has_blank_mbchars(const char *s);
#endif
#ifdef ENABLE_UTF8
bool is_valid_unicode(wchar_t wc);
#endif
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
bool is_valid_mbstring(const char *s);
#endif
@@ -246,14 +245,11 @@ void alloc_multidata_if_needed(filestruct *fileptr);
void precalc_multicolorinfo(void);
#endif
/* All functions in cut.c. */
/* Most functions in cut.c. */
void cutbuffer_reset(void);
bool keeping_cutbuffer(void);
void cut_line(void);
#ifndef NANO_TINY
void cut_marked(bool *right_side_up);
void cut_to_eol(void);
void cut_to_eof(void);
#endif
void do_cut_text(bool copy_text, bool cut_till_eof);
void do_cut_text_void(void);
@@ -264,7 +260,6 @@ void do_cut_till_eof(void);
void do_uncut_text(void);
/* Most functions in files.c. */
void make_new_buffer(void);
void initialize_buffer_text(void);
bool open_buffer(const char *filename, bool undoable);
#ifndef DISABLE_SPELLER
@@ -274,20 +269,18 @@ void replace_marked_buffer(const char *filename, filestruct *top, size_t top_x,
filestruct *bot, size_t bot_x);
#endif
#endif
void display_buffer(void);
#ifndef DISABLE_MULTIBUFFER
void prepare_for_display(void);
#ifdef ENABLE_MULTIBUFFER
void switch_to_prev_buffer_void(void);
void switch_to_next_buffer_void(void);
bool close_buffer(void);
#endif
char *encode_data(char *buf, size_t buf_len);
void read_file(FILE *f, int fd, const char *filename, bool undoable,
bool checkwritable);
int open_file(const char *filename, bool newfie, bool quiet, FILE **f);
char *get_next_filename(const char *name, const char *suffix);
void do_insertfile_void(void);
char *get_full_path(const char *origpath);
char *check_writable_directory(const char *path);
char *safe_tempfile(FILE **f);
#ifndef DISABLE_OPERATINGDIR
void init_operating_dir(void);
@@ -298,7 +291,7 @@ void init_backup_dir(void);
int delete_lockfile(const char *lockfilename);
int write_lockfile(const char *lockfilename, const char *origfilename, bool modified);
#endif
int copy_file(FILE *inn, FILE *out);
int copy_file(FILE *inn, FILE *out, bool close_out);
bool write_file(const char *name, FILE *f_open, bool tmp,
kind_of_writing_type method, bool nonamechange);
#ifndef NANO_TINY
@@ -311,24 +304,17 @@ void do_writeout_void(void);
void do_savefile(void);
#endif
char *real_dir_from_tilde(const char *buf);
#if !defined(DISABLE_TABCOMP) || !defined(DISABLE_BROWSER)
#if defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
int diralphasort(const void *va, const void *vb);
void free_chararray(char **array, size_t len);
#endif
#ifndef DISABLE_TABCOMP
bool is_dir(const char *buf);
char **username_tab_completion(const char *buf, size_t *num_matches,
size_t buf_len);
char **cwd_tab_completion(const char *buf, bool allow_files, size_t
*num_matches, size_t buf_len);
#ifdef ENABLE_TABCOMP
char *input_tab(char *buf, bool allow_files, size_t *place,
bool *lastwastab, void (*refresh_func)(void), bool *listed);
#endif
const char *tail(const char *path);
#ifndef DISABLE_HISTORIES
char *histfilename(void);
void load_history(void);
bool writehist(FILE *hist, const filestruct *head);
void save_history(void);
int check_dotnano(void);
void load_poshistory(void);
@@ -358,7 +344,8 @@ void thanks_for_all_the_fish(void);
#endif
/* All functions in help.c. */
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
void wrap_the_help_text(bool redisplaying);
void do_help(void);
void help_init(void);
functionptrtype parse_help_input(int *kbinput);
@@ -372,16 +359,16 @@ void do_last_line(void);
void do_page_up(void);
void do_page_down(void);
#ifndef DISABLE_JUSTIFY
void do_para_begin(bool allow_update);
void do_para_begin(bool update_screen);
void do_para_begin_void(void);
void do_para_end(bool allow_update);
void do_para_end(bool update_screen);
void do_para_end_void(void);
#endif
void do_prev_block(void);
void do_next_block(void);
void do_prev_word(bool allow_punct, bool allow_update);
void do_prev_word(bool allow_punct, bool update_screen);
void do_prev_word_void(void);
bool do_next_word(bool allow_punct, bool allow_update);
bool do_next_word(bool allow_punct, bool update_screen);
void do_next_word_void(void);
void do_home(bool be_clever);
void do_home_void(void);
@@ -398,9 +385,8 @@ void do_scroll_down(void);
void do_left(void);
void do_right(void);
/* All functions in nano.c. */
/* Most functions in nano.c. */
filestruct *make_new_node(filestruct *prevnode);
filestruct *copy_node(const filestruct *src);
void splice_node(filestruct *afterthis, filestruct *newnode);
void unlink_node(filestruct *fileptr);
void delete_node(filestruct *fileptr);
@@ -419,24 +405,15 @@ void unlink_opennode(openfilestruct *fileptr);
void delete_opennode(openfilestruct *fileptr);
void print_view_warning(void);
void show_restricted_warning(void);
#ifdef DISABLE_HELP
#ifndef ENABLE_HELP
void say_there_is_no_help(void);
#endif
void finish(void);
void die(const char *msg, ...);
void die_save_file(const char *die_filename, struct stat *die_stat);
void window_init(void);
#ifndef DISABLE_MOUSE
void disable_mouse_support(void);
void enable_mouse_support(void);
void mouse_init(void);
#endif
void print_opt(const char *shortflag, const char *longflag, const char *desc);
void usage(void);
void version(void);
void do_exit(void);
void close_and_go(void);
void signal_init(void);
RETSIGTYPE handle_hupterm(int signal);
RETSIGTYPE do_suspend(int signal);
RETSIGTYPE do_continue(int signal);
@@ -453,13 +430,13 @@ void enable_flow_control(void);
void terminal_init(void);
void unbound_key(int code);
int do_input(bool allow_funcs);
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
int do_mouse(void);
#endif
void do_output(char *output, size_t output_len, bool allow_cntrls);
/* Most functions in prompt.c. */
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
int do_statusbar_mouse(void);
#endif
void do_statusbar_output(int *the_input, size_t input_len,
@@ -479,7 +456,6 @@ void do_statusbar_verbatim_input(void);
size_t statusbar_xplustabs(void);
size_t get_statusbar_page_start(size_t start_col, size_t column);
void reinit_statusbar_x(void);
void reset_statusbar_cursor(void);
void update_the_statusbar(void);
int do_prompt(bool allow_tabs, bool allow_files,
int menu, const char *curranswer,
@@ -490,24 +466,18 @@ int do_prompt(bool allow_tabs, bool allow_files,
int do_yesno_prompt(bool all, const char *msg);
/* Most functions in rcfile.c. */
#if !defined(DISABLE_NANORC) || !defined(DISABLE_HISTORIES)
char *parse_next_word(char *ptr);
#endif
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
#ifndef DISABLE_COLOR
bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright);
void grab_and_store(const char *kind, char *ptr, regexlisttype **storage);
#endif
void parse_rcfile(FILE *rcstream, bool syntax_only);
void do_rcfiles(void);
#endif /* !DISABLE_NANORC */
#endif /* ENABLE_NANORC */
/* All functions in search.c. */
bool regexp_init(const char *regexp);
void regexp_cleanup(void);
/* Most functions in search.c. */
void not_found_msg(const char *str);
void search_replace_abort(void);
int search_init(bool replacing, bool use_answer);
int findnextstr(const char *needle, bool whole_word_only, bool have_region,
size_t *match_len, bool skipone, const filestruct *begin, size_t begin_x);
void do_search(void);
@@ -517,8 +487,6 @@ void do_findnext(void);
#endif
void do_research(void);
void go_looking(void);
int replace_regexp(char *string, bool create);
char *replace_line(const char *needle);
ssize_t do_replace_loop(const char *needle, bool whole_word_only,
const filestruct *real_current, size_t *real_current_x);
void do_replace(void);
@@ -527,9 +495,8 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
bool interactive);
void do_gotolinecolumn_void(void);
#ifndef NANO_TINY
bool find_bracket_match(bool reverse, const char *bracket_set);
void do_find_bracket(void);
#ifndef DISABLE_TABCOMP
#ifdef ENABLE_TABCOMP
char *get_history_completion(filestruct **h, char *s, size_t len);
#endif
#endif
@@ -537,8 +504,6 @@ char *get_history_completion(filestruct **h, char *s, size_t len);
bool history_has_changed(void);
void history_init(void);
void history_reset(const filestruct *h);
filestruct *find_history(const filestruct *h_start, const filestruct
*h_end, const char *s, size_t len);
void update_history(filestruct **h, const char *s);
char *get_history_older(filestruct **h);
char *get_history_newer(filestruct **h);
@@ -546,7 +511,7 @@ void get_history_older_void(void);
void get_history_newer_void(void);
#endif
/* All functions in text.c. */
/* Most functions in text.c. */
#ifndef NANO_TINY
void do_mark(void);
#endif
@@ -558,8 +523,7 @@ void do_cut_next_word(void);
#endif
void do_tab(void);
#ifndef NANO_TINY
void do_indent(ssize_t cols);
void do_indent_void(void);
void do_indent(void);
void do_unindent(void);
#endif
bool white_string(const char *s);
@@ -575,7 +539,7 @@ RETSIGTYPE cancel_command(int signal);
bool execute_command(const char *command);
void discard_until(const undo *thisitem, openfilestruct *thefile);
void add_undo(undo_type action);
#ifndef DISABLE_COMMENT
#ifdef ENABLE_COMMENT
void update_comment_undo(ssize_t lineno);
#endif
void update_undo(undo_type action);
@@ -584,7 +548,7 @@ void update_undo(undo_type action);
void wrap_reset(void);
bool do_wrap(filestruct *line);
#endif
#if !defined(DISABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
#if defined(ENABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl);
#endif
#if !defined(NANO_TINY) || !defined(DISABLE_JUSTIFY)
@@ -592,23 +556,13 @@ size_t indent_length(const char *line);
#endif
#ifndef DISABLE_JUSTIFY
void justify_format(filestruct *paragraph, size_t skip);
size_t quote_length(const char *line);
bool quotes_match(const char *a_line, size_t a_quote, const char
*b_line);
bool indents_match(const char *a_line, size_t a_indent, const char
*b_line, size_t b_indent);
bool begpar(const filestruct *const foo);
bool inpar(const filestruct *const foo);
void backup_lines(filestruct *first_line, size_t par_len);
bool find_paragraph(size_t *const quote, size_t *const par);
void do_justify(bool full_justify);
void do_justify_void(void);
void do_full_justify(void);
#endif
#ifndef DISABLE_SPELLER
bool do_int_spell_fix(const char *word);
const char *do_int_speller(const char *tempfile_name);
const char *do_alt_speller(char *tempfile_name);
void do_spell(void);
#endif
#ifndef DISABLE_COLOR
@@ -650,8 +604,10 @@ size_t actual_x(const char *s, size_t column);
size_t strnlenpt(const char *s, size_t maxlen);
size_t strlenpt(const char *s);
void new_magicline(void);
#ifndef NANO_TINY
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
void remove_magicline(void);
#endif
#ifndef NANO_TINY
void mark_order(const filestruct **top, size_t *top_x, const filestruct
**bot, size_t *bot_x, bool *right_side_up);
#endif
@@ -667,34 +623,25 @@ void dump_filestruct_reverse(void);
/* Most functions in winio.c. */
void get_key_buffer(WINDOW *win);
size_t get_key_buffer_len(void);
void unget_input(int *input, size_t input_len);
void unget_kbinput(int kbinput, bool metakey);
int *get_input(WINDOW *win, size_t input_len);
int get_kbinput(WINDOW *win);
int parse_kbinput(WINDOW *win);
int arrow_from_abcd(int kbinput);
int parse_escape_sequence(WINDOW *win, int kbinput);
int get_byte_kbinput(int kbinput);
#ifdef ENABLE_UTF8
long add_unicode_digit(int kbinput, long factor, long *uni);
long get_unicode_kbinput(WINDOW *win, int kbinput);
#endif
int get_control_kbinput(int kbinput);
void unparse_kbinput(char *output, size_t output_len);
int *get_verbatim_kbinput(WINDOW *win, size_t *kbinput_len);
int *parse_verbatim_kbinput(WINDOW *win, size_t *count);
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
int get_mouseinput(int *mouse_x, int *mouse_y, bool allow_shortcuts);
#endif
const sc *get_shortcut(int *kbinput);
void blank_row(WINDOW *win, int y, int x, int n);
void blank_titlebar(void);
void blank_edit(void);
void blank_statusbar(void);
void blank_bottombars(void);
void check_statusblank(void);
char *display_string(const char *buf, size_t start_col, size_t span,
bool dollars);
char *display_string(const char *buf, size_t column, size_t span, bool isdata);
void titlebar(const char *path);
extern void set_modified(void);
void statusbar(const char *msg);
@@ -702,7 +649,7 @@ void warn_and_shortly_pause(const char *msg);
void statusline(message_type importance, const char *msg, ...);
void bottombars(int menu);
void onekey(const char *keystroke, const char *desc, int length);
void reset_cursor(void);
void place_the_cursor(bool forreal);
void edit_draw(filestruct *fileptr, const char *converted,
int line, size_t from_col);
int update_line(filestruct *fileptr, size_t index);
@@ -714,10 +661,16 @@ int go_back_chunks(int nrows, filestruct **line, size_t *leftedge);
int go_forward_chunks(int nrows, filestruct **line, size_t *leftedge);
bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge);
void edit_scroll(scroll_dir direction, int nrows);
#ifndef NANO_TINY
size_t get_softwrap_breakpoint(const char *text, size_t leftedge,
bool *end_of_line);
size_t get_chunk_and_edge(size_t column, filestruct *line, size_t *leftedge);
size_t chunk_for(size_t column, filestruct *line);
size_t leftedge_for(size_t column, filestruct *line);
size_t number_of_chunks_in(filestruct *line);
void ensure_firstcolumn_is_aligned(void);
bool current_is_above_screen(void);
bool current_is_below_screen(void);
bool current_is_offscreen(void);
#endif
size_t actual_last_column(size_t leftedge, size_t column);
void edit_redraw(filestruct *old_current);
void edit_refresh(void);
void adjust_viewport(update_type location);
@@ -726,32 +679,41 @@ void total_refresh(void);
void display_main_list(void);
void do_cursorpos(bool force);
void do_cursorpos_void(void);
void spotlight(bool active, const char *word);
void spotlight(bool active, size_t from_col, size_t to_col);
#ifndef NANO_TINY
void spotlight_softwrapped(bool active, size_t from_col, size_t to_col);
#endif
void xon_complaint(void);
void xoff_complaint(void);
void do_suspend_void(void);
void enable_nodelay(void);
void disable_nodelay(void);
void disable_waiting(void);
void enable_waiting(void);
#ifndef DISABLE_EXTRA
void do_credits(void);
#endif
/* May as well throw these here, since they are just placeholders. */
/* These are just name definitions. */
void do_cancel(void);
void case_sens_void(void);
void regexp_void(void);
void backwards_void(void);
void flip_replace(void);
void gototext_void(void);
#ifdef ENABLE_BROWSER
void to_files_void(void);
void goto_dir_void(void);
#endif
#ifndef NANO_TINY
void dos_format_void(void);
void mac_format_void(void);
void append_void(void);
void prepend_void(void);
void backup_file_void(void);
void flip_execute(void);
#endif
#ifdef ENABLE_MULTIBUFFER
void flip_newbuffer(void);
#endif
void discard_buffer(void);
void new_buffer_void(void);
void backwards_void(void);
void goto_dir_void(void);
void flip_replace_void(void);
void flip_execute_void(void);
#endif /* !PROTO_H */

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* rcfile.c -- This file is part of GNU nano. *
* *
* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, *
* 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 2001-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2014 Mike Frysinger *
* Copyright (C) 2014, 2015, 2016 Benno Schulenberg *
* *
@@ -31,7 +30,7 @@
#include <unistd.h>
#include <ctype.h>
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
#ifndef RCFILE_NAME
#define RCFILE_NAME ".nanorc"
@@ -45,8 +44,8 @@ static const rcoption rcopts[] = {
#ifndef DISABLE_JUSTIFY
{"brackets", 0},
#endif
{"const", CONST_UPDATE}, /* deprecated form, remove in 2018 */
{"constantshow", CONST_UPDATE},
{"const", CONSTANT_SHOW}, /* deprecated form, remove in 2018 */
{"constantshow", CONSTANT_SHOW},
#ifndef DISABLE_WRAPJUSTIFY
{"fill", 0},
#endif
@@ -54,10 +53,10 @@ static const rcoption rcopts[] = {
{"historylog", HISTORYLOG},
#endif
{"morespace", MORE_SPACE},
#ifndef DISABLE_MOUSE
#ifdef ENABLE_MOUSE
{"mouse", USE_MOUSE},
#endif
#ifndef DISABLE_MULTIBUFFER
#ifdef ENABLE_MULTIBUFFER
{"multibuffer", MULTIBUFFER},
#endif
{"nohelp", NO_HELP},
@@ -78,6 +77,7 @@ static const rcoption rcopts[] = {
{"punct", 0},
{"quotestr", 0},
#endif
{"quickblank", QUICK_BLANK},
{"rebinddelete", REBIND_DELETE},
{"rebindkeypad", REBIND_KEYPAD},
{"regexp", USE_REGEXP},
@@ -90,17 +90,18 @@ static const rcoption rcopts[] = {
{"view", VIEW_MODE},
#ifndef NANO_TINY
{"allow_insecure_backup", INSECURE_BACKUP},
{"atblanks", AT_BLANKS},
{"autoindent", AUTOINDENT},
{"backup", BACKUP_FILE},
{"backupdir", 0},
{"backwards", BACKWARDS_SEARCH},
{"casesensitive", CASE_SENSITIVE},
{"cut", CUT_TO_END},
{"cut", CUT_FROM_CURSOR}, /* deprecated form, remove in 2020 */
{"cutfromcursor", CUT_FROM_CURSOR},
{"justifytrim", JUSTIFY_TRIM},
{"locking", LOCKING},
{"matchbrackets", 0},
{"noconvert", NO_CONVERT},
{"quickblank", QUICK_BLANK},
{"quiet", QUIET},
{"showcursor", SHOW_CURSOR},
{"smarthome", SMART_HOME},
@@ -160,9 +161,9 @@ void rcfile_error(const char *msg, ...)
fprintf(stderr, "\n");
}
#endif /* !DISABLE_NANORC */
#endif /* ENABLE_NANORC */
#if !defined(DISABLE_NANORC) || !defined(DISABLE_HISTORIES)
#if defined(ENABLE_NANORC) || !defined(DISABLE_HISTORIES)
/* Parse the next word from the string, null-terminate it, and return
* a pointer to the first character after the null terminator. The
* returned pointer will point to '\0' if we hit the end of the line. */
@@ -182,9 +183,9 @@ char *parse_next_word(char *ptr)
return ptr;
}
#endif /* !DISABLE_NANORC || !DISABLE_HISTORIES */
#endif /* ENABLE_NANORC || !DISABLE_HISTORIES */
#ifndef DISABLE_NANORC
#ifdef ENABLE_NANORC
/* Parse an argument, with optional quotes, after a keyword that takes
* one. If the next word starts with a ", we say that it ends with the
* last " of the line. Otherwise, we interpret it as usual, so that the
@@ -316,7 +317,9 @@ void parse_syntax(char *ptr)
live_syntax->magics = NULL;
live_syntax->linter = NULL;
live_syntax->formatter = NULL;
live_syntax->comment = NULL;
#ifdef ENABLE_COMMENT
live_syntax->comment = mallocstrcpy(NULL, GENERAL_COMMENT_CHARACTER);
#endif
live_syntax->color = NULL;
lastcolor = NULL;
live_syntax->nmultis = 0;
@@ -347,11 +350,13 @@ void parse_syntax(char *ptr)
/* Check whether the given executable function is "universal" (meaning
* any horizontal movement or deletion) and thus is present in almost
* all menus. */
bool is_universal(void (*func))
bool is_universal(void (*func)(void))
{
if (func == do_left || func == do_right ||
func == do_home_void || func == do_end_void ||
#ifndef NANO_TINY
func == do_prev_word_void || func == do_next_word_void ||
#endif
func == do_verbatim_input || func == do_cut_text_void ||
func == do_delete || func == do_backspace ||
func == do_tab || func == do_enter)
@@ -608,8 +613,6 @@ void parse_includes(char *ptr)
* and set bright to TRUE if that color is bright. */
short color_to_short(const char *colorname, bool *bright)
{
assert(colorname != NULL && bright != NULL);
if (strncasecmp(colorname, "bright", 6) == 0) {
*bright = TRUE;
colorname += 6;
@@ -649,8 +652,6 @@ void parse_colors(char *ptr, int rex_flags)
bool bright = FALSE;
char *item;
assert(ptr != NULL);
if (!opensyntax) {
rcfile_error(
N_("A '%s' command requires a preceding 'syntax' command"),
@@ -724,9 +725,6 @@ void parse_colors(char *ptr, int rex_flags)
newcolor->next = NULL;
#ifdef DEBUG
fprintf(stderr, "Adding an entry for fg %hd, bg %hd\n", fg, bg);
#endif
if (lastcolor == NULL)
live_syntax->color = newcolor;
else
@@ -777,33 +775,22 @@ void parse_colors(char *ptr, int rex_flags)
/* Parse the color name, or pair of color names, in combostr. */
bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright)
{
bool no_fgcolor = FALSE;
char *comma = strchr(combostr, ',');
if (combostr == NULL)
return FALSE;
if (strchr(combostr, ',') != NULL) {
char *bgcolorname;
strtok(combostr, ",");
bgcolorname = strtok(NULL, ",");
if (bgcolorname == NULL) {
/* If we have a background color without a foreground color,
* parse it properly. */
bgcolorname = combostr + 1;
no_fgcolor = TRUE;
}
if (strncasecmp(bgcolorname, "bright", 6) == 0) {
rcfile_error(N_("Background color \"%s\" cannot be bright"), bgcolorname);
if (comma != NULL) {
*bg = color_to_short(comma + 1, bright);
if (*bright) {
rcfile_error(N_("A background color cannot be bright"));
return FALSE;
}
*bg = color_to_short(bgcolorname, bright);
*comma = '\0';
} else
*bg = -1;
if (!no_fgcolor) {
if (comma != combostr) {
*fg = color_to_short(combostr, bright);
/* Don't try to parse screwed-up foreground colors. */
/* If the specified foreground color is bad, ignore the regexes. */
if (*fg == -1)
return FALSE;
} else
@@ -876,7 +863,7 @@ void grab_and_store(const char *kind, char *ptr, regexlisttype **storage)
}
}
/* Parse and store the name given after a linter/formatter command. */
/* Gather and store the string after a comment/linter/formatter command. */
void pick_up_name(const char *kind, char *ptr, char **storage)
{
assert(ptr != NULL);
@@ -888,35 +875,27 @@ void pick_up_name(const char *kind, char *ptr, char **storage)
}
if (*ptr == '\0') {
rcfile_error(N_("Missing command after '%s'"), kind);
rcfile_error(N_("Missing argument after '%s'"), kind);
return;
}
free(*storage);
/* If the argument starts with a quote, find the terminating quote. */
if (*ptr == '"') {
char *look = ++ptr;
/* Allow unsetting the command by using an empty string. */
if (!strcmp(ptr, "\"\""))
*storage = NULL;
else if (*ptr == '"') {
*storage = mallocstrcpy(NULL, ++ptr);
char* q = *storage;
char* p = *storage;
/* Snip out the backslashes of escaped characters. */
while (*p != '"') {
if (*p == '\0') {
look += strlen(ptr);
while (*look != '"') {
if (--look < ptr) {
rcfile_error(N_("Argument of '%s' lacks closing \""), kind);
free(*storage);
*storage = NULL;
return;
} else if (*p == '\\' && *(p + 1) != '\0') {
p++;
}
*q++ = *p++;
}
*q = '\0';
*look = '\0';
}
else
*storage = mallocstrcpy(NULL, ptr);
*storage = mallocstrcpy(*storage, ptr);
}
#endif /* !DISABLE_COLOR */
@@ -1301,4 +1280,4 @@ void do_rcfiles(void)
}
}
#endif /* !DISABLE_NANORC */
#endif /* ENABLE_NANORC */

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* search.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2015, 2016, 2017 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -144,7 +143,8 @@ int search_init(bool replacing, bool use_answer)
/* This is now one simple call. It just does a lot. */
i = do_prompt(FALSE, FALSE,
replacing ? MREPLACE : MWHEREIS, backupstring,
inhelp ? MFINDINHELP : (replacing ? MREPLACE : MWHEREIS),
backupstring,
#ifndef DISABLE_HISTORIES
&search_history,
#endif
@@ -202,7 +202,7 @@ int search_init(bool replacing, bool use_answer)
TOGGLE(USE_REGEXP);
backupstring = mallocstrcpy(backupstring, answer);
return 1;
} else if (func == do_replace || func == flip_replace_void) {
} else if (func == flip_replace) {
backupstring = mallocstrcpy(backupstring, answer);
return -2; /* Call the opposite search function. */
} else if (func == do_gotolinecolumn_void) {
@@ -234,8 +234,10 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region,
size_t found_x;
/* The x coordinate of a found occurrence. */
time_t lastkbcheck = time(NULL);
/* The time we last looked at the keyboard. */
enable_nodelay();
/* Set non-blocking input so that we can just peek for a Cancel. */
disable_waiting();
if (begin == NULL)
came_full_circle = FALSE;
@@ -252,7 +254,7 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region,
while (input) {
if (func_from_key(&input) == do_cancel) {
statusbar(_("Cancelled"));
disable_nodelay();
enable_waiting();
return -2;
}
input = parse_kbinput(NULL);
@@ -303,7 +305,7 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region,
/* If we're back at the beginning, then there is no needle. */
if (came_full_circle) {
not_found_msg(needle);
disable_nodelay();
enable_waiting();
return 0;
}
@@ -317,7 +319,7 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region,
* but stop when spell-checking or replacing in a region. */
if (line == NULL) {
if (whole_word_only || have_region) {
disable_nodelay();
enable_waiting();
return 0;
}
@@ -343,16 +345,15 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region,
found_x = found - line->data;
enable_waiting();
/* Ensure that the found occurrence is not beyond the starting x. */
if (came_full_circle && ((!ISSET(BACKWARDS_SEARCH) && found_x > begin_x) ||
(ISSET(BACKWARDS_SEARCH) && found_x < begin_x))) {
not_found_msg(needle);
disable_nodelay();
return 0;
}
disable_nodelay();
/* Set the current position to point at what we found. */
openfile->current = line;
openfile->current_x = found_x;
@@ -361,8 +362,11 @@ int findnextstr(const char *needle, bool whole_word_only, bool have_region,
if (match_len != NULL)
*match_len = found_len;
if (feedback > 0)
/* Wipe the "Searching..." message and unset the suppression flag. */
if (feedback > 0) {
blank_statusbar();
suppress_cursorpos = FALSE;
}
return 1;
}
@@ -438,7 +442,6 @@ void go_looking(void)
{
filestruct *was_current = openfile->current;
size_t was_current_x = openfile->current_x;
int didfind;
#ifdef DEBUG
clock_t start = clock();
#endif
@@ -611,10 +614,9 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
numreplaced = 0;
if (!replaceall) {
size_t xpt = xplustabs();
char *exp_word = display_string(openfile->current->data,
xpt, strnlenpt(openfile->current->data,
openfile->current_x + match_len) - xpt, FALSE);
size_t from_col = xplustabs();
size_t to_col = strnlenpt(openfile->current->data,
openfile->current_x + match_len);
/* Refresh the edit window, scrolling it if necessary. */
edit_refresh();
@@ -622,14 +624,12 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
/* Don't show cursor, to not distract from highlighted match. */
curs_set(0);
spotlight(TRUE, exp_word);
spotlight(TRUE, from_col, to_col);
/* TRANSLATORS: This is a prompt. */
i = do_yesno_prompt(TRUE, _("Replace this instance?"));
spotlight(FALSE, exp_word);
free(exp_word);
spotlight(FALSE, from_col, to_col);
if (i == -1) /* The replacing was cancelled. */
break;
@@ -856,10 +856,10 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
return;
}
} else {
if (line < 1)
if (line == 0)
line = openfile->current->lineno;
if (column < 1)
if (column == 0)
column = openfile->placewewant + 1;
}
@@ -884,6 +884,12 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
openfile->current_x = actual_x(openfile->current->data, column - 1);
openfile->placewewant = column - 1;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP) && openfile->placewewant / editwincols >
strlenpt(openfile->current->data) / editwincols)
openfile->placewewant = strlenpt(openfile->current->data);
#endif
/* When the position was manually given, center the target line. */
if (interactive) {
adjust_viewport(CENTERING);
@@ -894,7 +900,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
filestruct *line = openfile->current;
size_t leftedge = (xplustabs() / editwincols) * editwincols;
size_t leftedge = leftedge_for(xplustabs(), openfile->current);
rows_from_tail = (editwinrows / 2) -
go_forward_chunks(editwinrows / 2, &line, &leftedge);
@@ -906,7 +912,7 @@ void do_gotolinecolumn(ssize_t line, ssize_t column, bool use_answer,
/* If the target line is close to the tail of the file, put the last
* line or chunk on the bottom line of the screen; otherwise, just
* center the target line. */
if (rows_from_tail < editwinrows / 2) {
if (rows_from_tail < editwinrows / 2 && ISSET(SMOOTH_SCROLL)) {
openfile->current_y = editwinrows - 1 - rows_from_tail;
adjust_viewport(STATIONARY);
} else
@@ -994,7 +1000,7 @@ void do_find_bracket(void)
* the bracket at the current cursor position. */
int wanted_ch_len;
/* The length of wanted_ch in bytes. */
char *bracket_set;
char bracket_set[MAXCHARLEN * 2 + 1];
/* The pair of characters in ch and wanted_ch. */
size_t i;
/* Generic loop variable. */
@@ -1008,8 +1014,6 @@ void do_find_bracket(void)
/* The initial bracket count. */
bool reverse;
/* The direction we search. */
char *found_ch;
/* The character we find. */
assert(mbstrlen(matchbrackets) % 2 == 0);
@@ -1057,20 +1061,16 @@ void do_find_bracket(void)
wanted_ch_len = parse_mbchar(wanted_ch, NULL, NULL);
/* Fill bracket_set in with the values of ch and wanted_ch. */
bracket_set = charalloc((mb_cur_max() * 2) + 1);
strncpy(bracket_set, ch, ch_len);
strncpy(bracket_set + ch_len, wanted_ch, wanted_ch_len);
bracket_set[ch_len + wanted_ch_len] = '\0';
found_ch = charalloc(mb_cur_max() + 1);
while (TRUE) {
if (find_bracket_match(reverse, bracket_set)) {
/* If we found an identical bracket, increment count. If we
* found a complementary bracket, decrement it. */
parse_mbchar(openfile->current->data + openfile->current_x,
found_ch, NULL);
count += (strncmp(found_ch, ch, ch_len) == 0) ? 1 : -1;
count += (strncmp(openfile->current->data + openfile->current_x,
ch, ch_len) == 0) ? 1 : -1;
/* If count is zero, we've found a matching bracket. Update
* the screen and get out. */
@@ -1088,10 +1088,6 @@ void do_find_bracket(void)
break;
}
}
/* Clean up. */
free(bracket_set);
free(found_ch);
}
#endif /* !NANO_TINY */
@@ -1235,7 +1231,7 @@ void get_history_older_void(void)
;
}
#ifndef DISABLE_TABCOMP
#ifdef ENABLE_TABCOMP
/* Move h to the next string that's a tab completion of the string s,
* looking at only the first len characters of s, and return that
* string. If there isn't one, or if len is 0, don't move h and return
@@ -1288,5 +1284,5 @@ char *get_history_completion(filestruct **h, char *s, size_t len)
* match, or len is 0. Return s. */
return (char *)s;
}
#endif /* !DISABLE_TABCOMP */
#endif /* ENSABLE_TABCOMP */
#endif /* !DISABLE_HISTORIES */

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* text.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2014, 2015 Mark Majeres *
* Copyright (C) 2016 Mike Scalora *
* Copyright (C) 2015, 2016 Benno Schulenberg *
@@ -92,7 +91,7 @@ char *invocation_error(const char *name)
void do_deletion(undo_type action)
{
#ifndef NANO_TINY
size_t orig_rows = 0;
size_t old_amount = 0;
#endif
assert(openfile->current != NULL && openfile->current->data != NULL &&
@@ -113,7 +112,7 @@ void do_deletion(undo_type action)
update_undo(action);
if (ISSET(SOFTWRAP))
orig_rows = strlenpt(openfile->current->data) / editwincols;
old_amount = number_of_chunks_in(openfile->current);
#endif
/* Move the remainder of the line "in", over the current character. */
@@ -182,7 +181,7 @@ void do_deletion(undo_type action)
/* If the number of screen rows that a softwrapped line occupies
* has changed, we need a full refresh. */
if (ISSET(SOFTWRAP) && refresh_needed == FALSE &&
strlenpt(openfile->current->data) / editwincols != orig_rows)
number_of_chunks_in(openfile->current) != old_amount)
refresh_needed = TRUE;
#endif
@@ -278,17 +277,11 @@ void do_tab(void)
}
#ifndef NANO_TINY
/* Indent or unindent the current line (or, if the mark is on, all lines
* covered by the mark) len columns, depending on whether len is
* positive or negative. If the TABS_TO_SPACES flag is set, indent or
* unindent by len spaces. Otherwise, indent or unindent by (len /
* tabsize) tabs and (len % tabsize) spaces. */
void do_indent(ssize_t cols)
/* Indent the current line (or the marked lines) by tabsize columns.
* This inserts either a tab character or a tab's worth of spaces,
* depending on whether --tabstospaces is in effect. */
void do_indent(void)
{
bool indent_changed = FALSE;
/* Whether any indenting or unindenting was done. */
bool unindent = FALSE;
/* Whether we're unindenting text. */
char *line_indent = NULL;
/* The text added to each line in order to indent it. */
size_t line_indent_len = 0;
@@ -299,19 +292,6 @@ void do_indent(ssize_t cols)
assert(openfile->current != NULL && openfile->current->data != NULL);
/* If cols is zero, get out. */
if (cols == 0)
return;
/* If cols is negative, make it positive and set unindent to TRUE. */
if (cols < 0) {
cols = -cols;
unindent = TRUE;
/* Otherwise, we're indenting, in which case the file will always be
* modified, so set indent_changed to TRUE. */
} else
indent_changed = TRUE;
/* If the mark is on, use all lines covered by the mark. */
if (openfile->mark_set)
mark_order((const filestruct **)&top, &top_x,
@@ -322,105 +302,134 @@ void do_indent(ssize_t cols)
bot = top;
}
if (!unindent) {
/* Set up the text we'll be using as indentation. */
line_indent = charalloc(cols + 1);
/* Set up the text we'll be using as indentation. */
line_indent = charalloc(tabsize + 1);
if (ISSET(TABS_TO_SPACES)) {
/* Set the indentation to cols spaces. */
charset(line_indent, ' ', cols);
line_indent_len = cols;
} else {
/* Set the indentation to (cols / tabsize) tabs and (cols %
* tabsize) spaces. */
size_t num_tabs = cols / tabsize;
size_t num_spaces = cols % tabsize;
charset(line_indent, '\t', num_tabs);
charset(line_indent + num_tabs, ' ', num_spaces);
line_indent_len = num_tabs + num_spaces;
}
line_indent[line_indent_len] = '\0';
if (ISSET(TABS_TO_SPACES)) {
/* Set the indentation to tabsize spaces. */
charset(line_indent, ' ', tabsize);
line_indent_len = tabsize;
} else {
/* Set the indentation to a tab. */
line_indent[0] = '\t';
line_indent_len = 1;
}
line_indent[line_indent_len] = '\0';
/* Go through each line of the text. */
for (f = top; f != bot->next; f = f->next) {
size_t line_len = strlen(f->data);
size_t indent_len = indent_length(f->data);
if (!unindent) {
/* If we're indenting, add the characters in line_indent to
* the beginning of the non-whitespace text of this line. */
f->data = charealloc(f->data, line_len + line_indent_len + 1);
charmove(&f->data[indent_len + line_indent_len],
/* Add the characters in line_indent to
* the beginning of the non-whitespace text of this line. */
f->data = charealloc(f->data, line_len + line_indent_len + 1);
charmove(&f->data[indent_len + line_indent_len],
&f->data[indent_len], line_len - indent_len + 1);
strncpy(f->data + indent_len, line_indent, line_indent_len);
openfile->totsize += line_indent_len;
strncpy(f->data + indent_len, line_indent, line_indent_len);
openfile->totsize += line_indent_len;
/* Keep track of the change in the current line. */
if (openfile->mark_set && f == openfile->mark_begin &&
openfile->mark_begin_x >= indent_len)
openfile->mark_begin_x += line_indent_len;
if (f == openfile->current && openfile->current_x >= indent_len) {
openfile->current_x += line_indent_len;
openfile->placewewant = xplustabs();
}
/* If the NO_NEWLINES flag isn't set, and this is the
* magicline, add a new magicline. */
if (!ISSET(NO_NEWLINES) && f == openfile->filebot)
new_magicline();
}
/* Clean up. */
free(line_indent);
/* Throw away the undo stack, to prevent making mistakes when
* the user tries to undo something in the indented text. */
discard_until(NULL, openfile);
/* Mark the file as modified. */
set_modified();
/* Update the screen. */
refresh_needed = TRUE;
}
/* Unindent the current line (or the marked lines) by tabsize columns.
* The removed indent can be a mixture of spaces plus at most one tab. */
void do_unindent(void)
{
bool indent_changed = FALSE;
/* Whether any unindenting was done. */
filestruct *top, *bot, *f;
size_t top_x, bot_x;
assert(openfile->current != NULL && openfile->current->data != NULL);
/* If the mark is on, use all lines covered by the mark. */
if (openfile->mark_set)
mark_order((const filestruct **)&top, &top_x,
(const filestruct **)&bot, &bot_x, NULL);
/* Otherwise, use the current line. */
else {
top = openfile->current;
bot = top;
}
/* Go through each line of the text. */
for (f = top; f != bot->next; f = f->next) {
size_t line_len = strlen(f->data);
size_t indent_len = indent_length(f->data);
size_t indent_col = strnlenpt(f->data, indent_len);
/* The length in columns of the indentation on this line. */
if (tabsize <= indent_col) {
size_t indent_new = actual_x(f->data, indent_col - tabsize);
/* The length of the indentation remaining on
* this line after we unindent. */
size_t indent_shift = indent_len - indent_new;
/* The change in the indentation on this line
* after we unindent. */
/* If there's at least tabsize
* columns' worth of indentation at the beginning of the
* non-whitespace text of this line, remove it. */
charmove(&f->data[indent_new], &f->data[indent_len],
line_len - indent_shift - indent_new + 1);
null_at(&f->data, line_len - indent_shift + 1);
openfile->totsize -= indent_shift;
/* Keep track of the change in the current line. */
if (openfile->mark_set && f == openfile->mark_begin &&
openfile->mark_begin_x >= indent_len)
openfile->mark_begin_x += line_indent_len;
if (f == openfile->current && openfile->current_x >= indent_len)
openfile->current_x += line_indent_len;
/* If the NO_NEWLINES flag isn't set, and this is the
* magicline, add a new magicline. */
if (!ISSET(NO_NEWLINES) && f == openfile->filebot)
new_magicline();
} else {
size_t indent_col = strnlenpt(f->data, indent_len);
/* The length in columns of the indentation on this line. */
if (cols <= indent_col) {
size_t indent_new = actual_x(f->data, indent_col - cols);
/* The length of the indentation remaining on
* this line after we unindent. */
size_t indent_shift = indent_len - indent_new;
/* The change in the indentation on this line
* after we unindent. */
/* If we're unindenting, and there's at least cols
* columns' worth of indentation at the beginning of the
* non-whitespace text of this line, remove it. */
charmove(&f->data[indent_new], &f->data[indent_len],
line_len - indent_shift - indent_new + 1);
null_at(&f->data, line_len - indent_shift + 1);
openfile->totsize -= indent_shift;
/* Keep track of the change in the current line. */
if (openfile->mark_set && f == openfile->mark_begin &&
openfile->mark_begin_x > indent_new) {
if (openfile->mark_begin_x <= indent_len)
openfile->mark_begin_x = indent_new;
else
openfile->mark_begin_x -= indent_shift;
}
if (f == openfile->current &&
openfile->current_x > indent_new) {
if (openfile->current_x <= indent_len)
openfile->current_x = indent_new;
else
openfile->current_x -= indent_shift;
}
/* We've unindented, so the indentation changed. */
indent_changed = TRUE;
if (openfile->mark_begin_x <= indent_len)
openfile->mark_begin_x = indent_new;
else
openfile->mark_begin_x -= indent_shift;
}
if (f == openfile->current &&
openfile->current_x > indent_new) {
if (openfile->current_x <= indent_len)
openfile->current_x = indent_new;
else
openfile->current_x -= indent_shift;
openfile->placewewant = xplustabs();
}
/* We've unindented, so the indentation changed. */
indent_changed = TRUE;
}
}
if (!unindent)
/* Clean up. */
free(line_indent);
if (indent_changed) {
/* Throw away the undo stack, to prevent making mistakes when
* the user tries to undo something in the reindented text. */
* the user tries to undo something in the unindented text. */
discard_until(NULL, openfile);
/* Mark the file as modified. */
@@ -430,20 +439,6 @@ void do_indent(ssize_t cols)
refresh_needed = TRUE;
}
}
/* Indent the current line, or all lines covered by the mark if the mark
* is on, tabsize columns. */
void do_indent_void(void)
{
do_indent(tabsize);
}
/* Unindent the current line, or all lines covered by the mark if the
* mark is on, tabsize columns. */
void do_unindent(void)
{
do_indent(-tabsize);
}
#endif /* !NANO_TINY */
/* Test whether the string is empty or consists of only blanks. */
@@ -457,9 +452,9 @@ bool white_string(const char *s)
#ifdef ENABLE_COMMENT
/* Comment or uncomment the current line or the marked lines. */
void do_comment()
void do_comment(void)
{
const char *comment_seq = "#";
const char *comment_seq = GENERAL_COMMENT_CHARACTER;
undo_type action = UNCOMMENT;
filestruct *top, *bot, *f;
size_t top_x, bot_x;
@@ -468,11 +463,10 @@ void do_comment()
assert(openfile->current != NULL && openfile->current->data != NULL);
#ifndef DISABLE_COLOR
if (openfile->syntax && openfile->syntax->comment)
if (openfile->syntax)
comment_seq = openfile->syntax->comment;
/* Does the syntax not allow comments? */
if (strlen(comment_seq) == 0) {
if (*comment_seq == '\0') {
statusbar(_("Commenting is not supported for this file type"));
return;
}
@@ -654,12 +648,14 @@ void undo_cut(undo *u)
/* Redo a cut, or undo an uncut. */
void redo_cut(undo *u)
{
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
/* If we cut the magicline, we may as well not crash. :/ */
if (!u->cutbuffer)
return;
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
cutbuffer = cutbottom = NULL;
cutbuffer = NULL;
cutbottom = NULL;
goto_line_posx(u->lineno, u->begin);
@@ -679,7 +675,9 @@ void do_undo(void)
{
undo *u = openfile->current_undo;
filestruct *f, *t = NULL;
filestruct *oldcutbuffer, *oldcutbottom;
char *data, *undidmsg = NULL;
size_t from_x, to_x;
if (!u) {
statusbar(_("Nothing in undo buffer!"));
@@ -750,7 +748,7 @@ void do_undo(void)
splice_node(f, t);
goto_line_posx(u->lineno, u->begin);
break;
case CUT_EOF:
case CUT_TO_EOF:
case CUT:
undidmsg = _("text cut");
undo_cut(u);
@@ -768,11 +766,13 @@ void do_undo(void)
break;
}
undidmsg = _("line break");
from_x = (u->begin == 0) ? 0 : u->mark_begin_x;
to_x = (u->begin == 0) ? u->mark_begin_x : u->begin;
f->data = charealloc(f->data, strlen(f->data) +
strlen(&f->next->data[u->mark_begin_x]) + 1);
strcat(f->data, &f->next->data[u->mark_begin_x]);
strlen(&u->strdata[from_x]) + 1);
strcat(f->data, &u->strdata[from_x]);
unlink_node(f->next);
goto_line_posx(u->lineno, u->begin);
goto_line_posx(u->lineno, to_x);
break;
#ifdef ENABLE_COMMENT
case COMMENT:
@@ -786,7 +786,8 @@ void do_undo(void)
#endif
case INSERT:
undidmsg = _("text insert");
filestruct *oldcutbuffer = cutbuffer, *oldcutbottom = cutbottom;
oldcutbuffer = cutbuffer;
oldcutbottom = cutbottom;
cutbuffer = NULL;
cutbottom = NULL;
openfile->mark_begin = fsfromline(u->mark_begin_lineno);
@@ -831,7 +832,7 @@ void do_undo(void)
/* Redo the last thing(s) we undid. */
void do_redo(void)
{
filestruct *f;
filestruct *f, *shoveline;
char *data, *redidmsg = NULL;
undo *u = openfile->undotop;
@@ -882,7 +883,7 @@ void do_redo(void)
break;
case ENTER:
redidmsg = _("line break");
filestruct *shoveline = make_new_node(f);
shoveline = make_new_node(f);
shoveline->data = mallocstrcpy(NULL, u->strdata);
data = mallocstrncpy(NULL, f->data, u->begin + 1);
data[u->begin] = '\0';
@@ -925,7 +926,7 @@ void do_redo(void)
renumber(f);
goto_line_posx(u->mark_begin_lineno, u->mark_begin_x);
break;
case CUT_EOF:
case CUT_TO_EOF:
case CUT:
redidmsg = _("text cut");
redo_cut(u);
@@ -982,11 +983,8 @@ void do_enter(void)
{
filestruct *newnode = make_new_node(openfile->current);
size_t extra = 0;
assert(openfile->current != NULL && openfile->current->data != NULL);
#ifndef NANO_TINY
add_undo(ENTER);
bool allblanks = FALSE;
if (ISSET(AUTOINDENT)) {
extra = indent_length(openfile->current->data);
@@ -995,6 +993,8 @@ void do_enter(void)
* indentation to the current x position. */
if (extra > openfile->current_x)
extra = openfile->current_x;
else if (extra == openfile->current_x)
allblanks = TRUE;
}
#endif
newnode->data = charalloc(strlen(openfile->current->data +
@@ -1005,13 +1005,19 @@ void do_enter(void)
if (ISSET(AUTOINDENT)) {
/* Copy the whitespace from the current line to the new one. */
strncpy(newnode->data, openfile->current->data, extra);
openfile->totsize += extra;
/* If there were only blanks before the cursor, trim them. */
if (allblanks)
openfile->current_x = 0;
else
openfile->totsize += extra;
}
#endif
null_at(&openfile->current->data, openfile->current_x);
#ifndef NANO_TINY
add_undo(ENTER);
/* Adjust the mark if it was on the current line after the cursor. */
if (openfile->mark_set && openfile->current == openfile->mark_begin &&
openfile->current_x < openfile->mark_begin_x) {
@@ -1134,7 +1140,9 @@ bool execute_command(const char *command)
void discard_until(const undo *thisitem, openfilestruct *thefile)
{
undo *dropit = thefile->undotop;
#ifdef ENABLE_COMMENT
undo_group *group;
#endif
while (dropit != NULL && dropit != thisitem) {
thefile->undotop = dropit->next;
@@ -1221,7 +1229,7 @@ void add_undo(undo_type action)
u->xflags = WAS_FINAL_BACKSPACE;
case DEL:
if (openfile->current->data[openfile->current_x] != '\0') {
char *char_buf = charalloc(mb_cur_max() + 1);
char *char_buf = charalloc(MAXCHARLEN + 1);
int char_len = parse_mbchar(&openfile->current->data[u->begin],
char_buf, NULL);
char_buf[char_len] = '\0';
@@ -1253,7 +1261,7 @@ void add_undo(undo_type action)
case REPLACE:
u->strdata = mallocstrcpy(NULL, openfile->current->data);
break;
case CUT_EOF:
case CUT_TO_EOF:
cutbuffer_reset();
break;
case CUT:
@@ -1262,7 +1270,7 @@ void add_undo(undo_type action)
u->mark_begin_lineno = openfile->mark_begin->lineno;
u->mark_begin_x = openfile->mark_begin_x;
u->xflags = MARK_WAS_SET;
} else if (!ISSET(CUT_TO_END)) {
} else if (!ISSET(CUT_FROM_CURSOR)) {
/* The entire line is being cut regardless of the cursor position. */
u->begin = 0;
u->xflags = WAS_WHOLE_LINE;
@@ -1354,7 +1362,7 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
fprintf(stderr, " >> openfile->current->data = \"%s\", current_x = %lu, u->begin = %lu\n",
openfile->current->data, (unsigned long)openfile->current_x, (unsigned long)u->begin);
#endif
char *char_buf = charalloc(mb_cur_max());
char *char_buf = charalloc(MAXCHARLEN);
int char_len = parse_mbchar(&openfile->current->data[u->mark_begin_x], char_buf, NULL);
u->strdata = addstrings(u->strdata, u->strdata ? strlen(u->strdata) : 0, char_buf, char_len);
#ifdef DEBUG
@@ -1366,7 +1374,7 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
}
case BACK:
case DEL: {
char *char_buf = charalloc(mb_cur_max());
char *char_buf = charalloc(MAXCHARLEN);
int char_len = parse_mbchar(&openfile->current->data[openfile->current_x], char_buf, NULL);
if (openfile->current_x == u->begin) {
/* They deleted more: add removed character after earlier stuff. */
@@ -1387,7 +1395,7 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
#endif
break;
}
case CUT_EOF:
case CUT_TO_EOF:
case CUT:
if (!cutbuffer)
break;
@@ -1398,11 +1406,12 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
* bottom-->top, then swap the mark points. */
if ((u->lineno == u->mark_begin_lineno && u->begin < u->mark_begin_x)
|| u->lineno < u->mark_begin_lineno) {
ssize_t line = u->lineno;
size_t x_loc = u->begin;
u->begin = u->mark_begin_x;
u->mark_begin_x = x_loc;
ssize_t line = u->lineno;
u->lineno = u->mark_begin_lineno;
u->mark_begin_lineno = line;
} else
@@ -1414,7 +1423,7 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf
u->cutbottom = u->cutbottom->next;
u->lineno = u->mark_begin_lineno + u->cutbottom->lineno -
u->cutbuffer->lineno;
if (ISSET(CUT_TO_END) || u->type == CUT_EOF) {
if (ISSET(CUT_FROM_CURSOR) || u->type == CUT_TO_EOF) {
u->begin = strlen(u->cutbottom->data);
if (u->lineno == u->mark_begin_lineno)
u->begin += u->mark_begin_x;
@@ -1479,6 +1488,9 @@ bool do_wrap(filestruct *line)
size_t next_line_len = 0;
/* The length of next_line. */
size_t old_x = openfile->current_x;
filestruct * old_line = openfile->current;
/* There are three steps. First, we decide where to wrap. Then, we
* create the new wrap line. Finally, we clean up. */
@@ -1521,8 +1533,6 @@ bool do_wrap(filestruct *line)
add_undo(SPLIT_BEGIN);
#endif
size_t old_x = openfile->current_x;
filestruct * oldLine = openfile->current;
openfile->current = line;
/* Step 2, making the new wrap line. It will consist of indentation
@@ -1585,7 +1595,7 @@ bool do_wrap(filestruct *line)
if (old_x < wrap_loc) {
openfile->current_x = old_x;
openfile->current = oldLine;
openfile->current = old_line;
prepend_wrap = TRUE;
} else {
openfile->current_x += (old_x - wrap_loc);
@@ -1602,7 +1612,7 @@ bool do_wrap(filestruct *line)
}
#endif /* !DISABLE_WRAPPING */
#if !defined(DISABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
#if defined(ENABLE_HELP) || !defined(DISABLE_WRAPJUSTIFY)
/* We are trying to break a chunk off line. We find the last blank such
* that the display length to there is at most (goal + 1). If there is
* no such blank, then we find the first blank. We then take the last
@@ -1637,7 +1647,7 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
if (column <= goal)
return index;
#ifndef DISABLE_HELP
#ifdef ENABLE_HELP
/* If we're wrapping a help text and no blank was found, or was
* found only as the first character, force a line break. */
if (snap_at_nl && lastblank < 1)
@@ -1674,7 +1684,7 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
return lastblank;
}
#endif /* !DISABLE_HELP || !DISABLE_WRAPJUSTIFY */
#endif /* ENABLE_HELP || !DISABLE_WRAPJUSTIFY */
#if !defined(NANO_TINY) || !defined(DISABLE_JUSTIFY)
/* The "indentation" of a line is the whitespace between the quote part
@@ -1682,25 +1692,19 @@ ssize_t break_line(const char *line, ssize_t goal, bool snap_at_nl)
size_t indent_length(const char *line)
{
size_t len = 0;
char *blank_mb;
int blank_mb_len;
assert(line != NULL);
blank_mb = charalloc(mb_cur_max());
char onechar[MAXCHARLEN];
int charlen;
while (*line != '\0') {
blank_mb_len = parse_mbchar(line, blank_mb, NULL);
charlen = parse_mbchar(line, onechar, NULL);
if (!is_blank_mbchar(blank_mb))
if (!is_blank_mbchar(onechar))
break;
line += blank_mb_len;
len += blank_mb_len;
line += charlen;
len += charlen;
}
free(blank_mb);
return len;
}
#endif /* !NANO_TINY || !DISABLE_JUSTIFY */
@@ -2009,13 +2013,11 @@ void backup_lines(filestruct *first_line, size_t par_len)
for (i = par_len; i > 0 && bot != openfile->filebot; i--)
bot = bot->next;
/* Move the paragraph from the current buffer's filestruct to the
* justify buffer. */
/* Move the paragraph from the current buffer to the justify buffer. */
extract_buffer(&jusbuffer, &jusbottom, top, 0, bot,
(i == 1 && bot == openfile->filebot) ? strlen(bot->data) : 0);
/* Copy the paragraph back to the current buffer's filestruct from
* the justify buffer. */
/* Copy the paragraph back to the current buffer. */
copy_from_buffer(jusbuffer);
/* Move upward from the last line of the paragraph to the first
@@ -2431,7 +2433,7 @@ void do_justify(bool full_justify)
edit_refresh();
/* Display the shortcut list with UnJustify. */
/* Show "Unjustify" in the help lines. */
uncutfunc->desc = unjust_tag;
display_main_list();
@@ -2441,17 +2443,15 @@ void do_justify(bool full_justify)
do {
#endif
statusbar(_("Can now UnJustify!"));
reset_cursor();
place_the_cursor(TRUE);
curs_set(1);
kbinput = do_input(FALSE);
#ifndef NANO_TINY
} while (kbinput == KEY_WINCH);
#endif
/* If needed, unset the cursor-position suppression flag, so the cursor
* position /will/ be displayed upon a return to the main loop. */
if (ISSET(CONST_UPDATE))
do_cursorpos(FALSE);
/* Unset the suppression flag after showing the Unjustify message. */
suppress_cursorpos = FALSE;
func = func_from_key(&kbinput);
@@ -2509,10 +2509,11 @@ void do_justify(bool full_justify)
jusbuffer = NULL;
blank_statusbar();
wnoutrefresh(bottomwin);
/* Display the shortcut list with UnCut. */
/* Show "Uncut" again in the help lines, and force their redrawing. */
uncutfunc->desc = uncut_tag;
display_main_list();
currmenu = MMOST;
}
/* Justify the current paragraph. */
@@ -2533,7 +2534,7 @@ void do_full_justify(void)
* return FALSE if the user cancels. */
bool do_int_spell_fix(const char *word)
{
char *save_search, *exp_word;
char *save_search;
size_t firstcolumn_save = openfile->firstcolumn;
size_t current_x_save = openfile->current_x;
filestruct *edittop_save = openfile->edittop;
@@ -2598,11 +2599,12 @@ bool do_int_spell_fix(const char *word)
proceed = TRUE;
napms(2800);
} else if (result == 1) {
exp_word = display_string(openfile->current->data, xplustabs(),
strlenpt(word), FALSE);
size_t from_col = xplustabs();
size_t to_col = from_col + strlenpt(word);
edit_refresh();
spotlight(TRUE, exp_word);
spotlight(TRUE, from_col, to_col);
/* Let the user supply a correctly spelled alternative. */
proceed = (do_prompt(FALSE, FALSE, MSPELL, word,
@@ -2611,9 +2613,7 @@ bool do_int_spell_fix(const char *word)
#endif
edit_refresh, _("Edit a replacement")) != -1);
spotlight(FALSE, exp_word);
free(exp_word);
spotlight(FALSE, from_col, to_col);
/* If a replacement was given, go through all occurrences. */
if (proceed && strcmp(word, answer) != 0) {
@@ -3265,30 +3265,55 @@ void do_linter(void)
SET(MULTIBUFFER);
open_buffer(curlint->filename, FALSE);
} else {
char *dontwantfile = curlint->filename;
char *dontwantfile = mallocstrcpy(NULL, curlint->filename);
lintstruct *restlint = NULL;
while (curlint != NULL && !strcmp(curlint->filename, dontwantfile))
curlint = curlint->next;
if (curlint == NULL) {
while (curlint != NULL) {
if (strcmp(curlint->filename, dontwantfile) == 0) {
if (curlint == lints)
lints = curlint->next;
else
curlint->prev->next = curlint->next;
if (curlint->next != NULL)
curlint->next->prev = curlint->prev;
tmplint = curlint;
curlint = curlint->next;
free(tmplint->msg);
free(tmplint->filename);
free(tmplint);
} else {
if (restlint == NULL)
restlint = curlint;
curlint = curlint->next;
}
}
if (restlint == NULL) {
statusbar(_("No more errors in unopened files, cancelling"));
napms(2400);
break;
} else
} else {
curlint = restlint;
goto new_lint_loop;
}
free(dontwantfile);
}
} else
openfile = tmpof;
}
}
#endif /* !NANO_TINY */
do_gotolinecolumn(curlint->lineno, curlint->colno, FALSE, FALSE);
goto_line_posx(curlint->lineno, curlint->colno - 1);
titlebar(NULL);
adjust_viewport(CENTERING);
edit_refresh();
statusbar(curlint->msg);
bottombars(MLINTER);
}
/* Place and show the cursor to indicate the affected line. */
reset_cursor();
place_the_cursor(TRUE);
wnoutrefresh(edit);
curs_set(1);
@@ -3320,6 +3345,7 @@ void do_linter(void)
}
blank_statusbar();
wnoutrefresh(bottomwin);
#ifndef NANO_TINY
free_lints_and_return:
@@ -3363,8 +3389,10 @@ void do_formatter(void)
return;
}
#ifndef NANO_TINY
/* We're not supporting partial formatting, oi vey. */
openfile->mark_set = FALSE;
#endif
status = write_file(temp, temp_file, TRUE, OVERWRITE, FALSE);
if (!status) {
@@ -3430,10 +3458,11 @@ void do_formatter(void)
set_modified();
#ifndef NANO_TINY
/* Flush the undo stack, to avoid a mess or crash when
* the user tries to undo things in reformatted lines. */
discard_until(NULL, openfile);
#endif
finalstatus = _("Finished formatting");
}
@@ -3471,7 +3500,7 @@ void do_wordlinechar_count(void)
filestruct *top, *bot;
size_t top_x, bot_x;
/* If the mark is on, partition the filestruct so that it
/* If the mark is on, partition the buffer so that it
* contains only the marked text, and turn the mark off. */
if (old_mark_set) {
mark_order((const filestruct **)&top, &top_x,
@@ -3501,7 +3530,7 @@ void do_wordlinechar_count(void)
nlines = openfile->filebot->lineno - openfile->fileage->lineno + 1;
chars = get_totsize(openfile->fileage, openfile->filebot);
/* Unpartition the filestruct so that it contains all the text
/* Unpartition the buffer so that it contains all the text
* again, and turn the mark back on. */
unpartition_filestruct(&filepart);
openfile->mark_set = TRUE;
@@ -3532,15 +3561,15 @@ void do_verbatim_input(void)
/* TRANSLATORS: This is displayed when the next keystroke will be
* inserted verbatim. */
statusbar(_("Verbatim Input"));
reset_cursor();
place_the_cursor(TRUE);
curs_set(1);
/* Read in all the verbatim characters. */
kbinput = get_verbatim_kbinput(edit, &kbinput_len);
/* Unsuppress cursor-position display or blank the statusbar. */
if (ISSET(CONST_UPDATE))
do_cursorpos(FALSE);
if (ISSET(CONSTANT_SHOW))
suppress_cursorpos = FALSE;
else {
blank_statusbar();
wnoutrefresh(bottomwin);

View File

@@ -1,8 +1,7 @@
/**************************************************************************
* utils.c -- This file is part of GNU nano. *
* *
* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
* 2008, 2009, 2010, 2011, 2013, 2014 Free Software Foundation, Inc. *
* Copyright (C) 1999-2011, 2013-2017 Free Software Foundation, Inc. *
* Copyright (C) 2016 Benno Schulenberg *
* *
* GNU nano is free software: you can redistribute it and/or modify *
@@ -61,30 +60,29 @@ void get_homedir(void)
int digits(ssize_t n)
{
if (n < 100000) {
if (n < 1000) {
if (n < 100)
return 2;
else
return 3;
} else {
if (n < 10000)
return 4;
else
return 5;
}
if (n < 1000) {
if (n < 100)
return 2;
else
return 3;
} else {
if (n < 10000)
return 4;
else
return 5;
}
} else {
if (n < 10000000) {
if (n < 1000000)
return 6;
else
return 7;
}
else {
if (n < 100000000)
return 8;
else
return 9;
}
if (n < 10000000) {
if (n < 1000000)
return 6;
else
return 7;
} else {
if (n < 100000000)
return 8;
else
return 9;
}
}
}
#endif
@@ -118,7 +116,7 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
const char *comma;
while (*str == ' ')
str++;
str++;
comma = strpbrk(str, "m,. /;");
@@ -215,7 +213,7 @@ const char *fixbounds(const char *r)
* a separate word? That is: is it not part of a longer word?*/
bool is_separate_word(size_t position, size_t length, const char *buf)
{
char before[mb_cur_max()], after[mb_cur_max()];
char before[MAXCHARLEN], after[MAXCHARLEN];
size_t word_end = position + length;
/* Get the characters before and after the word, if any. */
@@ -238,6 +236,13 @@ bool is_separate_word(size_t position, size_t length, const char *buf)
const char *strstrwrapper(const char *haystack, const char *needle,
const char *start)
{
if (*needle == '\0') {
#ifndef NANO_TINY
statusline(ALERT, "Searching for nothing -- please report a bug");
#endif
return (char *)start;
}
if (ISSET(USE_REGEXP)) {
if (ISSET(BACKWARDS_SEARCH)) {
size_t last_find, ceiling, far_end;
@@ -276,7 +281,7 @@ const char *strstrwrapper(const char *haystack, const char *needle,
regmatches[0].rm_eo = far_end;
if (regexec(&search_regexp, haystack, 10, regmatches,
REG_STARTEND) != 0)
statusline(ALERT, "BAD: failed to refind the match!");
return NULL;
return haystack + regmatches[0].rm_so;
}
@@ -393,10 +398,10 @@ size_t xplustabs(void)
* not overshoot the given column. */
size_t actual_x(const char *text, size_t column)
{
size_t index = 0;
/* The index in text, returned. */
const char *start = text;
/* From where we start walking through the text. */
size_t width = 0;
/* The screen display width to text[index], in columns. */
/* The current accumulated span, in columns. */
while (*text != '\0') {
int charlen = parse_mbchar(text, NULL, &width);
@@ -404,11 +409,10 @@ size_t actual_x(const char *text, size_t column)
if (width > column)
break;
index += charlen;
text += charlen;
}
return index;
return (text - start);
}
/* A strnlen() with tabs and multicolumn characters factored in:
@@ -454,7 +458,7 @@ void new_magicline(void)
openfile->totsize++;
}
#ifndef NANO_TINY
#if !defined(NANO_TINY) || defined(ENABLE_HELP)
/* Remove the magicline from filebot, if there is one and it isn't the
* only line in the file. Assume that edittop and current are not at
* filebot. */
@@ -468,7 +472,9 @@ void remove_magicline(void)
openfile->totsize--;
}
}
#endif
#ifndef NANO_TINY
/* Set top_x and bot_x to the top and bottom x-coordinates of the mark,
* respectively, based on the locations of top and bot. If
* right_side_up isn't NULL, set it to TRUE if the mark begins with
@@ -537,7 +543,7 @@ size_t get_totsize(const filestruct *begin, const filestruct *end)
}
#ifdef DEBUG
/* Dump the filestruct inptr to stderr. */
/* Dump the given buffer to stderr. */
void dump_filestruct(const filestruct *inptr)
{
if (inptr == openfile->fileage)
@@ -553,7 +559,7 @@ void dump_filestruct(const filestruct *inptr)
}
}
/* Dump the current buffer's filestruct to stderr in reverse. */
/* Dump the current buffer to stderr in reverse. */
void dump_filestruct_reverse(void)
{
const filestruct *fileptr = openfile->filebot;

File diff suppressed because it is too large Load Diff

View File

@@ -22,6 +22,7 @@ pkgdata_DATA = asm.nanorc \
man.nanorc \
mgp.nanorc \
mutt.nanorc \
nanohelp.nanorc \
nanorc.nanorc \
nftables.nanorc \
objc.nanorc \

View File

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

View File

@@ -1,19 +1,20 @@
## Here is an example for Gentoo ebuilds/eclasses.
## Here is an example for Gentoo ebuilds/eclasses,
## and (further down) one for Portage control files.
syntax "ebuild" "\.e(build|class|blit)$"
comment "#"
## All the standard portage functions
## All the standard portage functions:
color brightgreen "(^|\<default_)src_(unpack|prepare|configure|compile|install|test)\>"
color brightgreen "^pkg_(config|nofetch|info|pretend|setup|(pre|post)(inst|rm))\>"
color brightgreen "\<default(_pkg_nofetch|_src_(unpack|prepare|configure|compile|test))?\>"
## Highlight bash related syntax
## Bash-related syntax:
color green "\<(break|case|continue|do|done|elif|else|esac|exit|fi|for|function|if|in|read|return|select|shift|then|time|until|while)\>"
color green "\<(declare|eval|exec|export|let|local)\>"
color green "[{}():;|`$<>!=&\\]" "(\]|\[)"
color green "-[defhnrsuwxzL]\>"
color green "-(eq|ne|gt|lt|ge|le)\>"
## Highlight variables ... official portage ones in red, all others in bright red
## Variables... official portage ones in red, all others in bright red:
color brightred "\$[-0-9@*#?$!]" "\$[[:alpha:]_][[:alnum:]_]*"
color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:digit:]]|@)+\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
color red "\<(EAPI|ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|[HPR]?DEPEND|PROVIDE|PROPERTIES|REQUIRED_USE|RESTRICT|USERLAND)\>"
@@ -22,7 +23,7 @@ color red "\<(AS|C(PP|XX)?|LD)FLAGS\>" "\<C(HOST|TARGET|BUILD)\>" "\<(MERGE_TYPE
color red "\<EBUILD_PHASE(_FUNC)?\>"
color red "\<QA_((TEXTRELS|EXECSTACK|WX_LOAD)(_[a-zA-Z_0-9]+)?|DT_HASH|PRESTRIPPED)\>"
color red "\<(PATCHES|(HTML_)?DOCS)\>" "\<WANT_(AUTO(CONF|MAKE)|LIBTOOL)\>" "\<AT_M4DIR\>"
## Highlight portage commands
## Portage commands:
color magenta "\<(use(_(with|enable|if_iuse)|x)?|in_iuse)\> [!a-zA-Z0-9_+ -]*" "inherit.*"
color brightblue "\<e(begin|end|conf|install|make|qmake4|ant|(qa)?warn|infon?|error|log|patch(_user)?|new(group|user))\>"
color brightblue "\<e(pause|beep|mktemp|(cvs|svn)_clean|punt_cxx)\>" "\<e(aclocal|auto(reconf|header|conf|make)|libtoolize)\>"
@@ -35,20 +36,21 @@ color brightblue "\<prepall(docs|info|man|strip)?\>" "\<prep(info|lib|lib\.(so|a
color brightblue "\<(doc|ins|exe)?into\>" "\<(f|games)(owners|perms)\>" "\<(exe|ins|dir)opts\>"
color brightblue "\<tc-get(BUILD_)?(AR|AS|CC|CPP|CXX|LD|NM|OBJCOPY|PKG_CONFIG|RANLIB)\>"
color brightblue "\<tc-(arch(-kernel)?|export|has-(tls|openmp))\>"
## Highlight common commands used in ebuilds
## Common commands used in ebuilds:
color blue "\<(awk|cat|cd|chmod|chown|cp|echo|env|find|e?grep|ln|make|mkdir|mv|popd|printf|pushd|rm|rmdir|sed|set|tar|touch|unset|xargs)\>"
## Highlight comments (doesnt work that well)
## Comments (doesn't work that well):
color yellow "(^|[[:space:]])#.*$"
## Highlight strings (doesnt work that well)
## Strings (doesn't work that well):
color brightyellow ""(\\.|[^\"])*"" "'(\\.|[^'])*'"
## Trailing space is bad!
color ,green "[[:space:]]+$"
## Mixed whitespace is also bad.
color ,green " "
## Here is an example for Portage control files.
##
syntax "/etc/portage" "\.(accept_keywords|env|keywords|mask|unmask|use)(/.+)?$"
comment "#"
## Base text:
color green "^.+$"
## Likely version and slot numbers:

View File

@@ -7,7 +7,7 @@ color red "[:=]"
color magenta "\<(if|ifeq|else|endif)\>"
color blue "\$+[{(][a-zA-Z0-9_-]+[})]"
color brightblue "^[^ ]+:"
color green "#.*$"
color green "(^|[[:space:]]+)#.*"
## Trailing whitespace.
color ,green "[[:space:]]+$"

12
syntax/nanohelp.nanorc Normal file
View File

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

View File

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

View File

@@ -1,32 +1,35 @@
## Here is an example for PHP.
syntax "php" "\.php[2345s~]?$"
syntax "php" "\.ph(p[23457s~]?|tml)$"
magic "PHP script text"
comment "//"
# PHP markings.
color brightgreen "(<\?(php)?|\?>)"
# Functions.
# Function names.
color white "\<[a-z_]*\("
# Variable names.
color cyan "\$[a-z_]+"
# Types.
color green "\<(var|float|global|double|bool|char|int|enum|const)\>"
color green "\<(array|bool|callable|const|float|global|int|object|string|var)\>"
# Structure.
color brightyellow "\<(class|new|private|public|function|for|foreach|if|while|do|else|elseif|case|default|switch)\>"
# Directives and structure.
color brightyellow "\<(abstract|as|class|clone|(end)?declare|extends|function|implements|include(_once)?|inst(ance|ead)of|interface|namespace|new|private|protected|public|require(_once)?|static|trait|use|yield)\>"
color brightyellow "\<(case|catch|default|do|echo|else(if)?|end(for(each)?|if|switch|while)|final(ly)?|for(each)?|if|print|switch|throw|try|while)\>"
# Operators.
color brightyellow "\<(and|or|xor)\>"
# Control flow.
color magenta "\<(goto|continue|break|return)\>"
color magenta "\<(break|continue|goto|return)\>"
# Strings.
color brightyellow "<[^= ]*>" ""(\.|[^"])*""
color brightyellow ""(\.|[^"])*"" "'(\.|[^'])*'"
# Comments.
color brightblue "//.*"
color brightblue "(^|[[:space:]]+)//.*"
color brightblue start="/\*" end="\*/"
##color blue start="<" end=">"
##color red "&[^;[:space:]]*;"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -7,9 +7,9 @@ comment "@c "
# Command arguments, trailing and enclosed.
color cyan "^@[a-z]+[[:space:]]+.*$"
color brightmagenta "@[a-z]+\{[^}]*\}"
color brightmagenta "@[a-zA-Z]+\{[^}]*\}"
# Commands themselves.
color yellow "@[a-z]+\{?" "\}"
color yellow "@[a-zA-Z]+\{?" "\}"
# Menu items.
color brightred "^\*[[:space:]]+.*::.*$"

View File

@@ -1,6 +1,7 @@
## Here is an example for XML files.
syntax "xml" "\.([jrsx]html?|jnlp|mml|pom|rng|sgml?|svg|w[as]dl|wsdd|xjb|xml|xs(d|lt?)|xul)$"
header "<\?xml.*version=.*\?>"
magic "(XML|SGML) (sub)?document text"
comment "<!--|-->"