Commit Graph

287 Commits

Author SHA1 Message Date
Benjamin Mintz
790f98560b syntax: python: do not highlight 'print' and 'exec' in Python 3
Assume that 'print' and 'exec' are statements when they are followed
by whitespace, and are functions otherwise.  This does not highlight
"print'x'" nor "print{x}", but these statements are poor style.

Signed-off-by: Benjamin Mintz <bmintz@protonmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-09-20 20:45:01 +02:00
Benno Schulenberg
e2051a61e0 syntax: sh: let the header regex match also busybox shell scripts
And recognize calls via 'env' too.

This addresses https://savannah.gnu.org/bugs/?54674.
Reported-by: Aaron Sears <geodelic@gmail.com>
2018-09-18 19:06:11 +02:00
Benno Schulenberg
921f8ae4c9 syntax: default: colorize also two-digit and capitalized nano versions 2018-08-30 19:46:34 +02:00
Mark-Weston
bf5949395d syntax: lua: do not color strings inside comments, and add a linter
Also, don't partially color "..." as an operator, because it isn't,
and color also the unary operator "#".

Signed-off-by: Mark-Weston <markweston@cock.li>
2018-08-28 20:16:16 +02:00
Benno Schulenberg
c524fbe6d0 tweaks: remove some ineffectual parts from header-line regexes
Adding "[abc]*" does not restrict the recognized header line in any way.

Also, improve the header-line regex for shell scripts, because it should
not match "barunscript" (for example).
2018-08-28 19:53:36 +02:00
Benno Schulenberg
850e538ff7 syntax: python: avoid coloring the three special values inside strings
Reported-by: Benjamin Mintz <bmintz@protonmail.com>
Suggested-by: Brand Huntsman <alpha@qzx.com>
2018-08-16 19:56:01 +02:00
Benno Schulenberg
18419b5e3f syntax: awk: recognize any {g,m,n,}awk script also by its shebang line
This fulfills https://savannah.gnu.org/bugs/?54516.

Suggested-by: Javier Valencia <javiervalencia80@gmail.com>
2018-08-15 20:20:22 +02:00
Benno Schulenberg
2d434f63e2 syntaxes: remove all traces of the 'formatter' command 2018-08-09 21:12:10 +02:00
Benno Schulenberg
db1893ef2d syntax: nanorc: recognize 'yesno' as a valid menu to bind/unbind keys in 2018-08-06 18:05:10 +02:00
Benno Schulenberg
ac102a7516 tweaks: show "Space" and "Bsp" in the help text of the browser
These keys make more mnemonic sense for scrolling than F7 and F8.

Also adjust the nanohelp syntax to cover the lone word "Space".
2018-07-31 20:36:32 +02:00
Devin Hussey
4a268678a5 syntax: sh: recognize more file extensions and header lines
Signed-off-by: Devin Hussey <husseydevin@gmail.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-07-20 19:12:20 +02:00
Benno Schulenberg
acadf71b13 syntax: nanorc: show ^@ as validly rebindable, but not any ^digit 2018-07-11 14:14:40 +02:00
Benno Schulenberg
8492de53f7 syntax: makefile: color all keywords that GNU make recognizes
Plus one that automake recognizes: if.  Color them only at the start
of a line.  Also color all possible assignment sequences (surrounded
by spaces to not color the ones in shell fragments), and add some
comments.
2018-05-30 11:29:08 +02:00
Cristian Caloghera
22663f8a2e syntax: makefile: recognize also an all-lowercase makefile name
Recognize not just "Makefile" but also "makefile" and "GNUmakefile".
And recognize these only when they are the full filenames, not when
they are the tail part of a longer name.

Signed-off-by: Cristian Caloghera <cristi.caloghera@gmail.com>
2018-05-22 20:41:43 +02:00
Benno Schulenberg
cdd637d69f syntaxes: condense and/or correct some extension regexes 2018-05-18 20:40:08 +02:00
Mark-Weston
858663444e new feature: an option to make the 'nextword' function stop at word ends
When 'afterends' is set and Ctrl+Right or Shift+Ctrl+Right is pressed,
nano will stop at the ends of words instead of their beginnings.

