work save

This commit is contained in:
royqh1979@gmail.com 2021-07-01 22:29:51 +08:00
parent eb827f019d
commit b8c1e937bf
4 changed files with 67 additions and 25 deletions

View File

@ -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

View File

@ -35,26 +35,22 @@ const QSet<QString> SynEditASMHighlighter::Keywords {
"wait","wbinvd","xadd","xchg","xlat","xlatb","xor"
};
SynEditASMHighlighter::SynEditASMHighlighter()
void SynEditASMHighlighter::CommentProc()
{
mCommentAttribute = std::make_shared<SynHighlighterAttribute>(SYNS_AttrComment);
mCommentAttribute->setStyles(SynFontStyle::fsItalic);
addAttribute(mCommentAttribute);
mIdentifierAttribute = std::make_shared<SynHighlighterAttribute>(SYNS_AttrIdentifier);
addAttribute(mIdentifierAttribute);
mKeywordAttribute = std::make_shared<SynHighlighterAttribute>(SYNS_AttrReservedWord);
mKeywordAttribute->setStyles(SynFontStyle::fsBold);
addAttribute(mKeywordAttribute);
mNumberAttribute = std::make_shared<SynHighlighterAttribute>(SYNS_AttrNumber);
addAttribute(mNumberAttribute);
mWhitespaceAttribute = std::make_shared<SynHighlighterAttribute>(SYNS_AttrSpace);
addAttribute(mWhitespaceAttribute);
mStringAttribute = std::make_shared<SynHighlighterAttribute>(SYNS_AttrString);
addAttribute(mStringAttribute);
mSymbolAttribute = std::make_shared<SynHighlighterAttribute>(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;
}

View File

@ -18,7 +18,25 @@ class SynEditASMHighlighter : public SynHighlighter
Unknown
};
public:
explicit SynEditASMHighlighter();
explicit SynEditASMHighlighter()
{
mCommentAttribute = std::make_shared<SynHighlighterAttribute>(SYNS_AttrComment);
mCommentAttribute->setStyles(SynFontStyle::fsItalic);
addAttribute(mCommentAttribute);
mIdentifierAttribute = std::make_shared<SynHighlighterAttribute>(SYNS_AttrIdentifier);
addAttribute(mIdentifierAttribute);
mKeywordAttribute = std::make_shared<SynHighlighterAttribute>(SYNS_AttrReservedWord);
mKeywordAttribute->setStyles(SynFontStyle::fsBold);
addAttribute(mKeywordAttribute);
mNumberAttribute = std::make_shared<SynHighlighterAttribute>(SYNS_AttrNumber);
addAttribute(mNumberAttribute);
mWhitespaceAttribute = std::make_shared<SynHighlighterAttribute>(SYNS_AttrSpace);
addAttribute(mWhitespaceAttribute);
mStringAttribute = std::make_shared<SynHighlighterAttribute>(SYNS_AttrString);
addAttribute(mStringAttribute);
mSymbolAttribute = std::make_shared<SynHighlighterAttribute>(SYNS_AttrSymbol);
addAttribute(mSymbolAttribute);
}
static const QSet<QString> 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

View File

@ -26,6 +26,7 @@ enum class SynHighlighterTokenType {
enum class SynHighlighterClass {
Composition,
CppHighlighter,
AsmHighlighter
};
enum class SynHighlighterLanguage {