diff options
author | Iain Clarke <unknown> | 2018-05-06 21:06:50 +1000 |
---|---|---|
committer | Iain Clarke <unknown> | 2018-05-06 21:06:50 +1000 |
commit | 27350b902ec6bf006522d14e5abbae1ac55a9820 (patch) | |
tree | fffc16924fa82e787c7908079fb67f4d43a04b69 | |
parent | febfe318c389054b29f93ada0952dfbc9ac76145 (diff) | |
download | scintilla-mirror-27350b902ec6bf006522d14e5abbae1ac55a9820.tar.gz |
Feature [feature-requests:#1166]. Property lexer.edifact.highlight.un.all
highlights UN* segments.
-rw-r--r-- | doc/ScintillaHistory.html | 4 | ||||
-rw-r--r-- | lexers/LexEDIFACT.cxx | 38 |
2 files changed, 32 insertions, 10 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index 8aa1c0bc5..b22267265 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -554,6 +554,10 @@ SciTE can read settings in EditorConfig format when enabled with editor.config.enable property. </li> <li> + EDIFACT lexer adds property lexer.edifact.highlight.un.all to highlight all UN* segments. + <a href="https://sourceforge.net/p/scintilla/feature-requests/1166/">Feature #1166.</a> + </li> + <li> Fortran folder understands "change team" and "endteam". <a href="https://sourceforge.net/p/scintilla/feature-requests/1216/">Feature #1216.</a> </li> diff --git a/lexers/LexEDIFACT.cxx b/lexers/LexEDIFACT.cxx index 3f30fb8cf..6796c185d 100644 --- a/lexers/LexEDIFACT.cxx +++ b/lexers/LexEDIFACT.cxx @@ -43,7 +43,7 @@ public: const char * SCI_METHOD PropertyNames() override { - return "fold"; + return "fold\nlexer.edifact.highlight.un.all"; } int SCI_METHOD PropertyType(const char *) override { @@ -51,17 +51,26 @@ public: } const char * SCI_METHOD DescribeProperty(const char *name) override { - if (strcmp(name, "fold")) - return NULL; - return "Whether to apply folding to document or not"; + if (!strcmp(name, "fold")) + return "Whether to apply folding to document or not"; + if (!strcmp(name, "lexer.edifact.highlight.un.all")) + return "Whether to apply UN* highlighting to all UN segments, or just to UNH"; + return NULL; } Sci_Position SCI_METHOD PropertySet(const char *key, const char *val) override { - if (strcmp(key, "fold")) - return -1; - m_bFold = strcmp(val, "0") ? true : false; - return 0; + if (!strcmp(key, "fold")) + { + m_bFold = strcmp(val, "0") ? true : false; + return 0; + } + if (!strcmp(key, "lexer.edifact.highlight.un.all")) // GetProperty + { + m_bHighlightAllUN = strcmp(val, "0") ? true : false; + return 0; + } + return -1; } const char * SCI_METHOD DescribeWordListSets() override { @@ -85,6 +94,11 @@ protected: int DetectSegmentHeader(char SegmentHeader[3]) const; bool m_bFold; + + // property lexer.edifact.highlight.un.all + // Set to 0 to highlight only UNA segments, or 1 to highlight all UNx segments. + bool m_bHighlightAllUN; + char m_chComponent; char m_chData; char m_chDecimal; @@ -103,6 +117,7 @@ LexerModule lmEDIFACT(SCLEX_EDIFACT, LexerEDIFACT::Factory, "edifact"); LexerEDIFACT::LexerEDIFACT() { m_bFold = false; + m_bHighlightAllUN = false; m_chComponent = ':'; m_chData = '+'; m_chDecimal = '.'; @@ -294,9 +309,12 @@ int LexerEDIFACT::DetectSegmentHeader(char SegmentHeader[3]) const SegmentHeader[2] < 'A' || SegmentHeader[2] > 'Z') return SCE_EDI_BADSEGMENT; - if (memcmp(SegmentHeader, "UNA", 3) == 0) + if (!memcmp(SegmentHeader, "UNA", 3)) return SCE_EDI_UNA; - if (memcmp(SegmentHeader, "UNH", 3) == 0) + + if (m_bHighlightAllUN && !memcmp(SegmentHeader, "UN", 2)) + return SCE_EDI_UNH; + else if (memcmp(SegmentHeader, "UNH", 3) == 0) return SCE_EDI_UNH; return SCE_EDI_SEGMENTSTART; |