From 70899edb71fa4a205acafe57c595a233b8c6ddd9 Mon Sep 17 00:00:00 2001 From: Liu Hao Date: Thu, 7 Dec 2017 17:13:25 +0800 Subject: [PATCH 2/9] syntax: adjust highlighting of preprocessor directives Rules of highlighting of preprocessor directives are moved after everything but comments, so an entire directive is always colored, as preprocessor directives do not follow the other syntactical rules. A preprocessor directive is terminated by an unescaped new line, no matter whether it is single-line or multiple-line. Signed-off-by: Liu Hao --- syntax/c.nanorc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/syntax/c.nanorc b/syntax/c.nanorc index c6de55c6..20f7bee2 100644 --- a/syntax/c.nanorc +++ b/syntax/c.nanorc @@ -15,7 +15,6 @@ color green "\<(class|namespace|template|public|protected|private|typename|this| color brightyellow "\<(for|if|while|do|else|case|default|switch)\>" color brightyellow "\<(try|throw|catch|operator|new|delete|(static|dynamic|const|reinterpret)_cast|static_assert|_Static_assert)\>" color magenta "\<(goto|continue|break|return)\>" -color brightcyan "^[[:space:]]*#[[:space:]]*(define|include(_next)?|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)" color brightmagenta "'([^'\]|(\\["'abfnrtv\\]))'" "'\\(([0-3]?[0-7]{1,2}))'" "'\\x[0-9A-Fa-f]{1,2}'" color brightgreen "\<(_Pragma|__has_include|_Generic)\>" @@ -29,6 +28,9 @@ color brightyellow ""([^"]|\\")*"" "<[^[:blank:]=]*>" # and sometimes colours things that shouldn't be coloured. ###color brightyellow start=""(\\.|[^"])*\\[[:space:]]*$" end="^(\\.|[^"])*"" +# Preprocessor directives. +color brightcyan start="^[[:space:]]*#[[:space:]]*(define|include(_next)?|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)[[:space:]]" end="[^\\]$" + # Comments. color brightblue "//.*" color brightblue start="/\*" end="\*/" -- 2.15.0