Signed-off-by: Mark-Weston <markweston@cock.li>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
2018-05-10 11:32:01 +02:00
Benno Schulenberg
30a984661b syntax: po: highlight also other escaped characters, not just \n
Especially color \a and \t, to make it easier to distinguish them
from contiguous text.
2018-04-17 09:56:19 +02:00
Benno Schulenberg
cf1129a8b4 syntax: sh: colorize options only when they are preceded by whitespace
To prevent any filenames containing hyphens getting partially colored.

Reported-by: Brand Huntsman <alpha@qzx.com>
2018-03-30 10:46:56 +02:00
Benno Schulenberg
0bce5ba4d9 syntax: sh: color options distinctively, and color also long options
Also add some comments, and accept hyphens in function names.
2018-03-29 09:51:39 +02:00
Benno Schulenberg
20d1823d90 syntax: sh: uncolor "tar" when it's part of a filename 2018-03-28 14:04:00 +02:00
Benno Schulenberg
e01bcddf16 docs: document the newly added color name "normal" 2018-03-28 14:03:52 +02:00
Benno Schulenberg
1de3667555 syntax: sh: color also the 'cut', 'head', 'tail', and 'sort' commands 2018-03-27 14:09:38 +02:00
Benno Schulenberg
ae9ec6d4ad syntax: nanorc: color also bindings to a string as valid 2018-03-01 10:09:28 +01:00
Benno Schulenberg
8f1a657a37 bindings: revert the ^/ changes, as ^/ is not always Go-To-Line
On a Linux console, ^/ produces Backspace, making it unrebindable.

This fixes https://savannah.gnu.org/bugs/?53248.
2018-03-01 09:50:54 +01:00
Benno Schulenberg
082e5db4b7 syntax: color also ^/ in nano's help texts and in nanorc files
As of commit c79fe1a1, the more readable ^/ has replaced ^_ as the
advertised shortcut for Go-To-Line -- color it too as valid.
2018-02-27 18:06:33 +01:00
Benno Schulenberg
b027263a37 small addition: allow customizing the color of an error message
The new option 'set errorcolor' allows the user to specify the color
combination for the status bar when an error message is displayed.
2018-02-23 12:35:17 +01:00
Tom Levy
fef195bce9 syntax: go: highlight also floats with leading zeroes as valid
See the discussion on the mailing list:
https://lists.gnu.org/archive/html/nano-devel/2018-01/msg00022.html
https://lists.gnu.org/archive/html/nano-devel/2018-02/msg00090.html

Signed-off-by: Tom Levy <tomlevy93@gmail.com>
2018-02-20 10:31:38 +01:00
Benno Schulenberg
3e1fc6385b syntaxes: remove quotes from each syntax name, and color it differently
The different color will make the name stand out, as it should, instead
of looking the same as all the regex strings.
2018-02-14 17:36:50 +01:00
Benno Schulenberg
452008c81d syntax: go: colorize only valid octal numbers
Reported-by: Tom Levy <tomlevy93@gmail.com>
2018-01-26 11:15:26 +01:00
Benno Schulenberg
8067efa6cc syntax: nanohelp: color also the Sh-Tab key combo 2018-01-09 16:34:31 +01:00
Benno Schulenberg
c6f367268b syntax: lua: do not color debug.setinfo as it doesn't exist
Reported-by: Tom Levy <tomlevy93@gmail.com>
2018-01-06 17:59:28 +01:00
Benno Schulenberg
5965e80a38 tweaks: fold some regexes into one another, for conciseness
The anchored "^texture" appears to have been a mistake.

Inspired-by: Tom Levy <tomlevy93@gmail.com>
2018-01-01 16:00:18 +01:00
Tom Levy
a794c3318b syntax: go: sign of exponent in number literal is optional
Signed-off-by: Tom Levy <tomlevy93@gmail.com>
2018-01-01 15:27:31 +01:00
Tom Levy
d04b0c123e syntax: go: fix word boundary before dot in number literal
The fragment "\<\." can never match anything because \< matches the
beginning of a word but "." is not a word character.

Replace \< with \B (the empty string not at the edge of a word).

Signed-off-by: Tom Levy <tomlevy93@gmail.com>
2018-01-01 15:25:26 +01:00
Benno Schulenberg
21cd953e85 syntax: lua: condense some regexes, tweak comments, reorder things
Also remove some redundant backslashes and parentheses.
2018-01-01 14:59:00 +01:00
Tom Levy
058b9da9b9 syntax: lua: add new and missing standard library functions
The list now includes all the Lua 5.3 functions listed on
https://www.lua.org/manual/5.3/#index.

