Compare commits

...

88 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
63 changed files with 12261 additions and 11727 deletions

View File

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

View File

@@ -2,10 +2,11 @@ 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.
- 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.

20
NEWS
View File

@@ -1,3 +1,13 @@
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,
@@ -134,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!
@@ -581,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
@@ -746,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
@@ -1274,12 +1284,12 @@
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
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 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

View File

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

View File

@@ -16,7 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
AC_INIT([GNU nano], [2.8.5], [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])

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

@@ -83,7 +83,7 @@
<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.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.5</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<blockquote><p>The current version of nano <i>should</i> be <b>2.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%">

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 2.8.5" "June 2017"
.TH NANO 1 "version 2.8.6" "July 2017"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
@@ -36,8 +36,8 @@ 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
@@ -145,7 +145,8 @@ Set the size (width) of a tab to \fInumber\fP columns. The value of
.TP
.BR \-U ", " \-\-quickblank
Do quick status-bar blanking: status-bar messages will disappear after 1
keystroke instead of 25. Note that \fB\-c\fP overrides this.
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.
@@ -163,9 +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 on the status bar.
Note that this overrides \fB\-U\fP.
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
@@ -183,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
@@ -221,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.
@@ -239,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.
@@ -255,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

File diff suppressed because it is too large Load Diff

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <http://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 2.8.5" "June 2017"
.TH NANORC 5 "version 2.8.6" "July 2017"
.\" Please adjust this date whenever revising the manpage.
.SH NAME
@@ -57,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
@@ -66,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 +79,9 @@ Do backwards searches by default.
.TP
.B set boldtext
Use bold instead of reverse video for the title bar, status bar, key combos,
line numbers, and selected text. This can be overridden for the first four
by setting the options \fBtitlecolor\fP, \fBstatuscolor\fP, \fBkeycolor\fP,
and \fBnumbercolor\fP.
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
@@ -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.
@@ -184,7 +192,7 @@ specfified closing punctuation, optionally followed by closing brackets
.TP
.B set quickblank
Do quick status-bar blanking: status-bar messages will disappear after 1
keystroke instead of 25.
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
@@ -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 " ""\fIname\fR"" [""\fIfileregex\fR"" ...]"
Defines a syntax named \fIname\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
\fIname\fP syntax until a new \fBsyntax\fR command is encountered.
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
@@ -365,13 +379,13 @@ 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 " name directive " \fR[ "arg " \fR...]
Extend the syntax previously defined as \fIname\fP to include
new information. This allows adding a new \fBcolor\fP, \fBicolor\fP,
.BI extendsyntax " name command " \fR[ "arg " \fR...]
Extend the syntax previously defined as \fIname\fR with another
\fIcommand\fR. This allows adding a new \fBcolor\fP, \fBicolor\fP,
\fBheader\fP, \fBmagic\fP, \fBcomment\fP, \fBlinter\fP, or \fBformatter\fP
directive to an already defined syntax -- useful when you want to
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:

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.5" "June 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
@@ -49,8 +53,9 @@
# 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
@@ -125,7 +130,7 @@
# set punct "!.?"
## Do quick status-bar blanking. Status-bar messages will disappear after
## 1 keystroke instead of 26. Note that "const" overrides this.
## 1 keystroke instead of 26. Note that "constantshow" overrides this.
# set quickblank
## The email-quote string, used to justify email-quoted paragraphs.

636
po/bg.po

File diff suppressed because it is too large Load Diff

652
po/ca.po

File diff suppressed because it is too large Load Diff

638
po/cs.po

File diff suppressed because it is too large Load Diff

651
po/da.po

File diff suppressed because it is too large Load Diff

784
po/de.po

File diff suppressed because it is too large Load Diff

658
po/eo.po

File diff suppressed because it is too large Load Diff

650
po/es.po

File diff suppressed because it is too large Load Diff

636
po/eu.po

File diff suppressed because it is too large Load Diff

636
po/fi.po

File diff suppressed because it is too large Load Diff

651
po/fr.po

File diff suppressed because it is too large Load Diff

650
po/ga.po

File diff suppressed because it is too large Load Diff

638
po/gl.po

File diff suppressed because it is too large Load Diff

640
po/hr.po

File diff suppressed because it is too large Load Diff

640
po/hu.po

File diff suppressed because it is too large Load Diff

635
po/id.po

File diff suppressed because it is too large Load Diff

698
po/it.po

File diff suppressed because it is too large Load Diff

640
po/ja.po

File diff suppressed because it is too large Load Diff

640
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

640
po/nb.po

File diff suppressed because it is too large Load Diff

651
po/nl.po

File diff suppressed because it is too large Load Diff

635
po/nn.po

File diff suppressed because it is too large Load Diff

638
po/pl.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

640
po/ro.po

File diff suppressed because it is too large Load Diff

640
po/ru.po

File diff suppressed because it is too large Load Diff

636
po/sl.po

