work save
This commit is contained in:
parent
b3a986f1ca
commit
378cdeefd2
|
@ -67,11 +67,11 @@ QSynedit::PHighlighter HighlighterManager::copyHighlighter(QSynedit::PHighlighte
|
|||
{
|
||||
if (!highlighter)
|
||||
return QSynedit::PHighlighter();
|
||||
if (highlighter->getName() == SYN_HIGHLIGHTER_CPP)
|
||||
if (highlighter->language() == QSynedit::HighlighterLanguage::Cpp)
|
||||
return getCppHighlighter();
|
||||
else if (highlighter->getName() == SYN_HIGHLIGHTER_ASM)
|
||||
else if (highlighter->language() == QSynedit::HighlighterLanguage::Asssembly)
|
||||
return getAsmHighlighter();
|
||||
else if (highlighter->getName() == SYN_HIGHLIGHTER_GLSL)
|
||||
else if (highlighter->language() == QSynedit::HighlighterLanguage::GLSL)
|
||||
return getGLSLHighlighter();
|
||||
//todo
|
||||
return QSynedit::PHighlighter();
|
||||
|
@ -99,8 +99,8 @@ void HighlighterManager::applyColorScheme(QSynedit::PHighlighter highlighter, co
|
|||
{
|
||||
if (!highlighter)
|
||||
return;
|
||||
if ( (highlighter->getName() == SYN_HIGHLIGHTER_CPP)
|
||||
|| (highlighter->getName() == SYN_HIGHLIGHTER_ASM)
|
||||
if ( (highlighter->language() == QSynedit::HighlighterLanguage::Cpp)
|
||||
|| (highlighter->language() == QSynedit::HighlighterLanguage::Asssembly)
|
||||
) {
|
||||
for (QString name: highlighter->attributes().keys()) {
|
||||
PColorSchemeItem item = pColorManager->getItem(schemeName,name);
|
||||
|
|
|
@ -390,7 +390,7 @@ bool Editor::saveAs(const QString &name, bool fromProject){
|
|||
setUseCodeFolding(false);
|
||||
}
|
||||
setHighlighter(newHighlighter);
|
||||
if (!newHighlighter || newHighlighter->getName() != SYN_HIGHLIGHTER_CPP) {
|
||||
if (!newHighlighter || newHighlighter->language() != QSynedit::HighlighterLanguage::Cpp) {
|
||||
mSyntaxIssues.clear();
|
||||
}
|
||||
applyColorScheme(pSettings->editor().colorScheme());
|
||||
|
@ -2650,7 +2650,7 @@ void Editor::initParser()
|
|||
{
|
||||
if (pSettings->codeCompletion().shareParser()) {
|
||||
if (pSettings->codeCompletion().enabled()
|
||||
&& (highlighter() && highlighter()->getClass() == QSynedit::HighlighterClass::CppHighlighter)
|
||||
&& (highlighter() && highlighter()->language() == QSynedit::HighlighterLanguage::Cpp)
|
||||
) {
|
||||
mParser = sharedParser(mUseCppSyntax?ParserLanguage::CPlusPlus:ParserLanguage::C);
|
||||
}
|
||||
|
@ -2670,7 +2670,7 @@ void Editor::initParser()
|
|||
resetCppParser(mParser);
|
||||
mParser->setEnabled(
|
||||
pSettings->codeCompletion().enabled() &&
|
||||
(highlighter() && highlighter()->getClass() == QSynedit::HighlighterClass::CppHighlighter));
|
||||
(highlighter() && highlighter()->language() == QSynedit::HighlighterLanguage::Cpp));
|
||||
}
|
||||
|
||||
Editor::QuoteStatus Editor::getQuoteStatus()
|
||||
|
|
|
@ -58,10 +58,6 @@ extern const QChar SoftBreakGlyph;
|
|||
#define SYNS_ExporterFormatRTF "RTF"
|
||||
#define SYNS_ExporterFormatTeX "TeX"
|
||||
|
||||
#define SYN_HIGHLIGHTER_CPP "SynCppHighlighter"
|
||||
#define SYN_HIGHLIGHTER_ASM "SynASMHighlighter"
|
||||
#define SYN_HIGHLIGHTER_GLSL "SynGLSLHighlighter"
|
||||
|
||||
}
|
||||
|
||||
#endif // CONSTANTS_H
|
||||
|
|
|
@ -54,11 +54,9 @@ bool internalEnumHighlighterAttris(PHighlighter Highlighter,
|
|||
} else {
|
||||
HighlighterList.append(Highlighter);
|
||||
}
|
||||
if (Highlighter->getClass() == HighlighterClass::Composition) {
|
||||
//todo: handle composition highlighter
|
||||
} else if (Highlighter) {
|
||||
if (Highlighter) {
|
||||
for (PHighlighterAttribute pAttr: Highlighter->attributes()){
|
||||
QString UniqueAttriName = Highlighter->getName()
|
||||
QString UniqueAttriName = Highlighter->languageName()
|
||||
+ QString("%1").arg(HighlighterList.indexOf(Highlighter)) + '.'
|
||||
+ pAttr->name();
|
||||
Result = highlighterAttriProc(Highlighter, pAttr,
|
||||
|
|
|
@ -1619,13 +1619,13 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent)
|
|||
matchingIndents = rangeAfterFirstToken.matchingIndents;
|
||||
indentAdded = true;
|
||||
l = startLine;
|
||||
} else if (mHighlighter->getClass() == HighlighterClass::CppHighlighter
|
||||
} else if (mHighlighter->language() == HighlighterLanguage::Cpp
|
||||
&& trimmedLineText.startsWith('#')
|
||||
&& attr == ((CppHighlighter *)mHighlighter.get())->preprocessorAttribute()) {
|
||||
indentAdded = true;
|
||||
indentSpaces=0;
|
||||
l=0;
|
||||
} else if (mHighlighter->getClass() == HighlighterClass::CppHighlighter
|
||||
} else if (mHighlighter->language() == HighlighterLanguage::Cpp
|
||||
&& mHighlighter->isLastLineCommentNotFinished(rangePreceeding.state)
|
||||
) {
|
||||
// last line is a not finished comment,
|
||||
|
@ -2906,7 +2906,7 @@ void SynEdit::doAddChar(QChar AChar)
|
|||
if (mActiveSelectionMode==SelectionMode::Normal
|
||||
&& mOptions.testFlag(eoAutoIndent)
|
||||
&& mHighlighter
|
||||
&& mHighlighter->getClass()==HighlighterClass::CppHighlighter
|
||||
&& mHighlighter->language() == HighlighterLanguage::Cpp
|
||||
&& (oldCaretY<=mDocument->count()) ) {
|
||||
|
||||
//unindent if ':' at end of the line
|
||||
|
|
|
@ -766,7 +766,7 @@ void SynEditTextPainter::getBraceColorAttr(int level, PHighlighterAttribute &att
|
|||
{
|
||||
if (!edit->mOptions.testFlag(EditorOption::eoShowRainbowColor))
|
||||
return;
|
||||
if (!attr || attr->tokenType() != TokenType::Operator)
|
||||
if (attr->tokenType() != TokenType::Operator)
|
||||
return;
|
||||
PHighlighterAttribute oldAttr = attr;
|
||||
switch(level % 4) {
|
||||
|
|
|
@ -324,16 +324,6 @@ void ASMHighlighter::setLine(const QString &newLine, int lineNumber)
|
|||
next();
|
||||
}
|
||||
|
||||
HighlighterClass ASMHighlighter::getClass() const
|
||||
{
|
||||
return HighlighterClass::CppHighlighter;
|
||||
}
|
||||
|
||||
QString ASMHighlighter::getName() const
|
||||
{
|
||||
return SYN_HIGHLIGHTER_CPP;
|
||||
}
|
||||
|
||||
bool ASMHighlighter::getTokenFinished() const
|
||||
{
|
||||
return true;
|
||||
|
|
|
@ -79,11 +79,6 @@ public:
|
|||
void next() override;
|
||||
void setLine(const QString &newLine, int lineNumber) override;
|
||||
|
||||
// SynHighlighter interface
|
||||
public:
|
||||
HighlighterClass getClass() const override;
|
||||
QString getName() const override;
|
||||
|
||||
// SynHighlighter interface
|
||||
public:
|
||||
bool getTokenFinished() const override;
|
||||
|
|
|
@ -74,18 +74,13 @@ enum class TokenType {
|
|||
Embeded //language embeded in others
|
||||
};
|
||||
|
||||
enum class HighlighterClass {
|
||||
Composition,
|
||||
CppHighlighter,
|
||||
AsmHighlighter,
|
||||
GLSLHighlighter
|
||||
};
|
||||
|
||||
enum class HighlighterLanguage {
|
||||
DecideBySuffix,
|
||||
Composition,
|
||||
Asssembly,
|
||||
Cpp,
|
||||
GLSL
|
||||
GLSL,
|
||||
Custom
|
||||
};
|
||||
|
||||
class HighlighterAttribute {
|
||||
|
@ -138,9 +133,6 @@ public:
|
|||
|
||||
virtual bool isIdentChar(const QChar& ch) const;
|
||||
|
||||
virtual HighlighterClass getClass() const = 0;
|
||||
virtual QString getName() const = 0;
|
||||
|
||||
virtual bool getTokenFinished() const = 0;
|
||||
virtual bool isLastLineCommentNotFinished(int state) const = 0;
|
||||
virtual bool isLastLineStringNotFinished(int state) const = 0;
|
||||
|
|
|
@ -19,21 +19,6 @@
|
|||
|
||||
namespace QSynedit {
|
||||
|
||||
CompositedHighlighter::CompositedHighlighter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
HighlighterClass CompositedHighlighter::getClass() const
|
||||
{
|
||||
return HighlighterClass::Composition;
|
||||
}
|
||||
|
||||
QString CompositedHighlighter::getName() const
|
||||
{
|
||||
return "SynHighlightComposition";
|
||||
}
|
||||
|
||||
HighlighterSchema::HighlighterSchema(QObject *parent):
|
||||
QObject(parent),
|
||||
mCaseSensitive(true)
|
||||
|
|
|
@ -62,18 +62,5 @@ private slots:
|
|||
void MarkerAttriChanged();
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CompositedHighlighter : public Highlighter
|
||||
{
|
||||
public:
|
||||
explicit CompositedHighlighter();
|
||||
|
||||
// SynHighligterBase interface
|
||||
public:
|
||||
HighlighterClass getClass() const override;
|
||||
QString getName() const override;
|
||||
};
|
||||
|
||||
}
|
||||
#endif // SYNHIGHLIGHTCOMPOSITION_H
|
||||
|
|
|
@ -1607,16 +1607,6 @@ void CppHighlighter::resetState()
|
|||
mAsmStart = false;
|
||||
}
|
||||
|
||||
HighlighterClass CppHighlighter::getClass() const
|
||||
{
|
||||
return HighlighterClass::CppHighlighter;
|
||||
}
|
||||
|
||||
QString CppHighlighter::getName() const
|
||||
{
|
||||
return SYN_HIGHLIGHTER_CPP;
|
||||
}
|
||||
|
||||
QString CppHighlighter::languageName()
|
||||
{
|
||||
return "cpp";
|
||||
|
|
|
@ -181,8 +181,6 @@ public:
|
|||
bool isKeyword(const QString &word) override;
|
||||
void setState(const HighlighterState& rangeState) override;
|
||||
void resetState() override;
|
||||
HighlighterClass getClass() const override;
|
||||
QString getName() const override;
|
||||
|
||||
QString languageName() override;
|
||||
HighlighterLanguage language() override;
|
||||
|
|
|
@ -5,4 +5,27 @@ CustomHighlighterV1::CustomHighlighterV1()
|
|||
{
|
||||
|
||||
}
|
||||
|
||||
void CustomHighlighterV1::resetState()
|
||||
{
|
||||
mRange.state = RangeState::rsUnknown;
|
||||
mRange.braceLevel = 0;
|
||||
mRange.bracketLevel = 0;
|
||||
mRange.parenthesisLevel = 0;
|
||||
mRange.leftBraces = 0;
|
||||
mRange.rightBraces = 0;
|
||||
mRange.indents.clear();
|
||||
mRange.firstIndentThisLine = 0;
|
||||
mRange.matchingIndents.clear();
|
||||
}
|
||||
|
||||
QString CustomHighlighterV1::languageName()
|
||||
{
|
||||
return mLanguageName;
|
||||
}
|
||||
|
||||
HighlighterLanguage CustomHighlighterV1::language()
|
||||
{
|
||||
return HighlighterLanguage::Custom;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,36 @@ namespace QSynedit {
|
|||
class CustomHighlighterV1:public Highlighter
|
||||
{
|
||||
public:
|
||||
CustomHighlighterV1();
|
||||
enum RangeState {
|
||||
rsUnknown, rsComment, rsInlineComment,
|
||||
rsString, rsMultiLineString,
|
||||
rsRawString, rsSpace,
|
||||
};
|
||||
|
||||
CustomHighlighterV1();
|
||||
// bool getTokenFinished() const override;
|
||||
// bool isLastLineCommentNotFinished(int state) const override;
|
||||
// bool isLastLineStringNotFinished(int state) const override;
|
||||
// bool eol() const override;
|
||||
// QString getToken() const override;
|
||||
// PHighlighterAttribute getTokenAttribute() const override;
|
||||
// int getTokenPos() override;
|
||||
// void next() override;
|
||||
// void setLine(const QString &newLine, int lineNumber) override;
|
||||
// bool isKeyword(const QString &word) override;
|
||||
// void setState(const HighlighterState& rangeState) override;
|
||||
void resetState() override;
|
||||
|
||||
QString languageName() override;
|
||||
HighlighterLanguage language() override;
|
||||
protected:
|
||||
bool mIgnoreCase;
|
||||
QString mCommentBlockStart;
|
||||
QString mCommentBlockEnd;
|
||||
QString mInlineCommentStart;
|
||||
|
||||
QSet<QString> mTypeKeywords;
|
||||
QSet<QString> mCallableKeywords;
|
||||
QSet<QString> mFunctionKeywords;
|
||||
QSet<QString> mKeywords1;
|
||||
QSet<QString> mKeywords2;
|
||||
QSet<QString> mKeywords3;
|
||||
|
@ -19,10 +43,10 @@ protected:
|
|||
QSet<QString> mKeywords5;
|
||||
QSet<QString> mKeywords6;
|
||||
QSet<QString> mOperators;
|
||||
|
||||
QString mLanguageName;
|
||||
QSet<QString> mSuffixes;
|
||||
|
||||
|
||||
HighlighterState mRange;
|
||||
// SynRangeState mSpaceRange;
|
||||
QString mLine;
|
||||
|
|
|
@ -1447,16 +1447,6 @@ void GLSLHighlighter::resetState()
|
|||
mAsmStart = false;
|
||||
}
|
||||
|
||||
HighlighterClass GLSLHighlighter::getClass() const
|
||||
{
|
||||
return HighlighterClass::GLSLHighlighter;
|
||||
}
|
||||
|
||||
QString GLSLHighlighter::getName() const
|
||||
{
|
||||
return SYN_HIGHLIGHTER_GLSL;
|
||||
}
|
||||
|
||||
QString GLSLHighlighter::languageName()
|
||||
{
|
||||
return "glsl";
|
||||
|
|
|
@ -177,8 +177,6 @@ public:
|
|||
bool isKeyword(const QString &word) override;
|
||||
void setState(const HighlighterState& rangeState) override;
|
||||
void resetState() override;
|
||||
HighlighterClass getClass() const override;
|
||||
QString getName() const override;
|
||||
|
||||
QString languageName() override;
|
||||
HighlighterLanguage language() override;
|
||||
|
|
Loading…
Reference in New Issue