Compare commits
180 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f981cd5d9 | ||
|
|
44a6c4963b | ||
|
|
622bfb5b83 | ||
|
|
a2cb22faab | ||
|
|
9f8309fba8 | ||
|
|
bf7954bdb7 | ||
|
|
0371dd1bde | ||
|
|
7c53b133a1 | ||
|
|
b1e5f9d9a8 | ||
|
|
424969258a | ||
|
|
6d0fc38285 | ||
|
|
984c9e1078 | ||
|
|
101dc4e805 | ||
|
|
d7e3226158 | ||
|
|
74c6bdac9f | ||
|
|
73168bb1b9 | ||
|
|
f895f1beba | ||
|
|
e2e8bf0a3e | ||
|
|
3f340836a6 | ||
|
|
092c62ccb8 | ||
|
|
97dd505647 | ||
|
|
635977fe33 | ||
|
|
6ab70c2b0a | ||
|
|
3a86b24a3e | ||
|
|
77ca8735ab | ||
|
|
3a0922799d | ||
|
|
b27efce732 | ||
|
|
8974430c11 | ||
|
|
e044284998 | ||
|
|
4f9d55bb15 | ||
|
|
89adacff3d | ||
|
|
2314a1932f | ||
|
|
fb5eb4856b | ||
|
|
f857959b8e | ||
|
|
405c2162b5 | ||
|
|
8797ada815 | ||
|
|
30bafc70cc | ||
|
|
b38f0cbaf4 | ||
|
|
ceaae49b2d | ||
|
|
d1957819c4 | ||
|
|
7993fc8b12 | ||
|
|
51adf02d34 | ||
|
|
f23e98dd3a | ||
|
|
6472a6b828 | ||
|
|
b741b1c985 | ||
|
|
5f87ed5644 | ||
|
|
8d974cd292 | ||
|
|
2cf28f9db7 | ||
|
|
36ffb5f0ac | ||
|
|
07fd4c4598 | ||
|
|
44fb3e9991 | ||
|
|
088557c516 | ||
|
|
4712d46462 | ||
|
|
c01b13a32c | ||
|
|
b368faf11c | ||
|
|
7303f0c7b4 | ||
|
|
eb3cc3a32d | ||
|
|
02df950240 | ||
|
|
a69a8ce3ca | ||
|
|
8a03d55c53 | ||
|
|
544351f3be | ||
|
|
96ebaf8ab4 | ||
|
|
6b7c661fb7 | ||
|
|
6823831c06 | ||
|
|
ec82530125 | ||
|
|
a45e1f89c0 | ||
|
|
c1cd813dcb | ||
|
|
c96e62e33a | ||
|
|
6283557d2f | ||
|
|
af90f03ac5 | ||
|
|
588022ab8c | ||
|
|
cf0820549b | ||
|
|
f54bc6c7d6 | ||
|
|
2cdff6c32c | ||
|
|
49d8b99e4f | ||
|
|
bb81932422 | ||
|
|
5efb6836a8 | ||
|
|
48fa14acc0 | ||
|
|
eb7181b35e | ||
|
|
8db42023bb | ||
|
|
018a8e12ca | ||
|
|
b4a5aedc6c | ||
|
|
d6ed174d09 | ||
|
|
78f92e044a | ||
|
|
f11931a0dd | ||
|
|
31a6931be9 | ||
|
|
debb288115 | ||
|
|
c75a3839da | ||
|
|
b6a32fbd5f | ||
|
|
09e4c86606 | ||
|
|
20eb422829 | ||
|
|
90c6b572d0 | ||
|
|
712b574fb7 | ||
|
|
fd023d6dcf | ||
|
|
9c16be32d7 | ||
|
|
c3cdb099da | ||
|
|
682a088fb8 | ||
|
|
8c25bd0e94 | ||
|
|
20e122ef41 | ||
|
|
0dcac9188f | ||
|
|
1c010d8ec9 | ||
|
|
b020937475 | ||
|
|
e3f46b066a | ||
|
|
df7fe1280d | ||
|
|
929770191e | ||
|
|
66d9d6c6d2 | ||
|
|
de816840cb | ||
|
|
74fcc3be79 | ||
|
|
b6909d3737 | ||
|
|
823d79b36c | ||
|
|
735757b0c1 | ||
|
|
09b919a68f | ||
|
|
2f718e11a7 | ||
|
|
77da54c6c6 | ||
|
|
6bf52dcc8d | ||
|
|
3d9e803aed | ||
|
|
ede64d7ea0 | ||
|
|
e8db390d6f | ||
|
|
0c1bf429e8 | ||
|
|
f6357a73f0 | ||
|
|
49ca7e5aa8 | ||
|
|
be9b1a1887 | ||
|
|
bb74aacf2d | ||
|
|
b72d9af52c | ||
|
|
a9ccd99b90 | ||
|
|
ac5e5179fb | ||
|
|
a543f8cd8f | ||
|
|
d7853df8b6 | ||
|
|
1e9d12abc5 | ||
|
|
3bce9fb755 | ||
|
|
0a57da42e0 | ||
|
|
73067e0e16 | ||
|
|
b9328d0eac | ||
|
|
0596b875f0 | ||
|
|
b94dcfd34b | ||
|
|
4238564673 | ||
|
|
764ab96bda | ||
|
|
f0cc59bead | ||
|
|
282f438967 | ||
|
|
1b01adfa9f | ||
|
|
87fe73ddaa | ||
|
|
c2746c0bb2 | ||
|
|
399a024857 | ||
|
|
d131c2d438 | ||
|
|
eb0962fb06 | ||
|
|
7bf253702e | ||
|
|
76742cc193 | ||
|
|
37717baeed | ||
|
|
ade2fafbd3 | ||
|
|
53fe7ba26a | ||
|
|
7e04fea92b | ||
|
|
1fdd23d347 | ||
|
|
5ea930e25f | ||
|
|
45defd25f3 | ||
|
|
0d11964503 | ||
|
|
7545eb5bbf | ||
|
|
878bd53d11 | ||
|
|
e0a4ee0148 | ||
|
|
d3fbc4d498 | ||
|
|
a8e2a24f60 | ||
|
|
36855544d1 | ||
|
|
dc745c0b77 | ||
|
|
a8ed1d7a9a | ||
|
|
94c371a38f | ||
|
|
36618f1dca | ||
|
|
3ea2694d9c | ||
|
|
85cc99a2a3 | ||
|
|
befe4ea5de | ||
|
|
43d94692ce | ||
|
|
1364b41dc9 | ||
|
|
7d3a555464 | ||
|
|
0508520b47 | ||
|
|
6cbb7bc443 | ||
|
|
055e262b56 | ||
|
|
9d8388e836 | ||
|
|
895de17a58 | ||
|
|
b202966d30 | ||
|
|
a19a7820f9 | ||
|
|
0122119a44 | ||
|
|
64bf03b0d9 |
204
ChangeLog
204
ChangeLog
@@ -1,3 +1,207 @@
|
||||
Changes between v5.7 and v5.8:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (53):
|
||||
bindings: show either "^/" or "^-" in the help lines, instead of "^_"
|
||||
bump version numbers and add a news item for the 5.8 release
|
||||
display: when a message gets overwritten, note that it is cleared
|
||||
docs: add a relevant item to the news for the 4.3 release
|
||||
docs: add example bindings for uppercasing and lowercasing a word
|
||||
docs: improve the contact info and some line spacing in the PDF
|
||||
docs: make ^E access the Execute menu in the example CUA bindings
|
||||
docs: mention that "grey"/"gray" may be used as a synonym of "lightblack"
|
||||
docs: mention the new 'set minicolor' option
|
||||
docs: say thanks to the Icelandic and Slovak translators
|
||||
feedback: ensure that the reporting of DOS/Mac format is truthful
|
||||
gnulib: update to its current upstream state
|
||||
help: use smaller triangles for the arrows
|
||||
linter: block the resizing signal while reading output from the linter
|
||||
linter: strip filename and line plus column number from the message
|
||||
memory: move the correct number of bytes, and not one too many
|
||||
memory: prevent a leak when copying the leading quoting to the next line
|
||||
minibar: stay out of sight when the terminal has just one row
|
||||
options: accept 'set minicolor' for setting the color of the minibar
|
||||
rcfile: allow using "grey" or "gray" as a synonym for "lightblack"
|
||||
rcfile: do not allow color name "normal" to have a prefix
|
||||
replacing: report the number of replacements also on a one-row terminal
|
||||
search: automatically drop the spotlighting after a few moments
|
||||
search: show "This is the only occurrence" also on a one-row terminal
|
||||
startup: allow using a bare "+" to mean put-cursor-on-last-line
|
||||
startup: do not accept stray characters after a "+" on the command line
|
||||
startup: skip drawing edit window when having message on one-row terminal
|
||||
startup: suppress "Search Wrapped" when using +? to search from EOF
|
||||
statusbar: ensure that "No further matches" does not get overwritten
|
||||
statusbar: on a one-row terminal, drop light messages after a few moments
|
||||
statusbar: suppress --constantshow when the terminal has just one row
|
||||
statusbar: suppress the cursor when the terminal has just one row
|
||||
syntax: nanohelp: avoid colorizing M-) in (M-) and M-" in "M-"
|
||||
syntax: nanorc: colorize "light" as valid only for the eight basic colors
|
||||
syntax: nanorc: colorize literal control codes, to make them stand out
|
||||
syntax: php: colorize the full short tag for echo (<?=)
|
||||
tweaks: avoid the subtraction of two size_t variables becoming negative
|
||||
tweaks: condense and correct a comment, and move another
|
||||
tweaks: condense some code by putting all color names in a single array
|
||||
tweaks: drop an assignment that is already part of the called function
|
||||
tweaks: frob some whitespace, and rewrap a line
|
||||
tweaks: improve a comment, remove unneeded braces, reshuffle some lines
|
||||
tweaks: normalize the indentation after the previous change
|
||||
tweaks: prevent two more size_t subtractions from going negative
|
||||
tweaks: redraw only the affected line instead of doing a full refresh
|
||||
tweaks: remove a check that has become superfluous
|
||||
tweaks: remove a check that is not needed
|
||||
tweaks: rename a variable, for contrast with the function name
|
||||
tweaks: rename two functions, to get rid of an ugly _void suffix
|
||||
tweaks: reshuffle the coloring of color names, to remove some duplication
|
||||
tweaks: use a symbol instead of a hard-coded number
|
||||
tweaks: use two symbolic names instead of TRUE and FALSE, for clarity
|
||||
wrapping: when copying the quoting part, adjust the file size accordingly
|
||||
|
||||
Hussam al-Homsi (1):
|
||||
bindings: allow copying text (with M-6) also when in view mode
|
||||
|
||||
|
||||
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:
|
||||
------------------------------
|
||||
|
||||
Benno Schulenberg (52):
|
||||
build: avoid a warning about duplicate symbol when building from tarball
|
||||
build: detect a build from git also when building out of tree
|
||||
build: include a workaround only for versions of ncurses that need it
|
||||
bump version numbers and add a news item for the 5.6 release
|
||||
color: do not look for another 'end' match after already finding one
|
||||
color: give highlighted text its own color, to not look like marked text
|
||||
color: recompile the file-probing regexes a little faster with REG_NOSUB
|
||||
color: use bright yellow to highlight a search match
|
||||
color: use inverse video for highlighting when there are no colors
|
||||
debug: add timing instruments to cache precalculation and screen refresh
|
||||
display: for a large paste or insertion, recalculate the multiline cache
|
||||
docs: correct the description of --quickblank for the changed base value
|
||||
docs: correct the formatting of a comment in the sample nanorc
|
||||
docs: correct the word order for Alt+D in the cheat sheet -- it changed
|
||||
docs: mention the new 'set highlightcolor' option
|
||||
docs: remove all mentions of --markmatch and 'set markmatch'
|
||||
docs: say that --minibar is modified by --constantshow and --stateflags
|
||||
feedback: make Full Justify show a message also when using --minibar
|
||||
gnulib: update to its current upstream state
|
||||
minibar: show a message a little longer when --quickblank isn't used
|
||||
minibar: show cursor position + character code only with --constantshow
|
||||
minibar: show the state flags only when --stateflags is used
|
||||
minibar: suppress the toggling feedback for M-C, but show it for M-Y/M-P
|
||||
options: remove --markmatch and 'set markmatch', as the behavior is gone
|
||||
painting: always do backtracking for the first row of the screen
|
||||
painting: trigger a refresh when a second start match appears on a line
|
||||
painting: trigger fewer unneeded full-screen refreshes
|
||||
painting: when finding an end match, set its multidata right away
|
||||
scrolling: keep centering after large paste, also when line numbers widen
|
||||
search: just highlight the found occurrence, instead of marking it
|
||||
search: make highlighting the standard, non-changeable behavior
|
||||
tweaks: avoid the vague possibility of advancing beyond end-of-line
|
||||
tweaks: be slightly more efficient in marking lines as WOULDBE
|
||||
tweaks: call wattron()/wattroff() only when actually painting something
|
||||
tweaks: correct a comment, improve another, and trim some verbosity
|
||||
tweaks: don't bother comparing virgin multidata with current situation
|
||||
tweaks: don't bother initializing freshly allocated multidata
|
||||
tweaks: don't bother wiping the multidata before recomputing it
|
||||
tweaks: elide a function that is now just one line
|
||||
tweaks: frob a condition, to be more concise, and reshuffle another
|
||||
tweaks: frob some comments, and adjust indentation after previous change
|
||||
tweaks: frob some comments, and reshuffle two fragments of code
|
||||
tweaks: frob two fragments of code, to be more readable
|
||||
tweaks: make a skipping condition more precise
|
||||
tweaks: remove an old fix that was made superfluous by a recent fix
|
||||
tweaks: remove a strangely placed warning
|
||||
tweaks: rename six symbols, to be more straightforward
|
||||
tweaks: reshuffle some code, and reduce the scope of a variable
|
||||
tweaks: reshuffle three conditions into a better order
|
||||
tweaks: rewrap and reindent a few lines
|
||||
tweaks: rewrap two lines, for esthetics
|
||||
tweaks: stop evaluating a rule when the match is offscreen to the right
|
||||
|
||||
|
||||
Changes between v5.4 and v5.5:
|
||||
------------------------------
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ Improvements in GNU nano
|
||||
========================
|
||||
|
||||
Since 5.0:
|
||||
- A search highlights the found text, in black on yellow by default.
|
||||
- Option --minibar reduces the interface to a bottom bar with basic info.
|
||||
- Option --markmatch marks the search result, for better visibility.
|
||||
- The cursor skips over combining characters, <Del> deletes them together
|
||||
with the character they combine with, but <Bsp> deletes them separately.
|
||||
- For using libmagic the option --magic or -! or 'set magic' is required.
|
||||
|
||||
35
NEWS
35
NEWS
@@ -1,3 +1,37 @@
|
||||
2021.06.15 - GNU nano 5.8 "Why is it necessary to be special?"
|
||||
• After a search, the spotlighting is dropped after 1.5 seconds (0.8
|
||||
seconds with --quick) to avoid the idea that the text is selected.
|
||||
• A + and a space before a filename on the command line will put the
|
||||
cursor at the end of the corresponding buffer.
|
||||
• Linter messages no longer include filename and line/column numbers.
|
||||
• Color name "grey" or "gray" can be used instead of "lightblack".
|
||||
• The color of the minibar can be chosen with 'set minicolor'.
|
||||
|
||||
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.
|
||||
The color combination can be changed with 'set highlightcolor'.
|
||||
By default the cursor is hidden until the next keystroke, but
|
||||
it can be forced on with --showcursor / 'set showcursor'.
|
||||
• Option --markmatch / 'set markmatch' has been removed.
|
||||
• Cursor position and character code are displayed in the minibar
|
||||
only when option --constantshow / 'set constantshow' is used,
|
||||
and their display can be toggled with M-C.
|
||||
• The state flags are displayed in the minibar only when option
|
||||
--stateflags / 'set stateflags' is used.
|
||||
|
||||
2021.01.14 - GNU nano 5.5 "Rebecca"
|
||||
• Option 'set minibar' makes nano suppress the title bar and instead
|
||||
show a bar with basic editing information at the bottom: file name
|
||||
@@ -161,6 +195,7 @@
|
||||
|
||||
2019.06.18 - GNU nano 4.3 "Musa Kart"
|
||||
• The ability to read from and write to a FIFO has been regained.
|
||||
• Opening a file no longer triggers an inotify CLOSE_WRITE event.
|
||||
• Startup time is reduced by fully parsing a syntax only when needed.
|
||||
• Asking for help (^G) when using --operatingdir does not crash.
|
||||
• The reading of a huge or slow file can be stopped with ^C.
|
||||
|
||||
2
THANKS
2
THANKS
@@ -18,6 +18,8 @@ Mihai Cristescu <mihai.cristescu@archlinux.info> Romanian
|
||||
Yavor Doganov <yavor@doganov.org> Bulgarian
|
||||
Karl Eichwalder <keichwa@gmx.net> German
|
||||
A. Murat EREN <meren@comu.edu.tr> Turkish
|
||||
Sveinn í Felli <sv1@fellsnet.is> Icelandic
|
||||
Marek Felšöci <marek@felsoci.sk> Slovak
|
||||
Doruk Fisek <dfisek@fisek.com.tr> Turkish
|
||||
Rafael Fontenelle <rffontenelle@gmail.com> Brazilian Portuguese
|
||||
Pavel Fric <pavelfric@seznam.cz> Czech
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# Generate configure & friends for GIT users.
|
||||
|
||||
gnulib_url="git://git.sv.gnu.org/gnulib.git"
|
||||
gnulib_hash="30820c2d7c9f04a6a0aa6cdaaea09c9672f502a1"
|
||||
gnulib_hash="ff7c8b21e259fdc4bc721ed55519cfee06739efa"
|
||||
|
||||
modules="
|
||||
futimens
|
||||
|
||||
@@ -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.5], [nano-devel@gnu.org], [nano])
|
||||
AC_INIT([GNU nano], [5.8], [nano-devel@gnu.org], [nano])
|
||||
AC_CONFIG_SRCDIR([src/nano.c])
|
||||
AC_CANONICAL_HOST
|
||||
AM_INIT_AUTOMAKE([1.14])
|
||||
@@ -59,7 +59,7 @@ AC_DEFINE_DIR([PKGDATADIR], [pkgdatadir], [Where data are placed to.])
|
||||
dnl Whether this is a git repository.
|
||||
|
||||
AC_MSG_CHECKING([whether building from git])
|
||||
if test -f roll-a-release.sh ; then
|
||||
if test -f "$srcdir/roll-a-release.sh" ; then
|
||||
AC_MSG_RESULT([yes])
|
||||
from_git=yes
|
||||
else
|
||||
@@ -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
|
||||
|
||||
@@ -108,7 +108,7 @@
|
||||
<b>Information</b>
|
||||
<table><tbody>
|
||||
<tr><td>Ctrl+C </td><td>Report cursor position</td></tr>
|
||||
<tr><td>Alt+D</td><td>Report word/line/char count</td></tr>
|
||||
<tr><td>Alt+D</td><td>Report line/word/character count</td></tr>
|
||||
<tr><td>Ctrl+G</td><td>Display help text</td></tr>
|
||||
</tbody></table>
|
||||
<br>
|
||||
|
||||
@@ -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 "establishes a full duplex terminal connection to a remote host", 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.5</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
|
||||
<blockquote><p>The current version of nano <i>should</i> be <b>5.8</b>. Of course, you should always check the <a href="https://nano-editor.org/">nano homepage</a> to see what the latest and greatest version is.</p></blockquote>
|
||||
<h3><a name="1.5"></a>1.5. I want to read the man page without having to download the program!</h3>
|
||||
<blockquote><p>Jeez, demanding, aren't we? Okay, look <a href="https://nano-editor.org/dist/latest/nano.1.html">here</a>.</p></blockquote>
|
||||
<hr width="100%">
|
||||
|
||||
17
doc/nano.1
17
doc/nano.1
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANO 1 "version 5.5" "January 2021"
|
||||
.TH NANO 1 "version 5.8" "June 2021"
|
||||
|
||||
.SH NAME
|
||||
nano \- Nano's ANOther editor, inspired by Pico
|
||||
@@ -190,9 +190,9 @@ Set the size (width) of a tab to \fInumber\fP columns. The value of
|
||||
\fInumber\fR must be greater than 0. The default value is \fB8\fR.
|
||||
.TP
|
||||
.BR \-U ", " \-\-quickblank
|
||||
Do quick status-bar blanking: status-bar messages will disappear after 1
|
||||
keystroke instead of 25. Note that option \fB\-c\fR (\fB\-\-constantshow\fR)
|
||||
overrides this.
|
||||
Make status-bar messages disappear after 1 keystroke instead of after 20.
|
||||
Note that options \fB\-c\fR (\fB\-\-constantshow\fR)
|
||||
and \fB\-_\fR (\fB\-\-minibar\fR) override this.
|
||||
.TP
|
||||
.BR \-V ", " \-\-version
|
||||
Show the current version number and exit.
|
||||
@@ -329,12 +329,6 @@ Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
|
||||
.BR \-z ", " \-\-suspendable
|
||||
Allow the user to suspend the editor (with \fB^Z\fR by default).
|
||||
.TP
|
||||
.BR \-^ ", " \-\-markmatch
|
||||
After a search, set the mark at the end of the found match
|
||||
(if there is any) so that it gets highlighted. This makes
|
||||
the match more visible, but also allows deleting the match
|
||||
with a single keystroke.
|
||||
.TP
|
||||
.BR \-% ", " \-\-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
|
||||
@@ -356,6 +350,9 @@ When a file is loaded or saved, and also when switching between buffers,
|
||||
the number of lines in the buffer is displayed after the file name.
|
||||
This number is cleared upon the next keystroke, or replaced with an
|
||||
[i/n] counter when multiple buffers are open.
|
||||
The line plus column numbers and the character code are displayed only when
|
||||
\fB\-\-constantshow\fR is used, and can be toggled on and off with \fBM-C\fR.
|
||||
The state flags are displayed only when \fB\-\-stateflags\fR is used.
|
||||
.TP
|
||||
.BR \-! ", " \-\-magic
|
||||
When neither the file's name nor its first line give a clue,
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
@documentencoding UTF-8
|
||||
|
||||
@smallbook
|
||||
@set EDITION 0.5
|
||||
@set VERSION 5.5
|
||||
@set UPDATED January 2021
|
||||
@set EDITION 0.6
|
||||
@set VERSION 5.8
|
||||
@set UPDATED June 2021
|
||||
|
||||
@dircategory Editors
|
||||
@direntry
|
||||
@@ -23,7 +23,7 @@
|
||||
@titlepage
|
||||
@title GNU @command{nano}
|
||||
@subtitle a small and friendly text editor
|
||||
@subtitle version 5.5
|
||||
@subtitle version 5.8
|
||||
|
||||
@author Chris Allegretta
|
||||
@page
|
||||
@@ -53,8 +53,10 @@ under the terms of either of the following licenses:
|
||||
along with this program. If not, see @url{https://www.gnu.org/licenses/}.
|
||||
|
||||
@sp 1
|
||||
You may contact the author by
|
||||
You may contact the original author by
|
||||
e-mail: @email{chrisa@@asty.org}@*
|
||||
|
||||
For suggesting improvements: @email{nano-devel@@gnu.org}@*
|
||||
@end titlepage
|
||||
|
||||
@ifnottex
|
||||
@@ -63,7 +65,7 @@ e-mail: @email{chrisa@@asty.org}@*
|
||||
@node Top
|
||||
@top
|
||||
|
||||
This manual documents the GNU @command{nano} editor, version 5.5.
|
||||
This manual documents the GNU @command{nano} editor, version 5.8.
|
||||
|
||||
@menu
|
||||
* Introduction::
|
||||
@@ -103,9 +105,9 @@ If you want the old, Pico behavior back, you can use the
|
||||
following options: @option{--breaklonglines},
|
||||
@option{--jumpyscrolling}, and @option{--emptyline}
|
||||
(or @option{-bje}).
|
||||
|
||||
@sp 1
|
||||
Please report bugs via @url{https://savannah.gnu.org/bugs/?group=nano}.
|
||||
|
||||
@sp 1
|
||||
For background information see @url{https://nano-editor.org/}.
|
||||
|
||||
@node Invoking
|
||||
@@ -281,9 +283,9 @@ Set the displayed tab length to @var{number} columns. The value of
|
||||
|
||||
@item -U
|
||||
@itemx --quickblank
|
||||
Do quick status-bar blanking: status-bar messages will disappear after 1
|
||||
keystroke instead of 25. Note that option @option{-c}
|
||||
(@option{--constantshow}) overrides this.
|
||||
Make status-bar messages disappear after 1 keystroke instead of after 20.
|
||||
Note that options @option{-c} (@option{--constantshow})
|
||||
and @option{-_} (@option{--minibar}) override this.
|
||||
|
||||
@item -V
|
||||
@itemx --version
|
||||
@@ -468,13 +470,6 @@ Make Ctrl+Right and Ctrl+Delete stop at word ends instead of beginnings.
|
||||
Enable the ability to suspend @command{nano} using the system's suspend
|
||||
keystroke (usually @kbd{^Z}).
|
||||
|
||||
@item -^
|
||||
@itemx --markmatch
|
||||
After a search, set the mark at the end of the found match
|
||||
(if there is any) so that it gets highlighted. This makes
|
||||
the match more visible, but also allows deleting the match
|
||||
with a single keystroke.
|
||||
|
||||
@item -%
|
||||
@itemx --stateflags
|
||||
Use the top-right corner of the screen for showing some state flags:
|
||||
@@ -498,6 +493,9 @@ When a file is loaded or saved, and also when switching between buffers,
|
||||
the number of lines in the buffer is displayed after the file name.
|
||||
This number is cleared upon the next keystroke, or replaced with an
|
||||
[i/n] counter when multiple buffers are open.
|
||||
The line plus column numbers and the character code are displayed only when
|
||||
@code{--constantshow} is used, and can be toggled on and off with @key{M-C}.
|
||||
The state flags are displayed only when @code{--stateflags} is used.
|
||||
|
||||
@item -!
|
||||
@itemx --magic
|
||||
@@ -880,6 +878,8 @@ Valid names for the foreground and background colors are:
|
||||
@code{white}, and @code{black}.
|
||||
Each of these eight names may be prefixed with the word
|
||||
@code{light} to get a brighter version of that color.
|
||||
The word @code{grey} or @code{gray} may be used as
|
||||
a synonym for @code{lightblack}.
|
||||
|
||||
On terminal emulators that can do at least 256 colors,
|
||||
other valid (but unprefixable) color names are:
|
||||
@@ -926,12 +926,6 @@ try using libmagic to determine the applicable syntax.
|
||||
(Calling libmagic can be relatively time consuming.
|
||||
It is therefore not done by default.)
|
||||
|
||||
@item set markmatch
|
||||
After a search, set the mark at the end of the found match
|
||||
(if there is any) so that it gets highlighted. This makes
|
||||
the match more visible, but also allows deleting the match
|
||||
with a single keystroke.
|
||||
|
||||
@anchor{@code{set matchbrackets}}
|
||||
@item set matchbrackets "@var{characters}"
|
||||
Specify the opening and closing brackets that can be found by bracket
|
||||
@@ -952,10 +946,14 @@ When a file is loaded or saved, and also when switching between buffers,
|
||||
the number of lines in the buffer is displayed after the file name.
|
||||
This number is cleared upon the next keystroke, or replaced with an
|
||||
[i/n] counter when multiple buffers are open.
|
||||
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 minicolor [bold,][italic,]@var{fgcolor},@var{bgcolor}
|
||||
Use this color combination for the minibar.
|
||||
(When this option is not specified, the colors of the title bar are used.)
|
||||
@xref{@code{set functioncolor}} for valid color names.
|
||||
|
||||
@item set mouse
|
||||
Enable mouse support, so that mouse clicks can be used to place the
|
||||
@@ -974,9 +972,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.
|
||||
@@ -1011,8 +1006,8 @@ specified closing punctuation, optionally followed by closing brackets
|
||||
The default value is "@t{!.?}".
|
||||
|
||||
@item set quickblank
|
||||
Do quick status-bar blanking: status-bar messages will disappear after 1
|
||||
keystroke instead of 25. Note that @option{constantshow} overrides this.
|
||||
Make status-bar messages disappear after 1 keystroke instead of after 20.
|
||||
Note that options @option{constantshow} and @option{minibar} override this.
|
||||
|
||||
@item set quotestr "@var{regex}"
|
||||
Set the regular expression for matching the quoting part of a line.
|
||||
@@ -1062,10 +1057,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
|
||||
@@ -1075,6 +1066,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
|
||||
|
||||
36
doc/nanorc.5
36
doc/nanorc.5
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH NANORC 5 "version 5.5" "January 2021"
|
||||
.TH NANORC 5 "version 5.8 "June 2021"
|
||||
|
||||
.SH NAME
|
||||
nanorc \- GNU nano's configuration file
|
||||
@@ -176,12 +176,6 @@ try using libmagic to determine the applicable syntax.
|
||||
(Calling libmagic can be relatively time consuming.
|
||||
It is therefore not done by default.)
|
||||
.TP
|
||||
.B set markmatch
|
||||
After a search, set the mark at the end of the found match
|
||||
(if there is any) so that it gets highlighted. This makes
|
||||
the match more visible, but also allows deleting the match
|
||||
with a single keystroke.
|
||||
.TP
|
||||
.BI "set matchbrackets """ characters """
|
||||
Specify the opening and closing brackets that can be found by bracket
|
||||
searches. This may not include blank characters. The opening set must
|
||||
@@ -201,10 +195,14 @@ When a file is loaded or saved, and also when switching between buffers,
|
||||
the number of lines in the buffer is displayed after the file name.
|
||||
This number is cleared upon the next keystroke, or replaced with an
|
||||
[i/n] counter when multiple buffers are open.
|
||||
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.
|
||||
.B set minicolor \fR[\fBbold,\fR][\fBitalic,\fR]\fIfgcolor\fB,\fIbgcolor\fR
|
||||
Use this color combination for the minibar.
|
||||
(When this option is not specified, the colors of the title bar are used.)
|
||||
See \fBset titlecolor\fR for more details.
|
||||
.TP
|
||||
.B set mouse
|
||||
Enable mouse support, if available for your system. When enabled, mouse
|
||||
@@ -226,9 +224,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.
|
||||
@@ -262,8 +257,8 @@ specfified closing punctuation, optionally followed by closing brackets
|
||||
(see \fBbrackets\fP), can end sentences. The default value is "\fB!.?\fP".
|
||||
.TP
|
||||
.B set quickblank
|
||||
Do quick status-bar blanking: status-bar messages will disappear after 1
|
||||
keystroke instead of 25. The option \fBconstantshow\fR overrides this.
|
||||
Make status-bar messages disappear after 1 keystroke instead of after 20.
|
||||
Note that options \fBconstantshow\fR and \fBminibar\fR override this.
|
||||
.TP
|
||||
.BI "set quotestr """ regex """
|
||||
Set the regular expression for matching the quoting part of a line.
|
||||
@@ -312,10 +307,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
|
||||
@@ -325,6 +316,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
|
||||
@@ -358,6 +354,8 @@ Valid names for the foreground and background colors are:
|
||||
.BR white ", and " black .
|
||||
Each of these eight names may be prefixed with the word \fBlight\fR
|
||||
to get a brighter version of that color.
|
||||
The word \fBgrey\fR or \fBgray\fR may be used
|
||||
as a synonym for \fBlightblack\fR.
|
||||
On terminal emulators that can do at least 256 colors,
|
||||
other valid (but unprefixable) color names are:
|
||||
.BR pink ", " purple ", " mauve ", " lagoon ", " mint ", "
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
.\" Documentation License along with this program. If not, see
|
||||
.\" <https://www.gnu.org/licenses/>.
|
||||
.\"
|
||||
.TH RNANO 1 "version 5.5" "January 2021"
|
||||
.TH RNANO 1 "version 5.8" "June 2021"
|
||||
|
||||
.SH NAME
|
||||
rnano \- a restricted nano
|
||||
|
||||
@@ -44,8 +44,7 @@
|
||||
## Do case-sensitive searches by default.
|
||||
# set casesensitive
|
||||
|
||||
## Constantly display the cursor position in the status bar. Note that
|
||||
## this overrides "quickblank".
|
||||
## Constantly display the cursor position in the status bar or minibar.
|
||||
# set constantshow
|
||||
|
||||
## Use cut-from-cursor-to-end-of-line by default.
|
||||
@@ -79,9 +78,6 @@
|
||||
## Fall back to slow libmagic to try and determine an applicable syntax.
|
||||
# set magic
|
||||
|
||||
# After a search, set the mark at the end of the found match (if any).
|
||||
# set markmatch
|
||||
|
||||
## The opening and closing brackets that can be found by bracket
|
||||
## searches. They cannot contain blank characters. The former set must
|
||||
## come before the latter set, and both must be in the same order.
|
||||
@@ -127,8 +123,7 @@
|
||||
## sentences.
|
||||
# set punct "!.?"
|
||||
|
||||
## Do quick status-bar blanking. Status-bar messages will disappear after
|
||||
## 1 keystroke instead of 26. Note that "constantshow" overrides this.
|
||||
## Make status-bar messages disappear after 1 keystroke instead of after 20.
|
||||
# set quickblank
|
||||
|
||||
## The regular expression that matches quoting characters in email
|
||||
@@ -206,12 +201,14 @@
|
||||
## of a single character, and without affecting the cutbuffer).
|
||||
# set zap
|
||||
|
||||
## Paint the interface elements of nano. These are examples;
|
||||
## by default there are no colors, except for errorcolor.
|
||||
|
||||
## Paint the interface elements of nano. These are examples; there are
|
||||
## 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 stripecolor ,yellow
|
||||
# set scrollercolor cyan
|
||||
@@ -224,6 +221,7 @@
|
||||
# set promptcolor black,yellow
|
||||
# set statuscolor bold,lightwhite,magenta
|
||||
# set errorcolor bold,lightwhite,red
|
||||
# set spotlightcolor black,orange
|
||||
# set selectedcolor lightwhite,cyan
|
||||
# set stripecolor ,yellow
|
||||
# set scrollercolor magenta
|
||||
@@ -267,6 +265,12 @@
|
||||
## <Ctrl+Backspace> delete the word to the left of the cursor with:
|
||||
# bind ^H chopwordleft main
|
||||
|
||||
## For quickly uppercasing or lowercasing the word under the cursor.
|
||||
## (These effectively do a Ctrl+Right followed by a Shift+Ctrl+Left,
|
||||
## and then pipe the selected text through a sed command.)
|
||||
#bind Sh-M-U "Oc[1;6D|sed 's/.*/\U&/'
|
||||
" main
|
||||
#bind Sh-M-L "Oc[1;6D|sed 's/.*/\L&/'
|
||||
" main
|
||||
|
||||
## If you would like nano to have keybindings that are more "usual",
|
||||
@@ -281,11 +285,11 @@
|
||||
#bind ^F whereis all
|
||||
#bind ^G findnext all
|
||||
#bind ^B wherewas all
|
||||
#bind M-X flipnewbuffer all
|
||||
#bind ^X cut all
|
||||
#bind ^D findprevious all
|
||||
#bind ^R replace main
|
||||
#bind ^X cut main
|
||||
#bind ^C copy main
|
||||
#bind ^V paste all
|
||||
#bind ^P location main
|
||||
#bind ^E execute main
|
||||
#bind ^A mark main
|
||||
@@ -295,9 +299,10 @@
|
||||
#unbind ^Y all
|
||||
#unbind M-J main
|
||||
#unbind M-T main
|
||||
#bind ^Y speller main
|
||||
#bind ^T gotoline main
|
||||
#bind ^T gotodir browser
|
||||
#bind ^T cutrestoffile execute
|
||||
#bind ^L linter execute
|
||||
#bind ^U undo main
|
||||
#bind ^E redo main
|
||||
#bind M-U undo main
|
||||
#bind M-R redo main
|
||||
#bind ^Z undo main
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
# List of available languages.
|
||||
bg ca cs da de eo es eu fi fr ga gl hr hu id it ja ko ms nb nl nn pl pt pt_BR ro ru sl sr sv tr uk vi zh_CN zh_TW
|
||||
bg ca cs da de eo es eu fi fr ga gl hr hu id is it ja ko ms nb nl nn pl pt pt_BR ro ru sk sl sr sv tr uk vi zh_CN zh_TW
|
||||
|
||||
731
po/nano.pot
731
po/nano.pot
File diff suppressed because it is too large
Load Diff
737
po/pt_BR.po
737
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
735
po/zh_CN.po
735
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
739
po/zh_TW.po
739
po/zh_TW.po
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERSION="5.5"
|
||||
VERSION="5.8"
|
||||
|
||||
./configure -C --enable-tiny && make && ./configure -C &&
|
||||
|
||||
@@ -12,7 +12,7 @@ po/update_linguas.sh &&
|
||||
|
||||
make distcheck && make dist-xz &&
|
||||
|
||||
git add po/*.po po/nano.pot &&
|
||||
git add po/*.po po/nano.pot po/LINGUAS &&
|
||||
git commit -m "$(git log -1 --grep 'po: up' | grep o: | sed 's/^ //')" &&
|
||||
|
||||
gpg -a -b nano-$VERSION.tar.gz &&
|
||||
|
||||
@@ -6,7 +6,7 @@ CLEANFILES = revision.h
|
||||
if BUILDING_FROM_GIT
|
||||
SOMETHING = "REVISION \"`git describe --tags 2>/dev/null`\""
|
||||
else
|
||||
SOMETHING = "NOTHING \"from tarball\""
|
||||
SOMETHING = "PLAINBUILD \"from tarball\""
|
||||
endif
|
||||
|
||||
nano.o: revision.h
|
||||
|
||||
242
src/chars.c
242
src/chars.c
@@ -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)
|
||||
@@ -452,7 +498,7 @@ char *revstrstr(const char *haystack, const char *needle,
|
||||
size_t tail_len = strlen(pointer);
|
||||
|
||||
if (tail_len < needle_len)
|
||||
pointer += tail_len - needle_len;
|
||||
pointer -= (needle_len - tail_len);
|
||||
|
||||
while (pointer >= haystack) {
|
||||
if (strncmp(pointer, needle, needle_len) == 0)
|
||||
@@ -472,7 +518,7 @@ char *revstrcasestr(const char *haystack, const char *needle,
|
||||
size_t tail_len = strlen(pointer);
|
||||
|
||||
if (tail_len < needle_len)
|
||||
pointer += tail_len - needle_len;
|
||||
pointer -= (needle_len - tail_len);
|
||||
|
||||
while (pointer >= haystack) {
|
||||
if (strncasecmp(pointer, needle, needle_len) == 0)
|
||||
@@ -494,7 +540,7 @@ char *mbrevstrcasestr(const char *haystack, const char *needle,
|
||||
size_t tail_len = mbstrlen(pointer);
|
||||
|
||||
if (tail_len < needle_len)
|
||||
pointer += tail_len - needle_len;
|
||||
pointer -= (needle_len - tail_len);
|
||||
|
||||
if (pointer < haystack)
|
||||
return NULL;
|
||||
@@ -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
|
||||
|
||||
129
src/color.c
129
src/color.c
@@ -58,7 +58,10 @@ 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 == PROMPT_BAR)
|
||||
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 == MINI_INFOBAR || index == PROMPT_BAR)
|
||||
interface_color_pair[index] = interface_color_pair[TITLE_BAR];
|
||||
else if (index == ERROR_MESSAGE) {
|
||||
init_pair(index + 1, COLOR_WHITE, COLOR_RED);
|
||||
@@ -116,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);
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -231,15 +224,6 @@ void find_and_prime_applicable_syntax(void)
|
||||
openfile->syntax = sntx;
|
||||
}
|
||||
|
||||
/* Allocate and initialize (for the given line) the cache for multiline info. */
|
||||
void set_up_multicache(linestruct *line)
|
||||
{
|
||||
line->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
|
||||
for (short index = 0; index < openfile->syntax->nmultis; index++)
|
||||
line->multidata[index] = -1;
|
||||
}
|
||||
|
||||
/* Determine whether the matches of multiline regexes are still the same,
|
||||
* and if not, schedule a screen refresh, so things will be repainted. */
|
||||
void check_the_multis(linestruct *line)
|
||||
@@ -253,8 +237,10 @@ void check_the_multis(linestruct *line)
|
||||
if (openfile->syntax == NULL || openfile->syntax->nmultis == 0)
|
||||
return;
|
||||
|
||||
if (line->multidata == NULL)
|
||||
set_up_multicache(line);
|
||||
if (line->multidata == NULL) {
|
||||
refresh_needed = TRUE;
|
||||
return;
|
||||
}
|
||||
|
||||
for (ink = openfile->syntax->color; ink != NULL; ink = ink->next) {
|
||||
/* If it's not a multiline regex, skip. */
|
||||
@@ -266,19 +252,22 @@ void check_the_multis(linestruct *line)
|
||||
anend = (regexec(ink->end, afterstart, 1, &endmatch, 0) == 0);
|
||||
|
||||
/* Check whether the multidata still matches the current situation. */
|
||||
if (line->multidata[ink->id] == CNONE ||
|
||||
line->multidata[ink->id] == CWHOLELINE) {
|
||||
if (line->multidata[ink->id] == NOTHING) {
|
||||
if (!astart)
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] & (WHOLELINE|WOULDBE)) {
|
||||
if (!astart && !anend)
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] == CSTARTENDHERE) {
|
||||
if (astart && anend && startmatch.rm_so < endmatch.rm_so)
|
||||
} else if (line->multidata[ink->id] == JUSTONTHIS) {
|
||||
if (astart && anend && regexec(ink->start, line->data + endmatch.rm_eo,
|
||||
1, &startmatch, 0) != 0)
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] == CBEGINBEFORE) {
|
||||
if (!astart && anend)
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] == CENDAFTER) {
|
||||
} else if (line->multidata[ink->id] == STARTSHERE) {
|
||||
if (astart && !anend)
|
||||
continue;
|
||||
} else if (line->multidata[ink->id] == ENDSHERE) {
|
||||
if (!astart && anend)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* There is a mismatch, so something changed: repaint. */
|
||||
@@ -295,13 +284,19 @@ void precalc_multicolorinfo(void)
|
||||
regmatch_t startmatch, endmatch;
|
||||
linestruct *line, *tailline;
|
||||
|
||||
if (openfile->syntax == NULL || openfile->syntax->nmultis == 0 ||
|
||||
openfile->filetop->multidata || ISSET(NO_SYNTAX))
|
||||
if (!openfile->syntax || openfile->syntax->nmultis == 0 || ISSET(NO_SYNTAX))
|
||||
return;
|
||||
|
||||
//#define TIMEPRECALC 123
|
||||
#ifdef TIMEPRECALC
|
||||
#include <time.h>
|
||||
clock_t start = clock();
|
||||
#endif
|
||||
|
||||
/* For each line, allocate cache space for the multiline-regex info. */
|
||||
for (line = openfile->filetop; line != NULL; line = line->next)
|
||||
set_up_multicache(line);
|
||||
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. */
|
||||
@@ -312,66 +307,68 @@ void precalc_multicolorinfo(void)
|
||||
int index = 0;
|
||||
|
||||
/* Assume nothing applies until proven otherwise below. */
|
||||
line->multidata[ink->id] = CNONE;
|
||||
line->multidata[ink->id] = NOTHING;
|
||||
|
||||
/* For an unpaired start match, mark all remaining lines. */
|
||||
if (line->prev && line->prev->multidata[ink->id] == CWOULDBE) {
|
||||
line->multidata[ink->id] = CWOULDBE;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* When the line contains a start match, look for an end, and if
|
||||
* found, mark all the lines that are affected. */
|
||||
while (regexec(ink->start, line->data + index, 1,
|
||||
&startmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
/* When the line contains a start match, look for an end,
|
||||
* and if found, mark all the lines that are affected. */
|
||||
while (regexec(ink->start, line->data + index, 1, &startmatch,
|
||||
(index == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
/* Begin looking for an end match after the start match. */
|
||||
index += startmatch.rm_eo;
|
||||
|
||||
/* If there is an end match on this line, mark the line, but
|
||||
* continue looking for other starts after it. */
|
||||
if (regexec(ink->end, line->data + index, 1,
|
||||
&endmatch, (index == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
line->multidata[ink->id] = CSTARTENDHERE;
|
||||
/* If there is an end match on this same line, mark the line,
|
||||
* but continue looking for other starts after it. */
|
||||
if (regexec(ink->end, line->data + index, 1, &endmatch,
|
||||
(index == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
line->multidata[ink->id] = JUSTONTHIS;
|
||||
|
||||
index += endmatch.rm_eo;
|
||||
/* If both start and end are mere anchors, step ahead. */
|
||||
if (startmatch.rm_so == startmatch.rm_eo &&
|
||||
endmatch.rm_so == endmatch.rm_eo) {
|
||||
/* When at end-of-line, we're done. */
|
||||
|
||||
/* If the total match has zero length, force an advance. */
|
||||
if (startmatch.rm_eo - startmatch.rm_so + endmatch.rm_eo == 0) {
|
||||
/* When at end-of-line, there is no other start. */
|
||||
if (line->data[index] == '\0')
|
||||
break;
|
||||
index = step_right(line->data, index);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Look for an end match on later lines. */
|
||||
tailline = line->next;
|
||||
|
||||
while (tailline != NULL) {
|
||||
if (regexec(ink->end, tailline->data, 1, &endmatch, 0) == 0)
|
||||
break;
|
||||
while (tailline && regexec(ink->end, tailline->data,
|
||||
1, &endmatch, 0) != 0)
|
||||
tailline = tailline->next;
|
||||
}
|
||||
|
||||
/* When there is no end match, mark relevant lines as such. */
|
||||
if (tailline == NULL) {
|
||||
line->multidata[ink->id] = CWOULDBE;
|
||||
for (; line->next != NULL; line = line->next)
|
||||
line->multidata[ink->id] = WOULDBE;
|
||||
line->multidata[ink->id] = WOULDBE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* We found it, we found it, la la la la la. Mark all
|
||||
* the lines in between and the end properly. */
|
||||
line->multidata[ink->id] = CENDAFTER;
|
||||
/* We found it, we found it, la lala lala. Mark the lines. */
|
||||
line->multidata[ink->id] = STARTSHERE;
|
||||
|
||||
// Note that this also advances the line in the main loop.
|
||||
for (line = line->next; line != tailline; line = line->next)
|
||||
line->multidata[ink->id] = CWHOLELINE;
|
||||
line->multidata[ink->id] = WHOLELINE;
|
||||
|
||||
tailline->multidata[ink->id] = CBEGINBEFORE;
|
||||
tailline->multidata[ink->id] = ENDSHERE;
|
||||
|
||||
/* Begin looking for a new start after the end match. */
|
||||
/* Look for a possible new start after the end match. */
|
||||
index = endmatch.rm_eo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TIMEPRECALC
|
||||
statusline(INFO, "Precalculation: %.1f ms", 1000 * (double)(clock() - start) / CLOCKS_PER_SEC);
|
||||
napms(1200);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* ENABLE_COLOR */
|
||||
|
||||
32
src/cut.c
32
src/cut.c
@@ -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);
|
||||
@@ -734,6 +714,10 @@ void paste_text(void)
|
||||
/* If we pasted less than a screenful, don't center the cursor. */
|
||||
if (less_than_a_screenful(was_lineno, was_leftedge))
|
||||
focusing = FALSE;
|
||||
#ifdef ENABLE_COLOR
|
||||
else
|
||||
precalc_multicolorinfo();
|
||||
#endif
|
||||
|
||||
/* Set the desired x position to where the pasted text ends. */
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
@@ -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
|
||||
@@ -138,17 +138,17 @@
|
||||
#define BAD_COLOR -2
|
||||
|
||||
/* Flags for indicating how a multiline regex pair apply to a line. */
|
||||
#define CNONE (1<<1)
|
||||
#define NOTHING (1<<1)
|
||||
/* The start/end regexes don't cover this line at all. */
|
||||
#define CBEGINBEFORE (1<<2)
|
||||
/* The start regex matches on an earlier line, the end regex on this one. */
|
||||
#define CENDAFTER (1<<3)
|
||||
#define STARTSHERE (1<<2)
|
||||
/* The start regex matches on this line, the end regex on a later one. */
|
||||
#define CWHOLELINE (1<<4)
|
||||
#define WHOLELINE (1<<3)
|
||||
/* The start regex matches on an earlier line, the end regex on a later one. */
|
||||
#define CSTARTENDHERE (1<<5)
|
||||
#define ENDSHERE (1<<4)
|
||||
/* The start regex matches on an earlier line, the end regex on this one. */
|
||||
#define JUSTONTHIS (1<<5)
|
||||
/* Both the start and end regexes match within this line. */
|
||||
#define CWOULDBE (1<<6)
|
||||
#define WOULDBE (1<<6)
|
||||
/* An unpaired start match is on or before this line. */
|
||||
#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,6 +282,8 @@ enum {
|
||||
GUIDE_STRIPE,
|
||||
SCROLL_BAR,
|
||||
SELECTED_TEXT,
|
||||
SPOTLIGHTED,
|
||||
MINI_INFOBAR,
|
||||
PROMPT_BAR,
|
||||
STATUS_BAR,
|
||||
ERROR_MESSAGE,
|
||||
@@ -306,7 +308,6 @@ enum {
|
||||
CUT_FROM_CURSOR,
|
||||
BACKWARDS_SEARCH,
|
||||
MULTIBUFFER,
|
||||
SMOOTH_SCROLL,
|
||||
REBIND_DELETE,
|
||||
RAW_SEQUENCES,
|
||||
NO_CONVERT,
|
||||
@@ -318,7 +319,6 @@ enum {
|
||||
RESTRICTED,
|
||||
SMART_HOME,
|
||||
WHITESPACE_DISPLAY,
|
||||
MORE_SPACE,
|
||||
TABS_TO_SPACES,
|
||||
QUICK_BLANK,
|
||||
WORD_BOUNDS,
|
||||
@@ -332,7 +332,6 @@ enum {
|
||||
TRIM_BLANKS,
|
||||
SHOW_CURSOR,
|
||||
LINE_NUMBERS,
|
||||
NO_PAUSES,
|
||||
AT_BLANKS,
|
||||
AFTER_ENDS,
|
||||
LET_THEM_ZAP,
|
||||
@@ -343,8 +342,7 @@ enum {
|
||||
BOOKSTYLE,
|
||||
STATEFLAGS,
|
||||
USE_MAGIC,
|
||||
MINIBAR,
|
||||
MARK_MATCH
|
||||
MINIBAR
|
||||
};
|
||||
|
||||
/* Structure types. */
|
||||
@@ -369,8 +367,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 +439,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 +561,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;
|
||||
|
||||
124
src/files.c
124
src/files.c
@@ -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;
|
||||
}
|
||||
@@ -498,7 +501,8 @@ void prepare_for_display(void)
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
/* Precalculate the data for any multiline coloring regexes. */
|
||||
precalc_multicolorinfo();
|
||||
if (!openfile->filetop->multidata)
|
||||
precalc_multicolorinfo();
|
||||
have_palette = FALSE;
|
||||
#endif
|
||||
refresh_needed = TRUE;
|
||||
@@ -517,7 +521,7 @@ void mention_name_and_linecount(void)
|
||||
return;
|
||||
}
|
||||
|
||||
if (openfile->fmt != NIX_FILE)
|
||||
if (openfile->fmt > NIX_FILE)
|
||||
/* TRANSLATORS: First %s is file name, second %s is file format. */
|
||||
statusline(HUSH, P_("%s -- %zu line (%s)", "%s -- %zu lines (%s)", count),
|
||||
openfile->filename[0] == '\0' ?
|
||||
@@ -540,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
|
||||
|
||||
@@ -556,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();
|
||||
}
|
||||
@@ -593,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 */
|
||||
@@ -644,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);
|
||||
|
||||
@@ -677,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 {
|
||||
@@ -757,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("");
|
||||
@@ -769,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;
|
||||
}
|
||||
@@ -798,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",
|
||||
@@ -818,6 +824,10 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable)
|
||||
/* If we inserted less than a screenful, don't center the cursor. */
|
||||
if (undoable && less_than_a_screenful(was_lineno, was_leftedge))
|
||||
focusing = FALSE;
|
||||
#ifdef ENABLE_COLOR
|
||||
else if (undoable)
|
||||
precalc_multicolorinfo();
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (undoable)
|
||||
@@ -825,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
|
||||
}
|
||||
|
||||
@@ -1104,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;
|
||||
@@ -1274,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;
|
||||
}
|
||||
|
||||
@@ -1998,7 +2004,7 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
|
||||
}
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(MINIBAR) && fullbuffer && !tmp)
|
||||
if (ISSET(MINIBAR) && LINES > 1 && fullbuffer && !tmp)
|
||||
report_size = TRUE;
|
||||
else
|
||||
#endif
|
||||
|
||||
52
src/global.c
52
src/global.c
@@ -384,7 +384,7 @@ int keycode_from_string(const char *keystring)
|
||||
{
|
||||
if (keystring[0] == '^') {
|
||||
if (keystring[2] == '\0') {
|
||||
if (keystring[1] == '/')
|
||||
if (keystring[1] == '/' || keystring[1] == '-')
|
||||
return 31;
|
||||
if (keystring[1] <= '_')
|
||||
return keystring[1] - 64;
|
||||
@@ -776,7 +776,7 @@ void shortcut_init(void)
|
||||
CAN_OPEN_OTHER_BUFFER);
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
else
|
||||
add_to_funcs(do_justify_void, MMAIN,
|
||||
add_to_funcs(do_justify, MMAIN,
|
||||
N_("Justify"), WITHORSANS(justify_gist), BLANKAFTER, NOVIEW);
|
||||
#endif
|
||||
|
||||
@@ -815,7 +815,7 @@ void shortcut_init(void)
|
||||
N_("Execute"), WITHORSANS(execute_gist), TOGETHER, NOVIEW);
|
||||
#endif
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
add_to_funcs(do_justify_void, MMAIN,
|
||||
add_to_funcs(do_justify, MMAIN,
|
||||
N_("Justify"), WITHORSANS(justify_gist), BLANKAFTER, NOVIEW);
|
||||
#endif
|
||||
}
|
||||
@@ -841,7 +841,7 @@ void shortcut_init(void)
|
||||
add_to_funcs(do_mark, MMAIN,
|
||||
N_("Set Mark"), WITHORSANS(mark_gist), TOGETHER, VIEW);
|
||||
add_to_funcs(copy_text, MMAIN,
|
||||
N_("Copy"), WITHORSANS(copy_gist), BLANKAFTER, NOVIEW);
|
||||
N_("Copy"), WITHORSANS(copy_gist), BLANKAFTER, VIEW);
|
||||
#endif
|
||||
|
||||
add_to_funcs(case_sens_void, MWHEREIS|MREPLACE,
|
||||
@@ -1192,6 +1192,12 @@ void shortcut_init(void)
|
||||
N_("Next Linter message"), WITHORSANS(nextlint_gist), TOGETHER, VIEW);
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#define SLASH_OR_DASH (on_a_vt) ? "^-" : "^/"
|
||||
#else
|
||||
#define SLASH_OR_DASH "^/"
|
||||
#endif
|
||||
|
||||
/* Link key combos to functions in certain menus. */
|
||||
add_to_sclist(MMOST|MBROWSER, "^M", '\r', do_enter, 0);
|
||||
add_to_sclist(MMOST|MBROWSER, "Enter", KEY_ENTER, do_enter, 0);
|
||||
@@ -1220,7 +1226,7 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN, "^T", 0, do_execute, 0);
|
||||
#endif
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
add_to_sclist(MMAIN, "^J", '\n', do_justify_void, 0);
|
||||
add_to_sclist(MMAIN, "^J", '\n', do_justify, 0);
|
||||
#endif
|
||||
#ifdef ENABLE_SPELLER
|
||||
add_to_sclist(MEXECUTE, "^S", 0, do_spell, 0);
|
||||
@@ -1233,8 +1239,9 @@ void shortcut_init(void)
|
||||
add_to_sclist(MEXECUTE, "^O", 0, do_formatter, 0);
|
||||
#endif
|
||||
add_to_sclist(MMAIN, "^C", 0, report_cursor_position, 0);
|
||||
add_to_sclist(MMAIN, "^_", 0, do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN, SLASH_OR_DASH, 0, do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN, "M-G", 0, do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN, "^_", 0, do_gotolinecolumn_void, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "^Y", 0, do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "PgUp", KEY_PPAGE, do_page_up, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP|MLINTER, "^V", 0, do_page_down, 0);
|
||||
@@ -1286,14 +1293,14 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMOST|MBROWSER, "^F", 0, do_right, 0);
|
||||
#ifdef ENABLE_UTF8
|
||||
if (using_utf8()) {
|
||||
add_to_sclist(MMOST|MBROWSER|MHELP, "\xE2\x97\x80", KEY_LEFT, do_left, 0);
|
||||
add_to_sclist(MMOST|MBROWSER|MHELP, "\xE2\x96\xb6", KEY_RIGHT, do_right, 0);
|
||||
add_to_sclist(MSOME, "^\xE2\x97\x80", CONTROL_LEFT, to_prev_word, 0);
|
||||
add_to_sclist(MSOME, "^\xE2\x96\xb6", CONTROL_RIGHT, to_next_word, 0);
|
||||
add_to_sclist(MMOST|MBROWSER|MHELP, "\xE2\x97\x82", KEY_LEFT, do_left, 0);
|
||||
add_to_sclist(MMOST|MBROWSER|MHELP, "\xE2\x96\xb8", KEY_RIGHT, do_right, 0);
|
||||
add_to_sclist(MSOME, "^\xE2\x97\x82", CONTROL_LEFT, to_prev_word, 0);
|
||||
add_to_sclist(MSOME, "^\xE2\x96\xb8", CONTROL_RIGHT, to_next_word, 0);
|
||||
#if !defined(NANO_TINY) && defined(ENABLE_MULTIBUFFER)
|
||||
if (!on_a_vt) {
|
||||
add_to_sclist(MMAIN, "M-\xE2\x97\x80", ALT_LEFT, switch_to_prev_buffer, 0);
|
||||
add_to_sclist(MMAIN, "M-\xE2\x96\xb6", ALT_RIGHT, switch_to_next_buffer, 0);
|
||||
add_to_sclist(MMAIN, "M-\xE2\x97\x82", ALT_LEFT, switch_to_prev_buffer, 0);
|
||||
add_to_sclist(MMAIN, "M-\xE2\x96\xb8", ALT_RIGHT, switch_to_next_buffer, 0);
|
||||
}
|
||||
#endif
|
||||
} else
|
||||
@@ -1320,10 +1327,10 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "^N", 0, do_down, 0);
|
||||
#ifdef ENABLE_UTF8
|
||||
if (using_utf8()) {
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "\xE2\x96\xb2", KEY_UP, do_up, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "\xE2\x96\xbc", KEY_DOWN, do_down, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MLINTER, "^\xE2\x96\xb2", CONTROL_UP, to_prev_block, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MLINTER, "^\xE2\x96\xbc", CONTROL_DOWN, to_next_block, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "\xE2\x96\xb4", KEY_UP, do_up, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "\xE2\x96\xbe", KEY_DOWN, do_down, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MLINTER, "^\xE2\x96\xb4", CONTROL_UP, to_prev_block, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MLINTER, "^\xE2\x96\xbe", CONTROL_DOWN, to_next_block, 0);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
@@ -1343,8 +1350,8 @@ void shortcut_init(void)
|
||||
#ifndef NANO_TINY
|
||||
#ifdef ENABLE_UTF8
|
||||
if (using_utf8()) {
|
||||
add_to_sclist(MMAIN|MHELP, "M-\xE2\x96\xb2", ALT_UP, do_scroll_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-\xE2\x96\xbc", ALT_DOWN, do_scroll_down, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-\xE2\x96\xb4", ALT_UP, do_scroll_up, 0);
|
||||
add_to_sclist(MMAIN|MHELP, "M-\xE2\x96\xbe", ALT_DOWN, do_scroll_down, 0);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
@@ -1428,8 +1435,8 @@ void shortcut_init(void)
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "^N", 0, get_history_newer_void, 0);
|
||||
#ifdef ENABLE_UTF8
|
||||
if (using_utf8()) {
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\xb2", KEY_UP, get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\xbc", KEY_DOWN, get_history_newer_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\xb4", KEY_UP, get_history_older_void, 0);
|
||||
add_to_sclist(MWHEREIS|MREPLACE|MREPLACEWITH|MWHEREISFILE|MFINDINHELP|MEXECUTE, "\xE2\x96\xbe", KEY_DOWN, get_history_newer_void, 0);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
@@ -1455,8 +1462,9 @@ void shortcut_init(void)
|
||||
add_to_sclist(MBROWSER, "End", KEY_END, to_last_file, 0);
|
||||
add_to_sclist(MBROWSER, "^Home", CONTROL_HOME, to_first_file, 0);
|
||||
add_to_sclist(MBROWSER, "^End", CONTROL_END, to_last_file, 0);
|
||||
add_to_sclist(MBROWSER, "^_", 0, goto_dir, 0);
|
||||
add_to_sclist(MBROWSER, SLASH_OR_DASH, 0, goto_dir, 0);
|
||||
add_to_sclist(MBROWSER, "M-G", 0, goto_dir, 0);
|
||||
add_to_sclist(MBROWSER, "^_", 0, goto_dir, 0);
|
||||
#endif
|
||||
if (ISSET(SAVE_ON_EXIT) && !ISSET(PRESERVE))
|
||||
add_to_sclist(MWRITEFILE, "^Q", 0, discard_buffer, 0);
|
||||
@@ -1506,7 +1514,7 @@ void shortcut_init(void)
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "F2", KEY_F(2), do_exit, 0);
|
||||
add_to_sclist(MMAIN, "F3", KEY_F(3), do_writeout_void, 0);
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
add_to_sclist(MMAIN, "F4", KEY_F(4), do_justify_void, 0);
|
||||
add_to_sclist(MMAIN, "F4", KEY_F(4), do_justify, 0);
|
||||
#endif
|
||||
add_to_sclist(MMAIN, "F5", KEY_F(5), do_insertfile_void, 0);
|
||||
add_to_sclist(MMAIN|MBROWSER|MHELP, "F6", KEY_F(6), do_search_forward, 0);
|
||||
|
||||
@@ -461,7 +461,7 @@ void show_help(void)
|
||||
didfind = 0;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
openfile->mark = NULL;
|
||||
spotlighted = FALSE;
|
||||
hide_cursor = FALSE;
|
||||
|
||||
if (bracketed_paste || kbinput == BRACKETED_PASTE_MARKER) {
|
||||
|
||||
118
src/nano.c
118
src/nano.c
@@ -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
|
||||
|
||||
@@ -640,7 +641,6 @@ void usage(void)
|
||||
if (!ISSET(RESTRICTED))
|
||||
print_opt("-z", "--suspendable", N_("Enable suspension"));
|
||||
#ifndef NANO_TINY
|
||||
print_opt("-^", "--markmatch", N_("Select the match of a search"));
|
||||
print_opt("-%", "--stateflags", N_("Show some states on the title bar"));
|
||||
print_opt("-_", "--minibar", N_("Show a feedback bar at the bottom"));
|
||||
#endif
|
||||
@@ -1007,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)
|
||||
{
|
||||
@@ -1057,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();
|
||||
}
|
||||
@@ -1066,8 +1057,6 @@ void regenerate_screen(void)
|
||||
/* Handle the global toggle specified in flag. */
|
||||
void do_toggle(int flag)
|
||||
{
|
||||
bool enabled;
|
||||
|
||||
if (flag == SUSPENDABLE && in_restricted_mode())
|
||||
return;
|
||||
|
||||
@@ -1085,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;
|
||||
@@ -1103,19 +1090,27 @@ void do_toggle(int flag)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (ISSET(STATEFLAGS) && (flag == AUTOINDENT ||
|
||||
flag == BREAK_LONG_LINES || flag == SOFTWRAP))
|
||||
titlebar(NULL);
|
||||
if (!ISSET(MINIBAR) && ISSET(STATEFLAGS))
|
||||
if (flag == AUTOINDENT || flag == BREAK_LONG_LINES || flag == SOFTWRAP)
|
||||
titlebar(NULL);
|
||||
|
||||
enabled = ISSET(flag);
|
||||
if (ISSET(MINIBAR) && (flag == NO_HELP || flag == LINE_NUMBERS ))
|
||||
return;
|
||||
|
||||
if (flag == NO_HELP || flag == NO_SYNTAX)
|
||||
enabled = !enabled;
|
||||
if (flag == CONSTANT_SHOW)
|
||||
wipe_statusbar();
|
||||
else if (!ISSET(MINIBAR) || !ISSET(STATEFLAGS) || flag == SMART_HOME ||
|
||||
flag == NO_SYNTAX || flag == WHITESPACE_DISPLAY ||
|
||||
flag == CUT_FROM_CURSOR || flag == TABS_TO_SPACES ||
|
||||
flag == USE_MOUSE || flag == SUSPENDABLE) {
|
||||
bool enabled = ISSET(flag);
|
||||
|
||||
if (flag == NO_HELP || flag == NO_SYNTAX)
|
||||
enabled = !enabled;
|
||||
|
||||
if (!ISSET(MINIBAR) || flag == SMART_HOME || flag == CUT_FROM_CURSOR ||
|
||||
flag == TABS_TO_SPACES || flag == USE_MOUSE || flag == SUSPENDABLE)
|
||||
statusline(REMARK, "%s %s", _(flagtostr(flag)),
|
||||
enabled ? _("enabled") : _("disabled"));
|
||||
enabled ? _("enabled") : _("disabled"));
|
||||
}
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
@@ -1235,14 +1230,15 @@ void confirm_margin(void)
|
||||
needed_margin = 0;
|
||||
|
||||
if (needed_margin != margin) {
|
||||
bool keep_focus = (margin > 0) && focusing;
|
||||
|
||||
margin = needed_margin;
|
||||
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
|
||||
/* The margin has changed -- schedule a full refresh. */
|
||||
refresh_needed = TRUE;
|
||||
@@ -1406,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
|
||||
|
||||
@@ -1475,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
|
||||
|
||||
@@ -1758,7 +1752,6 @@ int main(int argc, char **argv)
|
||||
{"indicator", 0, NULL, 'q'},
|
||||
{"unix", 0, NULL, 'u'},
|
||||
{"afterends", 0, NULL, 'y'},
|
||||
{"markmatch", 0, NULL, '^'},
|
||||
{"stateflags", 0, NULL, '%'},
|
||||
{"minibar", 0, NULL, '_'},
|
||||
#endif
|
||||
@@ -1797,25 +1790,15 @@ 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')
|
||||
SET(RESTRICTED);
|
||||
|
||||
while ((optchr = getopt_long(argc, argv, "ABC:DEFGHIJ:KLMNOPQ:RST:UVWX:Y:Z"
|
||||
"abcdef:ghijklmno:pqr:s:tuvwxyz$^%_!", long_options, NULL)) != -1) {
|
||||
"abcdef:ghijklmno:pqr:s:tuvwxyz$%_!", long_options, NULL)) != -1) {
|
||||
switch (optchr) {
|
||||
#ifndef NANO_TINY
|
||||
case 'A':
|
||||
@@ -2052,9 +2035,6 @@ int main(int argc, char **argv)
|
||||
SET(SUSPENDABLE);
|
||||
break;
|
||||
#ifndef NANO_TINY
|
||||
case '^':
|
||||
SET(MARK_MATCH);
|
||||
break;
|
||||
case '%':
|
||||
SET(STATEFLAGS);
|
||||
break;
|
||||
@@ -2171,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++)
|
||||
@@ -2321,6 +2297,8 @@ 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[SPOTLIGHTED] = A_REVERSE;
|
||||
interface_color_pair[MINI_INFOBAR] = hilite_attribute;
|
||||
interface_color_pair[PROMPT_BAR] = hilite_attribute;
|
||||
interface_color_pair[STATUS_BAR] = hilite_attribute;
|
||||
interface_color_pair[ERROR_MESSAGE] = hilite_attribute;
|
||||
@@ -2401,9 +2379,9 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
/* If there's a +LINE[,COLUMN] argument here, eat it up. */
|
||||
if (optind < argc - 1 && argv[optind][0] == '+') {
|
||||
#ifndef NANO_TINY
|
||||
int n = 1;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
while (isalpha(argv[optind][n])) {
|
||||
switch (argv[optind][n++]) {
|
||||
case 'c': SET(CASE_SENSITIVE); break;
|
||||
@@ -2426,7 +2404,11 @@ int main(int argc, char **argv)
|
||||
optind++;
|
||||
} else
|
||||
#endif
|
||||
if (!parse_line_column(&argv[optind++][n], &givenline, &givencol))
|
||||
/* When there is nothing after the "+", understand it as go-to-EOF,
|
||||
* otherwise parse and store the given number(s).*/
|
||||
if (argv[optind++][1] == '\0')
|
||||
givenline = -1;
|
||||
else if (!parse_line_column(&argv[optind - 1][1], &givenline, &givencol))
|
||||
statusline(ALERT, _("Invalid line or column number"));
|
||||
}
|
||||
|
||||
@@ -2452,7 +2434,7 @@ int main(int argc, char **argv)
|
||||
if (!findnextstr(searchstring, FALSE, JUSTFIND, NULL,
|
||||
ISSET(BACKWARDS_SEARCH), openfile->filetop, 0))
|
||||
not_found_msg(searchstring);
|
||||
else if (lastmessage == HUSH)
|
||||
else if (lastmessage <= REMARK)
|
||||
wipe_statusbar();
|
||||
openfile->placewewant = xplustabs();
|
||||
if (ISSET(USE_REGEXP))
|
||||
@@ -2497,11 +2479,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
|
||||
|
||||
@@ -2519,13 +2506,14 @@ int main(int argc, char **argv)
|
||||
bottombars(MMAIN);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (ISSET(MINIBAR) && lastmessage < REMARK)
|
||||
if (ISSET(MINIBAR) && LINES > 1 && lastmessage < REMARK)
|
||||
minibar();
|
||||
else
|
||||
#endif
|
||||
/* Update the displayed current cursor position only when there
|
||||
* is no message and no keys are waiting in the input buffer. */
|
||||
if (ISSET(CONSTANT_SHOW) && lastmessage == VACUUM && get_key_buffer_len() == 0)
|
||||
if (ISSET(CONSTANT_SHOW) && lastmessage == VACUUM && LINES > 1 &&
|
||||
get_key_buffer_len() == 0)
|
||||
report_cursor_position();
|
||||
|
||||
as_an_at = TRUE;
|
||||
@@ -2534,7 +2522,7 @@ int main(int argc, char **argv)
|
||||
if (!refresh_needed) {
|
||||
place_the_cursor();
|
||||
wnoutrefresh(edit);
|
||||
} else
|
||||
} else if (LINES > 1 || lastmessage == VACUUM)
|
||||
edit_refresh();
|
||||
|
||||
errno = 0;
|
||||
|
||||
@@ -408,11 +408,13 @@ void draw_the_promptbar(void)
|
||||
|
||||
wattroff(bottomwin, interface_color_pair[PROMPT_BAR]);
|
||||
|
||||
#if defined(NCURSES_VERSION_PATCH) && (NCURSES_VERSION_PATCH < 20210220)
|
||||
/* Work around a cursor-misplacement bug -- https://sv.gnu.org/bugs/?59808. */
|
||||
if (ISSET(NO_HELP)) {
|
||||
wmove(bottomwin, 0, 0);
|
||||
wrefresh(bottomwin);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Place the cursor at the right spot. */
|
||||
wmove(bottomwin, 0, column - the_page);
|
||||
@@ -424,7 +426,7 @@ void draw_the_promptbar(void)
|
||||
void add_or_remove_pipe_symbol_from_answer(void)
|
||||
{
|
||||
if (answer[0] == '|') {
|
||||
memmove(answer, answer + 1, strlen(answer) + 1);
|
||||
memmove(answer, answer + 1, strlen(answer));
|
||||
if (typing_x > 0)
|
||||
typing_x--;
|
||||
} else {
|
||||
|
||||
@@ -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,16 +230,12 @@ 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
|
||||
void set_interface_colorpairs(void);
|
||||
void prepare_palette(void);
|
||||
void find_and_prime_applicable_syntax(void);
|
||||
void set_up_multicache(linestruct *line);
|
||||
void check_the_multis(linestruct *line);
|
||||
void precalc_multicolorinfo(void);
|
||||
#endif
|
||||
@@ -413,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
|
||||
@@ -512,8 +507,7 @@ size_t indent_length(const char *line);
|
||||
size_t quote_length(const char *line);
|
||||
bool begpar(const linestruct *const line, int depth);
|
||||
bool inpar(const linestruct *const line);
|
||||
void do_justify(bool full_justify);
|
||||
void do_justify_void(void);
|
||||
void do_justify(void);
|
||||
void do_full_justify(void);
|
||||
#endif
|
||||
#ifdef ENABLE_SPELLER
|
||||
@@ -533,9 +527,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);
|
||||
|
||||
77
src/rcfile.c
77
src/rcfile.c
@@ -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
|
||||
@@ -109,13 +107,11 @@ static const rcoption rcopts[] = {
|
||||
{"indicator", INDICATOR},
|
||||
{"jumpyscrolling", JUMPY_SCROLLING},
|
||||
{"locking", LOCKING},
|
||||
{"markmatch", MARK_MATCH},
|
||||
{"matchbrackets", 0},
|
||||
{"minibar", MINIBAR},
|
||||
{"noconvert", NO_CONVERT},
|
||||
{"showcursor", SHOW_CURSOR},
|
||||
{"smarthome", SMART_HOME},
|
||||
{"smooth", SMOOTH_SCROLL}, /* Deprecated; remove in 2021. */
|
||||
{"softwrap", SOFTWRAP},
|
||||
{"stateflags", STATEFLAGS},
|
||||
{"tabsize", 0},
|
||||
@@ -133,6 +129,8 @@ static const rcoption rcopts[] = {
|
||||
{"stripecolor", 0},
|
||||
{"scrollercolor", 0},
|
||||
{"selectedcolor", 0},
|
||||
{"spotlightcolor", 0},
|
||||
{"minicolor", 0},
|
||||
{"promptcolor", 0},
|
||||
{"statuscolor", 0},
|
||||
{"errorcolor", 0},
|
||||
@@ -293,7 +291,7 @@ keystruct *strtosc(const char *input)
|
||||
s->func = do_gotolinecolumn_void;
|
||||
#ifdef ENABLE_JUSTIFY
|
||||
else if (!strcmp(input, "justify"))
|
||||
s->func = do_justify_void;
|
||||
s->func = do_justify;
|
||||
else if (!strcmp(input, "fulljustify"))
|
||||
s->func = do_full_justify;
|
||||
else if (!strcmp(input, "beginpara"))
|
||||
@@ -625,9 +623,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
|
||||
@@ -996,9 +992,21 @@ void parse_includes(char *ptr)
|
||||
free(expanded);
|
||||
}
|
||||
|
||||
const char hues[9][7] = { "pink", "purple", "mauve", "lagoon", "mint",
|
||||
"lime", "peach", "orange", "latte" };
|
||||
short indices[9] = { 204, 163, 134, 38, 48, 148, 215, 208, 137 };
|
||||
#define COLORCOUNT 20
|
||||
|
||||
const char hues[COLORCOUNT][8] = { "red", "green", "blue",
|
||||
"yellow", "cyan", "magenta",
|
||||
"white", "black", "normal",
|
||||
"pink", "purple", "mauve",
|
||||
"lagoon", "mint", "lime",
|
||||
"peach", "orange", "latte",
|
||||
"grey", "gray" };
|
||||
|
||||
short indices[COLORCOUNT] = { COLOR_RED, COLOR_GREEN, COLOR_BLUE,
|
||||
COLOR_YELLOW, COLOR_CYAN, COLOR_MAGENTA,
|
||||
COLOR_WHITE, COLOR_BLACK, THE_DEFAULT,
|
||||
204, 163, 134, 38, 48, 148, 215, 208, 137,
|
||||
COLOR_BLACK + 8, COLOR_BLACK + 8 };
|
||||
|
||||
/* Return the short value corresponding to the given color name, and set
|
||||
* vivid to TRUE for a lighter color, and thick for a heavier typeface. */
|
||||
@@ -1018,35 +1026,16 @@ short color_to_short(const char *colorname, bool *vivid, bool *thick)
|
||||
*thick = FALSE;
|
||||
}
|
||||
|
||||
if (strcmp(colorname, "green") == 0)
|
||||
return COLOR_GREEN;
|
||||
else if (strcmp(colorname, "red") == 0)
|
||||
return COLOR_RED;
|
||||
else if (strcmp(colorname, "blue") == 0)
|
||||
return COLOR_BLUE;
|
||||
else if (strcmp(colorname, "white") == 0)
|
||||
return COLOR_WHITE;
|
||||
else if (strcmp(colorname, "yellow") == 0)
|
||||
return COLOR_YELLOW;
|
||||
else if (strcmp(colorname, "cyan") == 0)
|
||||
return COLOR_CYAN;
|
||||
else if (strcmp(colorname, "magenta") == 0)
|
||||
return COLOR_MAGENTA;
|
||||
else if (strcmp(colorname, "black") == 0)
|
||||
return COLOR_BLACK;
|
||||
else if (strcmp(colorname, "normal") == 0)
|
||||
return THE_DEFAULT;
|
||||
else
|
||||
for (int index = 0; index < 9; index++)
|
||||
if (strcmp(colorname, hues[index]) == 0) {
|
||||
if (*vivid) {
|
||||
jot_error(N_("Color '%s' takes no prefix"), colorname);
|
||||
return BAD_COLOR;
|
||||
} else if (COLORS < 255)
|
||||
return THE_DEFAULT;
|
||||
else
|
||||
return indices[index];
|
||||
}
|
||||
for (int index = 0; index < COLORCOUNT; index++)
|
||||
if (strcmp(colorname, hues[index]) == 0) {
|
||||
if (index > 7 && *vivid) {
|
||||
jot_error(N_("Color '%s' takes no prefix"), colorname);
|
||||
return BAD_COLOR;
|
||||
} else if (index > 8 && COLORS < 255)
|
||||
return THE_DEFAULT;
|
||||
else
|
||||
return indices[index];
|
||||
}
|
||||
|
||||
jot_error(N_("Color \"%s\" not understood"), colorname);
|
||||
return BAD_COLOR;
|
||||
@@ -1242,6 +1231,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 +1240,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,6 +1549,10 @@ 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, "spotlightcolor") == 0)
|
||||
color_combo[SPOTLIGHTED] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "minicolor") == 0)
|
||||
color_combo[MINI_INFOBAR] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "promptcolor") == 0)
|
||||
color_combo[PROMPT_BAR] = parse_interface_color(argument);
|
||||
else if (strcmp(option, "statuscolor") == 0)
|
||||
|
||||
62
src/search.c
62
src/search.c
@@ -82,7 +82,7 @@ void search_init(bool replacing, bool retain_answer)
|
||||
thedefault = nmalloc(strlen(disp) + 7);
|
||||
/* We use (COLS / 3) here because we need to see more on the line. */
|
||||
sprintf(thedefault, " [%s%s]", disp,
|
||||
(breadth(last_search) > COLS / 3) ? "..." : "");
|
||||
(breadth(last_search) > COLS / 3) ? "..." : "");
|
||||
free(disp);
|
||||
} else
|
||||
thedefault = copy_of("");
|
||||
@@ -323,21 +323,18 @@ int findnextstr(const char *needle, bool whole_word_only, int modus,
|
||||
*match_len = found_len;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (modus == JUSTFIND && ISSET(MARK_MATCH) && (!openfile->mark || openfile->softmark)) {
|
||||
openfile->mark = line;
|
||||
openfile->mark_x = found_x + found_len;
|
||||
openfile->softmark = TRUE;
|
||||
if (modus == JUSTFIND && (!openfile->mark || openfile->softmark)) {
|
||||
spotlighted = TRUE;
|
||||
light_from_col = xplustabs();
|
||||
light_to_col = wideness(line->data, found_x + found_len);
|
||||
if (!ISSET(SHOW_CURSOR))
|
||||
hide_cursor = TRUE;
|
||||
shift_held = TRUE;
|
||||
edit_refresh();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Wipe the "Searching..." message and unsuppress cursor-position display. */
|
||||
if (feedback > 0) {
|
||||
if (feedback > 0)
|
||||
wipe_statusbar();
|
||||
lastmessage = VACUUM;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -431,10 +428,8 @@ void go_looking(void)
|
||||
/* If we found something, and we're back at the exact same spot
|
||||
* where we started searching, then this is the only occurrence. */
|
||||
if (didfind == 1 && openfile->current == was_current &&
|
||||
openfile->current_x == was_current_x)
|
||||
openfile->current_x == was_current_x)
|
||||
statusline(REMARK, _("This is the only occurrence"));
|
||||
else if (didfind == 1 && LINES == 1)
|
||||
refresh_needed = TRUE;
|
||||
else if (didfind == 0)
|
||||
not_found_msg(last_search);
|
||||
|
||||
@@ -475,8 +470,7 @@ int replace_regexp(char *string, bool create)
|
||||
/* And if create is TRUE, append the result of the
|
||||
* subexpression match to the new line. */
|
||||
if (create) {
|
||||
strncpy(string, openfile->current->data +
|
||||
regmatches[num].rm_so, i);
|
||||
strncpy(string, openfile->current->data + regmatches[num].rm_so, i);
|
||||
string += i;
|
||||
}
|
||||
}
|
||||
@@ -521,19 +515,6 @@ char *replace_line(const char *needle)
|
||||
return copy;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
/* Reset the multiline coloring info and then recalculate it. */
|
||||
void wipe_and_recalculate_colorinfo(void)
|
||||
{
|
||||
for (linestruct *line = openfile->filetop; line != NULL; line = line->next)
|
||||
if (line->multidata)
|
||||
for (short index = 0; index < openfile->syntax->nmultis; index++)
|
||||
line->multidata[index] = -1;
|
||||
|
||||
precalc_multicolorinfo();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Step through each occurrence of the search string and prompt the user
|
||||
* before replacing it. We seek for needle, and replace it with answer.
|
||||
* The parameters real_current and real_current_x are needed in order to
|
||||
@@ -678,17 +659,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
|
||||
#ifdef ENABLE_COLOR
|
||||
/* Check whether the replacement requires a change in the coloring. */
|
||||
check_the_multis(openfile->current);
|
||||
|
||||
if (refresh_needed && !replaceall)
|
||||
wipe_and_recalculate_colorinfo();
|
||||
#endif
|
||||
set_modified();
|
||||
as_an_at = TRUE;
|
||||
numreplaced++;
|
||||
@@ -698,11 +668,6 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||
if (numreplaced == -1)
|
||||
not_found_msg(needle);
|
||||
|
||||
#ifdef ENABLE_COLOR
|
||||
if (refresh_needed)
|
||||
wipe_and_recalculate_colorinfo();
|
||||
#endif
|
||||
|
||||
#ifndef NANO_TINY
|
||||
openfile->mark = was_mark;
|
||||
#endif
|
||||
@@ -735,8 +700,8 @@ void ask_for_and_do_replacements(void)
|
||||
size_t begin_x = openfile->current_x;
|
||||
ssize_t numreplaced;
|
||||
int response = do_prompt(MREPLACEWITH, "", &replace_history,
|
||||
/* TRANSLATORS: This is a prompt. */
|
||||
edit_refresh, _("Replace with"));
|
||||
/* TRANSLATORS: This is a prompt. */
|
||||
edit_refresh, _("Replace with"));
|
||||
|
||||
#ifdef ENABLE_HISTORIES
|
||||
/* When not "", add the replace string to the replace history list. */
|
||||
@@ -758,11 +723,12 @@ void ask_for_and_do_replacements(void)
|
||||
openfile->firstcolumn = was_firstcolumn;
|
||||
openfile->current = beginline;
|
||||
openfile->current_x = begin_x;
|
||||
refresh_needed = TRUE;
|
||||
|
||||
edit_refresh();
|
||||
|
||||
if (numreplaced >= 0)
|
||||
statusline(REMARK, P_("Replaced %zd occurrence",
|
||||
"Replaced %zd occurrences", numreplaced), numreplaced);
|
||||
"Replaced %zd occurrences", numreplaced), numreplaced);
|
||||
}
|
||||
|
||||
/* Go to the specified line and x position. */
|
||||
|
||||
118
src/text.c
118
src/text.c
@@ -60,8 +60,8 @@ void do_mark(void)
|
||||
}
|
||||
#endif /* !NANO_TINY */
|
||||
|
||||
/* Insert a tab. If the TABS_TO_SPACES flag is set, insert the number
|
||||
* of spaces that a tab would normally take up. */
|
||||
/* Insert a tab. Or, if --tabstospaces is in effect, insert the number
|
||||
* of spaces that a tab would normally take up at this position. */
|
||||
void do_tab(void)
|
||||
{
|
||||
#ifdef ENABLE_COLOR
|
||||
@@ -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;
|
||||
@@ -136,12 +133,12 @@ void do_indent(void)
|
||||
|
||||
indentation = nmalloc(tabsize + 1);
|
||||
|
||||
/* Set the indentation to either a bunch of spaces or a single tab. */
|
||||
#ifdef ENABLE_COLOR
|
||||
if (openfile->syntax && openfile->syntax->tab)
|
||||
indentation = mallocstrcpy(indentation, openfile->syntax->tab);
|
||||
else
|
||||
#endif
|
||||
/* Set the indentation to either a bunch of spaces or a single tab. */
|
||||
if (ISSET(TABS_TO_SPACES)) {
|
||||
memset(indentation, ' ', tabsize);
|
||||
indentation[tabsize] = '\0';
|
||||
@@ -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);
|
||||
}
|
||||
@@ -284,9 +278,6 @@ void handle_indent_action(undostruct *u, bool undoing, bool add_indent)
|
||||
groupstruct *group = u->grouping;
|
||||
linestruct *line = line_from_number(group->top_line);
|
||||
|
||||
if (group->next != NULL)
|
||||
die("Multiple groups -- please report a bug\n");
|
||||
|
||||
/* When redoing, reposition the cursor and let the indenter adjust it. */
|
||||
if (!undoing)
|
||||
goto_line_posx(u->head_lineno, u->head_x);
|
||||
@@ -424,15 +415,9 @@ void do_comment(void)
|
||||
|
||||
/* Comment/uncomment each of the selected lines when possible, and
|
||||
* 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
|
||||
for (line = top; line != bot->next; line = line->next)
|
||||
if (comment_line(action, line, comment_seq))
|
||||
update_multiline_undo(line->lineno, "");
|
||||
}
|
||||
}
|
||||
|
||||
set_modified();
|
||||
ensure_firstcolumn_is_aligned();
|
||||
@@ -573,8 +558,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 +659,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 +705,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 +819,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 +882,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 +921,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;
|
||||
}
|
||||
@@ -1112,24 +1082,24 @@ void update_multiline_undo(ssize_t lineno, char *indentation)
|
||||
/* If there already is a group and the current line is contiguous with it,
|
||||
* extend the group; otherwise, create a new group. */
|
||||
if (u->grouping && u->grouping->bottom_line + 1 == lineno) {
|
||||
size_t number_of_lines;
|
||||
size_t number_of_lines = lineno - u->grouping->top_line + 1;
|
||||
|
||||
u->grouping->bottom_line++;
|
||||
u->grouping->bottom_line = lineno;
|
||||
|
||||
number_of_lines = u->grouping->bottom_line - u->grouping->top_line + 1;
|
||||
u->grouping->indentations = nrealloc(u->grouping->indentations,
|
||||
number_of_lines * sizeof(char *));
|
||||
u->grouping->indentations[number_of_lines - 1] = copy_of(indentation);
|
||||
} else {
|
||||
groupstruct *born = nmalloc(sizeof(groupstruct));
|
||||
|
||||
born->next = u->grouping;
|
||||
u->grouping = born;
|
||||
born->top_line = lineno;
|
||||
born->bottom_line = lineno;
|
||||
|
||||
u->grouping->indentations = nmalloc(sizeof(char *));
|
||||
u->grouping->indentations[0] = copy_of(indentation);
|
||||
born->indentations = nmalloc(sizeof(char *));
|
||||
born->indentations[0] = copy_of(indentation);
|
||||
|
||||
born->next = u->grouping;
|
||||
u->grouping = born;
|
||||
}
|
||||
|
||||
/* Store the file size after the change, to be used when redoing. */
|
||||
@@ -1357,7 +1327,9 @@ bool do_wrap(void)
|
||||
strncpy(line->data, line->prev->data, lead_len);
|
||||
|
||||
openfile->current_x += lead_len;
|
||||
openfile->totsize += lead_len;
|
||||
#ifndef NANO_TINY
|
||||
free(openfile->undotop->strdata);
|
||||
update_undo(ENTER);
|
||||
#endif
|
||||
if (autowhite)
|
||||
@@ -1453,21 +1425,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
|
||||
|
||||
@@ -1741,9 +1704,12 @@ void justify_paragraph(linestruct **line, size_t count)
|
||||
free(lead_string);
|
||||
}
|
||||
|
||||
/* Justify the current paragraph, or the entire buffer when full_justify is
|
||||
#define ONE_PARAGRAPH FALSE
|
||||
#define WHOLE_BUFFER TRUE
|
||||
|
||||
/* Justify the current paragraph, or the entire buffer when whole_buffer is
|
||||
* TRUE. But if the mark is on, justify only the marked text instead. */
|
||||
void do_justify(bool full_justify)
|
||||
void justify_text(bool whole_buffer)
|
||||
{
|
||||
size_t linecount;
|
||||
/* The number of lines in the original paragraph. */
|
||||
@@ -1859,7 +1825,7 @@ void do_justify(bool full_justify)
|
||||
{
|
||||
/* When justifying the entire buffer, start at the top. Otherwise, when
|
||||
* in a paragraph but not at its beginning, move back to its first line. */
|
||||
if (full_justify)
|
||||
if (whole_buffer)
|
||||
openfile->current = openfile->filetop;
|
||||
else if (inpar(openfile->current) && !begpar(openfile->current, 0))
|
||||
do_para_begin(&openfile->current);
|
||||
@@ -1881,7 +1847,7 @@ void do_justify(bool full_justify)
|
||||
start_x = 0;
|
||||
|
||||
/* Set the end point of the paragraph. */
|
||||
if (full_justify)
|
||||
if (whole_buffer)
|
||||
endline = openfile->filebot;
|
||||
else {
|
||||
endline = startline;
|
||||
@@ -1956,7 +1922,7 @@ void do_justify(bool full_justify)
|
||||
justify_paragraph(&jusline, linecount);
|
||||
|
||||
/* When justifying the entire buffer, find and justify all paragraphs. */
|
||||
if (full_justify) {
|
||||
if (whole_buffer) {
|
||||
while (find_paragraph(&jusline, &linecount)) {
|
||||
justify_paragraph(&jusline, linecount);
|
||||
|
||||
@@ -1968,7 +1934,7 @@ void do_justify(bool full_justify)
|
||||
|
||||
#ifndef NANO_TINY
|
||||
add_undo(PASTE, NULL);
|
||||
if (full_justify && !openfile->mark && !cutbuffer->has_anchor)
|
||||
if (whole_buffer && !openfile->mark && !cutbuffer->has_anchor)
|
||||
openfile->current->has_anchor = FALSE;
|
||||
#endif
|
||||
/* Do the equivalent of a paste of the justified text. */
|
||||
@@ -1999,8 +1965,8 @@ void do_justify(bool full_justify)
|
||||
statusline(REMARK, _("Justified selection"));
|
||||
else
|
||||
#endif
|
||||
if (full_justify)
|
||||
statusbar(_("Justified file"));
|
||||
if (whole_buffer)
|
||||
statusline(REMARK, _("Justified file"));
|
||||
else
|
||||
statusbar(_("Justified paragraph"));
|
||||
|
||||
@@ -2013,15 +1979,15 @@ void do_justify(bool full_justify)
|
||||
}
|
||||
|
||||
/* Justify the current paragraph. */
|
||||
void do_justify_void(void)
|
||||
void do_justify(void)
|
||||
{
|
||||
do_justify(FALSE);
|
||||
justify_text(ONE_PARAGRAPH);
|
||||
}
|
||||
|
||||
/* Justify the entire file. */
|
||||
void do_full_justify(void)
|
||||
{
|
||||
do_justify(TRUE);
|
||||
justify_text(WHOLE_BUFFER);
|
||||
ran_a_tool = TRUE;
|
||||
}
|
||||
#endif /* ENABLE_JUSTIFY */
|
||||
@@ -2644,6 +2610,9 @@ void do_linter(void)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Block resizing signals while reading from the pipe. */
|
||||
block_sigwinch(TRUE);
|
||||
|
||||
/* Read in the returned syntax errors. */
|
||||
totalread = 0;
|
||||
buffersize = pipesize + 1;
|
||||
@@ -2660,10 +2629,12 @@ void do_linter(void)
|
||||
*pointer = '\0';
|
||||
close(lint_fd[0]);
|
||||
|
||||
/* Process the linter output. */
|
||||
block_sigwinch(FALSE);
|
||||
|
||||
pointer = lintings;
|
||||
onelint = lintings;
|
||||
|
||||
/* Now parse the output of the linter. */
|
||||
while (*pointer != '\0') {
|
||||
if ((*pointer == '\r') || (*pointer == '\n')) {
|
||||
*pointer = '\0';
|
||||
@@ -2671,11 +2642,8 @@ void do_linter(void)
|
||||
char *filename = NULL, *linestr = NULL, *maybecol = NULL;
|
||||
char *message = copy_of(onelint);
|
||||
|
||||
/* At the moment we handle the following formats:
|
||||
*
|
||||
* filenameorcategory:line:column:message (e.g. splint)
|
||||
* filenameorcategory:line,column:message (e.g. pylint)
|
||||
* filenameorcategory:line:message (e.g. pyflakes) */
|
||||
/* The recognized format is "filename:line:column: message",
|
||||
* where ":column" may be absent or be ",column" instead. */
|
||||
if (strstr(message, ": ") != NULL) {
|
||||
filename = strtok(onelint, ":");
|
||||
if ((linestr = strtok(NULL, ":")) != NULL) {
|
||||
@@ -2708,7 +2676,7 @@ void do_linter(void)
|
||||
curlint->prev = tmplint;
|
||||
if (curlint->prev != NULL)
|
||||
curlint->prev->next = curlint;
|
||||
curlint->msg = copy_of(message);
|
||||
curlint->msg = copy_of(strstr(message, ": ") + 2);
|
||||
curlint->lineno = tmplineno;
|
||||
curlint->colno = tmpcolno;
|
||||
curlint->filename = copy_of(filename);
|
||||
@@ -3193,8 +3161,8 @@ void complete_a_word(void)
|
||||
|
||||
/* The search has reached the end of the file. */
|
||||
if (list_of_completions != NULL) {
|
||||
edit_refresh();
|
||||
statusline(AHEM, _("No further matches"));
|
||||
refresh_needed = TRUE;
|
||||
} else
|
||||
/* TRANSLATORS: Shown when there are zero possible completions. */
|
||||
statusline(AHEM, _("No matches"));
|
||||
|
||||
31
src/utils.c
31
src/utils.c
@@ -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++;
|
||||
}
|
||||
|
||||
|
||||
448
src/winio.c
448
src/winio.c
@@ -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;
|
||||
@@ -178,17 +182,22 @@ void read_keys_from(WINDOW *win)
|
||||
bool timed = FALSE;
|
||||
#endif
|
||||
|
||||
/* On a one-row terminal, overwrite an unimportant message. */
|
||||
if (LINES == 1 && currmenu == MMAIN && lastmessage == HUSH)
|
||||
edit_refresh();
|
||||
|
||||
/* Before reading the first keycode, display any pending screen updates. */
|
||||
doupdate();
|
||||
|
||||
if (reveal_cursor && !hide_cursor)
|
||||
if (reveal_cursor && !hide_cursor && (LINES > 1 || lastmessage <= HUSH))
|
||||
curs_set(1);
|
||||
|
||||
#ifndef NANO_TINY
|
||||
if (currmenu == MMAIN && ISSET(MINIBAR) && lastmessage > HUSH &&
|
||||
lastmessage != INFO && lastmessage < ALERT) {
|
||||
if (currmenu == MMAIN && (spotlighted || ((ISSET(MINIBAR) || LINES == 1) &&
|
||||
lastmessage > HUSH &&
|
||||
lastmessage != INFO && lastmessage < ALERT))) {
|
||||
timed = TRUE;
|
||||
halfdelay(8);
|
||||
halfdelay(ISSET(QUICK_BLANK) ? 8 : 15);
|
||||
disable_kb_interrupt();
|
||||
}
|
||||
#endif
|
||||
@@ -208,7 +217,15 @@ void read_keys_from(WINDOW *win)
|
||||
raw();
|
||||
|
||||
if (input == ERR) {
|
||||
minibar();
|
||||
if (spotlighted || LINES == 1) {
|
||||
lastmessage = VACUUM;
|
||||
spotlighted = FALSE;
|
||||
update_line(openfile->current, openfile->current_x);
|
||||
wnoutrefresh(edit);
|
||||
curs_set(1);
|
||||
}
|
||||
if (ISSET(MINIBAR) && LINES > 1)
|
||||
minibar();
|
||||
as_an_at = TRUE;
|
||||
place_the_cursor();
|
||||
doupdate();
|
||||
@@ -232,6 +249,10 @@ void read_keys_from(WINDOW *win)
|
||||
key_buffer_len = 1;
|
||||
|
||||
#ifndef NANO_TINY
|
||||
/* Cancel the highlighting of a search match, if there still is one. */
|
||||
refresh_needed |= spotlighted;
|
||||
spotlighted = FALSE;
|
||||
|
||||
/* If we got a SIGWINCH, get out as the win argument is no longer valid. */
|
||||
if (input == KEY_WINCH)
|
||||
return;
|
||||
@@ -1377,7 +1398,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 +1428,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 */
|
||||
@@ -1656,6 +1678,7 @@ void wipe_statusbar(void)
|
||||
{
|
||||
blank_row(bottomwin, 0);
|
||||
wnoutrefresh(bottomwin);
|
||||
lastmessage = VACUUM;
|
||||
}
|
||||
|
||||
/* Blank out the two help lines (when they are present). */
|
||||
@@ -1678,7 +1701,7 @@ void check_statusblank(void)
|
||||
statusblank--;
|
||||
|
||||
/* When editing and 'constantshow' is active, skip the blanking. */
|
||||
if (currmenu == MMAIN && ISSET(CONSTANT_SHOW))
|
||||
if (currmenu == MMAIN && ISSET(CONSTANT_SHOW) && LINES > 1)
|
||||
return;
|
||||
|
||||
if (statusblank == 0)
|
||||
@@ -1695,32 +1718,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 +1757,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 +1776,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 +1807,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 +1828,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 +1846,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 +1861,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 +1886,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 +1908,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;
|
||||
}
|
||||
|
||||
@@ -2081,13 +2118,12 @@ void minibar(void)
|
||||
#endif
|
||||
|
||||
/* Draw a colored bar over the full width of the screen. */
|
||||
wattron(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
wattron(bottomwin, interface_color_pair[MINI_INFOBAR]);
|
||||
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 +2135,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 +2148,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');
|
||||
|
||||
@@ -2133,11 +2172,12 @@ void minibar(void)
|
||||
#endif
|
||||
|
||||
/* Display the line/column position of the cursor. */
|
||||
if (namewidth + tallywidth + placewidth + 32 < COLS)
|
||||
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. */
|
||||
if (namewidth + tallywidth + 28 < COLS) {
|
||||
/* 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;
|
||||
|
||||
if (*this_position == '\0')
|
||||
@@ -2151,7 +2191,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 +2203,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);
|
||||
}
|
||||
@@ -2179,7 +2219,7 @@ void minibar(void)
|
||||
}
|
||||
|
||||
/* Display the state of three flags, and the state of macro and mark. */
|
||||
if (!successor && namewidth + tallywidth + 14 + 2 * padding < COLS) {
|
||||
if (ISSET(STATEFLAGS) && !successor && namewidth + tallywidth + 14 + 2 * padding < COLS) {
|
||||
wmove(bottomwin, 0, COLS - 11 - padding);
|
||||
show_states_at(bottomwin);
|
||||
}
|
||||
@@ -2190,7 +2230,7 @@ void minibar(void)
|
||||
mvwaddstr(bottomwin, 0, COLS - 4 - padding, location);
|
||||
}
|
||||
|
||||
wattroff(bottomwin, interface_color_pair[TITLE_BAR]);
|
||||
wattroff(bottomwin, interface_color_pair[MINI_INFOBAR]);
|
||||
wrefresh(bottomwin);
|
||||
|
||||
free(number_of_lines);
|
||||
@@ -2223,6 +2263,23 @@ void statusline(message_type importance, const char *msg, ...)
|
||||
if (importance < lastmessage && lastmessage > NOTICE)
|
||||
return;
|
||||
|
||||
/* On a one-row terminal, ensure that any changes in the edit window are
|
||||
* written out first, to prevent them from overwriting the message. */
|
||||
if (LINES == 1 && importance < INFO)
|
||||
wnoutrefresh(edit);
|
||||
|
||||
/* 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 +2292,7 @@ void statusline(message_type importance, const char *msg, ...)
|
||||
napms(100);
|
||||
beep();
|
||||
}
|
||||
free(compound);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2251,11 +2309,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 +2320,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 +2332,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,16 +2482,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 displays at least partially on the window. */
|
||||
size_t till_x = actual_x(line->data, from_col + editwincols - 1) + 1;
|
||||
/* The position in the line's data of the first character that
|
||||
* is completely off the window to the right. Note that till_x
|
||||
* might be beyond the null terminator of the string. */
|
||||
#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. */
|
||||
@@ -2483,15 +2526,15 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||
if (openfile->syntax && !ISSET(NO_SYNTAX)) {
|
||||
const colortype *varnish = openfile->syntax->color;
|
||||
|
||||
/* If there are multiline regexes, make sure there is a cache. */
|
||||
/* If there are multiline regexes, make sure this line has a cache. */
|
||||
if (openfile->syntax->nmultis > 0 && line->multidata == NULL)
|
||||
set_up_multicache(line);
|
||||
line->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
|
||||
/* Iterate through all the coloring regexes. */
|
||||
for (; varnish != NULL; varnish = varnish->next) {
|
||||
size_t index = 0;
|
||||
/* Where in the line we currently begin looking for a match. */
|
||||
int start_col;
|
||||
int start_col = 0;
|
||||
/* The starting column of a piece to paint. Zero-based. */
|
||||
int paintlen = 0;
|
||||
/* The number of characters to paint. */
|
||||
@@ -2501,87 +2544,81 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||
/* The match positions of a single-line regex. */
|
||||
const linestruct *start_line = line->prev;
|
||||
/* The first line before line that matches 'start'. */
|
||||
const linestruct *end_line = line;
|
||||
linestruct *end_line = line;
|
||||
/* The line that matches 'end'. */
|
||||
regmatch_t startmatch, endmatch;
|
||||
/* The match positions of the start and end regexes. */
|
||||
|
||||
/* Two notes about regexec(). A return value of zero means
|
||||
* that there is a match. Also, rm_eo is the first
|
||||
* non-matching character after the match. */
|
||||
|
||||
wattron(edit, varnish->attributes);
|
||||
|
||||
/* First case: varnish is a single-line expression. */
|
||||
if (varnish->end == NULL) {
|
||||
/* We increment index by rm_eo, to move past the end of the
|
||||
* last match. Even though two matches may overlap, we
|
||||
* want to ignore them, so that we can highlight e.g. C
|
||||
* strings correctly. */
|
||||
while (index < till_x) {
|
||||
/* Note the fifth parameter to regexec(). It says
|
||||
* not to match the beginning-of-line character
|
||||
* unless index is zero. If regexec() returns
|
||||
* REG_NOMATCH, there are no more matches in the
|
||||
* line. */
|
||||
/* If there is no match, go on to the next line. */
|
||||
if (regexec(varnish->start, &line->data[index], 1,
|
||||
&match, (index == 0) ? 0 : REG_NOTBOL) != 0)
|
||||
break;
|
||||
|
||||
/* If the match is of length zero, skip it. */
|
||||
if (match.rm_so == match.rm_eo) {
|
||||
index = step_right(line->data, index + match.rm_eo);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Translate the match to the beginning of the line. */
|
||||
match.rm_so += index;
|
||||
match.rm_eo += index;
|
||||
index = match.rm_eo;
|
||||
|
||||
/* If the matching part is not visible, skip it. */
|
||||
if (match.rm_eo <= from_x || match.rm_so >= till_x)
|
||||
/* If the match is offscreen to the right, this rule is done. */
|
||||
if (match.rm_so >= till_x)
|
||||
break;
|
||||
|
||||
/* If the match has length zero, advance over it. */
|
||||
if (match.rm_so == match.rm_eo) {
|
||||
if (line->data[index] == '\0')
|
||||
break;
|
||||
index = step_right(line->data, index);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If the match is offscreen to the left, skip to next. */
|
||||
if (match.rm_eo <= from_x)
|
||||
continue;
|
||||
|
||||
start_col = (match.rm_so <= from_x) ?
|
||||
0 : wideness(line->data,
|
||||
match.rm_so) - from_col;
|
||||
if (match.rm_so > from_x)
|
||||
start_col = wideness(line->data, match.rm_so) - from_col;
|
||||
|
||||
thetext = converted + actual_x(converted, start_col);
|
||||
|
||||
paintlen = actual_x(thetext, wideness(line->data,
|
||||
match.rm_eo) - from_col - start_col);
|
||||
|
||||
wattron(edit, varnish->attributes);
|
||||
mvwaddnstr(edit, row, margin + start_col, thetext, paintlen);
|
||||
wattroff(edit, varnish->attributes);
|
||||
}
|
||||
goto tail_of_loop;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Second case: varnish is a multiline expression. */
|
||||
|
||||
/* Assume nothing gets painted until proven otherwise below. */
|
||||
line->multidata[varnish->id] = CNONE;
|
||||
line->multidata[varnish->id] = NOTHING;
|
||||
|
||||
/* First check the multidata of the preceding line -- it tells
|
||||
* us about the situation so far, and thus what to do here. */
|
||||
if (start_line != NULL && start_line->multidata != NULL) {
|
||||
if (start_line->multidata[varnish->id] == CWHOLELINE ||
|
||||
start_line->multidata[varnish->id] == CENDAFTER ||
|
||||
start_line->multidata[varnish->id] == CWOULDBE)
|
||||
/* Apart from the first row, check the multidata of the preceding line:
|
||||
* it tells us about the situation so far, and thus what to do here. */
|
||||
if (row > 0 && start_line != NULL && start_line->multidata != NULL) {
|
||||
if (start_line->multidata[varnish->id] == WHOLELINE ||
|
||||
start_line->multidata[varnish->id] == STARTSHERE ||
|
||||
start_line->multidata[varnish->id] == WOULDBE)
|
||||
goto seek_an_end;
|
||||
if (start_line->multidata[varnish->id] == CNONE ||
|
||||
start_line->multidata[varnish->id] == CBEGINBEFORE ||
|
||||
start_line->multidata[varnish->id] == CSTARTENDHERE)
|
||||
if (start_line->multidata[varnish->id] == NOTHING ||
|
||||
start_line->multidata[varnish->id] == ENDSHERE ||
|
||||
start_line->multidata[varnish->id] == JUSTONTHIS)
|
||||
goto step_two;
|
||||
}
|
||||
|
||||
/* The preceding line has no precalculated multidata. So, do
|
||||
* some backtracking to find out what to paint. */
|
||||
/* The preceding line has no precalculated multidata.
|
||||
* So, do some backtracking to find out what to paint. */
|
||||
|
||||
/* First step: see if there is a line before current that
|
||||
* matches 'start' and is not complemented by an 'end'. */
|
||||
while (start_line != NULL && regexec(varnish->start,
|
||||
start_line->data, 1, &startmatch, 0) == REG_NOMATCH) {
|
||||
start_line->data, 1, &startmatch, 0) == REG_NOMATCH) {
|
||||
/* There is no start on this line; but if there is an end,
|
||||
* there is no need to look for starts on earlier lines. */
|
||||
if (regexec(varnish->end, start_line->data, 0, NULL, 0) == 0)
|
||||
@@ -2593,14 +2630,14 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||
if (start_line == NULL)
|
||||
goto step_two;
|
||||
|
||||
/* If a found start has been qualified as an end earlier,
|
||||
* believe it and skip to the next step. */
|
||||
/* If the start has been qualified as an end earlier, believe it. */
|
||||
if (start_line->multidata != NULL &&
|
||||
(start_line->multidata[varnish->id] == CBEGINBEFORE ||
|
||||
start_line->multidata[varnish->id] == CSTARTENDHERE))
|
||||
(start_line->multidata[varnish->id] == ENDSHERE ||
|
||||
start_line->multidata[varnish->id] == JUSTONTHIS))
|
||||
goto step_two;
|
||||
|
||||
/* Is there an uncomplemented start on the found line? */
|
||||
/* Maybe there is an end on that same line? If yes, maybe
|
||||
* there is another start after it? And so on, until EOL. */
|
||||
while (TRUE) {
|
||||
/* Begin searching for an end after the start match. */
|
||||
index += startmatch.rm_eo;
|
||||
@@ -2614,7 +2651,7 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||
if (startmatch.rm_so == startmatch.rm_eo &&
|
||||
endmatch.rm_so == endmatch.rm_eo) {
|
||||
if (start_line->data[index] == '\0')
|
||||
break;
|
||||
goto step_two;
|
||||
index = step_right(start_line->data, index);
|
||||
}
|
||||
/* If there is no later start on this line, next step. */
|
||||
@@ -2622,79 +2659,87 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||
1, &startmatch, REG_NOTBOL) == REG_NOMATCH)
|
||||
goto step_two;
|
||||
}
|
||||
/* Indeed, there is a start without an end on that line. */
|
||||
|
||||
seek_an_end:
|
||||
/* We've already checked that there is no end between the start
|
||||
* and the current line. But is there an end after the start
|
||||
* at all? We don't paint unterminated starts. */
|
||||
while (end_line != NULL && regexec(varnish->end, end_line->data,
|
||||
1, &endmatch, 0) == REG_NOMATCH)
|
||||
end_line = end_line->next;
|
||||
* at all? Because we don't paint unterminated starts. */
|
||||
if (row == 0) {
|
||||
while (end_line != NULL && regexec(varnish->end, end_line->data,
|
||||
1, &endmatch, 0) == REG_NOMATCH)
|
||||
end_line = end_line->next;
|
||||
} else if (regexec(varnish->end, line->data, 1, &endmatch, 0) != 0)
|
||||
end_line = line->next;
|
||||
|
||||
/* If there is no end, there is nothing to paint. */
|
||||
if (end_line == NULL) {
|
||||
line->multidata[varnish->id] = CWOULDBE;
|
||||
goto tail_of_loop;
|
||||
line->multidata[varnish->id] = WOULDBE;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If it was already determined that there is no end... */
|
||||
if (end_line != line && line->prev == start_line && line->prev->multidata &&
|
||||
line->prev->multidata[varnish->id] == WOULDBE) {
|
||||
line->multidata[varnish->id] = WOULDBE;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If the end is on a later line, paint whole line, and be done. */
|
||||
if (end_line != line) {
|
||||
wattron(edit, varnish->attributes);
|
||||
mvwaddnstr(edit, row, margin, converted, -1);
|
||||
line->multidata[varnish->id] = CWHOLELINE;
|
||||
goto tail_of_loop;
|
||||
wattroff(edit, varnish->attributes);
|
||||
line->multidata[varnish->id] = WHOLELINE;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Only if it is visible, paint the part to be coloured. */
|
||||
if (endmatch.rm_eo > from_x) {
|
||||
paintlen = actual_x(converted, wideness(line->data,
|
||||
endmatch.rm_eo) - from_col);
|
||||
wattron(edit, varnish->attributes);
|
||||
mvwaddnstr(edit, row, margin, converted, paintlen);
|
||||
wattroff(edit, varnish->attributes);
|
||||
}
|
||||
line->multidata[varnish->id] = CBEGINBEFORE;
|
||||
line->multidata[varnish->id] = ENDSHERE;
|
||||
|
||||
step_two:
|
||||
/* Second step: look for starts on this line, but begin
|
||||
* looking only after an end match, if there is one. */
|
||||
index = (paintlen == 0) ? 0 : endmatch.rm_eo;
|
||||
|
||||
while (regexec(varnish->start, line->data + index,
|
||||
1, &startmatch, (index == 0) ?
|
||||
0 : REG_NOTBOL) == 0) {
|
||||
/* Translate the match to be relative to the
|
||||
* beginning of the line. */
|
||||
while (regexec(varnish->start, line->data + index, 1, &startmatch,
|
||||
(index == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
/* Make the match relative to the beginning of the line. */
|
||||
startmatch.rm_so += index;
|
||||
startmatch.rm_eo += index;
|
||||
|
||||
start_col = (startmatch.rm_so <= from_x) ?
|
||||
0 : wideness(line->data,
|
||||
startmatch.rm_so) - from_col;
|
||||
if (startmatch.rm_so > from_x)
|
||||
start_col = wideness(line->data, startmatch.rm_so) - from_col;
|
||||
|
||||
thetext = converted + actual_x(converted, start_col);
|
||||
|
||||
if (regexec(varnish->end, line->data + startmatch.rm_eo,
|
||||
1, &endmatch, (startmatch.rm_eo == 0) ?
|
||||
0 : REG_NOTBOL) == 0) {
|
||||
/* Translate the end match to be relative to
|
||||
* the beginning of the line. */
|
||||
if (regexec(varnish->end, line->data + startmatch.rm_eo, 1, &endmatch,
|
||||
(startmatch.rm_eo == 0) ? 0 : REG_NOTBOL) == 0) {
|
||||
/* Make the match relative to the beginning of the line. */
|
||||
endmatch.rm_so += startmatch.rm_eo;
|
||||
endmatch.rm_eo += startmatch.rm_eo;
|
||||
/* Only paint the match if it is visible on screen and
|
||||
* it is more than zero characters long. */
|
||||
if (endmatch.rm_eo > from_x &&
|
||||
endmatch.rm_eo > startmatch.rm_so) {
|
||||
/* Only paint the match if it is visible on screen
|
||||
* and it is more than zero characters long. */
|
||||
if (endmatch.rm_eo > from_x && endmatch.rm_eo > startmatch.rm_so) {
|
||||
paintlen = actual_x(thetext, wideness(line->data,
|
||||
endmatch.rm_eo) - from_col - start_col);
|
||||
endmatch.rm_eo) - from_col - start_col);
|
||||
|
||||
mvwaddnstr(edit, row, margin + start_col,
|
||||
thetext, paintlen);
|
||||
wattron(edit, varnish->attributes);
|
||||
mvwaddnstr(edit, row, margin + start_col, thetext, paintlen);
|
||||
wattroff(edit, varnish->attributes);
|
||||
|
||||
line->multidata[varnish->id] = CSTARTENDHERE;
|
||||
line->multidata[varnish->id] = JUSTONTHIS;
|
||||
}
|
||||
index = endmatch.rm_eo;
|
||||
/* If both start and end match are anchors, advance. */
|
||||
if (startmatch.rm_so == startmatch.rm_eo &&
|
||||
endmatch.rm_so == endmatch.rm_eo) {
|
||||
endmatch.rm_so == endmatch.rm_eo) {
|
||||
if (line->data[index] == '\0')
|
||||
break;
|
||||
index = step_right(line->data, index);
|
||||
@@ -2705,23 +2750,32 @@ void draw_row(int row, const char *converted, linestruct *line, size_t from_col)
|
||||
/* There is no end on this line. But maybe on later lines? */
|
||||
end_line = line->next;
|
||||
|
||||
while (end_line != NULL && regexec(varnish->end, end_line->data,
|
||||
0, NULL, 0) == REG_NOMATCH)
|
||||
while (end_line && regexec(varnish->end, end_line->data,
|
||||
0, NULL, 0) == REG_NOMATCH)
|
||||
end_line = end_line->next;
|
||||
|
||||
/* If there is no end, we're done with this regex. */
|
||||
if (end_line == NULL) {
|
||||
line->multidata[varnish->id] = CWOULDBE;
|
||||
line->multidata[varnish->id] = WOULDBE;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Paint the rest of the line, and we're done. */
|
||||
wattron(edit, varnish->attributes);
|
||||
mvwaddnstr(edit, row, margin + start_col, thetext, -1);
|
||||
line->multidata[varnish->id] = CENDAFTER;
|
||||
wattroff(edit, varnish->attributes);
|
||||
|
||||
line->multidata[varnish->id] = STARTSHERE;
|
||||
|
||||
if (end_line->multidata == NULL) {
|
||||
end_line->multidata = nmalloc(openfile->syntax->nmultis * sizeof(short));
|
||||
for (short item = 0; item < openfile->syntax->nmultis; item++)
|
||||
end_line->multidata[item] = 0;
|
||||
}
|
||||
end_line->multidata[varnish->id] = ENDSHERE;
|
||||
|
||||
break;
|
||||
}
|
||||
tail_of_loop:
|
||||
wattroff(edit, varnish->attributes);
|
||||
}
|
||||
}
|
||||
#endif /* ENABLE_COLOR */
|
||||
@@ -2844,7 +2898,7 @@ int update_line(linestruct *line, size_t index)
|
||||
wattroff(edit, hilite_attribute);
|
||||
}
|
||||
|
||||
if (spotlighted && line == openfile->current && !inhelp)
|
||||
if (spotlighted && line == openfile->current)
|
||||
spotlight(light_from_col, light_to_col);
|
||||
|
||||
return 1;
|
||||
@@ -2905,7 +2959,7 @@ int update_softwrapped_line(linestruct *line)
|
||||
from_col = to_col;
|
||||
}
|
||||
|
||||
if (spotlighted && line == openfile->current && !inhelp)
|
||||
if (spotlighted && line == openfile->current)
|
||||
spotlight_softwrapped(light_from_col, light_to_col);
|
||||
|
||||
return (row - starting_row);
|
||||
@@ -3024,22 +3078,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++) {
|
||||
@@ -3253,14 +3311,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));
|
||||
@@ -3269,8 +3324,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
|
||||
@@ -3283,16 +3337,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());
|
||||
@@ -3361,6 +3413,12 @@ void edit_refresh(void)
|
||||
draw_scrollbar();
|
||||
#endif
|
||||
|
||||
//#define TIMEREFRESH 123
|
||||
#ifdef TIMEREFRESH
|
||||
#include <time.h>
|
||||
clock_t start = clock();
|
||||
#endif
|
||||
|
||||
line = openfile->edittop;
|
||||
|
||||
while (row < editwinrows && line != NULL) {
|
||||
@@ -3380,6 +3438,10 @@ void edit_refresh(void)
|
||||
row++;
|
||||
}
|
||||
|
||||
#ifdef TIMEREFRESH
|
||||
statusline(INFO, "Refresh: %.1f ms", 1000 * (double)(clock() - start) / CLOCKS_PER_SEC);
|
||||
#endif
|
||||
|
||||
place_the_cursor();
|
||||
wnoutrefresh(edit);
|
||||
|
||||
@@ -3458,9 +3520,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. */
|
||||
@@ -3484,11 +3548,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[SELECTED_TEXT]);
|
||||
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[SELECTED_TEXT]);
|
||||
wattroff(edit, interface_color_pair[SPOTLIGHTED]);
|
||||
|
||||
free(word);
|
||||
}
|
||||
@@ -3524,9 +3588,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);
|
||||
|
||||
|
||||
@@ -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 "<[^= ]*>" ""(\\.|[^"])*""
|
||||
|
||||
@@ -23,7 +23,7 @@ color red ""[^"]*"" "'[^']*'"
|
||||
color green "`[^`]*`"
|
||||
|
||||
# Error lines:
|
||||
color brightred "^[[:space:]]*\*\*\*.*"
|
||||
color brightred "^[[:blank:]]*\*\*\*.*"
|
||||
|
||||
# Brackets:
|
||||
color magenta "\[|\]|\(|\)"
|
||||
|
||||
@@ -31,7 +31,7 @@ color magenta "\<(bindtextdomain|dcgettext|dcngettext)\>"
|
||||
# Strings.
|
||||
color brightyellow "<[^= ]*>" ""(\\.|[^"])*""
|
||||
# Comments.
|
||||
color brightblue "(^|[[:space:]])#.*$"
|
||||
color brightblue "(^|[[:blank:]])#.*$"
|
||||
|
||||
# Trailing whitespace.
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
@@ -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 "//.*"
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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:]]+$"
|
||||
|
||||
@@ -5,7 +5,7 @@ syntax default
|
||||
comment "#"
|
||||
|
||||
# Comments.
|
||||
color cyan "^[[:space:]]*#.*"
|
||||
color cyan "^[[:blank:]]*#.*"
|
||||
|
||||
# Spaces in front of tabs.
|
||||
color ,red " + +"
|
||||
|
||||
@@ -30,4 +30,4 @@ color blue ":(\w|[?-])+"
|
||||
color yellow start="^[[:blank:]]+"" end="[^\]""
|
||||
color yellow ""(\\.|[^"])*""
|
||||
# Comments
|
||||
color cyan "(^|[[:space:]]);.*"
|
||||
color cyan "(^|[[:blank:]]);.*"
|
||||
|
||||
@@ -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:]]+$"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -21,4 +21,4 @@ color blue "#?:(\w|[?-])+"
|
||||
color yellow start="^[[:blank:]]+"" end="[^\]""
|
||||
color yellow ""(\\.|[^"])*""
|
||||
# Comments
|
||||
color cyan "(^|[[:space:]]);.*"
|
||||
color cyan "(^|[[:blank:]]);.*"
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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:]]+$"
|
||||
|
||||
@@ -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)\>"
|
||||
|
||||
@@ -18,7 +18,7 @@ color blue "\$+[{(][a-zA-Z0-9_-]+[})]"
|
||||
color brightblue "^[^ ]+:"
|
||||
|
||||
# Comments.
|
||||
color green "(^|[[:space:]]+)#.*"
|
||||
color green "(^|[[:blank:]]+)#.*"
|
||||
|
||||
# Trailing whitespace.
|
||||
color ,green "[[:space:]]+$"
|
||||
|
||||
@@ -4,8 +4,14 @@
|
||||
syntax nanohelp
|
||||
|
||||
# Key combos:
|
||||
color cyan "\^[]/4-8@A-Z\^_`◀▶▲▼]" "[◀▶▲▼]" "\<(M|S[Hh]-[Mm])-." "\<F([1-9]|1[0-9]|2[0-4])"
|
||||
color cyan "\^[]/4-8@A-Z\^_`◂▸▴▾-]" "[◂▸▴▾]" "\<(M|S[Hh]-[Mm])-[^")”»“」]" "\<F([1-9]|1[0-9]|2[0-4])"
|
||||
color cyan "\<((Sh-)?Tab|Enter|Ins|(Sh-\^?)?Del|Space|Bsp|Up|Down|Left|Right|Home|End|PgUp|PgDn)\>"
|
||||
|
||||
# Colorize M-) and M-" only when between parentheses...
|
||||
color cyan "\(M-(\)|")\)"
|
||||
color normal " \(|\) "
|
||||
# ...or when at start of line.
|
||||
color cyan "^M-(\)|")"
|
||||
|
||||
# Quoted indicators:
|
||||
color brightred "'(\^|M-)'"
|
||||
|
||||
@@ -6,27 +6,31 @@ comment "#"
|
||||
# Everything that does not get recolored is invalid
|
||||
color brightred ".*"
|
||||
|
||||
# Color names
|
||||
color yellow "^[[:blank:]]*(i?color|set[[:blank:]]+((error|function|key|mini|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|grey|gray)?(,(((light)?(white|black|red|blue|green|yellow|magenta|cyan))|normal|pink|purple|mauve|lagoon|mint|lime|peach|orange|latte|grey|gray))?\>"
|
||||
|
||||
# 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|markmatch|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|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|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 brightgreen "^[[:blank:]]*set[[:blank:]]+(backupdir|brackets|errorcolor|functioncolor|keycolor|matchbrackets|minicolor|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)="
|
||||
# Control codes
|
||||
color bold,pink "[[:cntrl:]]"
|
||||
|
||||
# Color commands
|
||||
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:]]+$"
|
||||
|
||||
@@ -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:]]+$"
|
||||
|
||||
@@ -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 "//.*"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -5,7 +5,7 @@ magic "PHP script"
|
||||
comment "//"
|
||||
|
||||
# PHP markings.
|
||||
color brightgreen "(<\?(php)?|\?>)"
|
||||
color brightgreen "(<\?(php|=)?|\?>)"
|
||||
|
||||
# Function names.
|
||||
color white "\<[A-Za-z_][A-Za-z_0-9]*\("
|
||||
@@ -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.
|
||||
|
||||
@@ -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})"
|
||||
|
||||
@@ -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 ""(\\.|[^"])*"" "'(\\.|[^'])*'"
|
||||
|
||||
@@ -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:]]*#.*"
|
||||
|
||||
Reference in New Issue
Block a user