Compare commits

...

70 Commits
v5.6 ... v5.7

Author SHA1 Message Date
Benno Schulenberg
02df950240 po: update translations and regenerate POT file and PO files 2021-04-29 12:57:17 +02:00
Benno Schulenberg
a69a8ce3ca bump version numbers and add a news item for the 5.7 release 2021-04-29 11:28:21 +02:00
Benno Schulenberg
8a03d55c53 gnulib: pull in the fix for a build problem on older Debian
The issue was reported here:
  https://lists.gnu.org/archive/html/bug-gnulib/2021-04/msg00198.html
2021-04-28 09:49:14 +02:00
Benno Schulenberg
544351f3be syntaxes: replace [[:space:]] with [[:blank:]] to exclude carriage return
In many places a carriage return is not valid whitespace and should
thus not be colored as such.  In some of these places a vertical tab
or form feed is maybe valid whitespace, but it would be ugly or even
wrong to color them because they are not part of the subsequent
comment or keyword.

This fixes https://savannah.gnu.org/bugs/?60456.
2021-04-27 11:18:41 +02:00
Hussam al-Homsi
96ebaf8ab4 syntax: c: make the highlighting of '#include <...>' more compliant
Changes:
  1. There may be zero spaces between 'include' and '<...>'.
  2. Blanks and '=' may occur inside '<...>' but '>' may not.
  3. There must be at least one character inside '<...>'.

References:
  Change 1:
    C:   www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf#subsection.6.10.2
    C++: www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf#section.19.2

  Changes 2 and 3:
    C:   www.open-std.org/jtc1/sc22/wg14/www/docs/n2310.pdf#subsection.6.4.7
    C++: www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/n4659.pdf#section.5.8

Signed-off-by: Hussam al-Homsi <sawuare@gmail.com>
2021-04-26 12:14:44 +02:00
Benno Schulenberg
6b7c661fb7 syntax: po: improve the coloring of format specifiers
This now handles most of the things listed in 'man 3 printf'.
2021-04-26 11:29:05 +02:00
Benno Schulenberg
6823831c06 build: drop the check for two functions that we don't use any more
Since commits b0209374 and 1c010d8e from a month ago, nano does not use
mblen() and mbtowc() any more, so there is no need to check for their
presence.

Instead, add a check for iswalpha(), which we do use.
2021-04-25 11:55:04 +02:00
Benno Schulenberg
ec82530125 gnulib: update to its current upstream state 2021-04-25 10:48:56 +02:00
Benno Schulenberg
a45e1f89c0 oops: that doesn't work -- you can't break out of two for loops at once
This effectively reverts the previous commit.
2021-04-24 13:56:36 +02:00
Benno Schulenberg
c1cd813dcb tweaks: elide a function that is now basically just two lines 2021-04-24 11:48:04 +02:00
Benno Schulenberg
c96e62e33a startup: save the compiled file-matching regexes, to avoid recompiling
This reduces startup time by seven percent (when using the standard set
of syntaxes) when opening just one file that doesn't match any syntax,
and more than ten percent when opening multiple files.  It takes some
extra memory, but... not wasting CPU cycles is more important.

This addresses https://savannah.gnu.org/bugs/?56433.
2021-04-24 10:54:04 +02:00
Benno Schulenberg
6283557d2f memory: prevent a use-after-free when the user respects a lock file
This fixes https://savannah.gnu.org/bugs/?60447.

Bug existed since commit 2f718e11 from a month ago.
2021-04-23 12:20:45 +02:00
Benno Schulenberg
af90f03ac5 tweaks: condense three comments, drop another, and rewrap a line 2021-04-23 12:04:19 +02:00
Benno Schulenberg
588022ab8c editing: prevent the pointer for the top row from becoming dangling
When undoing several actions, it is possible for the line at the top
of the screen to be removed, leaving 'edittop' pointing to a structure
that has been freed.  Soon after, 'edittop' is referenced to determine
whether the cursor is offscreen...  Prevent this invalid reference by
stepping 'edittop' one line back in that special case.  This changes
the normal centering behavior of Undo when the cursor goes offscreen,
but... so be it.

When a single node is deleted, it is always possible to step one line
back, because a buffer contains always at least one line (even though
maybe empty), so if the current line could be deleted, there must be
one before it (when at the top of the screen).

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

Bug existed since version 2.3.3, commit 60815461,
since undoing does not always center the cursor.
2021-04-23 09:35:12 +02:00
Benno Schulenberg
cf0820549b tweaks: avoid calling extra_chunks_in() when not softwrapping
The function is somewhat costly; better avoid it whenever possible.
2021-04-22 12:19:09 +02:00
Benno Schulenberg
f54bc6c7d6 indicator: adjust the size to the number of visible lines, not chunks
Since two commits ago, the position of the indicator shows the position
of the viewport relative to the full buffer in terms of actual lines,
not of visual chunks (to avoid excessive computation).  But the size of
the indicator stayed constant, as if it always covered as many lines as
the edit window has rows.  But the latter will not be the case when
softwrapping occurs.  Therefore, when softwrapping, compute how many
actual lines are visible in the viewport, and adjust the size of the
indicator accordingly.
2021-04-22 11:52:57 +02:00
Benno Schulenberg
2cdff6c32c tweaks: adjust two comments, and reshuffle two fragments
Also rename two variables, to be more fitting.
2021-04-21 16:52:35 +02:00
Benno Schulenberg
49d8b99e4f softwrap: avoid time-consuming computations, to burden large files less
Whenever softwrap was toggled on or line numbers were toggled on/off or
the window was resized, the extra rows per line needed to be recomputed
for ALL the lines.  For large files with many long lines this was too
costly.

(This change causes the indicator to have an incorrect size when there
are many softwrapped chunks onscreen, but that will be addressed later.)

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

Problem existed since version 5.0, since the indicator was introduced.
2021-04-21 16:40:20 +02:00
Benno Schulenberg
bb81932422 chars: work around the wrong private-use-character widths on OpenBSD
This fixes https://savannah.gnu.org/bugs/?60393.
2021-04-20 11:13:08 +02:00
Benno Schulenberg
5efb6836a8 options: retire the obsolete 'smooth', 'morespace', and 'nopauses' 2021-04-15 11:43:39 +02:00
Benno Schulenberg
48fa14acc0 tweaks: simplify two fragments of code
This makes the handling of plain ASCII a tiny bit slower, but it
affects only the users of --constantshow without --minibar, so...

All other uses of mbstrlen() and collect_char() are not in speed-
critical code paths.
2021-04-13 11:19:32 +02:00
Benno Schulenberg
eb7181b35e tweaks: adjust and improve one comment, and frob another 2021-04-12 15:14:05 +02:00
Benno Schulenberg
8db42023bb files: when Mac format has been detected, stay with it
This fixes https://savannah.gnu.org/bugs/?60382.

Bug existed since commit 09b919a6 from three weeks ago.
2021-04-12 14:50:04 +02:00
Benno Schulenberg
018a8e12ca build: fix compilation for --enable-tiny plus --enable-multibuffer
This will not show the error messages for other buffers when using
a tiny build, but... one cannot have everything.
2021-04-10 12:01:34 +02:00
Benno Schulenberg
b4a5aedc6c tweaks: remove a misplaced (and nested) #ifdef
It was accidentally introduced two weeks ago by commit 1c010d8e.
2021-04-09 16:55:07 +02:00
Benno Schulenberg
d6ed174d09 tweaks: morph a function into what it is actually used for
Since the previous commit, mbwidth() is used only to determine whether
a character is either double width or zero width.  There is no need to
return the actual width of the character; a simple yes or no is enough.

Transforming mbwidth() into is_doublewidth() also allows streamlining
it and is_zerowidth() a bit, so that they become slightly faster.
2021-04-09 16:38:23 +02:00
Benno Schulenberg
78f92e044a tweaks: avoid parsing a multibyte character twice
The number of bytes in the character were determined twice: first in
mbwidth() and then in char_length().  Do it just once, in mbtowide().

Also, avoid calling is_cntrl_char(), because it does unneeded checks
when we already know that the high bit is set.

This duplicates some code, but advance_over() is called a lot, so it
is important that it is as fast as possible.

This shouldn't slow down plain ASCII, as the extra checks (use_utf8
and *string < 0xA0) are done only for non-ASCII (apart from DEL).
2021-04-09 11:32:15 +02:00
Benno Schulenberg
f11931a0dd tweaks: rename a variable, for contrast with another
The 'start_index' was in index in the given text, while 'index' is an
index in the displayable string.  Having both of them using 'index' in
their name was somewhat confusing.
2021-04-08 12:19:34 +02:00
Benno Schulenberg
31a6931be9 tweaks: elide a call of strlen() for every row
For a normal file (without overlong lines) the strlen() wasn't much
of a problem.  But when there are very long lines, it wasted time
counting stuff that wouldn't be displayed on the current row anyway,
and reserved *far* too much memory for the displayable string.

Problem existed since commit cf0eed6c from five years ago that traded
a continuous comparison (of the used space with the reserved space)
against a one-time big reservation up front involving a strlen().
In retrospect that was not a good trade-off when softwrapping.

The extra check (charwidth == 0) is incurred only by characters that
have their high bit set, so the average file (with only ASCII) is not
affected by this -- it just loses an unneeded call of strlen().
2021-04-08 12:15:12 +02:00
Benno Schulenberg
debb288115 tweaks: reduce the maximum character length from six bytes to four
In UTF-8 valid multibyte characters are at most four bytes long,
and now that we no longer make use of mblen() and mbtowc() from
the underlying system, we won't get five- or six-byte sequences
mistakenly reported as valid (by glibc).  So it is always enough
to reserve space for just four bytes per character.
2021-04-07 17:21:25 +02:00
Benno Schulenberg
c75a3839da tweaks: elide a small function that is used just once 2021-04-07 17:08:05 +02:00
Benno Schulenberg
b6a32fbd5f tweaks: elide an unneeded resetting NULL call to wctomb()
Calling wctomb() with NULL as the first parameter returns zero in a
UTF-8 locale, meaning that there is no state, so there is no point
in resetting it either.
2021-04-07 16:11:40 +02:00
Benno Schulenberg
09e4c86606 tweaks: improve a couple of comments 2021-04-07 12:28:48 +02:00
Benno Schulenberg
20eb422829 tweaks: avoid converting a file name for more than will fit on screen 2021-04-07 12:12:06 +02:00
Benno Schulenberg
90c6b572d0 display: avoid determining twice from and until where to draw each row
The two calls of draw_row() are each immediately preceded by a call to
display_string(), which has already determined from which x position
and until which x position in the relevant line the current row will
be drawn -- doing this again in draw_row() is a waste of time.  Even
though it is ugly, pass the two data points from one function to the
other via global variables.

For normal files (without overlong lines), this saves on average some
fifty calls of advance_over() per row.  When softwrapping a file with
overlong lines, the savings for each softwrapped chunk are much higher.
2021-04-07 11:27:10 +02:00
Benno Schulenberg
712b574fb7 tweaks: rename a variable, away from an abbreviation 2021-04-06 16:27:46 +02:00
Benno Schulenberg
fd023d6dcf tweaks: put the most likely condition first, for a quicker return
Also condense a comment.
2021-04-06 11:32:25 +02:00
Benno Schulenberg
9c16be32d7 tweaks: reshuffle two conditions, to have the most unlikely one first
This also better fits the preceding comment.
2021-04-05 16:10:44 +02:00
Benno Schulenberg
c3cdb099da tweaks: reshuffle a comment, and put the main extension first
And add some air to the compact file.
2021-04-05 16:06:54 +02:00
Mike Frysinger
682a088fb8 syntax: tcl: support Expect scripts too 2021-04-05 16:02:44 +02:00
Benno Schulenberg
8c25bd0e94 tweaks: elide two more instances of useless character copying
Just point at the relevant characters directly
instead of first copying them out.
2021-04-02 16:39:10 +02:00
Benno Schulenberg
20e122ef41 startup: show the helpful message only when ^G has not been rebound
(Well, it now checks that ^G is still the first shortcut that is bound
to 'do_help', but that is good enough: if the user did any rebinding,
they probably do not need any reminder about how to invoke 'Help'.)

This fixes https://savannah.gnu.org/bugs/?60315.
Reported-by: Robert Goulding <goulding.2@nd.edu>
2021-04-01 10:09:28 +02:00
Benno Schulenberg
0dcac9188f tweaks: simplify two fragments of code, eliding useless character copying 2021-03-29 20:06:05 +02:00
Benno Schulenberg
1c010d8ec9 chars: implement mbtowc() ourselves, for more efficiency
This saves a function call, and the passing and checking of the
MAXCHARLEN parameter, and the checking whether wc is maybe NULL
(which for nano is never the case), and who knows what other
overheads mbtowc() has, and our workaround for glibc.

Code was written after looking at gnulib/lib/mbrtowc-impl-utf8.h.
2021-03-29 12:36:10 +02:00
Benno Schulenberg
b020937475 chars: implement mblen() ourselves, for efficiency
Most implementations of mblen() do a call to mbtowc(), which is
a waste of time when all we want to know is the number of bytes
(and when we already know that we're using UTF-8 and that the
first byte is at least 0xC2).

(This also avoids burdening correct implementations with the
workaround that was needed only for glibc.)

Code was written after looking at gnulib/lib/mbrtowc-impl-utf8.h.
2021-03-27 14:38:28 +01:00
Benno Schulenberg
e3f46b066a build: fix compilation when configured with --disable-multibuffer 2021-03-26 12:21:44 +01:00
Benno Schulenberg
df7fe1280d tweaks: drop unneeded braces and adjust indentation after previous change 2021-03-26 12:17:44 +01:00
Benno Schulenberg
929770191e chars: work around a UTF-8 bug in glibc, to display invalid codes right
The mblen() and mbtowc() functions will happily return 4 or 5 or 6
for byte sequences that start with 0xF4 0x90 or higher.  But those
sequences encode for U+110000 or higher, which are not valid Unicode
code points.  The libc of FreeBSD and OpenBSD and Alpine correctly
return -1 for such sequences.  Make nano behave correctly also when
linked against glibc, so that invalid sequences are always presented
as a series of invalid bytes and never as a single invalid code.

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

Bug existed since before version 2.0.0.
2021-03-26 11:07:05 +01:00
Benno Schulenberg
66d9d6c6d2 tweaks: elide the pointless is_valid_unicode() function
The call of this function in make_mbchar() does not add anything,
because wctomb() already returns -1 for codes U+D800 to U+DFFF,
and parse_verbatim_kbinput() already rejects anything that starts
with U+11.... or higher, so make_mbchar() is never called for codes
beyond U+10FFFF.

And the call in display_string() just needs to check for wc <= 0x10FFFF
because mbtowc() already returns -1 for codes U+D800 to U+DFFF.
2021-03-25 11:24:41 +01:00
Benno Schulenberg
de816840cb input: accept Unicode codes for non-characters as valid, since they are
That is, accept U+FDD0 to U+FDEF, and accept U+xxFFFE and U+xxFFFF
for xx from 00 to 10 hex, being the 66 reserved "non-characters".

It may not be wise of the user to input these "things" (by typing
their code after M-V), but the codes are valid Unicode code points
and should not be rejected.

See https://www.unicode.org/faq/private_use.html#nonchar8 et al.

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