File diff suppressed because it is too large Load Diff

640
po/sr.po

File diff suppressed because it is too large Load Diff

638
po/sv.po

File diff suppressed because it is too large Load Diff

655
po/tr.po

File diff suppressed because it is too large Load Diff

649
po/uk.po

File diff suppressed because it is too large Load Diff

649
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

@@ -37,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 $(LIB_CLOCK_GETTIME)
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

@@ -24,7 +24,6 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <time.h>
#include <unistd.h>
#ifdef HAVE_MAGIC_H
@@ -54,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)
@@ -63,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

View File

@@ -155,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
@@ -248,9 +248,9 @@ 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 */
@@ -270,7 +270,7 @@ 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 buffer

View File

@@ -21,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>
@@ -430,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;
@@ -527,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);
@@ -605,8 +601,6 @@ void prepare_for_display(void)
* 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 && !inhelp) {
statusbar(_("No more open file buffers"));
@@ -631,9 +625,14 @@ void switch_to_prevnext_buffer(bool to_next)
/* 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. */
if (!inhelp)
statusline(HUSH, _("Switched to %s"),
statusline(HUSH, _("Switched to %s"),
((openfile->filename[0] == '\0') ?
_("New Buffer") : openfile->filename));
@@ -659,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;
@@ -677,7 +674,7 @@ 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;
@@ -700,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);
@@ -777,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. */
@@ -931,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
@@ -953,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);
@@ -1018,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
@@ -1386,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. */
@@ -1428,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;
@@ -1461,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
@@ -1987,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
@@ -1997,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) {
@@ -2284,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;
@@ -2455,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

View File

@@ -227,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;
@@ -667,7 +667,7 @@ void shortcut_init(void)
add_to_funcs(do_cancel, ((MMOST & ~MMAIN & ~MBROWSER) | MYESNO),
N_("Cancel"), IFSCHELP(nano_cancel_msg), BLANKAFTER, VIEW);
add_to_funcs(do_exit, MMAIN|MHELP,
add_to_funcs(do_exit, MMAIN,
exit_tag, IFSCHELP(nano_exit_msg), TOGETHER, VIEW);
/* Remember the entry for Exit, to be able to replace it with Close. */
exitfunc = tailfunc;
@@ -721,6 +721,7 @@ void shortcut_init(void)
/* The description ("x") and blank_after (0) are irrelevant,
* because the help viewer does not have a help text. */
add_to_funcs(total_refresh, MHELP, refresh_tag, "x", 0, VIEW);
add_to_funcs(do_exit, MHELP, close_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);
@@ -929,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);
@@ -1105,7 +1106,7 @@ void shortcut_init(void)
add_to_sclist(MMAIN, "F15", 0, do_mark, 0);
add_to_sclist(MMAIN, "M-6", 0, do_copy_text, 0);
add_to_sclist(MMAIN, "M-^", 0, do_copy_text, 0);
add_to_sclist(MMAIN, "M-}", 0, do_indent_void, 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);
@@ -1203,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
@@ -1375,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");
@@ -1488,7 +1489,7 @@ 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"))
@@ -1634,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;

View File

@@ -53,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 (realspan > openfile->placewewant)
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
{
@@ -79,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;
}
@@ -93,7 +90,7 @@ 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));
/* Move the viewport so that the cursor stays immobile, if possible. */
adjust_viewport(STATIONARY);
@@ -111,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;
}
@@ -125,7 +124,7 @@ 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));
/* Move the viewport so that the cursor stays immobile, if possible. */
adjust_viewport(STATIONARY);
@@ -346,15 +345,16 @@ void do_next_word_void(void)
void do_home(bool be_clever)
{
filestruct *was_current = openfile->current;
size_t was_column = openfile->placewewant;
size_t was_column = xplustabs();
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);
@@ -376,11 +376,11 @@ void do_home(bool be_clever)
if (!moved && ISSET(SOFTWRAP)) {
/* If already at the left edge of the screen, move fully home.
* Otherwise, move to the left edge. */
if (was_column % editwincols == 0 && be_clever)
if (openfile->current_x == leftedge_x && be_clever)
openfile->current_x = 0;
else {
openfile->current_x = leftedge_x;
openfile->placewewant = (was_column / editwincols) * editwincols;
openfile->placewewant = leftedge;
moved_off_chunk = FALSE;
}
} else if (!moved)
@@ -411,15 +411,26 @@ void do_home_void(void)
void do_end(bool be_clever)
{
filestruct *was_current = openfile->current;
size_t was_column = openfile->placewewant;
size_t was_column = xplustabs();
size_t line_len = strlen(openfile->current->data);
bool moved_off_chunk = TRUE;
#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. */
@@ -427,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". */
@@ -471,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
@@ -515,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
@@ -562,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)
@@ -582,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;
}
@@ -598,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')
@@ -618,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;
}

View File

