From fec019ab586df8109390b2c33cd8395bd4625ea0 Mon Sep 17 00:00:00 2001 From: Liu Hao Date: Thu, 7 Dec 2017 17:13:25 +0800 Subject: [PATCH 2/7] 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/syntax/c.nanorc b/syntax/c.nanorc index 5025ff59..fd1e671f 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,10 @@ 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|ifn?def|endif|elif|if|warning|error|pragma)\>" end="[^\\]$" +color brightcyan "^[[:space:]]*#[[:space:]]*(include(_next)?|undef|endif|else).*$" + # Comments. color brightblue "//.*" color brightblue start="/\*" end="\*/" -- 2.15.0