From b8c1e937bf91ace6488f1b636f9d5c353b7bc4c3 Mon Sep 17 00:00:00 2001 From: "royqh1979@gmail.com" Date: Thu, 1 Jul 2021 22:29:51 +0800 Subject: [PATCH] work save --- RedPandaIDE/qsynedit/Constants.h | 1 + RedPandaIDE/qsynedit/highlighter/asm.cpp | 51 +++++++++++++++--------- RedPandaIDE/qsynedit/highlighter/asm.h | 39 ++++++++++++++---- RedPandaIDE/qsynedit/highlighter/base.h | 1 + 4 files changed, 67 insertions(+), 25 deletions(-) diff --git a/RedPandaIDE/qsynedit/Constants.h b/RedPandaIDE/qsynedit/Constants.h index 52cf2597..e13f94fd 100644 --- a/RedPandaIDE/qsynedit/Constants.h +++ b/RedPandaIDE/qsynedit/Constants.h @@ -166,4 +166,5 @@ extern const QChar SynSoftBreakGlyph; #define SYNS_ExporterFormatTeX "TeX" #define SYN_HIGHLIGHTER_CPP "SynCppHighlighter" +#define SYN_HIGHLIGHTER_ASM "SynASMHighlighter" #endif // CONSTANTS_H diff --git a/RedPandaIDE/qsynedit/highlighter/asm.cpp b/RedPandaIDE/qsynedit/highlighter/asm.cpp index f628a1d3..1ebff576 100644 --- a/RedPandaIDE/qsynedit/highlighter/asm.cpp +++ b/RedPandaIDE/qsynedit/highlighter/asm.cpp @@ -35,26 +35,22 @@ const QSet SynEditASMHighlighter::Keywords { "wait","wbinvd","xadd","xchg","xlat","xlatb","xor" }; -SynEditASMHighlighter::SynEditASMHighlighter() + + +void SynEditASMHighlighter::CommentProc() { - mCommentAttribute = std::make_shared(SYNS_AttrComment); - mCommentAttribute->setStyles(SynFontStyle::fsItalic); - addAttribute(mCommentAttribute); - mIdentifierAttribute = std::make_shared(SYNS_AttrIdentifier); - addAttribute(mIdentifierAttribute); - mKeywordAttribute = std::make_shared(SYNS_AttrReservedWord); - mKeywordAttribute->setStyles(SynFontStyle::fsBold); - addAttribute(mKeywordAttribute); - mNumberAttribute = std::make_shared(SYNS_AttrNumber); - addAttribute(mNumberAttribute); - mWhitespaceAttribute = std::make_shared(SYNS_AttrSpace); - addAttribute(mWhitespaceAttribute); - mStringAttribute = std::make_shared(SYNS_AttrString); - addAttribute(mStringAttribute); - mSymbolAttribute = std::make_shared(SYNS_AttrSymbol); - addAttribute(mSymbolAttribute); - + mTokenID = TokenKind::Comment; + do { + mRun++; + } while (! (mLine[mRun]==0 || mLine[mRun] == '\r' || mLine[mRun]=='\n')); +} +void SynEditASMHighlighter::CRProc() +{ + mTokenID = TokenKind::Space; + mRun++; + if (mLine[mRun] == 10) + mRun++; } bool SynEditASMHighlighter::eol() const @@ -188,3 +184,22 @@ void SynEditASMHighlighter::next() } } } + +void SynEditASMHighlighter::setLine(const QString &newLine, int lineNumber) +{ + mLineString = newLine; + mLine = mLineString.data(); + mLineNumber = lineNumber; + mRun = 0; + next(); +} + +SynHighlighterClass SynEditASMHighlighter::getClass() const +{ + return SynHighlighterClass::CppHighlighter; +} + +QString SynEditASMHighlighter::getName() const +{ + return SYN_HIGHLIGHTER_CPP; +} diff --git a/RedPandaIDE/qsynedit/highlighter/asm.h b/RedPandaIDE/qsynedit/highlighter/asm.h index 188c4d43..d846fe1c 100644 --- a/RedPandaIDE/qsynedit/highlighter/asm.h +++ b/RedPandaIDE/qsynedit/highlighter/asm.h @@ -18,7 +18,25 @@ class SynEditASMHighlighter : public SynHighlighter Unknown }; public: - explicit SynEditASMHighlighter(); + explicit SynEditASMHighlighter() + { + mCommentAttribute = std::make_shared(SYNS_AttrComment); + mCommentAttribute->setStyles(SynFontStyle::fsItalic); + addAttribute(mCommentAttribute); + mIdentifierAttribute = std::make_shared(SYNS_AttrIdentifier); + addAttribute(mIdentifierAttribute); + mKeywordAttribute = std::make_shared(SYNS_AttrReservedWord); + mKeywordAttribute->setStyles(SynFontStyle::fsBold); + addAttribute(mKeywordAttribute); + mNumberAttribute = std::make_shared(SYNS_AttrNumber); + addAttribute(mNumberAttribute); + mWhitespaceAttribute = std::make_shared(SYNS_AttrSpace); + addAttribute(mWhitespaceAttribute); + mStringAttribute = std::make_shared(SYNS_AttrString); + addAttribute(mStringAttribute); + mSymbolAttribute = std::make_shared(SYNS_AttrSymbol); + addAttribute(mSymbolAttribute); + } static const QSet Keywords; private: @@ -32,21 +50,28 @@ private: SynTokenKind mTokenID; PSynHighlighterAttribute mNumberAttribute; +private: + void CommentProc(); + void CRProc(); + // SynHighlighter interface public: bool eol() const override; - // SynHighlighter interface -public: QString languageName() override; - - // SynHighlighter interface -public: SynHighlighterLanguage language() override; + QString getToken() const override; + PSynHighlighterAttribute getTokenAttribute() const override; + SynTokenKind getTokenKind() override; + SynHighlighterTokenType getTokenType() override; + int getTokenPos() override; + void next() override; + void setLine(const QString &newLine, int lineNumber) override; // SynHighlighter interface public: - QString getToken() const override; + SynHighlighterClass getClass() const override; + QString getName() const override; }; #endif // SYNEDITASMHIGHLIGHTER_H diff --git a/RedPandaIDE/qsynedit/highlighter/base.h b/RedPandaIDE/qsynedit/highlighter/base.h index 67fcc4ee..3f191a11 100644 --- a/RedPandaIDE/qsynedit/highlighter/base.h +++ b/RedPandaIDE/qsynedit/highlighter/base.h @@ -26,6 +26,7 @@ enum class SynHighlighterTokenType { enum class SynHighlighterClass { Composition, CppHighlighter, + AsmHighlighter }; enum class SynHighlighterLanguage {