@@ -780,7 +780,7 @@ void usage(void)
* It's best to keep its lines within 80 characters. */
printf(_("To place the cursor on a specific line of a file, put the line number with\n"
"a '+' before the filename. The column number can be added after a comma.\n"));
printf(_("When the first filename is '-', nano reads data from standard input.\n\n"));
printf(_("When a filename is '-', nano reads data from standard input.\n\n"));
printf(_("Option\t\tGNU long option\t\tMeaning\n"));
#ifndef NANO_TINY
print_opt("-A", "--smarthome",
@@ -850,6 +850,9 @@ void usage(void)
if (!ISSET(RESTRICTED))
print_opt(_("-Y <name>"), _("--syntax=<name>"),
N_("Syntax definition to use for coloring"));
#endif
#ifndef NANO_TINY
print_opt("-a", "--atblanks", N_("When soft-wrapping, do it at whitespace"));
#endif
print_opt("-c", "--constantshow", N_("Constantly show cursor position"));
print_opt("-d", "--rebinddelete",
@@ -861,7 +864,7 @@ void usage(void)
print_opt("-h", "--help", N_("Show this help text and exit"));
#ifndef NANO_TINY
print_opt("-i", "--autoindent", N_("Automatically indent new lines"));
print_opt("-k", "--cut", N_("Cut from cursor to end of line"));
print_opt("-k", "--cutfromcursor", N_("Cut from cursor to end of line"));
#endif
#ifdef ENABLE_LINENUMBERS
print_opt("-l", "--linenumbers", N_("Show line numbers in front of the text"));
@@ -1285,7 +1288,7 @@ RETSIGTYPE do_continue(int signal)
terminal_init();
#endif
/* Tickle the input routine so it will update the screen. */
ungetch(KEY_F0);
ungetch(KEY_FLUSH);
}
#ifndef NANO_TINY
@@ -1684,7 +1687,7 @@ int do_input(bool allow_funcs)
#ifndef NANO_TINY
if (s->scfunc == do_toggle_void) {
do_toggle(s->toggle);
if (s->toggle != CUT_TO_END)
if (s->toggle != CUT_FROM_CURSOR)
preserve = TRUE;
} else
#endif
@@ -1759,7 +1762,7 @@ int do_mouse(void)
/* Whether the click was on the row where the cursor is. */
if (ISSET(SOFTWRAP))
leftedge = (xplustabs() / editwincols) * editwincols;
leftedge = leftedge_for(xplustabs(), openfile->current);
else
#endif
leftedge = get_page_start(xplustabs());
@@ -1775,7 +1778,7 @@ int do_mouse(void)
go_forward_chunks(row_count, &openfile->current, &leftedge);
openfile->current_x = actual_x(openfile->current->data,
leftedge + mouse_col);
actual_last_column(leftedge, mouse_col));
#ifndef NANO_TINY
/* Clicking where the cursor is toggles the mark, as does clicking
@@ -1805,12 +1808,12 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
size_t current_len = strlen(openfile->current->data);
size_t i = 0;
#ifndef NANO_TINY
size_t orig_rows = 0, original_row = 0;
size_t original_row = 0, old_amount = 0;
if (ISSET(SOFTWRAP)) {
if (openfile->current_y == editwinrows - 1)
original_row = xplustabs() / editwincols;
orig_rows = strlenpt(openfile->current->data) / editwincols;
original_row = chunk_for(xplustabs(), openfile->current);
old_amount = number_of_chunks_in(openfile->current);
}
#endif
@@ -1875,9 +1878,9 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
* of the edit window, and we moved one screen row, we're now below
* the last line of the edit window, so we need a full refresh too. */
if (ISSET(SOFTWRAP) && refresh_needed == FALSE &&
(strlenpt(openfile->current->data) / editwincols != orig_rows ||
(number_of_chunks_in(openfile->current) != old_amount ||
(openfile->current_y == editwinrows - 1 &&
xplustabs() / editwincols != original_row)))
chunk_for(xplustabs(), openfile->current) != original_row)))
refresh_needed = TRUE;
#endif
@@ -1972,8 +1975,9 @@ int main(int argc, char **argv)
{"smooth", 0, NULL, 'S'},
{"wordbounds", 0, NULL, 'W'},
{"wordchars", 1, NULL, 'X'},
{"atblanks", 0, NULL, 'a'},
{"autoindent", 0, NULL, 'i'},
{"cut", 0, NULL, 'k'},
{"cutfromcursor", 0, NULL, 'k'},
{"unix", 0, NULL, 'u'},
{"softwrap", 0, NULL, '$'},
#endif
@@ -2024,7 +2028,6 @@ int main(int argc, char **argv)
"ABC:DEFGHIKLNOPQ:RST:UVWX:Y:abcdefghijklmno:pqr:s:tuvwxz$",
long_options, NULL)) != -1) {
switch (optchr) {
case 'a':
case 'b':
case 'e':
case 'f':
@@ -2127,6 +2130,11 @@ int main(int argc, char **argv)
case 'Y':
syntaxstr = mallocstrcpy(syntaxstr, optarg);
break;
#endif
#ifndef NANO_TINY
case 'a':
SET(AT_BLANKS);
break;
#endif
case 'c':
SET(CONSTANT_SHOW);
@@ -2142,7 +2150,7 @@ int main(int argc, char **argv)
SET(AUTOINDENT);
break;
case 'k':
SET(CUT_TO_END);
SET(CUT_FROM_CURSOR);
break;
#endif
#ifdef ENABLE_MOUSE
@@ -2534,7 +2542,6 @@ int main(int argc, char **argv)
/* Read the files mentioned on the command line into new buffers. */
while (optind < argc && (!openfile || ISSET(MULTIBUFFER))) {
ssize_t givenline = 0, givencol = 0;
bool dash = FALSE;
/* If there's a +LINE[,COLUMN] argument here, eat it up. */
if (optind < argc - 1 && argv[optind][0] == '+') {
@@ -2547,7 +2554,6 @@ int main(int argc, char **argv)
if (strcmp(argv[optind], "-") == 0) {
if (!scoop_stdin())
continue;
dash = TRUE;
optind++;
} else if (!open_buffer(argv[optind++], FALSE))
continue;
@@ -2556,7 +2562,7 @@ int main(int argc, char **argv)
if (givenline != 0 || givencol != 0)
do_gotolinecolumn(givenline, givencol, FALSE, FALSE);
#ifndef DISABLE_HISTORIES
else if (ISSET(POS_HISTORY) && !dash) {
else if (ISSET(POS_HISTORY) && openfile->filename[0] != '\0') {
ssize_t savedline, savedcol;
/* If edited before, restore the last cursor position. */
if (has_old_position(argv[optind - 1], &savedline, &savedcol))

View File

@@ -48,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)
@@ -160,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
@@ -220,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;
@@ -489,7 +489,7 @@ enum
USE_MOUSE,
USE_REGEXP,
TEMP_FILE,
CUT_TO_END,
CUT_FROM_CURSOR,
BACKWARDS_SEARCH,
MULTIBUFFER,
SMOOTH_SCROLL,
@@ -519,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. */
@@ -575,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
@@ -597,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

@@ -137,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();
@@ -291,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';

View File

@@ -523,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);
@@ -540,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);
@@ -663,8 +662,15 @@ 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);
#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);
@@ -673,7 +679,10 @@ 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);

View File

@@ -90,12 +90,14 @@ 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},
@@ -315,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;
@@ -346,7 +350,7 @@ 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 ||
@@ -609,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;
@@ -650,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"),
@@ -725,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
@@ -778,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
@@ -877,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);
@@ -889,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 */