Also, remove the coloring of just the library name, so that
only known library functions get highlighted.

Signed-off-by: Tom Levy <tomlevy93@gmail.com>
2018-01-01 14:35:19 +01:00
Tom Levy
38a10a62d0 syntax: lua: support fractional part and exponent for decimal and hex
As of Lua 5.2: "Hexadecimal constants also accept an optional fractional
part plus an optional binary exponent, marked by a letter 'p' or 'P'"
(see at the end of https://www.lua.org/manual/5.2/manual.html#3.1).

The new regexes do not match a leading nor a trailing dot, but they
are good enough.  Discussion on the mailing list:
https://lists.gnu.org/archive/html/nano-devel/2017-12/msg00121.html

Signed-off-by: Tom Levy <tomlevy93@gmail.com>
2018-01-01 14:15:14 +01:00
Tom Levy
091e8faf6d syntax: lua: require at least one digit for hexadecimal numbers
Since a "0x" by itself is invalid.  Also add word boundaries, so that
e.g. "00x1" (which is invalid) does not get partial highlighting.

Also remove some redundant backslashes from the strings regex.

Signed-off-by: Tom Levy <tomlevy93@gmail.com>
2018-01-01 13:51:10 +01:00
Benno Schulenberg
1f48ed0412 syntaxes: remove redundant word-boundary markers 2017-12-30 17:32:15 +01:00
Tom Levy
4f2b01c7e5 syntax: lua: correct the word boundaries on standard library functions
Functions such as "io.close" should only be highlighted when the
package name ("io") is a word by itself, otherwise code such as
"fooio.close" gets unexpected partial highlighting.

Signed-off-by: Tom Levy <tomlevy93@gmail.com>
2017-12-28 21:46:26 +01:00
Benno Schulenberg
bdbd5ff0e7 syntax: javascript: add some comments, and color explicit numbers too 2017-12-25 16:03:05 +01:00
Benno Schulenberg
f769465284 syntax: javascript: add some keywords, and sort them more logically
Also, remove angle-bracketed "strings" -- they don't exist.
2017-12-25 15:40:05 +01:00
Benno Schulenberg
1b5b52d2e4 syntax: javascript: color strings differently from major keywords
Also, remove the coloring of special single-quoted strings as they
get recolored by the subsequent general string-coloring command.

And remove the coloring of all-uppercase words, as other editors
do not color those either.
2017-12-25 15:36:35 +01:00
Benno Schulenberg
ab62d28817 syntax: javascript: require that a comment is preceded by whitespace
Either by whitespace or by the start of a line.

This avoids treating part of a URL as a comment.
2017-12-25 15:25:04 +01:00
Mike Frysinger
8e0a7ec20d syntax: javascript: add newer keywords and string syntax 2017-12-25 15:08:03 +01:00
Michael Francis
53fc9a66a6 syntax: php: function and variable names can contain uppercase and digits
Reference: http://php.net/manual/en/language.variables.basics.php

Also color keywords differently from strings.

Signed-off-by: Michael Francis <mikefrancis95@gmail.com>
2017-12-11 21:02:36 +01:00
Benno Schulenberg
ddb8e95d39 syntax: python: color also the special values 'False', 'None', 'True'
And increase the contrast for the reminders, both for PO and Python.
2017-12-10 14:35:13 +01:00
Benjamin Mintz
fbac4505ce syntax: python: add 'async', 'await', and 'nonlocal' as keywords
A list of keywords can be obtained from `keyword.kwlist`.

Signed-off-by: Benjamin Mintz <bmintz@protonmail.com>
2017-12-10 14:23:51 +01:00
Liu Hao
5144162a2d syntax: c: increase the color contrast of reminders like FIXME
Bright white on yellow stands out much more than grey on yellow.

Signed-off-by: Liu Hao <lh_mouse@126.com>
2017-12-09 16:58:57 +01:00
Benno Schulenberg
66fd6a5ab1 options: rename 'justifytrim' to 'trimblanks', because it has morphed
The option now causes nano to trim trailing whitespace also when
hardwrapping occurs while the user is typing.
2017-12-06 20:38:13 +01:00
Benno Schulenberg
4761e00852 syntax: nanorc: don't color parts of valid strings as if invalid
It's better to color some invalid things as if valid than the other
way around.  So, as strings can validly contain any number of double
quotes, just accept *anything* between the delimiting double quotes
and demand that the closing quote is followed by whitespace or EOL.
2017-12-03 20:09:47 +01:00
Benno Schulenberg
bacb0f717d syntax: adjust the magic strings for the changes since file-5.10
Since file-5.10 (end of 2011), libmagic identifies a C file in most
cases as "C source" instead of as "C program".  Nano's magic strings
for some other files didn't match any more what file-5.32 currently
produces, either.  So, they have been adjusted, new ones added, and
old ones deleted.

This fixes https://savannah.gnu.org/bugs/?52445.
2017-11-19 11:24:30 +01:00
Benno Schulenberg
14bf53ddfc syntax: default: use colors that are readable also on dark backgrounds 2017-10-26 21:07:11 +02:00
Benno Schulenberg
58ecc034d0 tweaks: change the help-text arrows to triangles, to be more visible
Requested-by: Brand Huntsman <alpha@qzx.com>
2017-10-15 21:23:33 +02:00
Benno Schulenberg
d0119833c1 tweaks: reshuffle some regexes, for order and compactness 2017-10-11 21:52:18 +02:00
Brand Huntsman
d4074ca85b syntax: nanohelp: colorize Up, Down, Left and Right (when not in UTF-8)
Signed-off-by: Brand Huntsman <alpha@qzx.com>
2017-10-11 21:50:47 +02:00
David Lawrence Ramsey
3f35e9670f syntax: nanorc: properly color valid arguments of 'selectedcolor'
This fixes https://savannah.gnu.org/bugs/?52114.
2017-09-26 19:35:55 +02:00
Benno Schulenberg
3f0e42c13b syntax: c: give labels some color too 2017-08-15 11:00:31 +02:00
Benno Schulenberg
884d410d9d syntax: python: don't require a character after an opening triple quote
The succeeding character was needed to avoid miscolorings due to nano
getting confused about starts and ends.  But since commit 7ef5c532,
nano should be getting the starts and ends always right, so... undo
"temporary" commit 7b2ea405 from two years ago.

This addresses https://savannah.gnu.org/bugs/?51526.
Reported-by: <exodus6395@googlemail.com>
2017-08-06 09:50:34 +02:00
David Lawrence Ramsey
1c1cbae6bc small addition: allow customizing the color of selected text
The new option 'set selectedcolor' applies to marked text, to the
currently selected file in the file browser, and to the highlighted
match during interactive search-and-replace.
2017-08-06 09:30:32 +02:00
Benno Schulenberg
94b484ea97 syntax: html: don't bother coloring tags that cross line boundaries
Prefer speed above being fully correct.

This addresses https://savannah.gnu.org/bugs/?51644.
2017-08-03 21:18:34 +02:00
Benno Schulenberg
63c428ad08 options: rename --cut to --cutfromcursor, to be clearer
Rename the corresponding rc-file option too, of course.
2017-07-14 16:06:52 +02:00
Benno Schulenberg
f55b65bd99 syntax: nanorc: don't color the argument of 'linter' as if invalid
Color it bright green instead, like valid numeric arguments of
'fill' and 'tabsize'.  Also color the argument of 'formatter'.
2017-07-14 15:32:56 +02:00
Benno Schulenberg
fb5478338f syntax: texinfo: cover also some special cases like @U, @OE and @TeX 2017-07-14 10:29:36 +02:00
David Lawrence Ramsey
bb4d0d548a new feature: allow lines to be softwrapped at whitespace
Extend get_softwrap_breakpoint() to break softwrapped lines on
whitespace when a flag is set.  This flag is controlled by the new
rcfile option "atblanks".  The '>' characters marking two-column
characters at the edge of the screen are disabled when it's on.

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

This fulfills https://savannah.gnu.org/bugs/index.php?49959.
Requested-by: Nicholas Boel <axxisd@gmail.com>
2017-07-07 13:07:10 +02:00
Benno Schulenberg
79971a309f docs: remove the mention of backslashes for the argument of 'comment'
Also remove the backslashes from the two syntaxes that contained them.

This completes the fix for https://savannah.gnu.org/bugs/?51370.
2017-07-07 10:15:17 +02:00
Benno Schulenberg
09f516a58b syntax: man, groff: fix the string that introduces a comment
The comment marker is not «."» but «.\"», which requires three
backslashes to specify.  Also adjust the documentation.
2017-07-03 11:07:21 +02:00
Benno Schulenberg
1c05090a4a syntax: gentoo: make it clearer that the file contains two syntaxes 2017-07-02 20:27:04 +02:00
Benno Schulenberg
50cbde8b23 syntax: nanorc: don't color numeric arguments specially
Negative arguments of 'fill' are bright green since a few commits.
So now color all valid numeric arguments in that same style -- the
yellow was hard to see on a dark background anyway.

Also, color a zero tabsize as invalid.
2017-06-29 19:45:39 +02:00
David Lawrence Ramsey
2704b3874b syntax: nanorc: properly color a "fill" option with a negative value 2017-06-29 17:25:09 +02:00
Benno Schulenberg
4063fce6a0 syntax: default: allow leading whitespace before a hash comment 2017-05-23 20:07:15 +02:00
Benno Schulenberg
c68398f18f syntax: php: color "static" again as "function", like it used to be 2017-05-21 10:11:42 +02:00
Benno Schulenberg
d653aeab93 syntax: default: color also hash comments and email addresses 2017-05-19 21:09:15 +02:00
Benno Schulenberg
e4775c2060 syntax: php: color also variable names, and color more reserved words
Most of the keywords listed on the following URL are now highlighted:
  http://php.net/manual/en/reserved.keywords.php

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

With-feedback-from: M <taur@mail.com>
2017-05-18 10:03:43 +02:00
Benno Schulenberg
c830b8f51c syntax: php: recognize also the .phtml and .php7 extensions
(And in the bargain sort or group some of the keywords.)

This addresses https://savannah.gnu.org/patch/?9342.
Suggested-by: M <taur@mail.com>
2017-05-15 10:57:57 +02:00
Benno Schulenberg
7e09f2c64a syntax: makefile: color comments only at start of line or after whitespace 2017-05-09 17:37:05 +02:00
Benno Schulenberg
a3102cd4cf syntax: xml: recognize an XML file also by its first line
Some .rdf files are XML, but the .rdf extension seems to be used
also for other things.  So... use the 'header' mechanism.
2017-05-07 20:02:20 +02:00
Benno Schulenberg
da67883508 syntax: nanohelp: color also ^6 as a shortcut keystroke
(Hadn't seen that one because of my additional bindings.)
2017-05-07 20:00:52 +02:00
Benno Schulenberg
17cf7d1c62 syntax: nanohelp: change the hue of the keystrokes to match sample.nanorc
And because I think it looks slightly better.
2017-04-30 17:37:07 +02:00
Benno Schulenberg
9cff7a1689 help: use a dedicated syntax to color shortcuts in a help text
This avoids applying the default syntax, or the syntax specified
with --syntax, to a ^G help text.
2017-04-25 17:21:46 +02:00
David Lawrence Ramsey
f4ee83a76d syntax: nanorc: color also the option "linenumbers" as being valid 2017-03-24 21:18:17 +01:00
Benno Schulenberg
6d873d3760 startup: add option 'nopauses' to disable pausing after a warning
This addresses a followup of https://savannah.gnu.org/bugs/?50362.
Reported-by: Mike Frysinger <vapier@gentoo.org>
2017-03-16 19:26:39 +01:00
Mike Frysinger
d0c64e8086 syntax: gentoo: match .eblit files too 2017-02-22 13:35:36 -05:00
Mike Frysinger
cd5d7faa4e syntax: gentoo: flag mixed whitespace 2017-02-21 17:46:13 +01:00
Mike Frysinger
3ca6c9241f syntax: c++: add override keyword 2017-02-21 17:46:07 +01:00
Benno Schulenberg
124a859516 syntax: html: be more precise with tags, and paint attribute names
A tag begins not merely with a "<" but it must be followed by an
ASCII alphabetic character or one of "/", "!" and "?".

Further, color all the valid attribute names in red.
2017-01-08 11:32:30 +01:00
Benno Schulenberg
b0ef2e2803 build: move the syntax files out of the doc/ directory
They are not documentation, they are functional elements of nano.
2016-12-30 22:05:01 +01:00