From 2dcc31216c9b6a3bc8660829e6f589875527ed8f Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sat, 16 Apr 2011 15:04:59 +1000 Subject: Support cython cpdef keyword. Bug #3279728. From Stephan R.A. Deibel. --- lexers/LexPython.cxx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lexers/LexPython.cxx') diff --git a/lexers/LexPython.cxx b/lexers/LexPython.cxx index 5020d71df..70db1ecd8 100644 --- a/lexers/LexPython.cxx +++ b/lexers/LexPython.cxx @@ -28,7 +28,7 @@ using namespace Scintilla; #endif /* kwCDef, kwCTypeName only used for Cython */ -enum kwType { kwOther, kwClass, kwDef, kwImport, kwCDef, kwCTypeName }; +enum kwType { kwOther, kwClass, kwDef, kwImport, kwCDef, kwCTypeName, kwCPDef }; static const int indicatorWhitespace = 1; @@ -246,7 +246,7 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle, style = SCE_P_CLASSNAME; } else if (kwLast == kwDef) { style = SCE_P_DEFNAME; - } else if (kwLast == kwCDef) { + } else if (kwLast == kwCDef || kwLast == kwCPDef) { int pos = sc.currentPos; unsigned char ch = styler.SafeGetCharAt(pos, '\0'); while (ch != '\0') { @@ -277,11 +277,13 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle, kwLast = kwImport; else if (0 == strcmp(s, "cdef")) kwLast = kwCDef; + else if (0 == strcmp(s, "cpdef")) + kwLast = kwCPDef; else if (0 == strcmp(s, "cimport")) kwLast = kwImport; - else if (kwLast != kwCDef) + else if (kwLast != kwCDef && kwLast != kwCPDef) kwLast = kwOther; - } else if (kwLast != kwCDef) { + } else if (kwLast != kwCDef && kwLast != kwCPDef) { kwLast = kwOther; } } @@ -337,8 +339,8 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle, indentGood = true; } - // One cdef line, clear kwLast only at end of line - if (kwLast == kwCDef && sc.atLineEnd) { + // One cdef or cpdef line, clear kwLast only at end of line + if ((kwLast == kwCDef || kwLast == kwCPDef) && sc.atLineEnd) { kwLast = kwOther; } -- cgit v1.2.3