View File

@@ -614,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();
@@ -625,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;
@@ -903,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);
@@ -915,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

View File

@@ -91,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 &&
@@ -112,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. */
@@ -181,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
@@ -277,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;
@@ -298,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,
@@ -321,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. */
@@ -429,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. */
@@ -456,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;
@@ -467,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;
}
@@ -653,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);
@@ -678,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!"));
@@ -749,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);
@@ -767,8 +766,8 @@ void do_undo(void)
break;
}
undidmsg = _("line break");
size_t from_x = (u->begin == 0) ? 0 : u->mark_begin_x;
size_t to_x = (u->begin == 0) ? u->mark_begin_x : u->begin;
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(&u->strdata[from_x]) + 1);
strcat(f->data, &u->strdata[from_x]);
@@ -787,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);
@@ -832,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;
@@ -883,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';
@@ -926,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);
@@ -1261,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:
@@ -1270,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;
@@ -1395,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;
@@ -1406,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
@@ -1422,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;
@@ -1487,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. */
@@ -1529,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
@@ -1593,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);
@@ -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();
@@ -2507,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. */
@@ -2531,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;
@@ -2596,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,
@@ -2609,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) {
@@ -3343,6 +3345,7 @@ void do_linter(void)
}
blank_statusbar();
wnoutrefresh(bottomwin);
#ifndef NANO_TINY
free_lints_and_return:

View File