Bug existed since before version 2.0.0.
2021-03-24 17:11:05 +01:00
Benno Schulenberg
74fcc3be79 tweaks: normalize the indentation after an earlier change
(Should have been done yesterday, right after commit 2f718e11.)
2021-03-24 12:29:50 +01:00
Benno Schulenberg
b6909d3737 build: fix compilation when configured with --enable-tiny
Commit 0c1bf429 from last week added two calls to digits()
for --constantshow.
2021-03-24 12:21:50 +01:00
Benno Schulenberg
823d79b36c tweaks: shorten a comment and trim an #ifdef 2021-03-24 12:16:10 +01:00
Benno Schulenberg
735757b0c1 tweaks: set the file format only when unset, so it doesn't need saving
When inserting a file into the current buffer, the 'fmt' element will
already be set.  When we avoid overwriting the current value of 'fmt'
(when it's other than UNSPECIFIED), we don't need to save and restore
the value when inserting a file.
2021-03-24 12:00:34 +01:00
Benno Schulenberg
09b919a68f files: always register the format, also when the file is unwritable
When saving the buffer under a different name, it should by default
have the same format as the original file.

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

Bug existed since version 2.6.0, commit 0293eac1.
2021-03-24 11:53:56 +01:00
Benno Schulenberg
2f718e11a7 files: create a new buffer earlier, so that error messages can be stored
This improves the fix for https://savannah.gnu.org/bugs/?60269,
by not dropping error messages that happen before a buffer is opened.

This basically reverts commit b63c90bf from a year ago, except that
it now always deletes the created buffer when the user does not want
to override the lock file, also when it is the only buffer.
2021-03-23 16:46:37 +01:00
Benno Schulenberg
77da54c6c6 startup: do not store an error message in the record of another buffer
Set the 'format' of a file only when it has been fully read in,
so that this field can be used to indicate that any later error
message cannot be meant for this buffer.

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

Bug existed since commit 6bf52dcc from yesterday.
2021-03-23 16:19:07 +01:00
Benno Schulenberg
6bf52dcc8d startup: do not crash when trying to open a device or directory
Make sure there is an 'openfile' record before trying to save an
error message in this record.

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

Bug existed since commit ede64d7e from yesterday.
2021-03-22 15:50:31 +01:00
Benno Schulenberg
3d9e803aed syntax: c: colorize also labels that contain digits, and uncolorize colon
Labels may contain digits (after the first character).
And the colon after "default" should not be colored.

Inspired-by: Hussam al-Homsi <sawuare@gmail.com>
2021-03-22 11:41:08 +01:00
Benno Schulenberg
ede64d7ea0 feedback: upon first switch to a buffer, show its error message (if any)
When opening multiple files and some of them had an error, only the
first message was shown and the others were lost -- indicated only
by three dots.  Improve upon this by storing the first error message
for each buffer and showing this message when the buffer is first
switched to.

Requested-by: Mike Frysinger <vapier@gentoo.org>
2021-03-21 16:52:29 +01:00
Benno Schulenberg
e8db390d6f tweaks: reshuffle a fragment of code, to prepare for the next change
Also, don't reserve MAXCHARLEN bytes for the terminating NUL byte.
2021-03-21 16:52:29 +01:00
Benno Schulenberg
0c1bf429e8 display: make the output of --constantshow less jittery
That is: reserve for the current line and current character the number
of positions needed for the total number of lines and characters, and
reserve two positions for both the current column and the total number
of columns.  This will keep all nine numbers in the output in the same
place -- as long as there are no lines with more than 99 columns.  In
this latter case there will still be some jitter, but all-in-all the
output is much stabler than it was.

Suggested-by: Mike Frysinger <vapier@gentoo.org>
2021-03-18 16:20:04 +01:00
Benno Schulenberg
f6357a73f0 memory: fix an off-by-one error to free also the last line in a group
The number of lines in a group is the difference in line numbers
between the last line and the first line *plus one*.

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

Bug existed since version 2.9.0, since indenting and unindenting
became undoable, and commit f722c532 formed a part of that.
2021-03-05 18:50:34 +01:00
Benno Schulenberg
49ca7e5aa8 memory: do not allocate space for multidata when it's already allocated
Allocating it again would leak the existing space.

This fixes https://savannah.gnu.org/bugs/?60172.
Reported-by: Mike Frysinger <vapier@gentoo.org>

Bug existed since version 5.6, commit 1fdd23d3.
2021-03-05 11:25:14 +01:00
Benno Schulenberg
be9b1a1887 tweaks: avoid a warning on newer compilers, by writing an extra byte
When the version number is a trio, the version string will occupy
ten bytes and the terminating NUL byte would not be written (which
was not a problem as byte 12 of the lock data is zero anyway).
But it's better to not have the compiler complain, so allow writing
the terminating NUL byte outside of the ten bytes reserved for the
version string.
2021-03-03 10:47:41 +01:00
Benno Schulenberg
bb74aacf2d po: update translations and regenerate POT file and PO files 2021-03-03 10:11:58 +01:00
Benno Schulenberg
b72d9af52c bump version numbers and add a news item for the 5.6.1 release 2021-03-03 09:47:41 +01:00
Benno Schulenberg
a9ccd99b90 tweaks: rename a symbol, to better match the corresponding option 2021-03-03 09:39:49 +01:00
Benno Schulenberg
ac5e5179fb options: rename 'highlightcolor' to the more distinct 'spotlightcolor'
This way there cannot be any confusion with syntax highlighting,
and it indicates better that a single place will be highlighted.
2021-03-03 09:31:46 +01:00
Benno Schulenberg
a543f8cd8f search: correctly colorize a match also when softwrapping is active
This fixes https://savannah.gnu.org/bugs/?60149.
Reported-by: Peter Passchier <peter@passchier.net>
Reported-by: Liu Hao <lh_mouse@126.com>

Bug existed since version 5.6, since a special color for highlighting
search matches was introduced in commit 87fe73dd.
2021-03-01 10:43:28 +01:00
83 changed files with 16261 additions and 13256 deletions

View File

@@ -1,3 +1,87 @@
Changes between v5.6.1 and v5.7:
--------------------------------
Benno Schulenberg (62):
build: drop the check for two functions that we don't use any more
build: fix compilation for --enable-tiny plus --enable-multibuffer
build: fix compilation when configured with --disable-multibuffer
build: fix compilation when configured with --enable-tiny
bump version numbers and add a news item for the 5.7 release
chars: implement mblen() ourselves, for efficiency
chars: implement mbtowc() ourselves, for more efficiency
chars: work around a UTF-8 bug in glibc, to display invalid codes right
chars: work around the wrong private-use-character widths on OpenBSD
display: avoid determining twice from and until where to draw each row
display: make the output of --constantshow less jittery
editing: prevent the pointer for the top row from becoming dangling
feedback: upon first switch to a buffer, show its error message (if any)
files: always register the format, also when the file is unwritable
files: create a new buffer earlier, so that error messages can be stored
files: when Mac format has been detected, stay with it
gnulib: pull in the fix for a build problem on older Debian
gnulib: update to its current upstream state
indicator: adjust the size to the number of visible lines, not chunks
input: accept Unicode codes for non-characters as valid, since they are
memory: do not allocate space for multidata when it's already allocated
memory: fix an off-by-one error to free also the last line in a group
memory: prevent a use-after-free when the user respects a lock file
oops: that doesn't work -- you can't break out of two for loops at once
options: retire the obsolete 'smooth', 'morespace', and 'nopauses'
softwrap: avoid time-consuming computations, to burden large files less
startup: do not crash when trying to open a device or directory
startup: do not store an error message in the record of another buffer
startup: save the compiled file-matching regexes, to avoid recompiling
startup: show the helpful message only when ^G has not been rebound
syntax: c: colorize also labels that contain digits, and uncolorize colon
syntax: po: improve the coloring of format specifiers
syntaxes: replace [[:space:]] with [[:blank:]] to exclude carriage return
tweaks: adjust and improve one comment, and frob another
tweaks: adjust two comments, and reshuffle two fragments
tweaks: avoid a warning on newer compilers, by writing an extra byte
tweaks: avoid calling extra_chunks_in() when not softwrapping
tweaks: avoid converting a file name for more than will fit on screen
tweaks: avoid parsing a multibyte character twice
tweaks: condense three comments, drop another, and rewrap a line
tweaks: drop unneeded braces and adjust indentation after previous change
tweaks: elide a call of strlen() for every row
tweaks: elide a function that is now basically just two lines
tweaks: elide an unneeded resetting NULL call to wctomb()
tweaks: elide a small function that is used just once
tweaks: elide the pointless is_valid_unicode() function
tweaks: elide two more instances of useless character copying
tweaks: improve a couple of comments
tweaks: morph a function into what it is actually used for
tweaks: normalize the indentation after an earlier change
tweaks: put the most likely condition first, for a quicker return
tweaks: reduce the maximum character length from six bytes to four
tweaks: remove a misplaced (and nested) #ifdef
tweaks: rename a variable, away from an abbreviation
tweaks: rename a variable, for contrast with another
tweaks: reshuffle a comment, and put the main extension first
tweaks: reshuffle a fragment of code, to prepare for the next change
tweaks: reshuffle two conditions, to have the most unlikely one first
tweaks: set the file format only when unset, so it doesn't need saving
tweaks: shorten a comment and trim an #ifdef
tweaks: simplify two fragments of code
tweaks: simplify two fragments of code, eliding useless character copying
Hussam al-Homsi (1):
syntax: c: make the highlighting of '#include <...>' more compliant
Mike Frysinger (1):
syntax: tcl: support Expect scripts too
Changes between v5.6 and v5.6.1:
--------------------------------
Benno Schulenberg (4):
bump version numbers and add a news item for the 5.6.1 release
options: rename 'highlightcolor' to the more distinct 'spotlightcolor'
search: correctly colorize a match also when softwrapping is active
tweaks: rename a symbol, to better match the corresponding option
Changes between v5.5 and v5.6:
------------------------------

12
NEWS
View File

@@ -1,3 +1,15 @@
2021.04.29 - GNU nano 5.7 "Toți ceilalți arau câmpurile"
• The output of --constantshow (without --minibar) is more stable.
• When opening multiple buffers and there is an error message, this
message is shown again upon first switch to the relevant buffer.
• The position and size of the indicator now follow actual lines,
instead of visual lines when in softwrap mode, meaning that the
size of the indicator can change when scrolling in softwrap mode.
2021.03.03 - GNU nano 5.6.1 "Geelgors"
• Search matches are properly colorized in softwrap mode too.
• Option 'highlightcolor' has been renamed to 'spotlightcolor'.
2021.02.24 - GNU nano 5.6 "Wielewaal"
• A search match gets highlighted (in black on yellow by default),
in addition to placing the cursor at the start of the match.

View File

@@ -2,7 +2,7 @@
# Generate configure & friends for GIT users.
gnulib_url="git://git.sv.gnu.org/gnulib.git"
gnulib_hash="c9b44f214c7c798c7701c7a281584e262b263655"
gnulib_hash="afeeb21058d15e5250fff9fbea2c1fec011c061a"
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 https://www.gnu.org/licenses/.
AC_INIT([GNU nano], [5.6], [nano-devel@gnu.org], [nano])
AC_INIT([GNU nano], [5.7], [nano-devel@gnu.org], [nano])
AC_CONFIG_SRCDIR([src/nano.c])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.14])
@@ -350,7 +350,7 @@ fi])
dnl Checks for functions.
if test "x$enable_utf8" != xno; then
AC_CHECK_FUNCS(iswalnum iswpunct mblen mbstowcs mbtowc wctomb)
AC_CHECK_FUNCS(iswalpha iswalnum iswpunct mbstowcs wctomb)
fi
dnl Checks for available flags.
@@ -435,11 +435,10 @@ AC_SUBST(CURSES_LIB)
if test "x$enable_utf8" != xno && \
test x$CURSES_LIB_WIDE = xyes && \
test x$ac_cv_func_iswalpha = xyes && \
test x$ac_cv_func_iswalnum = xyes && \
test x$ac_cv_func_iswpunct = xyes && \
test x$ac_cv_func_mblen = xyes && \
test x$ac_cv_func_mbstowcs = xyes && \
test x$ac_cv_func_mbtowc = xyes && \
test x$ac_cv_func_wctomb = xyes; then
AC_DEFINE(ENABLE_UTF8, 1, [Define this if your system has sufficient UTF-8 support.])
else

View File

@@ -89,7 +89,7 @@
<h3><a name="1.3"></a>1.3. Why the name change from TIP?</h3>
<blockquote><p>On January 10, 2000, TIP was officially renamed to nano because of a namespace conflict with another program called 'tip'. The original 'tip' program &quot;establishes a full duplex terminal connection to a remote host&quot;, and was included with many older Unix systems (and newer ones like Solaris). The conflict was not noticed at first because there is no 'tip' utility included with most GNU/Linux distributions (where nano was developed).</p></blockquote>
<h3><a name="1.4"></a>1.4. What is the current version of nano?</h3>
<blockquote><p>The current version of nano <i>should</i> be <b>5.6</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<blockquote><p>The current version of nano <i>should</i> be <b>5.7</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
<h3><a name="1.5"></a>1.5. I want to read the man page without having to download the program!</h3>
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="https://nano-editor.org/dist/latest/nano.1.html">here</a>.</p></blockquote>
<hr width="100%">

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANO 1 "version 5.6" "February 2021"
.TH NANO 1 "version 5.7" "April 2021"
.SH NAME
nano \- Nano's ANOther editor, inspired by Pico

View File

