From 5525942013af4b23fe9a8d2dde20abd681e05ac2 Mon Sep 17 00:00:00 2001 From: Dejan Budimir Date: Tue, 21 Apr 2020 22:11:01 +1000 Subject: Feature [feature-requests:1346]. Add lexer.as.comment.character property to change comment character. --- doc/ScintillaHistory.html | 4 ++++ lexers/LexAsm.cxx | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index a585f0751..413d13ee4 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -578,6 +578,10 @@ Feature #1344.
  • + Assembler lexers asm and as can change comment character with lexer.as.comment.character property. + Feature #1314. +
  • +
  • Fix brace styling in Batch lexer so that brace matching works. Bug #1624, Bug #1906, diff --git a/lexers/LexAsm.cxx b/lexers/LexAsm.cxx index 8c30087cd..4560f9751 100644 --- a/lexers/LexAsm.cxx +++ b/lexers/LexAsm.cxx @@ -80,6 +80,7 @@ struct OptionsAsm { std::string foldExplicitEnd; bool foldExplicitAnywhere; bool foldCompact; + std::string commentChar; OptionsAsm() { delimiter = ""; fold = false; @@ -90,6 +91,7 @@ struct OptionsAsm { foldExplicitEnd = ""; foldExplicitAnywhere = false; foldCompact = true; + commentChar = ""; } }; @@ -134,6 +136,9 @@ struct OptionSetAsm : public OptionSet { DefineProperty("fold.compact", &OptionsAsm::foldCompact); + DefineProperty("lexer.as.comment.character", &OptionsAsm::commentChar, + "Overrides the default comment character (which is ';' for asm and '#' for as)."); + DefineWordListSets(asmWordListDesc); } }; @@ -245,6 +250,9 @@ Sci_Position SCI_METHOD LexerAsm::WordListSet(int n, const char *wl) { void SCI_METHOD LexerAsm::Lex(Sci_PositionU startPos, Sci_Position length, int initStyle, IDocument *pAccess) { LexAccessor styler(pAccess); + const char commentCharacter = options.commentChar.empty() ? + commentChar : options.commentChar.front(); + // Do not leak onto next line if (initStyle == SCE_ASM_STRINGEOL) initStyle = SCE_ASM_DEFAULT; @@ -350,7 +358,7 @@ void SCI_METHOD LexerAsm::Lex(Sci_PositionU startPos, Sci_Position length, int i // Determine if a new state should be entered. if (sc.state == SCE_ASM_DEFAULT) { - if (sc.ch == commentChar){ + if (sc.ch == commentCharacter) { sc.SetState(SCE_ASM_COMMENT); } else if (IsASCII(sc.ch) && (isdigit(sc.ch) || (sc.ch == '.' && IsASCII(sc.chNext) && isdigit(sc.chNext)))) { sc.SetState(SCE_ASM_NUMBER); -- cgit v1.2.3