From 173cde950018f9c8b4b75610d3f2981cf2e23776 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Fri, 8 Jul 2011 09:01:59 +1000 Subject: Bug #3325333. Property lexer.python.keywords2.no.sub.identifiers controls whether keywords from the keywords2 list are valid after '.'. From Todd Whiteman. --- lexers/LexPython.cxx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'lexers/LexPython.cxx') diff --git a/lexers/LexPython.cxx b/lexers/LexPython.cxx index 8cb95e1d3..b25289d2e 100644 --- a/lexers/LexPython.cxx +++ b/lexers/LexPython.cxx @@ -165,6 +165,11 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle, // Set to 1 to allow strings to span newline characters. bool stringsOverNewline = styler.GetPropertyInt("lexer.python.strings.over.newline") != 0; + // property lexer.python.keywords2.no.sub.identifiers + // When enabled, it will not style keywords2 items that are used as a sub-identifier. + // Example: when set, will not highlight "foo.open" when "open" is a keywords2 item. + const bool keywords2NoSubIdentifiers = styler.GetPropertyInt("lexer.python.keywords2.no.sub.identifiers") != 0; + initStyle = initStyle & 31; if (initStyle == SCE_P_STRINGEOL) { initStyle = SCE_P_DEFAULT; @@ -264,12 +269,16 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle, } } } else if (keywords2.InList(s)) { - // We don't want to highlight keywords2 - // that are used as a sub-identifier, - // i.e. not open in "foo.open". - int pos = styler.GetStartSegment() - 1; - if (pos < 0 || (styler.SafeGetCharAt(pos, '\0') != '.')) + if (keywords2NoSubIdentifiers) { + // We don't want to highlight keywords2 + // that are used as a sub-identifier, + // i.e. not open in "foo.open". + int pos = styler.GetStartSegment() - 1; + if (pos < 0 || (styler.SafeGetCharAt(pos, '\0') != '.')) + style = SCE_P_WORD2; + } else { style = SCE_P_WORD2; + } } sc.ChangeState(style); sc.SetState(SCE_P_DEFAULT); -- cgit v1.2.3