@@ -8,8 +8,8 @@
@smallbook
@set EDITION 0.5
@set VERSION 5.6
@set UPDATED February 2021
@set VERSION 5.7
@set UPDATED April 2021
@dircategory Editors
@direntry
@@ -23,7 +23,7 @@
@titlepage
@title GNU @command{nano}
@subtitle a small and friendly text editor
@subtitle version 5.6
@subtitle version 5.7
@author Chris Allegretta
@page
@@ -63,7 +63,7 @@ e-mail: @email{chrisa@@asty.org}@*
@node Top
@top
This manual documents the GNU @command{nano} editor, version 5.6.
This manual documents the GNU @command{nano} editor, version 5.7.
@menu
* Introduction::
@@ -892,11 +892,6 @@ if your terminal can do those.
Draw a vertical stripe at the given column, to help judge the width of the
text. (The color of the stripe can be changed with @code{set stripecolor}.)
@item set highlightcolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
Use this color combination for highlighting a search match.
The default value is @t{black,lightyellow}.
@xref{@code{set functioncolor}} for valid color names.
@item set historylog
Save the last hundred search strings and replacement strings and
executed commands, so they can be easily reused in later sessions.
@@ -951,10 +946,6 @@ The line plus column numbers and the character code are displayed only when
@code{set constantshow} is used, and can be toggled on and off with @key{M-C}.
The state flags are displayed only when @code{set stateflags} is used.
@item set morespace
Deprecated option since it has become the default setting.
When needed, use @code{unset emptyline} instead.
@item set mouse
Enable mouse support, so that mouse clicks can be used to place the
cursor, set the mark (with a double click), or execute shortcuts.
@@ -972,9 +963,6 @@ Don't display the help lists at the bottom of the screen.
Don't automatically add a newline when a text does not end with one.
(This can cause you to save non-POSIX text files.)
@item set nopauses
Obsolete option. Ignored.
@item set nowrap
Deprecated option since it has become the default setting.
When needed, use @code{unset breaklonglines} instead.
@@ -1060,10 +1048,6 @@ jump to that beginning (either forwards or backwards). If the cursor is
already at that position, it will jump to the true beginning of the
line.
@item set smooth
Deprecated option since it has become the default setting.
When needed, use @code{unset jumpyscrolling} instead.
@item set softwrap
Display lines that exceed the screen's width over multiple screen lines.
(You can make this soft-wrapping occur at whitespace instead of rudely at
@@ -1073,6 +1057,11 @@ the screen's edge, by using also @code{set atblanks}.)
Use the given program to do spell checking and correcting.
@xref{@option{--speller}} for details.
@item set spotlightcolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
Use this color combination for highlighting a search match.
The default value is @t{black,lightyellow}.
@xref{@code{set functioncolor}} for valid color names.
@item set stateflags
Use the top-right corner of the screen for showing some state flags:
@code{I} when auto-indenting, @code{M} when the mark is on, @code{L} when

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH NANORC 5 "version 5.6" "February 2021"
.TH NANORC 5 "version 5.7 "April 2021"
.SH NAME
nanorc \- GNU nano's configuration file
@@ -146,11 +146,6 @@ See \fBset titlecolor\fR for more details.
Draw a vertical stripe at the given column, to help judge the width of the
text. (The color of the stripe can be changed with \fBset stripecolor\fR.)
.TP
.B set highlightcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for highlighting a search match.
The default value is \fBblack,lightyellow\fR.
See \fBset titlecolor\fR for valid color names.
.TP
.B set historylog
Save the last hundred search strings and replacement strings and
executed commands, so they can be easily reused in later sessions.
@@ -204,10 +199,6 @@ The line plus column numbers and the character code are displayed only when
\fBset constantshow\fR is used, and can be toggled on and off with \fBM-C\fR.
The state flags are displayed only when \fBset stateflags\fR is used.
.TP
.B set morespace
Deprecated option since it has become the default setting.
When needed, use \fBunset emptyline\fR instead.
.TP
.B set mouse
Enable mouse support, if available for your system. When enabled, mouse
clicks can be used to place the cursor, set the mark (with a double
@@ -228,9 +219,6 @@ Don't display the two help lines at the bottom of the screen.
Don't automatically add a newline when a text does not end with one.
(This can cause you to save non-POSIX text files.)
.TP
.B set nopauses
Obsolete option. Ignored.
.TP
.B set nowrap
Deprecated option since it has become the default setting.
When needed, use \fBunset breaklonglines\fR instead.
@@ -314,10 +302,6 @@ jump to that beginning (either forwards or backwards). If the cursor is
already at that position, it will jump to the true beginning of the
line.
.TP
.B set smooth
Deprecated option since it has become the default setting.
When needed, use \fBunset jumpyscrolling\fR instead.
.TP
.B set softwrap
Display lines that exceed the screen's width over multiple screen lines.
(You can make this soft-wrapping occur at whitespace instead of rudely at
@@ -327,6 +311,11 @@ the screen's edge, by using also \fBset atblanks\fR.)
Use the given \fIprogram\fR to do spell checking and correcting, instead of
using the built-in corrector that calls \fBhunspell\fR(1) or \fBspell\fR(1).
.TP
.B set spotlightcolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
Use this color combination for highlighting a search match.
The default value is \fBblack,lightyellow\fR.
See \fBset titlecolor\fR for valid color names.
.TP
.B set stateflags
Use the top-right corner of the screen for showing some state flags:
\fBI\fR when auto-indenting, \fBM\fR when the mark is on, \fBL\fR when

View File

@@ -16,7 +16,7 @@
.\" Documentation License along with this program. If not, see
.\" <https://www.gnu.org/licenses/>.
.\"
.TH RNANO 1 "version 5.6" "February 2021"
.TH RNANO 1 "version 5.7" "April 2021"
.SH NAME
rnano \- a restricted nano

View File

@@ -203,13 +203,13 @@
## Paint the interface elements of nano. These are examples; there are
## no colors by default, except for errorcolor and highlightcolor.
## no colors by default, except for errorcolor and spotlightcolor.
# set titlecolor bold,lightwhite,blue
# set promptcolor lightwhite,lightblack
# set statuscolor bold,lightwhite,green
# set errorcolor bold,lightwhite,red
# set spotlightcolor black,lime
# set selectedcolor lightwhite,magenta
# set highlightcolor black,lime
# set stripecolor ,yellow
# set scrollercolor cyan
# set numbercolor cyan
@@ -221,8 +221,8 @@
# set promptcolor black,yellow
# set statuscolor bold,lightwhite,magenta
# set errorcolor bold,lightwhite,red
# set spotlightcolor black,orange
# set selectedcolor lightwhite,cyan
# set highlightcolor black,orange
# set stripecolor ,yellow
# set scrollercolor magenta
# set numbercolor magenta

703
po/bg.po

File diff suppressed because it is too large Load Diff

705
po/ca.po

File diff suppressed because it is too large Load Diff

705
po/cs.po

File diff suppressed because it is too large Load Diff

705
po/da.po

File diff suppressed because it is too large Load Diff

714
po/de.po

File diff suppressed because it is too large Load Diff

712
po/eo.po

File diff suppressed because it is too large Load Diff

705
po/es.po

File diff suppressed because it is too large Load Diff

703
po/eu.po

File diff suppressed because it is too large Load Diff

705
po/fi.po

File diff suppressed because it is too large Load Diff

713
po/fr.po

File diff suppressed because it is too large Load Diff

705
po/ga.po

File diff suppressed because it is too large Load Diff

705
po/gl.po

File diff suppressed because it is too large Load Diff

712
po/hr.po

File diff suppressed because it is too large Load Diff

705
po/hu.po

File diff suppressed because it is too large Load Diff

703
po/id.po

File diff suppressed because it is too large Load Diff

2948
po/is.po Normal file

File diff suppressed because it is too large Load Diff

705
po/it.po

File diff suppressed because it is too large Load Diff

711
po/ja.po

File diff suppressed because it is too large Load Diff

715
po/ko.po

File diff suppressed because it is too large Load Diff

717
po/ms.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

710
po/nb.po

File diff suppressed because it is too large Load Diff

710
po/nl.po

File diff suppressed because it is too large Load Diff

703
po/nn.po

File diff suppressed because it is too large Load Diff

705
po/pl.po

File diff suppressed because it is too large Load Diff

716
po/pt.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

711
po/ro.po

File diff suppressed because it is too large Load Diff

705
po/ru.po

File diff suppressed because it is too large Load Diff

703
po/sl.po

File diff suppressed because it is too large Load Diff

705
po/sr.po

File diff suppressed because it is too large Load Diff

705
po/sv.po

File diff suppressed because it is too large Load Diff

712
po/tr.po

File diff suppressed because it is too large Load Diff

713
po/uk.po

File diff suppressed because it is too large Load Diff

705
po/vi.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
#!/bin/bash
VERSION="5.6"
VERSION="5.7"
./configure -C --enable-tiny && make && ./configure -C &&

View File

@@ -51,7 +51,7 @@ bool is_alpha_char(const char *c)
#ifdef ENABLE_UTF8
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
if (mbtowide(&wc, c) < 0)
return FALSE;
return iswalpha(wc);
@@ -67,7 +67,7 @@ bool is_alnum_char(const char *c)
#ifdef ENABLE_UTF8
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
if (mbtowide(&wc, c) < 0)
return FALSE;
return iswalnum(wc);
@@ -85,7 +85,7 @@ bool is_blank_char(const char *c)
if ((signed char)*c >= 0)
return (*c == ' ' || *c == '\t');
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
if (mbtowide(&wc, c) < 0)
return FALSE;
return iswblank(wc);
@@ -112,7 +112,7 @@ bool is_punct_char(const char *c)
#ifdef ENABLE_UTF8
wchar_t wc;
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
if (mbtowide(&wc, c) < 0)
return FALSE;
return iswpunct(wc);
@@ -176,62 +176,123 @@ char control_mbrep(const char *c, bool isdata)
}
#ifdef ENABLE_UTF8
/* Return the width in columns of the given (multibyte) character. */
int mbwidth(const char *c)
/* Convert the given multibyte sequence c to wide character wc, and return
* the number of bytes in the sequence, or -1 for an invalid sequence. */
int mbtowide(wchar_t *wc, const char *c)
{
/* Only characters beyond U+02FF can be other than one column wide. */
if ((unsigned char)*c > 0xCB) {
wchar_t wc;
int width;
if ((signed char)*c < 0 && use_utf8) {
unsigned char v1 = (unsigned char)c[0];
unsigned char v2 = (unsigned char)c[1] ^ 0x80;
if (mbtowc(&wc, c, MAXCHARLEN) < 0)
return 1;
if (v2 > 0x3F || v1 < 0xC2)
return -1;
width = wcwidth(wc);
if (v1 < 0xE0) {
*wc = (((unsigned int)(v1 & 0x1F) << 6) | (unsigned int)v2);
return 2;
}
if (width < 0)
return 1;
unsigned char v3 = (unsigned char)c[2] ^ 0x80;
return width;
} else
return 1;
if (v3 > 0x3F)
return -1;
if (v1 < 0xF0) {
if ((v1 > 0xE0 || v2 >= 0x20) && (v1 != 0xED || v2 < 0x20)) {
*wc = (((unsigned int)(v1 & 0x0F) << 12) |
((unsigned int)v2 << 6) | (unsigned int)v3);
return 3;
} else
return -1;
}
unsigned char v4 = (unsigned char)c[3] ^ 0x80;
if (v4 > 0x3F || v1 > 0xF4)
return -1;
if ((v1 > 0xF0 || v2 >= 0x10) && (v1 != 0xF4 || v2 < 0x10)) {
*wc = (((unsigned int)(v1 & 0x07) << 18) | ((unsigned int)v2 << 12) |
((unsigned int)v3 << 6) | (unsigned int)v4);
return 4;
} else
return -1;
}
*wc = (unsigned int)*c;
return 1;
}
/* Return TRUE when the given character occupies two cells. */
bool is_doublewidth(const char *ch)
{
wchar_t wc;
/* Only from U+1100 can code points have double width. */
if ((unsigned char)*ch < 0xE1 || !use_utf8)
return FALSE;
if (mbtowide(&wc, ch) < 0)
return FALSE;
return (wcwidth(wc) == 2);
}
/* Return TRUE when the given character occupies zero cells. */
bool is_zerowidth(const char *ch)
{
return (use_utf8 && mbwidth(ch) == 0);
}
wchar_t wc;
/* Convert the given Unicode value to a multibyte character, if possible.
* If the conversion succeeds, return the (dynamically allocated) multibyte
* character and its length. Otherwise, return a length of zero. */
char *make_mbchar(long code, int *length)
{
char *mb_char = nmalloc(MAXCHARLEN);
/* Only from U+0300 can code points have zero width. */
if ((unsigned char)*ch < 0xCC || !use_utf8)
return FALSE;
*length = wctomb(mb_char, (wchar_t)code);
if (mbtowide(&wc, ch) < 0)
return FALSE;
/* Reject invalid Unicode characters. */
if (*length < 0 || !is_valid_unicode((wchar_t)code)) {
IGNORE_CALL_RESULT(wctomb(NULL, 0));
*length = 0;
}
#if defined(__OpenBSD__)
/* Work around an OpenBSD bug -- see https://sv.gnu.org/bugs/?60393. */
if (wc >= 0xF0000)
return FALSE;
#endif
return mb_char;
return (wcwidth(wc) == 0);
}
#endif /* ENABLE_UTF8 */
/* Return the length (in bytes) of the character located at *pointer. */
/* Return the number of bytes in the character that starts at *pointer. */
int char_length(const char *pointer)
{
#ifdef ENABLE_UTF8
/* If possibly a multibyte character, get its length; otherwise, it's 1. */
if ((unsigned char)*pointer > 0xC1) {
int length = mblen(pointer, MAXCHARLEN);
if ((unsigned char)*pointer > 0xC1 && use_utf8) {
unsigned char c1 = (unsigned char)pointer[0];
unsigned char c2 = (unsigned char)pointer[1];
return (length < 0 ? 1 : length);
} else
if ((c2 ^ 0x80) > 0x3F)
return 1;
if (c1 < 0xE0)
return 2;
if (((unsigned char)pointer[2] ^ 0x80) > 0x3F)
return 1;
if (c1 < 0xF0) {
if ((c1 > 0xE0 || c2 >= 0xA0) && (c1 != 0xED || c2 < 0xA0))
return 3;
else
return 1;
}
if (((unsigned char)pointer[3] ^ 0x80) > 0x3F)
return 1;
if (c1 > 0xF4)
return 1;
if ((c1 > 0xF0 || c2 >= 0x90) && (c1 != 0xF4 || c2 < 0x90))
return 4;
}
#endif
return 1;
}
@@ -242,15 +303,7 @@ size_t mbstrlen(const char *pointer)
size_t count = 0;
while (*pointer != '\0') {
#ifdef ENABLE_UTF8
if ((unsigned char)*pointer > 0xC1) {
int length = mblen(pointer, MAXCHARLEN);
pointer += (length < 0 ? 1 : length);
} else
#endif
pointer++;
pointer += char_length(pointer);
count++;
}
@@ -261,19 +314,7 @@ size_t mbstrlen(const char *pointer)
* given string, and return a copy of this character in *thechar. */
int collect_char(const char *string, char *thechar)
{
int charlen;
#ifdef ENABLE_UTF8
/* If this is a UTF-8 starter byte, get the number of bytes of the character. */
if ((unsigned char)*string > 0xC1) {
charlen = mblen(string, MAXCHARLEN);
/* When the multibyte sequence is invalid, only take the first byte. */
if (charlen <= 0)
charlen = 1;
} else
#endif
charlen = 1;
int charlen = char_length(string);
for (int i = 0; i < charlen; i++)
thechar[i] = string[i];
@@ -286,20 +327,29 @@ int collect_char(const char *string, char *thechar)
int advance_over(const char *string, size_t *column)
{
#ifdef ENABLE_UTF8
if ((signed char)*string < 0) {
int charlen = mblen(string, MAXCHARLEN);
if (charlen > 0) {
if (is_cntrl_char(string))
*column += 2;
else
*column += mbwidth(string);
if ((signed char)*string < 0 && use_utf8) {
/* A UTF-8 upper control code has two bytes and takes two columns. */
if (((unsigned char)string[0] == 0xC2 && (signed char)string[1] < -96)) {
*column += 2;
return 2;
} else {
charlen = 1;
*column += 1;
}
wchar_t wc;
int charlen = mbtowide(&wc, string);
return charlen;
if (charlen < 0) {
*column += 1;
return 1;
}
int width = wcwidth(wc);
#if defined(__OpenBSD__)
*column += (width < 0 || wc >= 0xF0000) ? 1 : width;
#else
*column += (width < 0) ? 1 : width;
#endif
return charlen;
}
}
#endif
@@ -308,12 +358,8 @@ int advance_over(const char *string, size_t *column)
*column += tabsize - *column % tabsize;
else
*column += 2;
} else if (*string == 0x7F)
} else if (0x7E < (unsigned char)*string && (unsigned char)*string < 0xA0)
*column += 2;
#ifndef ENABLE_UTF8
else if (0x7F < (unsigned char)*string && (unsigned char)*string < 0xA0)
*column += 2;
#endif
else
*column += 1;
@@ -396,8 +442,8 @@ int mbstrncasecmp(const char *s1, const char *s2, size_t n)
continue;
}
bool bad1 = (mbtowc(&wc1, s1, MAXCHARLEN) < 0);
bool bad2 = (mbtowc(&wc2, s2, MAXCHARLEN) < 0);
bool bad1 = (mbtowide(&wc1, s1) < 0);
bool bad2 = (mbtowide(&wc2, s2) < 0);
if (bad1 || bad2) {
if (*s1 != *s2)
@@ -522,13 +568,13 @@ char *mbstrchr(const char *string, const char *chr)
bool bad_s = FALSE, bad_c = FALSE;
wchar_t ws, wc;
if (mbtowc(&wc, chr, MAXCHARLEN) < 0) {
if (mbtowide(&wc, chr) < 0) {
wc = (unsigned char)*chr;
bad_c = TRUE;
}
while (*string != '\0') {
int symlen = mbtowc(&ws, string, MAXCHARLEN);
int symlen = mbtowide(&ws, string);
if (symlen < 0) {
ws = (unsigned char)*string;
@@ -590,20 +636,13 @@ char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer)
#endif /* !NANO_TINY */
#if defined(ENABLE_NANORC) && (!defined(NANO_TINY) || defined(ENABLE_JUSTIFY))
/* Return TRUE if the given string contains at least one blank character,
* and FALSE otherwise. */
/* Return TRUE if the given string contains at least one blank character. */
bool has_blank_char(const char *string)
{
char symbol[MAXCHARLEN];
while (*string != '\0' && !is_blank_char(string))
string += char_length(string);
while (*string != '\0') {
string += collect_char(string, symbol);
if (is_blank_char(symbol))
return TRUE;
}
return FALSE;
return *string;
}
#endif /* ENABLE_NANORC && (!NANO_TINY || ENABLE_JUSTIFY) */
@@ -615,14 +654,3 @@ bool white_string(const char *string)
return !*string;
}
#ifdef ENABLE_UTF8
/* Return TRUE if wc is valid Unicode, and FALSE otherwise. */
bool is_valid_unicode(wchar_t wc)
{
return ((0 <= wc && wc <= 0xD7FF) ||
(0xE000 <= wc && wc <= 0xFDCF) ||
(0xFDF0 <= wc && wc <= 0xFFFD) ||
(0xFFFF < wc && wc <= 0x10FFFF && (wc & 0xFFFF) <= 0xFFFD));
}
#endif

View File

@@ -58,7 +58,7 @@ void set_interface_colorpairs(void)
interface_color_pair[index] = A_NORMAL;
else if (index == GUIDE_STRIPE)
interface_color_pair[index] = A_REVERSE;
else if (index == HIGHLIGHTED) {
else if (index == SPOTLIGHTED) {
init_pair(index + 1, COLOR_BLACK, COLOR_YELLOW + (COLORS > 15 ? 8 : 0));
interface_color_pair[index] = COLOR_PAIR(index + 1);
} else if (index == PROMPT_BAR)
@@ -119,19 +119,9 @@ void prepare_palette(void)
* the list starting at head. Return TRUE upon success. */
bool found_in_list(regexlisttype *head, const char *shibboleth)
{
regexlisttype *item;
regex_t rgx;
for (item = head; item != NULL; item = item->next) {
regcomp(&rgx, item->full_regex, NANO_REG_EXTENDED | REG_NOSUB);
if (regexec(&rgx, shibboleth, 0, NULL, 0) == 0) {
regfree(&rgx);
for (regexlisttype *item = head; item != NULL; item = item->next)
if (regexec(item->one_rgx, shibboleth, 0, NULL, 0) == 0)
return TRUE;
}
regfree(&rgx);
}
return FALSE;
}
@@ -305,7 +295,8 @@ void precalc_multicolorinfo(void)
/* For each line, allocate cache space for the multiline-regex info. */
for (line = openfile->filetop; line != NULL; line = line->next)
line->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short));
if (!line->multidata)
line->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short));
for (ink = openfile->syntax->color; ink != NULL; ink = ink->next) {
/* If this is not a multi-line regex, skip it. */

View File

@@ -34,7 +34,7 @@ void do_deletion(undo_type action)
int charlen = char_length(openfile->current->data + openfile->current_x);
size_t line_len = strlen(openfile->current->data + openfile->current_x);
#ifndef NANO_TINY
size_t old_amount = openfile->current->extrarows;
size_t old_amount = ISSET(SOFTWRAP) ? extra_chunks_in(openfile->current) : 0;
/* If the type of action changed or the cursor moved to a different
* line, create a new undo item, otherwise update the existing item. */
@@ -49,13 +49,9 @@ void do_deletion(undo_type action)
&openfile->current->data[openfile->current_x + charlen],
line_len - charlen + 1);
#ifndef NANO_TINY
/* When softwrapping, recompute the number of chunks in the line,
* and schedule a refresh if the number changed. */
if (ISSET(SOFTWRAP)) {
openfile->current->extrarows = extra_chunks_in(openfile->current);
if (openfile->current->extrarows != old_amount)
refresh_needed = TRUE;
}
/* When softwrapping, a changed number of chunks requires a refresh. */
if (ISSET(SOFTWRAP) && extra_chunks_in(openfile->current) != old_amount)
refresh_needed = TRUE;
/* Adjust the mark if it is after the cursor on the current line. */
if (openfile->mark == openfile->current &&
@@ -94,10 +90,6 @@ void do_deletion(undo_type action)
unlink_node(joining);
#ifndef NANO_TINY
if (ISSET(SOFTWRAP))
openfile->current->extrarows = extra_chunks_in(openfile->current);
#endif
/* Two lines were joined, so do a renumbering and refresh the screen. */
renumber_from(openfile->current);
refresh_needed = TRUE;
@@ -336,9 +328,6 @@ void extract_segment(linestruct *top, size_t top_x, linestruct *bot, size_t bot_
#ifndef NANO_TINY
openfile->current->has_anchor = was_anchored;
if (ISSET(SOFTWRAP))
openfile->current->extrarows = extra_chunks_in(openfile->current);
if (post_marked || same_line)
openfile->mark = openfile->current;
if (post_marked)
@@ -391,10 +380,6 @@ void ingraft_buffer(linestruct *topline)
}
if (topline != botline) {
#ifndef NANO_TINY
/* First compute the softwrapped chunks for each line in the graft. */
compute_the_extra_rows_per_line_from(topline);
#endif
/* When inserting at end-of-buffer, update the relevant pointer. */
if (line->next == NULL)
openfile->filebot = botline;
@@ -427,11 +412,6 @@ void ingraft_buffer(linestruct *topline)
openfile->mark_x += length - xpos;
} else if (mark_follows)
openfile->mark_x += extralen;
if (ISSET(SOFTWRAP)) {
line->extrarows = extra_chunks_in(line);
openfile->current->extrarows = extra_chunks_in(openfile->current);
}
#endif
delete_node(topline);

View File

@@ -111,9 +111,9 @@
#define REPLACING 1
#define INREGION 2
/* In UTF-8 a character is at most six bytes long. */
#ifdef ENABLE_UTF8
#define MAXCHARLEN 6
/* In UTF-8 a valid character is at most four bytes long. */
#define MAXCHARLEN 4
#else
#define MAXCHARLEN 1
#endif
@@ -246,7 +246,7 @@
/* Enumeration types. */
typedef enum {
NIX_FILE, DOS_FILE, MAC_FILE
UNSPECIFIED, NIX_FILE, DOS_FILE, MAC_FILE
} format_type;
typedef enum {
@@ -282,7 +282,7 @@ enum {
GUIDE_STRIPE,
SCROLL_BAR,
SELECTED_TEXT,
HIGHLIGHTED,
SPOTLIGHTED,
PROMPT_BAR,
STATUS_BAR,
ERROR_MESSAGE,
@@ -307,7 +307,6 @@ enum {
CUT_FROM_CURSOR,
BACKWARDS_SEARCH,
MULTIBUFFER,
SMOOTH_SCROLL,
REBIND_DELETE,
RAW_SEQUENCES,
NO_CONVERT,
@@ -319,7 +318,6 @@ enum {
RESTRICTED,
SMART_HOME,
WHITESPACE_DISPLAY,
MORE_SPACE,
TABS_TO_SPACES,
QUICK_BLANK,
WORD_BOUNDS,
@@ -333,7 +331,6 @@ enum {
TRIM_BLANKS,
SHOW_CURSOR,
LINE_NUMBERS,
NO_PAUSES,
AT_BLANKS,
AFTER_ENDS,
LET_THEM_ZAP,
@@ -369,8 +366,8 @@ typedef struct colortype {
} colortype;
typedef struct regexlisttype {
char *full_regex;
/* A regex string to match things that imply a certain syntax. */
regex_t *one_rgx;
/* A regex to match things that imply a certain syntax. */
struct regexlisttype *next;
/* The next regex. */
} regexlisttype;
@@ -441,10 +438,6 @@ typedef struct linestruct {
/* The text of this line. */
ssize_t lineno;
/* The number of this line. */
#ifndef NANO_TINY
ssize_t extrarows;
/* The extra rows that this line occupies when softwrapping. */
#endif
struct linestruct *next;
/* Next node. */
struct linestruct *prev;
@@ -567,6 +560,8 @@ typedef struct openfilestruct {
/* The syntax that applies to this file, if any. */
#endif
#ifdef ENABLE_MULTIBUFFER
char *errormessage;
/* The ALERT message (if any) that occurred when opening the file. */
struct openfilestruct *next;
/* The next open file, if any. */
struct openfilestruct *prev;

View File

@@ -83,7 +83,7 @@ void make_new_buffer(void)
openfile->mark = NULL;
openfile->softmark = FALSE;
openfile->fmt = NIX_FILE;
openfile->fmt = UNSPECIFIED;
openfile->undotop = NULL;
openfile->current_undo = NULL;
@@ -93,6 +93,9 @@ void make_new_buffer(void)
openfile->statinfo = NULL;
openfile->lock_filename = NULL;
#endif
#ifdef ENABLE_MULTIBUFFER
openfile->errormessage = NULL;
#endif
#ifdef ENABLE_COLOR
openfile->syntax = NULL;
#endif
@@ -200,7 +203,8 @@ bool write_lockfile(const char *lockfilename, const char *filename, bool modifie
* some byte-order-checking numbers (bytes 1008-1022). */
lockdata[0] = 0x62;
lockdata[1] = 0x30;
snprintf(&lockdata[2], 10, "nano %s", VERSION);
/* It's fine to overwrite byte 12 with the \0 as it is 0x00 anyway. */
snprintf(&lockdata[2], 11, "nano %s", VERSION);
lockdata[24] = mypid % 256;
lockdata[25] = (mypid / 256) % 256;
lockdata[26] = (mypid / (256 * 256)) % 256;
@@ -370,9 +374,6 @@ bool open_buffer(const char *filename, bool new_one)
{
char *realname;
/* The filename after tilde expansion. */
#ifndef NANO_TINY
char *thelocksname = NULL;
#endif
struct stat fileinfo;
int descriptor = 0;
/* Code 0 means new file, -1 means failure, and else it's the fd. */
@@ -417,23 +418,28 @@ bool open_buffer(const char *filename, bool new_one)
/* When loading into a new buffer, first check the file's path is valid,
* and then (if requested and possible) create a lock file for it. */
if (new_one && has_valid_path(realname)) {
#ifndef NANO_TINY
if (ISSET(LOCKING) && !ISSET(VIEW_MODE) && filename[0] != '\0') {
thelocksname = do_lockfile(realname, TRUE);
/* When not overriding an existing lock, don't open a buffer. */
if (thelocksname == SKIPTHISFILE) {
free(realname);
return FALSE;
}
}
#endif
}
if (new_one)
if (new_one) {
make_new_buffer();
if (has_valid_path(realname)) {
#ifndef NANO_TINY
if (ISSET(LOCKING) && !ISSET(VIEW_MODE) && filename[0] != '\0') {
char *thelocksname = do_lockfile(realname, TRUE);
/* When not overriding an existing lock, discard the buffer. */
if (thelocksname == SKIPTHISFILE) {
#ifdef ENABLE_MULTIBUFFER
close_buffer();
#endif
free(realname);
return FALSE;
} else
openfile->lock_filename = thelocksname;
}
#endif /* NANO_TINY */
}
}
/* If we have a filename and are not in NOREAD mode, open the file. */
if (filename[0] != '\0' && !ISSET(NOREAD_MODE))
descriptor = open_file(realname, new_one, &f);
@@ -452,13 +458,9 @@ bool open_buffer(const char *filename, bool new_one)
#endif
}
/* When we've loaded a file into a new buffer, set the filename
* and put the cursor at the start of the buffer. */
/* For a new buffer, store filename and put cursor at start of buffer. */
if (descriptor >= 0 && new_one) {
openfile->filename = mallocstrcpy(openfile->filename, realname);
#ifndef NANO_TINY
openfile->lock_filename = thelocksname;
#endif
openfile->current = openfile->filetop;
openfile->current_x = 0;
openfile->placewewant = 0;
@@ -469,6 +471,7 @@ bool open_buffer(const char *filename, bool new_one)
if (new_one)
find_and_prime_applicable_syntax();
#endif
free(realname);
return TRUE;
}
@@ -541,10 +544,8 @@ void redecorate_after_switch(void)
}
#ifndef NANO_TINY
/* While in a different buffer, the effective width of the screen may
* have changed, so make sure that the softwrapped chunks per line and
* the starting column for the first row get corresponding values. */
compute_the_extra_rows_per_line_from(openfile->filetop);
/* While in a different buffer, the width of the screen may have changed,
* so make sure that the starting column for the first row is fitting. */
ensure_firstcolumn_is_aligned();
#endif
@@ -557,6 +558,11 @@ void redecorate_after_switch(void)
/* Prevent a possible Shift selection from getting cancelled. */
shift_held = TRUE;
if (openfile->errormessage) {
statusline(ALERT, openfile->errormessage);
free(openfile->errormessage);
openfile->errormessage = NULL;
} else
/* Indicate on the status bar where we switched to. */
mention_name_and_linecount();
}
@@ -594,12 +600,16 @@ void close_buffer(void)
/* Free the undo stack. */
discard_until(NULL);
#endif
free(orphan->errormessage);
openfile = orphan->prev;
if (openfile == orphan)
openfile = NULL;
free(orphan);
/* When just one buffer remains open, show "Exit" in the help lines. */
if (openfile == openfile->next)
if (openfile && openfile == openfile->next)
exitfunc->desc = exit_tag;
}
#endif /* ENABLE_MULTIBUFFER */
@@ -645,11 +655,9 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
bool writable = TRUE;
/* Whether the file is writable (in case we care). */
#ifndef NANO_TINY
int format = 0;
/* 0 = Unix, 1 = DOS, 2 = Mac. */
#endif
format_type format = NIX_FILE;
/* The type of line ending the file uses: Unix, DOS, or Mac. */
#ifndef NANO_TINY
if (undoable)
add_undo(INSERT, NULL);
@@ -678,20 +686,20 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
if (control_C_was_pressed)
break;
/* When the byte before the current one is a CR and we're doing
* format conversion, then strip this CR when it's before a LF
* OR when the file is in Mac format. Also, when still on the
* first line, set the format to either DOS (1) or Mac (2). */
/* When the byte before the current one is a CR and automatic format
* conversion has not been switched off, then strip this CR when it's
* before a LF OR when the file is in Mac format. Also, when this is
* the first line break, make a note of the format. */
if (input == '\n') {
#ifndef NANO_TINY
if (len > 0 && buf[len - 1] == '\r' && !ISSET(NO_CONVERT)) {
if (num_lines == 0)
format = 1;
format = DOS_FILE;
len--;
}
} else if ((num_lines == 0 || format == 2) &&
} else if ((num_lines == 0 || format == MAC_FILE) &&
len > 0 && buf[len - 1] == '\r' && !ISSET(NO_CONVERT)) {
format = 2;
format = MAC_FILE;
len--;
#endif
} else {
@@ -758,7 +766,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
if (fd > 0 && !undoable && !ISSET(VIEW_MODE))
writable = (access(filename, W_OK) == 0);
/* If the file ended with newline, or it was entirely empty, make the
/* If the file ended with a newline, or it was entirely empty, make the
* last line blank. Otherwise, put the last read data in. */
if (len == 0)
bottomline->data = copy_of("");
@@ -770,7 +778,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
* strip this CR and indicate that an extra blank line is needed. */
if (buf[len - 1] == '\r' && !ISSET(NO_CONVERT)) {
if (num_lines == 0)
format = 2;
format = MAC_FILE;
buf[--len] = '\0';
mac_line_needs_newline = TRUE;
}
@@ -799,18 +807,15 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
if (!writable)
statusline(ALERT, _("File '%s' is unwritable"), filename);
#ifndef NANO_TINY
else if (format == 2) {
else if (format == MAC_FILE)
/* TRANSLATORS: Keep the next three messages at most 78 characters. */
openfile->fmt = MAC_FILE;
statusline(HUSH, P_("Read %zu line (Converted from Mac format)",
"Read %zu lines (Converted from Mac format)",
num_lines), num_lines);
} else if (format == 1) {
openfile->fmt = DOS_FILE;
else if (format == DOS_FILE)
statusline(HUSH, P_("Read %zu line (Converted from DOS format)",
"Read %zu lines (Converted from DOS format)",
num_lines), num_lines);
}
#endif
else
statusline(HUSH, P_("Read %zu line", "Read %zu lines",
@@ -830,6 +835,8 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
if (ISSET(MAKE_IT_UNIX))
openfile->fmt = NIX_FILE;
else if (openfile->fmt == UNSPECIFIED)
openfile->fmt = format;
#endif
}
@@ -1109,9 +1116,6 @@ void do_insertfile(bool execute)
#ifdef ENABLE_MULTIBUFFER
bool was_multibuffer = ISSET(MULTIBUFFER);
#endif
#ifndef NANO_TINY
format_type was_fmt = openfile->fmt;
#endif
/* Display newlines in filenames as ^J. */
as_an_at = FALSE;
@@ -1279,12 +1283,9 @@ void do_insertfile(bool execute)
{
/* If the file actually changed, mark it as modified. */
if (openfile->current->lineno != was_current_lineno ||
openfile->current_x != was_current_x)
openfile->current_x != was_current_x)
set_modified();
#ifndef NANO_TINY
/* Ensure that the buffer retains the format that it had. */
openfile->fmt = was_fmt;
#endif
refresh_needed = TRUE;
}

View File

@@ -76,7 +76,6 @@ linestruct *make_new_node(linestruct *prevnode)
#endif
newnode->lineno = (prevnode) ? prevnode->lineno + 1 : 1;
#ifndef NANO_TINY
newnode->extrarows = -2; /* Bad value, to make it easier to find bugs. */
newnode->has_anchor = FALSE;
#endif
@@ -100,6 +99,9 @@ void splice_node(linestruct *afterthis, linestruct *newnode)
/* Free the data structures in the given node. */
void delete_node(linestruct *line)
{
/* If the first line on the screen gets deleted, step one back. */
if (line == openfile->edittop)
openfile->edittop = line->prev;
#ifdef ENABLE_WRAPPING
/* If the spill-over line for hard-wrapping is deleted... */
if (line == openfile->spillage_line)
@@ -152,7 +154,6 @@ linestruct *copy_node(const linestruct *src)
#endif
dst->lineno = src->lineno;
#ifndef NANO_TINY
dst->extrarows = src->extrarows;
dst->has_anchor = FALSE;
#endif
@@ -1006,14 +1007,6 @@ void handle_sigwinch(int signal)
the_window_resized = TRUE;
}
/* Compute and store how many extra rows each line needs when softwrapping. */
void compute_the_extra_rows_per_line_from(linestruct *fromline)
{
if (ISSET(SOFTWRAP))
for (linestruct *line = fromline; line != NULL; line = line->next)
line->extrarows = extra_chunks_in(line);
}
/* Reinitialize and redraw the screen completely. */
void regenerate_screen(void)
{
@@ -1056,7 +1049,6 @@ void regenerate_screen(void)
/* If we have an open buffer, redraw the contents of the subwindows. */
if (openfile) {
compute_the_extra_rows_per_line_from(openfile->filetop);
ensure_firstcolumn_is_aligned();
draw_all_subwindows();
}
@@ -1082,9 +1074,7 @@ void do_toggle(int flag)
break;
#endif
case SOFTWRAP:
if (ISSET(SOFTWRAP))
compute_the_extra_rows_per_line_from(openfile->filetop);
else
if (!ISSET(SOFTWRAP))
openfile->firstcolumn = 0;
refresh_needed = TRUE;
break;
@@ -1246,9 +1236,7 @@ void confirm_margin(void)
editwincols = COLS - margin - thebar;
#ifndef NANO_TINY
/* Recompute the softwrapped chunks for each line in the buffer,
* and ensure a proper starting column for the first screen row. */
compute_the_extra_rows_per_line_from(openfile->filetop);
/* Ensure a proper starting column for the first screen row. */
ensure_firstcolumn_is_aligned();
focusing = keep_focus;
#endif
@@ -1414,12 +1402,13 @@ void inject(char *burst, size_t count)
linestruct *thisline = openfile->current;
size_t datalen = strlen(thisline->data);
#ifndef NANO_TINY
size_t old_amount = openfile->current->extrarows;
size_t original_row = 0;
size_t old_amount = 0;
if (ISSET(SOFTWRAP)) {
if (openfile->current_y == editwinrows - 1)
original_row = chunk_for(xplustabs(), thisline);
old_amount = extra_chunks_in(thisline);
}
#endif
@@ -1483,14 +1472,11 @@ void inject(char *burst, size_t count)
/* When softwrapping and the number of chunks in the current line changed,
* or we were on the last row of the edit window and moved to a new chunk,
* we need a full refresh. */
if (ISSET(SOFTWRAP)) {
openfile->current->extrarows = extra_chunks_in(openfile->current);
if (openfile->current->extrarows != old_amount ||
if (ISSET(SOFTWRAP) && (extra_chunks_in(openfile->current) != old_amount ||
(openfile->current_y == editwinrows - 1 &&
chunk_for(xplustabs(), openfile->current) > original_row)) {
refresh_needed = TRUE;
focusing = FALSE;
}
chunk_for(xplustabs(), openfile->current) > original_row))) {
refresh_needed = TRUE;
focusing = FALSE;
}
#endif
@@ -1804,18 +1790,8 @@ int main(int argc, char **argv)
textdomain(PACKAGE);
#endif
#if defined(ENABLE_UTF8) && !defined(NANO_TINY)
if (MB_CUR_MAX > MAXCHARLEN)
fprintf(stderr, "Unexpected large character size: %i bytes"
" -- please report a bug\n", (int)MB_CUR_MAX);
#endif
/* Set sensible defaults, different from what Pico does. */
/* Set a sensible default, different from what Pico does. */
SET(NO_WRAP);
SET(SMOOTH_SCROLL);
/* Give a small visual hint that nano has changed. */
SET(MORE_SPACE);
/* If the executable's name starts with 'r', activate restricted mode. */
if (*(tail(argv[0])) == 'r')
@@ -2175,13 +2151,9 @@ int main(int argc, char **argv)
memmove(alt_speller, alt_speller + 1, strlen(alt_speller));
#endif
/* If an rcfile undid the default settings, copy it to the new flags. */
/* If an rcfile undid the default setting, copy it to the new flag. */
if (!ISSET(NO_WRAP))
SET(BREAK_LONG_LINES);
if (!ISSET(SMOOTH_SCROLL))
SET(JUMPY_SCROLLING);
if (!ISSET(MORE_SPACE))
SET(EMPTY_LINE);
/* Simply OR the boolean flags from rcfile and command line. */
for (size_t i = 0; i < sizeof(flags) / sizeof(flags[0]); i++)
@@ -2325,7 +2297,7 @@ int main(int argc, char **argv)
interface_color_pair[GUIDE_STRIPE] = A_REVERSE;
interface_color_pair[SCROLL_BAR] = A_NORMAL;
interface_color_pair[SELECTED_TEXT] = hilite_attribute;
interface_color_pair[HIGHLIGHTED] = A_REVERSE;
interface_color_pair[SPOTLIGHTED] = A_REVERSE;
interface_color_pair[PROMPT_BAR] = hilite_attribute;
interface_color_pair[STATUS_BAR] = hilite_attribute;
interface_color_pair[ERROR_MESSAGE] = hilite_attribute;
@@ -2502,11 +2474,16 @@ int main(int argc, char **argv)
#ifdef ENABLE_NANORC
if (startup_problem != NULL)
statusline(ALERT, startup_problem);
#define NOTREBOUND first_sc_for(MMAIN, do_help) && \
first_sc_for(MMAIN, do_help)->keycode == 0x07
#else
#define NOTREBOUND TRUE
#endif
#ifdef ENABLE_HELP
if (*openfile->filename == '\0' && openfile->totsize == 0 &&
openfile->next == openfile && !ISSET(NO_HELP))
openfile->next == openfile && !ISSET(NO_HELP) && NOTREBOUND)
statusbar(_("Welcome to nano. For basic help, type Ctrl+G."));
#endif

View File

@@ -204,9 +204,9 @@ bool is_cntrl_char(const char *c);
bool is_word_char(const char *c, bool allow_punct);
char control_mbrep(const char *c, bool isdata);
#ifdef ENABLE_UTF8
int mbwidth(const char *c);
int mbtowide(wchar_t *wc, const char *c);
bool is_doublewidth(const char *ch);
bool is_zerowidth(const char *ch);
char *make_mbchar(long code, int *length);
#endif
int char_length(const char *pointer);
size_t mbstrlen(const char *pointer);
@@ -230,9 +230,6 @@ char *mbrevstrpbrk(const char *head, const char *accept, const char *pointer);
bool has_blank_char(const char *string);
#endif
bool white_string(const char *string);
#ifdef ENABLE_UTF8
bool is_valid_unicode(wchar_t wc);
#endif
/* Most functions in color.c. */
#ifdef ENABLE_COLOR
@@ -412,7 +409,6 @@ void block_sigwinch(bool blockit);
#endif
#ifndef NANO_TINY
void handle_sigwinch(int signal);
void compute_the_extra_rows_per_line_from(linestruct *fromline);
void regenerate_screen(void);
void do_toggle(int flag);
#endif
@@ -532,9 +528,7 @@ void complete_a_word(void);
void get_homedir(void);
const char *tail(const char *path);
char *concatenate(const char *path, const char *name);
#ifdef ENABLE_LINENUMBERS
int digits(ssize_t n);
#endif
bool parse_num(const char *str, ssize_t *result);
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column);
void recode_NUL_to_LF(char *string, size_t length);

View File

@@ -60,7 +60,6 @@ static const rcoption rcopts[] = {
#ifdef HAVE_LIBMAGIC
{"magic", USE_MAGIC},
#endif
{"morespace", MORE_SPACE}, /* Deprecated; remove in 2021. */
#ifdef ENABLE_MOUSE
{"mouse", USE_MOUSE},
#endif
@@ -69,7 +68,6 @@ static const rcoption rcopts[] = {
#endif
{"nohelp", NO_HELP},
{"nonewlines", NO_NEWLINES},
{"nopauses", NO_PAUSES}, /* Obsolete; remove in 2021. */
#ifdef ENABLE_WRAPPING
{"nowrap", NO_WRAP}, /* Deprecated; remove in 2024. */
#endif
@@ -114,7 +112,6 @@ static const rcoption rcopts[] = {
{"noconvert", NO_CONVERT},
{"showcursor", SHOW_CURSOR},
{"smarthome", SMART_HOME},
{"smooth", SMOOTH_SCROLL}, /* Deprecated; remove in 2021. */
{"softwrap", SOFTWRAP},
{"stateflags", STATEFLAGS},
{"tabsize", 0},
@@ -132,7 +129,7 @@ static const rcoption rcopts[] = {
{"stripecolor", 0},
{"scrollercolor", 0},
{"selectedcolor", 0},
{"highlightcolor", 0},
{"spotlightcolor", 0},
{"promptcolor", 0},
{"statuscolor", 0},
{"errorcolor", 0},
@@ -625,9 +622,7 @@ bool compile(const char *expression, int rex_flags, regex_t **packed)
regerror(outcome, compiled, message, length);
jot_error(N_("Bad regex \"%s\": %s"), expression, message);
free(message);
}
if (packed == NULL || outcome != 0) {
regfree(compiled);
free(compiled);
} else
@@ -1242,6 +1237,8 @@ void grab_and_store(const char *kind, char *ptr, regexlisttype **storage)
/* Now gather any valid regexes and add them to the linked list. */
while (*ptr != '\0') {
regex_t *packed_rgx = NULL;
regexstring = ++ptr;
ptr = parse_next_regex(ptr);
@@ -1249,12 +1246,12 @@ void grab_and_store(const char *kind, char *ptr, regexlisttype **storage)
return;
/* If the regex string is malformed, skip it. */
if (!compile(regexstring, NANO_REG_EXTENDED | REG_NOSUB, NULL))
if (!compile(regexstring, NANO_REG_EXTENDED | REG_NOSUB, &packed_rgx))
continue;
/* Copy the regex into a struct, and hook this in at the end. */
newthing = nmalloc(sizeof(regexlisttype));
newthing->full_regex = copy_of(regexstring);
newthing->one_rgx = packed_rgx;
newthing->next = NULL;
if (lastthing == NULL)
@@ -1558,8 +1555,8 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
color_combo[SCROLL_BAR] = parse_interface_color(argument);
else if (strcmp(option, "selectedcolor") == 0)
color_combo[SELECTED_TEXT] = parse_interface_color(argument);
else if (strcmp(option, "highlightcolor") == 0)
color_combo[HIGHLIGHTED] = parse_interface_color(argument);
else if (strcmp(option, "spotlightcolor") == 0)
color_combo[SPOTLIGHTED] = parse_interface_color(argument);
else if (strcmp(option, "promptcolor") == 0)
color_combo[PROMPT_BAR] = parse_interface_color(argument);
else if (strcmp(option, "statuscolor") == 0)

View File

@@ -665,10 +665,6 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
free(openfile->current->data);
openfile->current->data = copy;
#ifndef NANO_TINY
if (ISSET(SOFTWRAP))
openfile->current->extrarows = extra_chunks_in(openfile->current);
#endif
set_modified();
as_an_at = TRUE;
numreplaced++;

View File

@@ -103,9 +103,6 @@ void indent_a_line(linestruct *line, char *indentation)
openfile->totsize += indent_len;
if (ISSET(SOFTWRAP))
line->extrarows = extra_chunks_in(line);
/* Compensate for the change in the current line. */
if (line == openfile->mark && openfile->mark_x > 0)
openfile->mark_x += indent_len;
@@ -234,9 +231,6 @@ void unindent_a_line(linestruct *line, size_t indent_len)
openfile->totsize -= indent_len;
if (ISSET(SOFTWRAP))
line->extrarows = extra_chunks_in(line);
/* Adjust the positions of mark and cursor, when they are affected. */
compensate_leftward(line, indent_len);
}
@@ -426,10 +420,6 @@ void do_comment(void)
* store undo data when a line changed. */
for (line = top; line != bot->next; line = line->next) {
if (comment_line(action, line, comment_seq)) {
#ifndef NANO_TINY
if (ISSET(SOFTWRAP))
line->extrarows = extra_chunks_in(line);
#endif
update_multiline_undo(line->lineno, "");
}
}
@@ -573,8 +563,6 @@ void do_undo(void)
break;
}
line->data[u->tail_x] = '\0';
if (ISSET(SOFTWRAP))
line->extrarows = extra_chunks_in(line);
intruder = make_new_node(line);
intruder->data = copy_of(u->strdata);
splice_node(line, intruder);
@@ -676,9 +664,6 @@ void do_undo(void)
openfile->mark = NULL;
openfile->placewewant = xplustabs();
if (ISSET(SOFTWRAP))
openfile->current->extrarows = extra_chunks_in(openfile->current);
openfile->totsize = u->wassize;
/* When at the point where the file was last saved, unset "Modified". */
@@ -725,8 +710,6 @@ void do_redo(void)
case ENTER:
redidmsg = _("line break");
line->data[u->head_x] = '\0';
if (ISSET(SOFTWRAP))
line->extrarows = extra_chunks_in(line);
intruder = make_new_node(line);
intruder->data = copy_of(u->strdata);
splice_node(line, intruder);
@@ -841,9 +824,6 @@ void do_redo(void)
openfile->mark = NULL;
openfile->placewewant = xplustabs();
if (ISSET(SOFTWRAP))
openfile->current->extrarows = extra_chunks_in(openfile->current);
openfile->totsize = u->newsize;
/* When at the point where the file was last saved, unset "Modified". */
@@ -907,11 +887,6 @@ void do_enter(void)
openfile->mark = newnode;
openfile->mark_x += extra - openfile->current_x;
}
if (ISSET(SOFTWRAP)) {
openfile->current->extrarows = extra_chunks_in(openfile->current);
newnode->extrarows = extra_chunks_in(newnode);
}
#endif
/* Insert the newly created line after the current one and renumber. */
@@ -951,7 +926,7 @@ void discard_until(const undostruct *thisitem)
while (group != NULL) {
groupstruct *next = group->next;
free_chararray(group->indentations,
group->bottom_line - group->top_line);
group->bottom_line - group->top_line + 1);
free(group);
group = next;
}
@@ -1453,21 +1428,12 @@ ssize_t break_line(const char *textstart, ssize_t goal, bool snap_at_nl)
* "indentation" of a line is the leading consecutive whitespace. */
size_t indent_length(const char *line)
{
size_t len = 0;
char onechar[MAXCHARLEN];
int charlen;
const char *start = line;
while (*line != '\0') {
charlen = collect_char(line, onechar);
while (*line != '\0' && is_blank_char(line))
line += char_length(line);
if (!is_blank_char(onechar))
break;
line += charlen;
len += charlen;
}
return len;
return (line - start);
}
#endif

View File

@@ -76,7 +76,6 @@ char *concatenate(const char *path, const char *name)
return joined;
}
#ifdef ENABLE_LINENUMBERS
/* Return the number of digits that the given integer n takes up. */
int digits(ssize_t n)
{
@@ -106,7 +105,6 @@ int digits(ssize_t n)
}
}
}
#endif
/* Read an integer from the given string. If it parses okay,
* store it in *result and return TRUE; otherwise, return FALSE. */
@@ -195,22 +193,18 @@ void free_chararray(char **array, size_t len)
#endif
#ifdef ENABLE_SPELLER
/* Is the word starting at the given position in buf and of the given length
* a separate word? That is: is it not part of a longer word?*/
bool is_separate_word(size_t position, size_t length, const char *buf)
/* Is the word starting at the given position in 'text' and of the given
* length a separate word? That is: is it not part of a longer word? */
bool is_separate_word(size_t position, size_t length, const char *text)
{
char before[MAXCHARLEN], after[MAXCHARLEN];
size_t word_end = position + length;
/* Get the characters before and after the word, if any. */
collect_char(buf + step_left(buf, position), before);
collect_char(buf + word_end, after);
const char *before = text + step_left(text, position);
const char *after = text + position + length;
/* If the word starts at the beginning of the line OR the character before
* the word isn't a letter, and if the word ends at the end of the line OR
* the character after the word isn't a letter, we have a whole word. */
return ((position == 0 || !is_alpha_char(before)) &&
(buf[word_end] == '\0' || !is_alpha_char(after)));
(*after == '\0' || !is_alpha_char(after)));
}
#endif /* ENABLE_SPELLER */
@@ -355,14 +349,12 @@ char *free_and_assign(char *dest, char *src)
return src;
}
/* When not in softwrap mode, nano scrolls horizontally within a line in
* chunks (a bit smaller than the chunks used in softwrapping). Return the
* column number of the first character displayed in the edit window when the
* cursor is at the given column. Note that (0 <= column -
* get_page_start(column) < COLS). */
/* When not softwrapping, nano scrolls the current line horizontally by
* chunks ("pages"). Return the column number of the first character
* displayed in the edit window when the cursor is at the given column. */
size_t get_page_start(size_t column)
{
if (column + 2 < editwincols || ISSET(SOFTWRAP) || column == 0)
if (column == 0 || column + 2 < editwincols || ISSET(SOFTWRAP))
return 0;
else if (editwincols > 8)
return column - 6 - (column - 6) % (editwincols - 8);
@@ -437,9 +429,6 @@ void new_magicline(void)
openfile->filebot->next = make_new_node(openfile->filebot);
openfile->filebot->next->data = copy_of("");
openfile->filebot = openfile->filebot->next;
#ifndef NANO_TINY
openfile->filebot->extrarows = 0;
#endif
openfile->totsize++;
}

View File

@@ -54,6 +54,10 @@ static bool linger_after_escape = FALSE;
/* Whether to give ncurses some time to get the next code. */
static int statusblank = 0;
/* The number of keystrokes left before we blank the status bar. */
size_t from_x = 0;
/* From where in the relevant line the current row is drawn. */
size_t till_x = 0;
/* Until where in the relevant line the current row is drawn. */
static bool has_more = FALSE;
/* Whether the current line has more text after the displayed part. */
static bool is_shorter = TRUE;
@@ -1377,7 +1381,7 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
* commence Unicode input. Otherwise, put the code back. */
if (using_utf8() && (keycode == '0' || keycode == '1')) {
long unicode = assemble_unicode(keycode);
char *multibyte;
char multibyte[MB_CUR_MAX];
reveal_cursor = FALSE;
@@ -1407,14 +1411,15 @@ int *parse_verbatim_kbinput(WINDOW *win, size_t *count)
}
/* Convert the Unicode value to a multibyte sequence. */
multibyte = make_mbchar(unicode, (int *)count);
*count = wctomb(multibyte, unicode);
if (*count > MAXCHARLEN)
*count = 0;
/* Change the multibyte character into a series of integers. */
for (size_t i = 0; i < *count; i++)
yield[i] = (int)multibyte[i];
free(multibyte);
return yield;
}
#endif /* ENABLE_UTF8 */
@@ -1695,32 +1700,35 @@ void set_blankdelay_to_one(void)
statusblank = 1;
}
/* Convert buf into a string that can be displayed on screen. The caller
* wants to display buf starting with the given column, and extending for
/* Convert text into a string that can be displayed on screen. The caller
* wants to display text starting with the given column, and extending for
* at most span columns. column is zero-based, and span is one-based, so
* span == 0 means you get "" returned. The returned string is dynamically
* allocated, and should be freed. If isdata is TRUE, the caller might put
* "<" at the beginning or ">" at the end of the line if it's too long. If
* isprompt is TRUE, the caller might put ">" at the end of the line if it's
* too long. */
char *display_string(const char *buf, size_t column, size_t span,
char *display_string(const char *text, size_t column, size_t span,
bool isdata, bool isprompt)
{
size_t start_index = actual_x(buf, column);
const char *origin = text;
/* The beginning of the text, to later determine the covered part. */
size_t start_x = actual_x(text, column);
/* The index of the first character that the caller wishes to show. */
size_t start_col = wideness(buf, start_index);
size_t start_col = wideness(text, start_x);
/* The actual column where that first character starts. */
char *converted;
/* The expanded string we will return. */
size_t stowaways = 20;
/* The number of zero-width characters for which to reserve space. */
size_t allocsize = (COLS + stowaways) * MAXCHARLEN + 1;
/* The amount of memory to reserve for the displayable string. */
char *converted = nmalloc(allocsize);
/* The displayable string we will return. */
size_t index = 0;
/* Current position in converted. */
size_t beyond = column + span;
/* The column number just beyond the last shown character. */
buf += start_index;
/* Allocate enough space for converting the relevant part of the line. */
converted = nmalloc(strlen(buf) * (MAXCHARLEN + tabsize) + 1);
text += start_x;
#ifndef NANO_TINY
if (span > HIGHEST_POSITIVE) {
@@ -1731,17 +1739,17 @@ char *display_string(const char *buf, size_t column, size_t span,
#endif
/* If the first character starts before the left edge, or would be
* overwritten by a "<" token, then show placeholders instead. */
if (*buf != '\0' && *buf != '\t' && (start_col < column ||
(start_col > 0 && isdata && !ISSET(SOFTWRAP)))) {
if (is_cntrl_char(buf)) {
if ((start_col < column || (start_col > 0 && isdata && !ISSET(SOFTWRAP))) &&
*text != '\0' && *text != '\t') {
if (is_cntrl_char(text)) {
if (start_col < column) {
converted[index++] = control_mbrep(buf, isdata);
converted[index++] = control_mbrep(text, isdata);
column++;
buf += char_length(buf);
text += char_length(text);
}
}
#ifdef ENABLE_UTF8
else if (mbwidth(buf) == 2) {
else if (is_doublewidth(text)) {
if (start_col == column) {
converted[index++] = ' ';
column++;
@@ -1750,29 +1758,29 @@ char *display_string(const char *buf, size_t column, size_t span,
/* Display the right half of a two-column character as ']'. */
converted[index++] = ']';
column++;
buf += char_length(buf);
text += char_length(text);
}
#endif
}
#ifdef ENABLE_UTF8
#define ISO8859_CHAR FALSE
#define ZEROWIDTH_CHAR (mbwidth(buf) == 0)
#define ZEROWIDTH_CHAR (is_zerowidth(text))
#else
#define ISO8859_CHAR ((unsigned char)*buf > 0x9F)
#define ISO8859_CHAR ((unsigned char)*text > 0x9F)
#define ZEROWIDTH_CHAR FALSE
#endif
while (*buf != '\0' && (column < beyond || ZEROWIDTH_CHAR)) {
while (*text != '\0' && (column < beyond || ZEROWIDTH_CHAR)) {
/* A plain printable ASCII character is one byte, one column. */
if (((signed char)*buf > 0x20 && *buf != DEL_CODE) || ISO8859_CHAR) {
converted[index++] = *(buf++);
if (((signed char)*text > 0x20 && *text != DEL_CODE) || ISO8859_CHAR) {
converted[index++] = *(text++);
column++;
continue;
}
/* Show a space as a visible character, or as a space. */
if (*buf == ' ') {
if (*text == ' ') {
#ifndef NANO_TINY
if (ISSET(WHITESPACE_DISPLAY)) {
for (int i = whitelen[0]; i < whitelen[0] + whitelen[1];)
@@ -1781,12 +1789,12 @@ char *display_string(const char *buf, size_t column, size_t span,
#endif
converted[index++] = ' ';
column++;
buf++;
text++;
continue;
}
/* Show a tab as a visible character plus spaces, or as just spaces. */
if (*buf == '\t') {
if (*text == '\t') {
#ifndef NANO_TINY
if (ISSET(WHITESPACE_DISPLAY) && (index > 0 || !isdata ||
!ISSET(SOFTWRAP) || column % tabsize == 0 ||
@@ -1802,15 +1810,15 @@ char *display_string(const char *buf, size_t column, size_t span,
converted[index++] = ' ';
column++;
}
buf++;
text++;
continue;
}
/* Represent a control character with a leading caret. */
if (is_cntrl_char(buf)) {
if (is_cntrl_char(text)) {
converted[index++] = '^';
converted[index++] = control_mbrep(buf, isdata);
buf += char_length(buf);
converted[index++] = control_mbrep(text, isdata);
text += char_length(text);
column += 2;
continue;
}
@@ -1820,14 +1828,14 @@ char *display_string(const char *buf, size_t column, size_t span,
wchar_t wc;
/* Convert a multibyte character to a single code. */
charlength = mbtowc(&wc, buf, MAXCHARLEN);
charlength = mbtowide(&wc, text);
/* Represent an invalid character with the Replacement Character. */
if (charlength < 0 || !is_valid_unicode(wc)) {
if (charlength < 0) {
converted[index++] = '\xEF';
converted[index++] = '\xBF';
converted[index++] = '\xBD';
buf += (charlength > 0 ? charlength : 1);
text++;
column++;
continue;
}
@@ -1835,17 +1843,24 @@ char *display_string(const char *buf, size_t column, size_t span,
/* Determine whether the character takes zero, one, or two columns. */
charwidth = wcwidth(wc);
/* Watch the number of zero-widths, to keep ample memory reserved. */
if (charwidth == 0 && --stowaways == 0) {
stowaways = 40;
allocsize += stowaways * MAXCHARLEN;
converted = nrealloc(converted, allocsize);
}
#ifdef __linux__
/* On a Linux console, skip zero-width characters, as it would show
* them WITH a width, thus messing up the display. See bug #52954. */
if (on_a_vt && charwidth == 0) {
buf += charlength;
text += charlength;
continue;
}
#endif
/* For any valid character, just copy its bytes. */
for (; charlength > 0; charlength--)
converted[index++] = *(buf++);
converted[index++] = *(text++);
/* If the codepoint is unassigned, assume a width of one. */
column += (charwidth < 0 ? 1 : charwidth);
@@ -1853,15 +1868,15 @@ char *display_string(const char *buf, size_t column, size_t span,
}
/* If there is more text than can be shown, make room for the ">". */
if (column > beyond || (*buf != '\0' && (isprompt ||
if (column > beyond || (*text != '\0' && (isprompt ||
(isdata && !ISSET(SOFTWRAP))))) {
#ifdef ENABLE_UTF8
do {
index = step_left(converted, index);
} while (mbwidth(converted + index) == 0);
} while (is_zerowidth(converted + index));
/* Display the left half of a two-column character as '['. */
if (mbwidth(converted + index) == 2)
if (is_doublewidth(converted + index))
converted[index++] = '[';
#else
index--;
@@ -1875,6 +1890,10 @@ char *display_string(const char *buf, size_t column, size_t span,
/* Null-terminate the converted string. */
converted[index] = '\0';
/* Remember what part of the original text is covered by converted. */
from_x = start_x;
till_x = text - origin;
return converted;
}
@@ -2084,10 +2103,9 @@ void minibar(void)
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
mvwprintw(bottomwin, 0, 0, "%*s", COLS, " ");
/* Display the name of the current file, plus a star when modified. */
if (openfile->filename[0] != '\0') {
as_an_at = FALSE;
thename = display_string(openfile->filename, 0, HIGHEST_POSITIVE, FALSE, FALSE);
thename = display_string(openfile->filename, 0, COLS, FALSE, FALSE);
} else
thename = copy_of(_("(nameless)"));
@@ -2099,8 +2117,9 @@ void minibar(void)
if (namewidth + 19 > COLS)
padding = 0;
/* Display the name of the current file (dottifying it if it doesn't fit),
* plus a star when the file has been modified. */
if (COLS > 4) {
/* If the full file name doesn't fit, dottify it. */
if (namewidth > COLS - 2) {
thename = display_string(thename, namewidth - COLS + 5, COLS - 5, FALSE, FALSE);
mvwaddstr(bottomwin, 0, 0, "...");
@@ -2111,6 +2130,8 @@ void minibar(void)
waddstr(bottomwin, openfile->modified ? " *" : " ");
}
/* Right after reading or writing a file, display its number of lines;
* otherwise, when there a mutiple buffers, display an [x/n] counter. */
if (report_size && COLS > 35) {
size_t count = openfile->filebot->lineno - (openfile->filebot->data[0] == '\0');
@@ -2136,7 +2157,8 @@ void minibar(void)
if (ISSET(CONSTANT_SHOW) && namewidth + tallywidth + placewidth + 32 < COLS)
mvwaddstr(bottomwin, 0, COLS - 27 - placewidth, location);
/* Display the hexadecimal code of the character under the cursor. */
/* Display the hexadecimal code of the character under the cursor,
* plus the codes of upto two succeeding zero-width characters. */
if (ISSET(CONSTANT_SHOW) && namewidth + tallywidth + 28 < COLS) {
char *this_position = openfile->current->data + openfile->current_x;
@@ -2151,7 +2173,7 @@ void minibar(void)
#ifdef ENABLE_UTF8
else if ((unsigned char)*this_position < 0x80 && using_utf8())
sprintf(hexadecimal, "U+%04X", (unsigned char)*this_position);
else if (using_utf8() && mbtowc(&widecode, this_position, MAXCHARLEN) >= 0)
else if (using_utf8() && mbtowide(&widecode, this_position) > 0)
sprintf(hexadecimal, "U+%04X", (int)widecode);
#endif
else
@@ -2163,13 +2185,13 @@ void minibar(void)
successor = this_position + char_length(this_position);
if (*this_position && *successor && is_zerowidth(successor) &&
mbtowc(&widecode, successor, MAXCHARLEN) >= 0) {
mbtowide(&widecode, successor) > 0) {
sprintf(hexadecimal, "|%04X", (int)widecode);
waddstr(bottomwin, hexadecimal);
successor += char_length(successor);
if (is_zerowidth(successor) && mbtowc(&widecode, successor, MAXCHARLEN) >= 0) {
if (is_zerowidth(successor) && mbtowide(&widecode, successor) > 0) {
sprintf(hexadecimal, "|%04X", (int)widecode);
waddstr(bottomwin, hexadecimal);
}
@@ -2223,6 +2245,18 @@ void statusline(message_type importance, const char *msg, ...)
if (importance < lastmessage && lastmessage > NOTICE)
return;
/* Construct the message out of all the arguments. */
compound = nmalloc(MAXCHARLEN * COLS + 1);
va_start(ap, msg);
vsnprintf(compound, MAXCHARLEN * COLS + 1, msg, ap);
va_end(ap);
#if !defined(NANO_TINY) && defined(ENABLE_MULTIBUFFER)
if (!we_are_running && importance == ALERT && openfile && !openfile->fmt &&
!openfile->errormessage && openfile->next != openfile)
openfile->errormessage = copy_of(compound);
#endif
/* If there are multiple alert messages, add trailing dots to the first. */
if (lastmessage == ALERT) {
if (start_col > 4) {
@@ -2235,6 +2269,7 @@ void statusline(message_type importance, const char *msg, ...)
napms(100);
beep();
}
free(compound);
return;
}
@@ -2251,11 +2286,6 @@ void statusline(message_type importance, const char *msg, ...)
blank_statusbar();
/* Construct the message out of all the arguments. */
compound = nmalloc(MAXCHARLEN * (COLS + 1));
va_start(ap, msg);
vsnprintf(compound, MAXCHARLEN * (COLS + 1), msg, ap);
va_end(ap);
message = display_string(compound, 0, COLS, FALSE, FALSE);
free(compound);
@@ -2267,7 +2297,6 @@ void statusline(message_type importance, const char *msg, ...)
if (bracketed)
waddstr(bottomwin, "[ ");
waddstr(bottomwin, message);
free(message);
if (bracketed)
waddstr(bottomwin, " ]");
wattroff(bottomwin, colorpair);
@@ -2280,6 +2309,7 @@ void statusline(message_type importance, const char *msg, ...)
/* Push the message to the screen straightaway. */
wrefresh(bottomwin);
free(message);
#ifndef NANO_TINY
if (old_whitespace)
@@ -2429,15 +2459,6 @@ void place_the_cursor(void)
* from_col is the column number of the first character of this "page". */
void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
{
#if !defined(NANO_TINY) || defined(ENABLE_COLOR)
size_t from_x = actual_x(line->data, from_col);
/* The position in the line's data of the leftmost character
* that is at least partially onscreen. */
size_t till_x = actual_x(line->data, from_col + editwincols - 1) + 1;
/* The position in the line's data just after the start of
* the last character that is at least partially onscreen. */
#endif
#ifdef ENABLE_LINENUMBERS
/* If line numbering is switched on, put a line number in front of
* the text -- but only for the parts that are not softwrapped. */
@@ -3034,22 +3055,26 @@ bool less_than_a_screenful(size_t was_lineno, size_t was_leftedge)
/* Draw a scroll bar on the righthand side of the screen. */
void draw_scrollbar(void)
{
int totalrows = openfile->filebot->lineno;
int first_row = openfile->edittop->lineno;
int totallines = openfile->filebot->lineno;
int fromline = openfile->edittop->lineno - 1;
int coveredlines = editwinrows;
if (ISSET(SOFTWRAP)) {
for (linestruct *ln = openfile->filetop; ln != openfile->edittop; ln = ln->next)
first_row += ln->extrarows;
first_row += chunk_for(openfile->firstcolumn, openfile->edittop);
linestruct *line = openfile->edittop;
int extras = extra_chunks_in(line) - chunk_for(openfile->firstcolumn, line);
for (linestruct *ln = openfile->filetop; ln != NULL; ln = ln->next)
totalrows += ln->extrarows;
while (line->lineno + extras < fromline + editwinrows && line->next) {
line = line->next;
extras += extra_chunks_in(line);
}
coveredlines = line->lineno - fromline;
}
int lowest = ((first_row - 1) * editwinrows) / totalrows;
int highest = lowest + (editwinrows * editwinrows) / totalrows;
int lowest = (fromline * editwinrows) / totallines;
int highest = lowest + (editwinrows * coveredlines) / totallines;
if (editwinrows > totalrows)
if (editwinrows > totallines)
highest = editwinrows;
for (int row = 0; row < editwinrows; row++) {
@@ -3263,14 +3288,11 @@ size_t actual_last_column(size_t leftedge, size_t column)
return leftedge + column;
}
/* Return TRUE if current[current_x] is above the top of the screen, and FALSE
* otherwise. */
/* Return TRUE if current[current_x] is before the viewport. */
bool current_is_above_screen(void)
{
#ifndef NANO_TINY
if (ISSET(SOFTWRAP))
/* The cursor is above screen when current[current_x] is before edittop
* at column firstcolumn. */
return (openfile->current->lineno < openfile->edittop->lineno ||
(openfile->current->lineno == openfile->edittop->lineno &&
xplustabs() < openfile->firstcolumn));
@@ -3279,8 +3301,7 @@ bool current_is_above_screen(void)
return (openfile->current->lineno < openfile->edittop->lineno);
}
/* Return TRUE if current[current_x] is below the bottom of the screen, and
* FALSE otherwise. */
/* Return TRUE if current[current_x] is beyond the viewport. */
bool current_is_below_screen(void)
{
#ifndef NANO_TINY
@@ -3293,16 +3314,14 @@ 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 < leftedge_for(xplustabs(),
openfile->current))));
leftedge < leftedge_for(xplustabs(), openfile->current))));
} else
#endif
return (openfile->current->lineno >=
openfile->edittop->lineno + editwinrows);
}
/* Return TRUE if current[current_x] is offscreen relative to edittop, and
* FALSE otherwise. */
/* Return TRUE if current[current_x] is outside the viewport. */
bool current_is_offscreen(void)
{
return (current_is_above_screen() || current_is_below_screen());
@@ -3478,9 +3497,11 @@ void report_cursor_position(void)
charpct = (openfile->totsize == 0) ? 0 : 100 * sum / openfile->totsize;
statusline(INFO,
_("line %zd/%zd (%d%%), col %zu/%zu (%d%%), char %zu/%zu (%d%%)"),
_("line %*zd/%zd (%2d%%), col %2zu/%2zu (%3d%%), char %*zu/%zu (%2d%%)"),
digits(openfile->filebot->lineno),
openfile->current->lineno, openfile->filebot->lineno, linepct,
column, fullwidth, colpct, sum, openfile->totsize, charpct);
column, fullwidth, colpct,
digits(openfile->totsize), sum, openfile->totsize, charpct);
}
/* Highlight the text between the given two columns on the current line. */
@@ -3504,11 +3525,11 @@ void spotlight(size_t from_col, size_t to_col)
word = display_string(openfile->current->data, from_col,
to_col - from_col, FALSE, overshoots);
wattron(edit, interface_color_pair[HIGHLIGHTED]);
wattron(edit, interface_color_pair[SPOTLIGHTED]);
waddnstr(edit, word, actual_x(word, to_col));
if (overshoots)
mvwaddch(edit, openfile->current_y, COLS - 1 - thebar, '>');
wattroff(edit, interface_color_pair[HIGHLIGHTED]);
wattroff(edit, interface_color_pair[SPOTLIGHTED]);
free(word);
}
@@ -3544,9 +3565,9 @@ void spotlight_softwrapped(size_t from_col, size_t to_col)
word = display_string(openfile->current->data, from_col,
break_col - from_col, FALSE, FALSE);
wattron(edit, interface_color_pair[SELECTED_TEXT]);
wattron(edit, interface_color_pair[SPOTLIGHTED]);
waddnstr(edit, word, actual_x(word, break_col));
wattroff(edit, interface_color_pair[SELECTED_TEXT]);
wattroff(edit, interface_color_pair[SPOTLIGHTED]);
free(word);

View File

@@ -8,8 +8,8 @@ color red "\<[A-Z_]{2,}\>"
color brightgreen "\.(data|subsection|text)"
color green "\.(align|file|globl|global|hidden|section|size|type|weak)"
color brightyellow "\.(ascii|asciz|byte|double|float|hword|int|long|short|single|struct|word)"
color brightred "^[[:space:]]*[.0-9A-Za-z_]*:"
color brightcyan "^[[:space:]]*#[[:space:]]*(define|undef|include|ifn?def|endif|elif|else|if|warning|error)"
color brightred "^[[:blank:]]*[.0-9A-Za-z_]*:"
color brightcyan "^[[:blank:]]*#[[:blank:]]*(define|undef|include|ifn?def|endif|elif|else|if|warning|error)"
# Strings.
color brightyellow "<[^= ]*>" ""(\\.|[^"])*""

View File

@@ -23,7 +23,7 @@ color red ""[^"]*"" "'[^']*'"
color green "`[^`]*`"
# Error lines:
color brightred "^[[:space:]]*\*\*\*.*"
color brightred "^[[:blank:]]*\*\*\*.*"
# Brackets:
color magenta "\[|\]|\(|\)"

View File

@@ -31,7 +31,7 @@ color magenta "\<(bindtextdomain|dcgettext|dcngettext)\>"
# Strings.
color brightyellow "<[^= ]*>" ""(\\.|[^"])*""
# Comments.
color brightblue "(^|[[:space:]])#.*$"
color brightblue "(^|[[:blank:]])#.*$"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -1,14 +1,15 @@
## Syntax highlighting for C and C++ files.
syntax c "\.([ch](pp|xx)?|C|cc|c\+\+|cu|H|hh|ii?)$"
header "-\*-.*\<C(\+\+)?((;|\s).*)?-\*-"
header "-\*-.*\<C(\+\+)?((;|[[:blank:]]).*)?-\*-"
magic "^(C|C\+\+) (source|program)"
comment "//"
# Constants.
color brightred "\<[A-Z_][0-9A-Z_]*\>"
# Labels.
color brightmagenta "^[[:space:]]*[A-Z_a-z]+:[[:space:]]*$"
color brightmagenta "^[[:blank:]]*[A-Z_a-z][0-9A-Z_a-z]*:[[:blank:]]*$"
color normal ":[[:blank:]]*$"
# Types and related keywords.
color green "\<(auto|bool|char|const|double|enum|extern|float|inline|int|long|restrict|short|signed|sizeof|static|struct|typedef|union|unsigned|void)\>"
@@ -25,15 +26,15 @@ color magenta "\<(break|continue|goto|return)\>"
color brightmagenta "'([^'\]|\\(["'\abfnrtv]|x[0-9A-Fa-f]{1,2}|[0-3]?[0-7]{1,2}))'"
# GCC builtins.
color cyan "__attribute__[[:space:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
color cyan "__attribute__[[:blank:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
# Strings. (In general you will want your strings and comments to come last,
# because highlighting rules are applied in the order they are read in.)
color brightyellow ""([^"]|\\")*"" "#[[:space:]]*include[[:space:]]+<[^[:blank:]=]*>"
color brightyellow ""([^"]|\\")*"" "#[[:blank:]]*include[[:blank:]]*<[^>]+>"
# Preprocessor directives.
color brightcyan start="^[[:space:]]*#[[:space:]]*(if(n?def)?|elif|warning|error|pragma)\>" end="(\`|[^\\])$"
color brightcyan "^[[:space:]]*#[[:space:]]*((define|else|endif|include(_next)?|line|undef)\>|$)"
color brightcyan start="^[[:blank:]]*#[[:blank:]]*(if(n?def)?|elif|warning|error|pragma)\>" end="(\`|[^\\])$"
color brightcyan "^[[:blank:]]*#[[:blank:]]*((define|else|endif|include(_next)?|line|undef)\>|$)"
# Comments.
color brightblue "//.*"

View File

@@ -13,7 +13,7 @@ color red "^(19|20)[0-9-]{8}"
color yellow "<[^>]*@[^>]*>"
# Command-line options.
color cyan "[[:space:]]-[a-zA-Z\$]" "--[8a-z-]+"
color cyan "[[:blank:]]-[a-zA-Z\$]" "--[8a-z-]+"
# Bug and patch numbers.
color cyan "(BZ|bug|patch)[ ]#[0-9]+" "PR [[:alnum:]]+/[0-9]+"
# Probable constants, for variety.

View File

@@ -3,17 +3,17 @@
syntax cmake "(CMakeLists\.txt|\.cmake)$"
comment "#"
color green "^[[:space:]]*[0-9A-Za-z_]+"
icolor brightyellow "^[[:space:]]*(include|include_directories|include_external_msproject)\>"
color green "^[[:blank:]]*[0-9A-Za-z_]+"
icolor brightyellow "^[[:blank:]]*(include|include_directories|include_external_msproject)\>"
icolor brightgreen "^[[:space:]]*((else|end)?if|else|(end)?while|(end)?foreach|break)\>"
color brightgreen "\<(NOT|COMMAND|POLICY|TARGET|EXISTS|IS_(DIRECTORY|ABSOLUTE)|DEFINED)[[:space:]]"
color brightgreen "[[:space:]](OR|AND|IS_NEWER_THAN|MATCHES|(STR|VERSION_)?(LESS|GREATER|EQUAL))[[:space:]]"
icolor brightgreen "^[[:blank:]]*((else|end)?if|else|(end)?while|(end)?foreach|break)\>"
color brightgreen "\<(NOT|COMMAND|POLICY|TARGET|EXISTS|IS_(DIRECTORY|ABSOLUTE)|DEFINED)[[:blank:]]"
color brightgreen "[[:blank:]](OR|AND|IS_NEWER_THAN|MATCHES|(STR|VERSION_)?(LESS|GREATER|EQUAL))[[:blank:]]"
icolor brightred "^[[:space:]]*((end)?(function|macro)|return)"
icolor brightred "^[[:blank:]]*((end)?(function|macro)|return)"
icolor cyan start="\$(ENV)?\{" end="\}"
color magenta "\<(APPLE|UNIX|WIN32|CYGWIN|BORLAND|MINGW|MSVC(_IDE|60|71|80|90)?)\>"
color brightblue "(^|[[:space:]])#.*"
color brightblue "(^|[[:blank:]])#.*"
color ,green "[[:space:]]+$"

View File

@@ -5,7 +5,7 @@ syntax default
comment "#"
# Comments.
color cyan "^[[:space:]]*#.*"
color cyan "^[[:blank:]]*#.*"
# Spaces in front of tabs.
color ,red " + +"

View File

@@ -30,4 +30,4 @@ color blue ":(\w|[?-])+"
color yellow start="^[[:blank:]]+"" end="[^\]""
color yellow ""(\\.|[^"])*""
# Comments
color cyan "(^|[[:space:]]);.*"
color cyan "(^|[[:blank:]]);.*"

View File

@@ -11,7 +11,7 @@ formatter gofmt -w
# Types.
color green "\<(bool|u?int(8|16|32|64)?|float(32|64)|complex(64|128)|byte|rune|uintptr|string|error)\>"
color green "\<(chan|const|func|interface|map|struct|type|var)\>"
color green "<-[[:space:]]*chan\>|\<chan[[:space:]]*<-"
color green "<-[[:blank:]]*chan\>|\<chan[[:blank:]]*<-"
# Predefined functions.
color blue "\<(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)\>"
@@ -36,14 +36,14 @@ color red "\<[0-9]+i\>"
color red "\<(true|false|nil|iota|_)\>"
color red "'(\\.|[^'])+'"
color red ""(\\.|[^"])*""
color red start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*""
color red start=""(\\.|[^"])*\\[[:blank:]]*$" end="^(\\.|[^"])*""
# Comments.
color brightblue "//.*"
color brightblue start="/\*" end="\*/"
# Special comments.
color brightcyan "//[[:space:]]*\+build[[:space:]]+(([a-zA-Z_0-9]+[[:space:]]*)+,[[:space:]]*)*[a-zA-Z_0-9]+"
color brightcyan "//[[:blank:]]*\+build[[:blank:]]+(([a-zA-Z_0-9]+[[:blank:]]*)+,[[:blank:]]*)*[a-zA-Z_0-9]+"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -13,7 +13,7 @@ color brightmagenta "\\f(.|\(..)" "\\s(\+|\-)?[0-9]"
color cyan "\\(\\)?n(.|\(..)"
color cyan start="\\(\\)?n\[" end="]"
# Requests
color brightgreen "^\.[[:space:]]*[^[:space:]]*"
color brightgreen "^\.[[:blank:]]*[^[:space:]]*"
# Comments
color yellow "^\.\\".*"
# Strings

View File

@@ -21,4 +21,4 @@ color blue "#?:(\w|[?-])+"
color yellow start="^[[:blank:]]+"" end="[^\]""
color yellow ""(\\.|[^"])*""
# Comments
color cyan "(^|[[:space:]]);.*"
color cyan "(^|[[:blank:]]);.*"

View File

@@ -19,7 +19,7 @@ color cyan "\<(true|false|null|undefined)\>"
# Strings.
color brightmagenta ""(\\.|[^"])*"" "'(\\.|[^'])*'" "`(\\.|[^`])*`"
# Comments.
color brightblue "(^|[[:space:]])//.*"
color brightblue "(^|[[:blank:]])//.*"
color brightblue start="/\*" end="\*/"
# Trailing whitespace.

View File

@@ -8,18 +8,18 @@ syntax json "\.json$"
comment ""
# Numbers (used as value).
color green ":[[:space:]]*\-?(0|[1-9][0-9]*)(\.[0-9]+)?([Ee]?[-+]?[0-9]+)?"
color green ":[[:blank:]]*\-?(0|[1-9][0-9]*)(\.[0-9]+)?([Ee]?[-+]?[0-9]+)?"
# Values (well, any string).
color brightmagenta "".+""
# Hex numbers (used as value).
color green ":[[:space:]]*"#[0-9abcdefABCDEF]+""
color green ":[[:blank:]]*"#[0-9abcdefABCDEF]+""
# Escapes.
color green "\\\\" "\\"" "\\[bfnrt]" "\\u[0-9abcdefABCDEF]{4})"
# Special words.
color green "\<(true|false|null)\>"
# Names (very unlikely to contain a quote).
color brightblue ""[^"]+"[[:space:]]*:"
color brightblue ""[^"]+"[[:blank:]]*:"
# Brackets, braces, and separators.
color brightblue "\[" "\]"
@@ -27,7 +27,7 @@ color brightred "\{" "\}"
color brightred "," ":"
# Comments.
color cyan "(^|[[:space:]]+)(//|#).*"
color cyan "(^|[[:blank:]]+)(//|#).*"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -20,7 +20,7 @@ color normal "\.\.\."
color brightblue "\<(do|end|while|repeat|until|if|elseif|then|else|for|in|function|local|return|break)\>"
# Keywords
color brightyellow "\<(_G|_VERSION|assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|module|next|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\s*\("
color brightyellow "\<(_G|_VERSION|assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|module|next|pairs|pcall|print|rawequal|rawget|rawlen|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)[[:blank:]]*\("
# Standard library
color brightyellow "\<coroutine\.(create|isyieldable|resume|running|status|wrap|yield)\>"

View File

@@ -18,7 +18,7 @@ color blue "\$+[{(][a-zA-Z0-9_-]+[})]"
color brightblue "^[^ ]+:"
# Comments.
color green "(^|[[:space:]]+)#.*"
color green "(^|[[:blank:]]+)#.*"
# Trailing whitespace.
color ,green "[[:space:]]+$"

View File

@@ -7,26 +7,26 @@ comment "#"
color brightred ".*"
# Keywords
color brightgreen "^[[:space:]]*(set|unset)[[:space:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|boldtext|bookstyle|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|historylog|indicator|jumpyscrolling|linenumbers|locking|magic|minibar|mouse|multibuffer|noconvert|nohelp|nonewlines|positionlog|preserve|quickblank|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|softwrap|stateflags|suspendable|tabstospaces|trimblanks|unix|wordbounds|zap)\>"
color yellow "^[[:space:]]*set[[:space:]]+((error|function|highlight|key|number|prompt|scroller|selected|status|stripe|title)color)[[:space:]]+(bold,)?(italic,)?(bright|light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte)?(,(light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte))?\>"
color brightgreen "^[[:space:]]*set[[:space:]]+(backupdir|brackets|errorcolor|functioncolor|highlightcolor|keycolor|matchbrackets|numbercolor|operatingdir|promptcolor|punct|quotestr|scrollercolor|selectedcolor|speller|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:space:]]+"
color brightgreen "^[[:space:]]*set[[:space:]]+(fill[[:space:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:space:]]+[1-9][0-9]*)\>"
color brightgreen "^[[:space:]]*bind[[:space:]]+((\^([A-Za-z]|[]/@\^_`]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:space:]]+([a-z]+|".*")[[:space:]]+(main|help|search|replace(with)?|yesno|gotoline|writeout|insert|browser|whereisfile|gotodir|execute|spell|linter|all)([[:space:]]+#|[[:space:]]*$)"
color brightgreen "^[[:space:]]*unbind[[:space:]]+((\^([A-Za-z]|[]/@\^_`]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:space:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:space:]]+#|[[:space:]]*$)"
color brightgreen "^[[:space:]]*extendsyntax[[:space:]]+[[:alpha:]]+[[:space:]]+(i?color|header|magic|comment|formatter|linter|tabgives)[[:space:]]+.*"
color brightgreen "^[[:space:]]*(syntax[[:space:]]+[^[:blank:]]+|(formatter|linter)[[:space:]]+.+)"
color green "^[[:space:]]*((un)?(bind|set)|include|syntax|header|magic|comment|formatter|linter|tabgives|extendsyntax)\>"
color brightgreen "^[[:blank:]]*(set|unset)[[:blank:]]+(afterends|allow_insecure_backup|atblanks|autoindent|backup|boldtext|bookstyle|breaklonglines|casesensitive|constantshow|cutfromcursor|emptyline|historylog|indicator|jumpyscrolling|linenumbers|locking|magic|minibar|mouse|multibuffer|noconvert|nohelp|nonewlines|positionlog|preserve|quickblank|rawsequences|rebinddelete|regexp|saveonexit|showcursor|smarthome|softwrap|stateflags|suspendable|tabstospaces|trimblanks|unix|wordbounds|zap)\>"
color yellow "^[[:blank:]]*set[[:blank:]]+((error|function|key|number|prompt|scroller|selected|spotlight|status|stripe|title)color)[[:blank:]]+(bold,)?(italic,)?(bright|light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte)?(,(light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte))?\>"
color brightgreen "^[[:blank:]]*set[[:blank:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|numbercolor|operatingdir|promptcolor|punct|quotestr|scrollercolor|selectedcolor|speller|spotlightcolor|statuscolor|stripecolor|titlecolor|whitespace|wordchars)[[:blank:]]+"
color brightgreen "^[[:blank:]]*set[[:blank:]]+(fill[[:blank:]]+-?[[:digit:]]+|(guidestripe|tabsize)[[:blank:]]+[1-9][0-9]*)\>"
color brightgreen "^[[:blank:]]*bind[[:blank:]]+((\^([A-Za-z]|[]/@\^_`]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:blank:]]+([a-z]+|".*")[[:blank:]]+(main|help|search|replace(with)?|yesno|gotoline|writeout|insert|browser|whereisfile|gotodir|execute|spell|linter|all)([[:blank:]]+#|[[:blank:]]*$)"
color brightgreen "^[[:blank:]]*unbind[[:blank:]]+((\^([A-Za-z]|[]/@\^_`]|Space)|([Ss][Hh]-)?[Mm]-[A-Za-z]|[Mm]-([][!"#$%&'()*+,./0-9:;<=>?@\^_`{|}~-]|Space))|F([1-9]|1[0-9]|2[0-4])|Ins|Del)[[:blank:]]+(all|main|search|replace(with)?|yesno|gotoline|writeout|insert|ext(ernal)?cmd|help|spell|linter|browser|whereisfile|gotodir)([[:blank:]]+#|[[:blank:]]*$)"
color brightgreen "^[[:blank:]]*extendsyntax[[:blank:]]+[[:alpha:]]+[[:blank:]]+(i?color|header|magic|comment|formatter|linter|tabgives)[[:blank:]]+.*"
color brightgreen "^[[:blank:]]*(syntax[[:blank:]]+[^[:space:]]+|(formatter|linter)[[:blank:]]+.+)"
color green "^[[:blank:]]*((un)?(bind|set)|include|syntax|header|magic|comment|formatter|linter|tabgives|extendsyntax)\>"
# Strings
color brightmagenta "([[:space:]]|(start|end)=)".+"([[:space:]]|$)"
color brightmagenta "([[:blank:]]|(start|end)=)".+"([[:blank:]]|$)"
# Colors
color yellow "^[[:space:]]*i?color[[:space:]]*(bold,)?(italic,)?(bright|light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte)?(,(light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte))?\>"
color magenta "^[[:space:]]*i?color\>" "\<(start|end)="
color yellow "^[[:blank:]]*i?color[[:blank:]]*(bold,)?(italic,)?(bright|light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte)?(,(light)?(white|black|red|blue|green|yellow|magenta|cyan|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte))?\>"
color magenta "^[[:blank:]]*i?color\>" "\<(start|end)="
# Comments
color brightblue "(^|[[:space:]]+)#.*"
color cyan "^[[:space:]]*##.*"
color brightblue "(^|[[:blank:]]+)#.*"
color cyan "^[[:blank:]]*##.*"
# Trailing whitespace
color ,green "[[:space:]]+$"

View File

@@ -20,7 +20,7 @@ color red "\<(drop|reject)\>"
color brightblue "\<(accept|continue|(d|s)nat|goto|jump|masquerade|return)\>"
# Comments
color cyan "(^|[[:space:]])#.*"
color cyan "(^|[[:blank:]])#.*"
# Trailing whitespace
color ,green "[[:space:]]+$"

View File

@@ -15,13 +15,13 @@ color brightgreen "\<(goto|continue|break|return)\>"
color brightgreen "@(encode|end|implementation|interface)|selector)\>"
# GCC builtins.
color cyan "__attribute__[[:space:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
color cyan "__attribute__[[:blank:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__"
# Selector/method.
color brightmagenta "(^|[[:space:]])\[.*[[:space:]].*\]"
color brightmagenta "(^|[[:blank:]])\[.*[[:blank:]].*\]"
color white ":[[:alnum:]]*"
color magenta "[[:alnum:]]*:"
color white "\[[^][:space:]]*\]"
color white "\[[^][:blank:]]*\]"
# Strings.
color brightblack "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'"
@@ -29,7 +29,7 @@ color brightblack "<[^= ]*>" ""(\\.|[^"])*""
color brightblue "@"(\\.|[^"])*""
# Preprocessor commands.
color brightblue "^[[:space:]]*#[[:space:]]*(define|include|import|(un|ifn?)def|endif|el(if|se)|if|warning|error)"
color brightblue "^[[:blank:]]*#[[:blank:]]*(define|include|import|(un|ifn?)def|endif|el(if|se)|if|warning|error)"
# Comments.
color yellow "//.*"

View File

@@ -12,13 +12,13 @@ color magenta "\<(continue|else|elsif|do|for|foreach|if|unless|until|while|eq|ne
color cyan "[$%&@]([A-Za-z_][0-9A-Za-z_]*|\^[][A-Z?\^_]|[0-9]+)\>"
color cyan "[$%&@]\{(\^?[A-Za-z_][0-9A-Za-z_]*|\^[][?\^][0-9]+)\}"
color cyan "[$%&@]([][!"#'()*+,.:;<=>?`|~-]|\{[][!-/:-@\`|~]\})|\$[$%&@]"
color cyan "(^|[[:space:]])[$%@][/\]"
color cyan "(^|[[:blank:]])[$%@][/\]"
color yellow "".*"|qq\|.*\|"
color white "[sm]/.*/"
color white start="(^use| = new)" end=";"
# Comments.
color green "(^|[[:space:]])#.*"
color green "(^|[[:blank:]])#.*"
color yellow start="<< 'STOP'" end="STOP"

View File

@@ -28,7 +28,7 @@ color magenta "\<(break|continue|goto|return)\>"
color brightyellow ""(\.|[^"])*"" "'(\.|[^'])*'"
# Comments.
color brightblue "(^|[[:space:]]+)//.*"
color brightblue "(^|[[:blank:]]+)//.*"
color brightblue start="/\*" end="\*/"
# Trailing whitespace.

View File

@@ -22,7 +22,7 @@ color brightblue "^(msgid|msgid_plural|msgstr)\>"
color red " fuzzy(,|$)"
color yellow " (no-)?[-[:alpha:]]+-format(,|$)"
# Format specifiers.
color brightmagenta "%([1-9]\$)?[a-z]*"
color brightmagenta "%([1-9]\$)?[#0 +'I-]?(\*([1-9]\$)?|[1-9](\.[0-9]?)?)?[hlLjzt]?[diouxXeEfFgGaAcspnm%]"
# Quotes and escaped characters.
color yellow """
color cyan "\\([abcefnrtv"\]|x[0-9abcdefABCDEF]{2}|[0-7]{3})"

View File

@@ -1,7 +1,7 @@
## Syntax highlighting for Bourne shell scripts.
syntax sh "(\.sh|(\.|/)(a|ba|c|da|k|mk|pdk|tc|z)sh(rc|_profile)?|/(etc/|\.)profile)$"
header "^#!.*/((env\s+)?((a|ba|c|da|k|mk|pdk|tc|z)?sh)|busybox\s+sh|openrc-run|runscript)\>"
header "^#!.*/((env[[:blank:]]+)?((a|ba|c|da|k|mk|pdk|tc|z)?sh)|busybox[[:blank:]]+sh|openrc-run|runscript)\>"
header "-\*-.*shell-script.*-\*-"
magic "(POSIX|Bourne-Again) shell script.*text"
comment "#"
@@ -27,10 +27,10 @@ color normal "[.-]tar\>"
# Basic variable names (no braces).
color brightred "\$[-0-9@*#?$!]" "\$[[:alpha:]_][[:alnum:]_]*"
# More complicated variable names; handles braces and replacements and arrays.
color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:space:]]*[[:alnum:]_]+[[:space:]]*|@)\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
color brightred "\$\{[#!]?([-@*#?$!]|[0-9]+|[[:alpha:]_][[:alnum:]_]*)(\[([[:blank:]]*[[:alnum:]_]+[[:blank:]]*|@)\])?(([#%/]|:?[-=?+])[^}]*\}|\[|\})"
# Comments.
color cyan "(^|[[:space:]])#.*"
color cyan "(^|[[:blank:]])#.*"
# Strings.
color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"

View File

@@ -1,22 +1,27 @@
## Syntax highlighting for Tcl files.
## Syntax highlighting for Tcl and Expect scripts.
syntax tcl "\.tcl$"
syntax tcl "\.(tcl|exp)$"
magic "Tcl(/Tk)? script"
comment "#"
# Standard Tcl [info commands]:
color green "\<(after|append|array|auto_execok|auto_import|auto_load|auto_load_index|auto_qualify|binary|break|case|catch|cd|clock|close|concat|continue|encoding|eof|error|eval|exec|exit|expr|fblocked|fconfigure|fcopy|file|fileevent|flush|for|foreach|format|gets|glob|global|history|if|incr|info|interp|join|lappend|lindex|linsert|list|llength|load|lrange|lreplace|lsearch|lset|lsort|namespace|open|package|pid|puts|pwd|read|regexp|regsub|rename|return|scan|seek|set|socket|source|split|string|subst|switch|tclLog|tell|time|trace|unknown|unset|update|uplevel|upvar|variable|vwait|while)\>"
# Basic Tcl subcommands:
color green "\<array (anymore|donesearch|exists|get|names|nextelement|set|size|startsearch|statistics|unset)\>"
color green "\<string (bytelength|compare|equal|first|index|is|last|length|map|match|range|repeat|replace|to|tolower|totitle|toupper|trim|trimleft|trimright|will|wordend|wordstart)\>"
# Extended TclX [info commands]:
color green "\<(alarm|auto_load_pkg|bsearch|catclose|catgets|catopen|ccollate|cconcat|cequal|chgrp|chmod|chown|chroot|cindex|clength|cmdtrace|commandloop|crange|csubstr|ctoken|ctype|dup|echo|execl|fcntl|flock|fork|fstat|ftruncate|funlock|host_info|id|infox|keyldel|keylget|keylkeys|keylset|kill|lassign|lcontain|lempty|lgets|link|lmatch|loadlibindex|loop|lvarcat|lvarpop|lvarpush|max|min|nice|pipe|profile|random|readdir|replicate|scancontext|scanfile|scanmatch|select|server_accept|server_create|signal|sleep|sync|system|tclx_findinit|tclx_fork|tclx_load_tndxs|tclx_sleep|tclx_system|tclx_wait|times|translit|try_eval|umask|wait)\>"
# Syntax:
color brightblue "\<proc[[:space:]]|\{|\}"
color brightblue "\<proc[[:blank:]]|\{|\}"
color green "\(|\)|\;|`|\\|\$|<|>|!|=|&|\|"
color brightyellow ""(\\.|[^"])*"" "'(\\.|[^'])*'"
color brightred "\$\{?[0-9A-Za-z_!@#$*?-]+\}?"
# Trailing whitespace:
color ,green "[[:space:]]+$"
# Comments:
color cyan "^[[:space:]]*#.*"
color cyan "^[[:blank:]]*#.*"