@@ -704,7 +704,10 @@ int parse_kbinput(WINDOW *win)
/* Slang and SunOS 5.7-5.9 don't support KEY_RESIZE. */
case KEY_RESIZE:
#endif
case KEY_F0:
#if defined(USE_SLANG) && defined(ENABLE_UTF8)
case KEY_BAD:
#endif
case KEY_FLUSH:
return ERR;
}
@@ -773,6 +776,19 @@ int convert_sequence(const int *seq, size_t seq_len)
}
}
break;
case '5':
if (seq_len >= 3) {
switch (seq[2]) {
case 'A': /* Esc O 5 A == Ctrl-Up on Haiku. */
return CONTROL_UP;
case 'B': /* Esc O 5 B == Ctrl-Down on Haiku. */
return CONTROL_DOWN;
case 'C': /* Esc O 5 C == Ctrl-Right on Haiku. */
return CONTROL_RIGHT;
case 'D': /* Esc O 5 D == Ctrl-Left on Haiku. */
return CONTROL_LEFT;
}
}
case 'A': /* Esc O A == Up on VT100/VT320/xterm. */
case 'B': /* Esc O B == Down on VT100/VT320/xterm. */
case 'C': /* Esc O C == Right on VT100/VT320/xterm. */
@@ -1889,7 +1905,7 @@ char *display_string(const char *buf, size_t column, size_t span, bool isdata)
converted[index++] = ' ';
column++;
/* Fill the tab up with the required number of spaces. */
while (column % tabsize != 0) {
while (column % tabsize != 0 && column < beyond) {
converted[index++] = ' ';
column++;
}
@@ -2162,6 +2178,10 @@ void statusline(message_type importance, const char *msg, ...)
waddstr(bottomwin, " ]");
wattroff(bottomwin, interface_color_pair[STATUS_BAR]);
/* Defeat a VTE/Konsole bug, where the cursor can go off-limits. */
if (ISSET(CONSTANT_SHOW) && ISSET(NO_HELP))
wmove(bottomwin, 0, 0);
/* Push the message to the screen straightaway. */
wrefresh(bottomwin);
@@ -2209,37 +2229,23 @@ void bottombars(int menu)
blank_bottombars();
#ifdef DEBUG
fprintf(stderr, "In bottombars, number of items == \"%d\"\n", (int) number);
#endif
/* Display the first number of shortcuts in the given menu that
* have a key combination assigned to them. */
for (f = allfuncs, i = 0; i < number && f != NULL; f = f->next) {
#ifdef DEBUG
fprintf(stderr, "Checking menu items....");
#endif
if ((f->menus & menu) == 0)
continue;
#ifdef DEBUG
fprintf(stderr, "found one! f->menus = %x, desc = \"%s\"\n", f->menus, f->desc);
#endif
s = first_sc_for(menu, f->scfunc);
if (s == NULL) {
#ifdef DEBUG
fprintf(stderr, "Whoops, guess not, no shortcut key found for func!\n");
#endif
if (s == NULL)
continue;
}
wmove(bottomwin, 1 + i % 2, (i / 2) * itemwidth);
#ifdef DEBUG
fprintf(stderr, "Calling onekey with keystr \"%s\" and desc \"%s\"\n", s->keystr, f->desc);
#endif
onekey(s->keystr, _(f->desc), itemwidth + (COLS % itemwidth));
i++;
}
/* Defeat a VTE bug by moving the cursor and forcing a screen update. */
/* Defeat a VTE bug by homing the cursor and forcing a screen update. */
wmove(bottomwin, 0, 0);
wrefresh(bottomwin);
}
@@ -2277,24 +2283,19 @@ void place_the_cursor(bool forreal)
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
filestruct *line = openfile->edittop;
size_t leftedge;
row -= (openfile->firstcolumn / editwincols);
row -= chunk_for(openfile->firstcolumn, openfile->edittop);
/* Calculate how many rows the lines from edittop to current use. */
while (line != NULL && line != openfile->current) {
row += strlenpt(line->data) / editwincols + 1;
row += number_of_chunks_in(line) + 1;
line = line->next;
}
/* Add the number of wraps in the current line before the cursor. */
row += xpt / editwincols;
col = xpt % editwincols;
/* If the cursor ought to be in column zero, nudge it there. */
if (forreal && openfile->placewewant % editwincols == 0 && col != 0) {
row++;
col = 0;
}
row += get_chunk_and_edge(xpt, openfile->current, &leftedge);
col = xpt - leftedge;
} else
#endif
{
@@ -2381,6 +2382,12 @@ void edit_draw(filestruct *fileptr, const char *converted,
/* The place in converted from where painting starts. */
regmatch_t match;
/* The match positions of a single-line regex. */
const filestruct *start_line = fileptr->prev;
/* The first line before fileptr that matches 'start'. */
const filestruct *end_line = fileptr;
/* The line that matches 'end'. */
regmatch_t startmatch, endmatch;
/* The match positions of the start and end regexes. */
/* Two notes about regexec(). A return value of zero means
* that there is a match. Also, rm_eo is the first
@@ -2436,12 +2443,6 @@ void edit_draw(filestruct *fileptr, const char *converted,
}
/* Second case: varnish is a multiline expression. */
const filestruct *start_line = fileptr->prev;
/* The first line before fileptr that matches 'start'. */
const filestruct *end_line = fileptr;
/* The line that matches 'end'. */
regmatch_t startmatch, endmatch;
/* The match positions of the start and end regexes. */
/* Assume nothing gets painted until proven otherwise below. */
fileptr->multidata[varnish->id] = CNONE;
@@ -2728,19 +2729,19 @@ int update_softwrapped_line(filestruct *fileptr)
/* The first row in the edit window that gets updated. */
size_t from_col = 0;
/* The starting column of the current chunk. */
size_t to_col = 0;
/* To which column a line is displayed. */
char *converted;
/* The data of the chunk with tabs and control characters expanded. */
size_t full_length;
/* The length of the expanded line. */
if (fileptr == openfile->edittop)
from_col = openfile->firstcolumn;
else
row -= (openfile->firstcolumn / editwincols);
row -= chunk_for(openfile->firstcolumn, openfile->edittop);
/* Find out on which screen row the target line should be shown. */
while (line != fileptr && line != NULL) {
row += (strlenpt(line->data) / editwincols) + 1;
row += number_of_chunks_in(line) + 1;
line = line->next;
}
@@ -2751,18 +2752,30 @@ int update_softwrapped_line(filestruct *fileptr)
return 0;
}
full_length = strlenpt(fileptr->data);
starting_row = row;
while (from_col <= full_length && row < editwinrows) {
while (row < editwinrows) {
bool end_of_line = FALSE;
to_col = get_softwrap_breakpoint(fileptr->data, from_col, &end_of_line);
blank_row(edit, row, 0, COLS);
/* Convert the chunk to its displayable form and draw it. */
converted = display_string(fileptr->data, from_col, editwincols, TRUE);
converted = display_string(fileptr->data, from_col, to_col - from_col, TRUE);
edit_draw(fileptr, converted, row++, from_col);
free(converted);
from_col += editwincols;
if (end_of_line)
break;
/* If the line is softwrapped before its last column, add a ">" just
* after its softwrap breakpoint, unless we're softwrapping at blanks
* and not in the middle of a word. */
if (!ISSET(AT_BLANKS) && to_col - from_col < editwincols)
mvwaddch(edit, row - 1, to_col - from_col, '>');
from_col = to_col;
}
return (row - starting_row);
@@ -2796,25 +2809,25 @@ int go_back_chunks(int nrows, filestruct **line, size_t *leftedge)
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
size_t current_chunk = (*leftedge) / editwincols;
/* Recede through the requested number of chunks. */
for (i = nrows; i > 0; i--) {
if (current_chunk > 0) {
current_chunk--;
continue;
}
size_t chunk = chunk_for(*leftedge, *line);
*leftedge = 0;
if (chunk >= i)
return go_forward_chunks(chunk - i, line, leftedge);
if (*line == openfile->fileage)
break;
i -= chunk;
*line = (*line)->prev;
current_chunk = strlenpt((*line)->data) / editwincols;
*leftedge = HIGHEST_POSITIVE;
}
/* Only change leftedge when we actually could move. */
if (i < nrows)
*leftedge = current_chunk * editwincols;
if (*leftedge == HIGHEST_POSITIVE)
*leftedge = leftedge_for(*leftedge, *line);
} else
#endif
for (i = nrows; i > 0 && (*line)->prev != NULL; i--)
@@ -2831,33 +2844,30 @@ int go_forward_chunks(int nrows, filestruct **line, size_t *leftedge)
{
int i;
/* Don't move more chunks than the window can hold. */
if (nrows > editwinrows - 1)
nrows = (editwinrows < 2) ? 1 : editwinrows - 1;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
size_t current_chunk = (*leftedge) / editwincols;
size_t last_chunk = strlenpt((*line)->data) / editwincols;
size_t current_leftedge = *leftedge;
/* Advance through the requested number of chunks. */
for (i = nrows; i > 0; i--) {
if (current_chunk < last_chunk) {
current_chunk++;
bool end_of_line = FALSE;
current_leftedge = get_softwrap_breakpoint((*line)->data,
current_leftedge, &end_of_line);
if (!end_of_line)
continue;
}
if (*line == openfile->filebot)
break;
*line = (*line)->next;
current_chunk = 0;
last_chunk = strlenpt((*line)->data) / editwincols;
current_leftedge = 0;
}
/* Only change leftedge when we actually could move. */
if (i < nrows)
*leftedge = current_chunk * editwincols;
*leftedge = current_leftedge;
} else
#endif
for (i = nrows; i > 0 && (*line)->next != NULL; i--)
@@ -2874,7 +2884,7 @@ bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge)
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
filestruct *line = openfile->current;
size_t leftedge = (xplustabs() / editwincols) * editwincols;
size_t leftedge = leftedge_for(xplustabs(), openfile->current);
int rows_left = go_back_chunks(editwinrows - 1, &line, &leftedge);
return (rows_left > 0 || line->lineno < was_lineno ||
@@ -2939,12 +2949,14 @@ void edit_scroll(scroll_dir direction, int nrows)
go_forward_chunks(editwinrows - nrows, &line, &leftedge);
#ifndef NANO_TINY
/* Compensate for the earlier chunks of a softwrapped line. */
nrows += leftedge / editwincols;
if (ISSET(SOFTWRAP)) {
/* Compensate for the earlier chunks of a softwrapped line. */
nrows += chunk_for(leftedge, line);
/* Don't compensate for the chunks that are offscreen. */
if (line == openfile->edittop)
nrows -= openfile->firstcolumn / editwincols;
/* Don't compensate for the chunks that are offscreen. */
if (line == openfile->edittop)
nrows -= chunk_for(openfile->firstcolumn, line);
}
#endif
/* Draw new content on the blank rows inside the scrolled region
@@ -2957,19 +2969,157 @@ void edit_scroll(scroll_dir direction, int nrows)
}
#ifndef NANO_TINY
/* Get the column number after leftedge where we can break the given text, and
* return it. This will always be editwincols or less after leftedge. Set
* end_of_line to TRUE if we reach the end of the line while searching the
* text. Assume leftedge is the leftmost column of a softwrapped chunk. */
size_t get_softwrap_breakpoint(const char *text, size_t leftedge,
bool *end_of_line)
{
size_t index = 0;
/* Current index in text. */
size_t column = 0;
/* Current column position in text. */
size_t prev_column = 0;
/* Previous column position in text. */
size_t goal_column;
/* Column of the last character where we can break the text. */
bool found_blank = FALSE;
/* Did we find at least one blank? */
size_t lastblank_index = 0;
/* Current index of the last blank in text. */
size_t lastblank_column = 0;
/* Current column position of the last blank in text. */
int char_len = 0;
/* Length of current character, in bytes. */
while (*text != '\0' && column < leftedge)
text += parse_mbchar(text, NULL, &column);
/* Use a full screen row for text. */
goal_column = column + editwincols;
while (*text != '\0' && column <= goal_column) {
/* When breaking at blanks, do it *before* the target column. */
if (ISSET(AT_BLANKS) && is_blank_mbchar(text) && column < goal_column) {
found_blank = TRUE;
lastblank_index = index;
lastblank_column = column;
}
prev_column = column;
char_len = parse_mbchar(text, NULL, &column);
text += char_len;
index += char_len;
}
/* If we didn't overshoot the target, we've found a breaking point. */
if (column <= goal_column) {
/* We've reached EOL if we didn't even reach the target. */
*end_of_line = (column < goal_column);
return column;
}
/* If we're softwrapping at blanks and we found at least one blank, move
* the pointer back to the last blank, step beyond it, and we're done. */
if (found_blank) {
text = text - index + lastblank_index;
parse_mbchar(text, NULL, &lastblank_column);
return lastblank_column;
}
/* Otherwise, return the column of the last character that doesn't
* overshoot the target, since we can't break the text anywhere else. */
return (editwincols > 1) ? prev_column : column - 1;
}
/* Get the row of the softwrapped chunk of the given line that column is on,
* relative to the first row (zero-based), and return it. If leftedge isn't
* NULL, return the leftmost column of the chunk in it. */
size_t get_chunk_and_edge(size_t column, filestruct *line, size_t *leftedge)
{
size_t current_chunk = 0, start_col = 0, end_col;
bool end_of_line = FALSE;
while (TRUE) {
end_col = get_softwrap_breakpoint(line->data, start_col, &end_of_line);
/* We reached the end of the line and/or found column, so get out. */
if (end_of_line || (column >= start_col && column < end_col)) {
if (leftedge != NULL)
*leftedge = start_col;
return current_chunk;
}
current_chunk++;
start_col = end_col;
}
}
/* Return the row of the softwrapped chunk of the given line that column is on,
* relative to the first row (zero-based). */
size_t chunk_for(size_t column, filestruct *line)
{
return get_chunk_and_edge(column, line, NULL);
}
/* Return the leftmost column of the softwrapped chunk of the given line that
* column is on. */
size_t leftedge_for(size_t column, filestruct *line)
{
size_t leftedge;
get_chunk_and_edge(column, line, &leftedge);
return leftedge;
}
/* Return the row of the last softwrapped chunk of the given line, relative to
* the first row (zero-based). */
size_t number_of_chunks_in(filestruct *line)
{
return chunk_for((size_t)-1, line);
}
/* Ensure that firstcolumn is at the starting column of the softwrapped chunk
* it's on. We need to do this when the number of columns of the edit window
* has changed, because then the width of softwrapped chunks has changed. */
void ensure_firstcolumn_is_aligned(void)
{
if (openfile->firstcolumn % editwincols != 0)
openfile->firstcolumn -= (openfile->firstcolumn % editwincols);
openfile->firstcolumn = leftedge_for(openfile->firstcolumn,
openfile->edittop);
/* If smooth scrolling is on, make sure the viewport doesn't center. */
focusing = FALSE;
}
#endif /* !NANO_TINY */
/* When in softwrap mode, and the given column is on or after the breakpoint of
* a softwrapped chunk, shift it back to the last column before the breakpoint.
* The given column is relative to the given leftedge in current. The returned
* column is relative to the start of the text. */
size_t actual_last_column(size_t leftedge, size_t column)
{
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
bool last_chunk;
size_t end_col = get_softwrap_breakpoint(openfile->current->data,
leftedge, &last_chunk) - leftedge;
/* If we're not on the last chunk, we're one column past the end of
* the row. Shifting back one column might put us in the middle of
* a multi-column character, but actual_x() will fix that later. */
if (!last_chunk)
end_col--;
if (column > end_col)
column = end_col;
}
#endif
return leftedge + column;
}
/* Return TRUE if current[current_x] is above the top of the screen, and FALSE
* otherwise. */
bool current_is_above_screen(void)
@@ -3000,7 +3150,8 @@ bool current_is_below_screen(void)
return (go_forward_chunks(editwinrows - 1, &line, &leftedge) == 0 &&
(line->lineno < openfile->current->lineno ||
(line->lineno == openfile->current->lineno &&
leftedge < (xplustabs() / editwincols) * editwincols)));
leftedge < leftedge_for(xplustabs(),
openfile->current))));
} else
#endif
return (openfile->current->lineno >=
@@ -3119,7 +3270,7 @@ void adjust_viewport(update_type manner)
openfile->edittop = openfile->current;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP))
openfile->firstcolumn = (xplustabs() / editwincols) * editwincols;
openfile->firstcolumn = leftedge_for(xplustabs(), openfile->current);
#endif
/* Move edittop back goal rows, starting at current[current_x]. */
@@ -3240,32 +3391,43 @@ void enable_waiting(void)
nodelay(edit, FALSE);
}
/* Highlight the current word being replaced or spell checked. We
* expect word to have tabs and control characters expanded. */
void spotlight(bool active, const char *word)
/* Highlight the text between from_col and to_col when active is TRUE.
* Remove the highlight when active is FALSE. */
void spotlight(bool active, size_t from_col, size_t to_col)
{
size_t word_span = strlenpt(word);
size_t room = word_span;
/* Compute the number of columns that are available for the word. */
if (!ISSET(SOFTWRAP)) {
room = editwincols + get_page_start(xplustabs()) - xplustabs();
/* If the word is partially offscreen, reserve space for the "$". */
if (word_span > room)
room--;
}
char *word;
size_t word_span, room;
place_the_cursor(FALSE);
#ifndef NANO_TINY
if (ISSET(SOFTWRAP)) {
spotlight_softwrapped(active, from_col, to_col);
return;
}
#endif
/* This is so we can show zero-length matches. */
if (to_col == from_col) {
word = mallocstrcpy(NULL, " ");
to_col++;
} else
word = display_string(openfile->current->data, from_col,
to_col - from_col, FALSE);
word_span = strlenpt(word);
/* Compute the number of columns that are available for the word. */
room = editwincols + get_page_start(from_col) - from_col;
/* If the word is partially offscreen, reserve space for the "$". */
if (word_span > room)
room--;
if (active)
wattron(edit, hilite_attribute);
/* This is so we can show zero-length matches. */
if (word_span == 0)
waddch(edit, ' ');
else
waddnstr(edit, word, actual_x(word, room));
waddnstr(edit, word, actual_x(word, room));
if (word_span > room)
waddch(edit, '$');
@@ -3273,9 +3435,65 @@ void spotlight(bool active, const char *word)
if (active)
wattroff(edit, hilite_attribute);
free(word);
wnoutrefresh(edit);
}
#ifndef NANO_TINY
/* Highlight the text between from_col and to_col when active is TRUE; remove
* the highlight when active is FALSE. This will not highlight softwrapped
* line breaks, since they're not actually part of the spotlighted text. */
void spotlight_softwrapped(bool active, size_t from_col, size_t to_col)
{
ssize_t row = openfile->current_y;
size_t leftedge = leftedge_for(from_col, openfile->current);
size_t break_col;
bool end_of_line = FALSE;
char *word;
while (row < editwinrows) {
break_col = get_softwrap_breakpoint(openfile->current->data,
leftedge, &end_of_line);
/* Stop after the end of the word, by pretending the end of the word is
* the end of the line. */
if (break_col >= to_col) {
end_of_line = TRUE;
break_col = to_col;
}
/* This is so we can show zero-length matches. */
if (break_col == from_col) {
word = mallocstrcpy(NULL, " ");
break_col++;
} else
word = display_string(openfile->current->data, from_col,
break_col - from_col, FALSE);
if (active)
wattron(edit, hilite_attribute);
waddnstr(edit, word, actual_x(word, break_col));
if (active)
wattroff(edit, hilite_attribute);
free(word);
if (end_of_line)
break;
wmove(edit, ++row, 0);
leftedge = break_col;
from_col = break_col;
}
wnoutrefresh(edit);
}
#endif
#ifndef DISABLE_EXTRA
#define CREDIT_LEN 54
#define XLCREDIT_LEN 9

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

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

@@ -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:]]+.*::.*$"