diff options
Diffstat (limited to 'lexers/LexEDIFACT.cxx')
-rw-r--r-- | lexers/LexEDIFACT.cxx | 38 |
1 files changed, 28 insertions, 10 deletions
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; |