refactor highlighters

This commit is contained in:
Roy Qu 2022-12-10 20:58:04 +08:00
parent 81d88fb5bd
commit d0732b9989
23 changed files with 336 additions and 337 deletions

View File

@ -42,25 +42,25 @@ int getEOL(const QString &Line, int start)
return Line.size();
}
bool internalEnumHighlighterAttris(PHighlighter Highlighter,
bool SkipDuplicates,
static bool internalEnumHighlighterAttris(PSyntaxer syntaxer,
bool skipDuplicates,
TokenAttributeProc highlighterAttriProc,
std::initializer_list<void *>& Params,
HighlighterList& HighlighterList) {
std::initializer_list<void *>& params,
SyntaxerList& highlighterList) {
bool Result = true;
if (HighlighterList.indexOf(Highlighter)>0) {
if (SkipDuplicates)
if (highlighterList.indexOf(syntaxer)>0) {
if (skipDuplicates)
return Result;
} else {
HighlighterList.append(Highlighter);
highlighterList.append(syntaxer);
}
if (Highlighter) {
for (PTokenAttribute pAttr: Highlighter->attributes()){
QString UniqueAttriName = Highlighter->languageName()
+ QString("%1").arg(HighlighterList.indexOf(Highlighter)) + '.'
if (syntaxer) {
for (PTokenAttribute pAttr: syntaxer->attributes()){
QString UniqueAttriName = syntaxer->languageName()
+ QString("%1").arg(highlighterList.indexOf(syntaxer)) + '.'
+ pAttr->name();
Result = highlighterAttriProc(Highlighter, pAttr,
UniqueAttriName, Params);
Result = highlighterAttriProc(syntaxer, pAttr,
UniqueAttriName, params);
if (!Result)
break;
}
@ -68,17 +68,17 @@ bool internalEnumHighlighterAttris(PHighlighter Highlighter,
return Result;
}
bool enumTokenAttributes(PHighlighter Highlighter, bool SkipDuplicates,
bool enumTokenAttributes(PSyntaxer syntaxer, bool skipDuplicates,
TokenAttributeProc highlighterAttriProc,
std::initializer_list<void *> Params)
std::initializer_list<void *> params)
{
if (!Highlighter || !highlighterAttriProc) {
if (!syntaxer || !highlighterAttriProc) {
return false;
}
HighlighterList HighlighterList;
return internalEnumHighlighterAttris(Highlighter, SkipDuplicates,
highlighterAttriProc, Params, HighlighterList);
SyntaxerList syntaxerList;
return internalEnumHighlighterAttris(syntaxer, skipDuplicates,
highlighterAttriProc, params, syntaxerList);
}
int mulDiv(int a, int b, int c)

View File

@ -21,7 +21,7 @@
#include <memory>
#include <QString>
#include <QSet>
#include "highlighter/base.h"
#include "highlighter/syntaxer.h"
#include <QPaintDevice>
#include <QTextStream>
#include <QVector>
@ -46,15 +46,15 @@ QStringList splitStrings(const QString& text);
int calSpanLines(const BufferCoord& startPos, const BufferCoord& endPos);
using TokenAttributeProc = std::function<bool(PHighlighter Highlighter,
PTokenAttribute Attri, const QString& UniqueAttriName,
QList<void *> Params)>;
using TokenAttributeProc = std::function<bool(PSyntaxer syntaxer,
PTokenAttribute attri, const QString& uniqueAttriName,
QList<void *> params)>;
// Enums all child highlighters and their attributes of a TSynMultiSyn through a
// callback function.
// This function also handles nested TSynMultiSyns including their MarkerAttri.
bool enumTokenAttributes(PHighlighter Highlighter,
bool SkipDuplicates, TokenAttributeProc highlighterAttriProc,
bool enumTokenAttributes(PSyntaxer syntaxer,
bool skipDuplicates, TokenAttributeProc tokenAttriProc,
std::initializer_list<void *> Params);
FontStyles getFontStyles(const QFont& font);

View File

@ -24,7 +24,7 @@
#include <QPaintEvent>
#include <QPainter>
#include <QTimerEvent>
#include "highlighter/base.h"
#include "highlighter/syntaxer.h"
#include "Constants.h"
#include "TextPainter.h"
#include <QClipboard>
@ -1621,7 +1621,7 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent)
l = startLine;
} else if (mHighlighter->language() == ProgrammingLanguage::Cpp
&& trimmedLineText.startsWith('#')
&& attr == ((CppHighlighter *)mHighlighter.get())->preprocessorAttribute()) {
&& attr == ((CppSyntaxer *)mHighlighter.get())->preprocessorAttribute()) {
indentAdded = true;
indentSpaces=0;
l=0;
@ -4772,14 +4772,14 @@ void SynEdit::setLineText(const QString s)
mDocument->putString(mCaretY-1,s);
}
PHighlighter SynEdit::highlighter() const
PSyntaxer SynEdit::highlighter() const
{
return mHighlighter;
}
void SynEdit::setHighlighter(const PHighlighter &highlighter)
void SynEdit::setHighlighter(const PSyntaxer &highlighter)
{
PHighlighter oldHighlighter= mHighlighter;
PSyntaxer oldHighlighter= mHighlighter;
mHighlighter = highlighter;
if (oldHighlighter && mHighlighter &&
oldHighlighter->language() == highlighter->language()) {

View File

@ -341,8 +341,8 @@ public:
bool modified() const;
void setModified(bool Value);
PHighlighter highlighter() const;
void setHighlighter(const PHighlighter &highlighter);
PSyntaxer highlighter() const;
void setHighlighter(const PSyntaxer &highlighter);
bool useCodeFolding() const;
void setUseCodeFolding(bool value);
@ -667,7 +667,7 @@ private:
ScrollStyle mScrollBars;
int mTextHeight;
int mTopLine;
PHighlighter mHighlighter;
PSyntaxer mHighlighter;
QColor mSelectedForeground;
QColor mSelectedBackground;
QColor mForegroundColor;

View File

@ -18,7 +18,7 @@
#define SYNEDITSTRINGLIST_H
#include <QStringList>
#include "highlighter/base.h"
#include "highlighter/syntaxer.h"
#include <QFontMetrics>
#include <QMutex>
#include <QVector>

View File

@ -21,7 +21,7 @@
#include <QPainter>
#include <QString>
#include "Types.h"
#include "highlighter/base.h"
#include "highlighter/syntaxer.h"
#include "MiscClasses.h"
namespace QSynedit {

View File

@ -166,12 +166,12 @@ void SynExporter::setFont(const QFont &font)
mFont = font;
}
PHighlighter SynExporter::highlighter() const
PSyntaxer SynExporter::highlighter() const
{
return mHighlighter;
}
void SynExporter::setHighlighter(PHighlighter Value)
void SynExporter::setHighlighter(PSyntaxer Value)
{
if (mHighlighter != Value) {
mHighlighter = Value;

View File

@ -21,7 +21,7 @@
#include "../SynEdit.h"
namespace QSynedit {
using FormatTokenHandler = std::function<void(PHighlighter syntaxHighlighter, int Line, int column, const QString& token,
using FormatTokenHandler = std::function<void(PSyntaxer syntaxHighlighter, int line, int column, const QString& token,
PTokenAttribute& attr)>;
class SynExporter
{
@ -69,8 +69,8 @@ public:
QFont font() const;
void setFont(const QFont &font);
PHighlighter highlighter() const;
void setHighlighter(PHighlighter Value);
PSyntaxer highlighter() const;
void setHighlighter(PSyntaxer Value);
QString title() const;
void setTitle(const QString &Value);
@ -112,7 +112,7 @@ protected:
QString mDefaultFilter;
bool mExportAsText;
QFont mFont;
PHighlighter mHighlighter;
PSyntaxer mHighlighter;
QColor mLastBG;
QColor mLastFG;
FontStyles mLastStyle;

View File

@ -67,7 +67,7 @@ QString SynHTMLExporter::AttriToCSS(PTokenAttribute Attri, const QString &Unique
return Result;
}
bool SynHTMLExporter::AttriToCSSCallback(PHighlighter , PTokenAttribute Attri, const QString& UniqueAttriName, QList<void *> params)
bool SynHTMLExporter::AttriToCSSCallback(PSyntaxer , PTokenAttribute Attri, const QString& UniqueAttriName, QList<void *> params)
{
QString& styles = *static_cast<QString *>(params[0]);
styles.append(AttriToCSS(Attri,UniqueAttriName) + lineBreak());
@ -79,7 +79,7 @@ QString SynHTMLExporter::ColorToHTML(const QColor &AColor)
return AColor.name();
}
QString SynHTMLExporter::GetStyleName(PHighlighter Highlighter, PTokenAttribute Attri)
QString SynHTMLExporter::GetStyleName(PSyntaxer Highlighter, PTokenAttribute Attri)
{
QString result;
enumTokenAttributes(Highlighter,false,
@ -104,7 +104,7 @@ QString SynHTMLExporter::MakeValidName(const QString &Name)
return Result;
}
bool SynHTMLExporter::StyleNameCallback(PHighlighter /*Highlighter*/, PTokenAttribute Attri, const QString& UniqueAttriName, QList<void *> params)
bool SynHTMLExporter::StyleNameCallback(PSyntaxer /*Highlighter*/, PTokenAttribute Attri, const QString& UniqueAttriName, QList<void *> params)
{
PTokenAttribute& AttriToFind = *static_cast<PTokenAttribute*>(params[0]);
QString& StyleName = *static_cast<QString *>(params[1]);

View File

@ -32,13 +32,13 @@ protected:
private:
PTokenAttribute mLastAttri;
QString AttriToCSS(PTokenAttribute Attri, const QString& UniqueAttriName);
bool AttriToCSSCallback(PHighlighter Highlighter, PTokenAttribute Attri,
bool AttriToCSSCallback(PSyntaxer Highlighter, PTokenAttribute Attri,
const QString& UniqueAttriName, QList<void *> params);
QString ColorToHTML(const QColor &AColor);
QString GetStyleName(PHighlighter Highlighter,
QString GetStyleName(PSyntaxer Highlighter,
PTokenAttribute Attri);
QString MakeValidName(const QString &Name);
bool StyleNameCallback(PHighlighter Highlighter, PTokenAttribute Attri,
bool StyleNameCallback(PSyntaxer Highlighter, PTokenAttribute Attri,
const QString& UniqueAttriName, QList<void *> params);
// SynExporter interface

View File

@ -20,7 +20,7 @@
namespace QSynedit {
const QSet<QString> ASMHighlighter::Registers {
const QSet<QString> ASMSyntaxer::Registers {
"ah","al","ax","eax",
"bh","bl","bx","ebx",
"ch","cl","cx","ecx",
@ -37,7 +37,7 @@ const QSet<QString> ASMHighlighter::Registers {
"r15h","r15l","r15w","r15d"
};
const QSet<QString> ASMHighlighter::Keywords {
const QSet<QString> ASMSyntaxer::Keywords {
"movb","movw","movl","movq",
"leab","leaw","leal","leaq",
"incb","incw","incl","incq",
@ -96,7 +96,7 @@ const QSet<QString> ASMHighlighter::Keywords {
ASMHighlighter::ASMHighlighter()
ASMSyntaxer::ASMSyntaxer()
{
mNumberAttribute = std::make_shared<TokenAttribute>(SYNS_AttrNumber, TokenType::Number);
addAttribute(mNumberAttribute);
@ -108,17 +108,17 @@ ASMHighlighter::ASMHighlighter()
addAttribute(mRegisterAttribute);
}
const PTokenAttribute &ASMHighlighter::numberAttribute() const
const PTokenAttribute &ASMSyntaxer::numberAttribute() const
{
return mNumberAttribute;
}
const PTokenAttribute &ASMHighlighter::registerAttribute() const
const PTokenAttribute &ASMSyntaxer::registerAttribute() const
{
return mRegisterAttribute;
}
void ASMHighlighter::CommentProc()
void ASMSyntaxer::CommentProc()
{
mTokenID = TokenId::Comment;
do {
@ -126,7 +126,7 @@ void ASMHighlighter::CommentProc()
} while (! (mLine[mRun]==0 || mLine[mRun] == '\r' || mLine[mRun]=='\n'));
}
void ASMHighlighter::CRProc()
void ASMSyntaxer::CRProc()
{
mTokenID = TokenId::Space;
mRun++;
@ -134,7 +134,7 @@ void ASMHighlighter::CRProc()
mRun++;
}
void ASMHighlighter::GreaterProc()
void ASMSyntaxer::GreaterProc()
{
mRun++;
mTokenID = TokenId::Symbol;
@ -142,7 +142,7 @@ void ASMHighlighter::GreaterProc()
mRun++;
}
void ASMHighlighter::IdentProc(IdentPrefix prefix)
void ASMSyntaxer::IdentProc(IdentPrefix prefix)
{
int start = mRun;
while (isIdentChar(mLine[mRun])) {
@ -171,13 +171,13 @@ void ASMHighlighter::IdentProc(IdentPrefix prefix)
}
}
void ASMHighlighter::LFProc()
void ASMSyntaxer::LFProc()
{
mTokenID = TokenId::Space;
mRun++;
}
void ASMHighlighter::LowerProc()
void ASMSyntaxer::LowerProc()
{
mRun++;
mTokenID = TokenId::Symbol;
@ -185,12 +185,12 @@ void ASMHighlighter::LowerProc()
mRun++;
}
void ASMHighlighter::NullProc()
void ASMSyntaxer::NullProc()
{
mTokenID = TokenId::Null;
}
void ASMHighlighter::NumberProc()
void ASMSyntaxer::NumberProc()
{
mRun++;
mTokenID = TokenId::Number;
@ -204,7 +204,7 @@ void ASMHighlighter::NumberProc()
}
}
void ASMHighlighter::SingleQuoteStringProc()
void ASMSyntaxer::SingleQuoteStringProc()
{
mTokenID = TokenId::String;
if ((mRun+2 < mLineString.size()) && (mLine[mRun + 1] == '\'') && (mLine[mRun + 2] == '\''))
@ -218,7 +218,7 @@ void ASMHighlighter::SingleQuoteStringProc()
mRun++;
}
void ASMHighlighter::SlashProc()
void ASMSyntaxer::SlashProc()
{
mRun++;
if (mLine[mRun] == '/') {
@ -232,7 +232,7 @@ void ASMHighlighter::SlashProc()
mTokenID = TokenId::Symbol;
}
void ASMHighlighter::SpaceProc()
void ASMSyntaxer::SpaceProc()
{
mTokenID = TokenId::Space;
while (true) {
@ -244,7 +244,7 @@ void ASMHighlighter::SpaceProc()
}
}
void ASMHighlighter::StringProc()
void ASMSyntaxer::StringProc()
{
mTokenID = TokenId::String;
if ((mRun+2 < mLineString.size()) && (mLine[mRun + 1] == '\"') && (mLine[mRun + 2] == '\"'))
@ -262,19 +262,19 @@ void ASMHighlighter::StringProc()
mRun++;
}
void ASMHighlighter::SymbolProc()
void ASMSyntaxer::SymbolProc()
{
mRun++;
mTokenID = TokenId::Symbol;
}
void ASMHighlighter::UnknownProc()
void ASMSyntaxer::UnknownProc()
{
mRun++;
mTokenID = TokenId::Unknown;
}
bool ASMHighlighter::isIdentStartChar(const QChar &ch)
bool ASMSyntaxer::isIdentStartChar(const QChar &ch)
{
if (ch == '_') {
return true;
@ -288,27 +288,27 @@ bool ASMHighlighter::isIdentStartChar(const QChar &ch)
return false;
}
bool ASMHighlighter::eol() const
bool ASMSyntaxer::eol() const
{
return mTokenID == TokenId::Null;
}
QString ASMHighlighter::languageName()
QString ASMSyntaxer::languageName()
{
return "asm";
}
ProgrammingLanguage ASMHighlighter::language()
ProgrammingLanguage ASMSyntaxer::language()
{
return ProgrammingLanguage::Asssembly;
}
QString ASMHighlighter::getToken() const
QString ASMSyntaxer::getToken() const
{
return mLineString.mid(mTokenPos,mRun-mTokenPos);
}
const PTokenAttribute &ASMHighlighter::getTokenAttribute() const
const PTokenAttribute &ASMSyntaxer::getTokenAttribute() const
{
switch(mTokenID) {
case TokenId::Comment:
@ -338,12 +338,12 @@ const PTokenAttribute &ASMHighlighter::getTokenAttribute() const
}
}
int ASMHighlighter::getTokenPos()
int ASMSyntaxer::getTokenPos()
{
return mTokenPos;
}
void ASMHighlighter::next()
void ASMSyntaxer::next()
{
mTokenPos = mRun;
switch(mLine[mRun].unicode()) {
@ -415,7 +415,7 @@ void ASMHighlighter::next()
}
}
void ASMHighlighter::setLine(const QString &newLine, int lineNumber)
void ASMSyntaxer::setLine(const QString &newLine, int lineNumber)
{
mLineString = newLine;
mLine = mLineString.data();
@ -424,47 +424,47 @@ void ASMHighlighter::setLine(const QString &newLine, int lineNumber)
next();
}
bool ASMHighlighter::getTokenFinished() const
bool ASMSyntaxer::getTokenFinished() const
{
return true;
}
bool ASMHighlighter::isLastLineCommentNotFinished(int /*state*/) const
bool ASMSyntaxer::isLastLineCommentNotFinished(int /*state*/) const
{
return true;
}
bool ASMHighlighter::isLastLineStringNotFinished(int /*state*/) const
bool ASMSyntaxer::isLastLineStringNotFinished(int /*state*/) const
{
return true;
}
SyntaxerState ASMHighlighter::getState() const
SyntaxerState ASMSyntaxer::getState() const
{
return SyntaxerState();
}
void ASMHighlighter::setState(const SyntaxerState&)
void ASMSyntaxer::setState(const SyntaxerState&)
{
}
void ASMHighlighter::resetState()
void ASMSyntaxer::resetState()
{
}
QSet<QString> ASMHighlighter::keywords() const
QSet<QString> ASMSyntaxer::keywords() const
{
return Keywords;
}
const PTokenAttribute &ASMHighlighter::directiveAttribute() const
const PTokenAttribute &ASMSyntaxer::directiveAttribute() const
{
return mDirectiveAttribute;
}
const PTokenAttribute &ASMHighlighter::labelAttribute() const
const PTokenAttribute &ASMSyntaxer::labelAttribute() const
{
return mLabelAttribute;
}

View File

@ -14,14 +14,14 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef SYNEDITASMHIGHLIGHTER_H
#define SYNEDITASMHIGHLIGHTER_H
#ifndef QSYNEDIT_ASM_SYNTAXER_H
#define QSYNEDIT_ASM_SYNTAXER_H
#include "base.h"
#include "syntaxer.h"
namespace QSynedit {
class ASMHighlighter : public Highlighter
class ASMSyntaxer : public Syntaxer
{
enum class TokenId {
Comment,
@ -44,7 +44,7 @@ class ASMHighlighter : public Highlighter
};
public:
explicit ASMHighlighter();
explicit ASMSyntaxer();
const PTokenAttribute &numberAttribute() const;
const PTokenAttribute &directiveAttribute() const;
const PTokenAttribute &labelAttribute() const;

View File

@ -49,12 +49,12 @@ void HighlighterSchema::setStartExpr(const QString &value)
StartExpr = value;
}
PHighlighter HighlighterSchema::getHighlighter() const
PSyntaxer HighlighterSchema::getHighlighter() const
{
return mHighlighter;
}
void HighlighterSchema::setHighlighter(const PHighlighter &highlighter)
void HighlighterSchema::setHighlighter(const PSyntaxer &highlighter)
{
mHighlighter = highlighter;
}

View File

@ -16,7 +16,7 @@
*/
#ifndef SYNHIGHLIGHTCOMPOSITION_H
#define SYNHIGHLIGHTCOMPOSITION_H
#include "base.h"
#include "syntaxer.h"
#include <memory>
#include <QObject>
@ -37,8 +37,8 @@ public:
QString getStartExpr() const;
void setStartExpr(const QString &value);
PHighlighter getHighlighter() const;
void setHighlighter(const PHighlighter &highlighter);
PSyntaxer getHighlighter() const;
void setHighlighter(const PSyntaxer &highlighter);
PTokenAttribute getMarkerAttribute() const;
@ -51,7 +51,7 @@ public:
private:
QString mEndExpr;
QString StartExpr;
PHighlighter mHighlighter;
PSyntaxer mHighlighter;
PTokenAttribute mMarkerAttribute;
QString mSchemeName;
int mCaseSensitive;

View File

@ -34,7 +34,7 @@ static const QSet<QString> CppStatementKeyWords {
const QSet<QString> CppHighlighter::Keywords {
const QSet<QString> CppSyntaxer::Keywords {
"and",
"and_eq",
"bitand",
@ -141,7 +141,7 @@ const QSet<QString> CppHighlighter::Keywords {
"nullptr",
};
CppHighlighter::CppHighlighter(): Highlighter()
CppSyntaxer::CppSyntaxer(): Syntaxer()
{
mAsmAttribute = std::make_shared<TokenAttribute>(SYNS_AttrAssembler,
TokenType::Embeded);
@ -190,77 +190,77 @@ CppHighlighter::CppHighlighter(): Highlighter()
resetState();
}
const PTokenAttribute &CppHighlighter::asmAttribute() const
const PTokenAttribute &CppSyntaxer::asmAttribute() const
{
return mAsmAttribute;
}
const PTokenAttribute &CppHighlighter::preprocessorAttribute() const
const PTokenAttribute &CppSyntaxer::preprocessorAttribute() const
{
return mPreprocessorAttribute;
}
const PTokenAttribute &CppHighlighter::invalidAttribute() const
const PTokenAttribute &CppSyntaxer::invalidAttribute() const
{
return mInvalidAttribute;
}
const PTokenAttribute &CppHighlighter::numberAttribute() const
const PTokenAttribute &CppSyntaxer::numberAttribute() const
{
return mNumberAttribute;
}
const PTokenAttribute &CppHighlighter::floatAttribute() const
const PTokenAttribute &CppSyntaxer::floatAttribute() const
{
return mFloatAttribute;
}
const PTokenAttribute &CppHighlighter::hexAttribute() const
const PTokenAttribute &CppSyntaxer::hexAttribute() const
{
return mHexAttribute;
}
const PTokenAttribute &CppHighlighter::octAttribute() const
const PTokenAttribute &CppSyntaxer::octAttribute() const
{
return mOctAttribute;
}
const PTokenAttribute &CppHighlighter::stringEscapeSequenceAttribute() const
const PTokenAttribute &CppSyntaxer::stringEscapeSequenceAttribute() const
{
return mStringEscapeSequenceAttribute;
}
const PTokenAttribute &CppHighlighter::charAttribute() const
const PTokenAttribute &CppSyntaxer::charAttribute() const
{
return mCharAttribute;
}
const PTokenAttribute &CppHighlighter::variableAttribute() const
const PTokenAttribute &CppSyntaxer::variableAttribute() const
{
return mVariableAttribute;
}
const PTokenAttribute &CppHighlighter::functionAttribute() const
const PTokenAttribute &CppSyntaxer::functionAttribute() const
{
return mFunctionAttribute;
}
const PTokenAttribute &CppHighlighter::classAttribute() const
const PTokenAttribute &CppSyntaxer::classAttribute() const
{
return mClassAttribute;
}
const PTokenAttribute &CppHighlighter::globalVarAttribute() const
const PTokenAttribute &CppSyntaxer::globalVarAttribute() const
{
return mGlobalVarAttribute;
}
const PTokenAttribute &CppHighlighter::localVarAttribute() const
const PTokenAttribute &CppSyntaxer::localVarAttribute() const
{
return mLocalVarAttribute;
}
CppHighlighter::TokenId CppHighlighter::getTokenId()
CppSyntaxer::TokenId CppSyntaxer::getTokenId()
{
if ((mRange.state == RangeState::rsAsm || mRange.state == RangeState::rsAsmBlock)
&& !mAsmStart && !(mTokenId == TokenId::Comment || mTokenId == TokenId::Space
@ -271,7 +271,7 @@ CppHighlighter::TokenId CppHighlighter::getTokenId()
}
}
void CppHighlighter::andSymbolProc()
void CppSyntaxer::andSymbolProc()
{
mTokenId = TokenId::Symbol;
if (mRun+1<mLineSize) {
@ -287,7 +287,7 @@ void CppHighlighter::andSymbolProc()
mRun+=1;
}
void CppHighlighter::ansiCppProc()
void CppSyntaxer::ansiCppProc()
{
mTokenId = TokenId::Comment;
if (mRun>=mLineSize) {
@ -306,7 +306,7 @@ void CppHighlighter::ansiCppProc()
}
}
void CppHighlighter::ansiCProc()
void CppSyntaxer::ansiCProc()
{
bool finishProcess = false;
mTokenId = TokenId::Comment;
@ -341,7 +341,7 @@ void CppHighlighter::ansiCProc()
}
}
void CppHighlighter::asciiCharProc()
void CppSyntaxer::asciiCharProc()
{
mTokenId = TokenId::Char;
do {
@ -357,13 +357,13 @@ void CppHighlighter::asciiCharProc()
mRange.state = RangeState::rsUnknown;
}
void CppHighlighter::atSymbolProc()
void CppSyntaxer::atSymbolProc()
{
mTokenId = TokenId::Unknown;
mRun+=1;
}
void CppHighlighter::braceCloseProc()
void CppSyntaxer::braceCloseProc()
{
mRun += 1;
mTokenId = TokenId::Symbol;
@ -385,7 +385,7 @@ void CppHighlighter::braceCloseProc()
popIndents(IndentForBrace);
}
void CppHighlighter::braceOpenProc()
void CppSyntaxer::braceOpenProc()
{
mRun += 1;
mTokenId = TokenId::Symbol;
@ -412,7 +412,7 @@ void CppHighlighter::braceOpenProc()
}
}
void CppHighlighter::colonProc()
void CppSyntaxer::colonProc()
{
mTokenId = TokenId::Symbol;
if (mRun+1<mLineSize && mLine[mRun+1]==':') {
@ -422,13 +422,13 @@ void CppHighlighter::colonProc()
}
}
void CppHighlighter::commaProc()
void CppSyntaxer::commaProc()
{
mRun+=1;
mTokenId = TokenId::Symbol;
}
void CppHighlighter::directiveProc()
void CppSyntaxer::directiveProc()
{
QString preContents = mLine.left(mRun).trimmed();
if (!preContents.isEmpty()) { // '#' is not first non-space char on the line, treat it as an invalid char
@ -457,7 +457,7 @@ void CppHighlighter::directiveProc()
mRange.state = RangeState::rsUnknown;
}
void CppHighlighter::defineIdentProc()
void CppSyntaxer::defineIdentProc()
{
mTokenId = TokenId::Identifier;
while(mRun < mLineSize && isIdentChar(mLine[mRun]))
@ -465,7 +465,7 @@ void CppHighlighter::defineIdentProc()
mRange.state = RangeState::rsDefineRemaining;
}
void CppHighlighter::defineRemainingProc()
void CppSyntaxer::defineRemainingProc()
{
mTokenId = TokenId::Directive;
do {
@ -495,7 +495,7 @@ void CppHighlighter::defineRemainingProc()
mRange.state=RangeState::rsUnknown;
}
void CppHighlighter::directiveEndProc()
void CppSyntaxer::directiveEndProc()
{
mTokenId = TokenId::Directive;
if (mRun >= mLineSize) {
@ -529,7 +529,7 @@ void CppHighlighter::directiveEndProc()
} while (mRun < mLineSize);
}
void CppHighlighter::equalProc()
void CppSyntaxer::equalProc()
{
mTokenId = TokenId::Symbol;
if (mRun+1<mLineSize && mLine[mRun+1] == '=') {
@ -539,7 +539,7 @@ void CppHighlighter::equalProc()
}
}
void CppHighlighter::greaterProc()
void CppSyntaxer::greaterProc()
{
mTokenId = TokenId::Symbol;
if (mRun+1<mLineSize) {
@ -559,7 +559,7 @@ void CppHighlighter::greaterProc()
mRun+=1;
}
void CppHighlighter::identProc()
void CppSyntaxer::identProc()
{
int wordEnd = mRun;
while (wordEnd<mLineSize && isIdentChar(mLine[wordEnd])) {
@ -577,7 +577,7 @@ void CppHighlighter::identProc()
}
}
void CppHighlighter::lowerProc()
void CppSyntaxer::lowerProc()
{
mTokenId = TokenId::Symbol;
if (mRun+1<mLineSize) {
@ -597,7 +597,7 @@ void CppHighlighter::lowerProc()
mRun+=1;
}
void CppHighlighter::minusProc()
void CppSyntaxer::minusProc()
{
mTokenId = TokenId::Symbol;
if (mRun+1<mLineSize) {
@ -620,7 +620,7 @@ void CppHighlighter::minusProc()
mRun += 1;
}
void CppHighlighter::modSymbolProc()
void CppSyntaxer::modSymbolProc()
{
mTokenId = TokenId::Symbol;
if (mRun+1<mLineSize && mLine[mRun+1]=='=') {
@ -630,7 +630,7 @@ void CppHighlighter::modSymbolProc()
}
}
void CppHighlighter::notSymbolProc()
void CppSyntaxer::notSymbolProc()
{
mTokenId = TokenId::Symbol;
if (mRun+1<mLineSize && mLine[mRun+1]=='=') {
@ -640,7 +640,7 @@ void CppHighlighter::notSymbolProc()
}
}
void CppHighlighter::nullProc()
void CppSyntaxer::nullProc()
{
if (
(mRange.state == RangeState::rsCppComment
@ -656,7 +656,7 @@ void CppHighlighter::nullProc()
mTokenId = TokenId::Null;
}
void CppHighlighter::numberProc()
void CppSyntaxer::numberProc()
{
int idx1; // token[1]
idx1 = mRun;
@ -827,7 +827,7 @@ void CppHighlighter::numberProc()
}
}
void CppHighlighter::orSymbolProc()
void CppSyntaxer::orSymbolProc()
{
mTokenId = TokenId::Symbol;
if (mRun+1<mLineSize) {
@ -843,7 +843,7 @@ void CppHighlighter::orSymbolProc()
mRun+=1;
}
void CppHighlighter::plusProc()
void CppSyntaxer::plusProc()
{
mTokenId = TokenId::Symbol;
if (mRun+1<mLineSize) {
@ -859,7 +859,7 @@ void CppHighlighter::plusProc()
mRun+=1;
}
void CppHighlighter::pointProc()
void CppSyntaxer::pointProc()
{
mTokenId = TokenId::Symbol;
if (mRun+1<mLineSize && mLine[mRun+1] == '*' ) {
@ -873,13 +873,13 @@ void CppHighlighter::pointProc()
}
}
void CppHighlighter::questionProc()
void CppSyntaxer::questionProc()
{
mTokenId = TokenId::Symbol;
mRun+=1;
}
void CppHighlighter::rawStringProc()
void CppSyntaxer::rawStringProc()
{
bool noEscaping = false;
if (mRange.state == RangeState::rsRawStringNotEscaping)
@ -905,7 +905,7 @@ void CppHighlighter::rawStringProc()
mRange.state = RangeState::rsUnknown;
}
void CppHighlighter::roundCloseProc()
void CppSyntaxer::roundCloseProc()
{
mRun += 1;
mTokenId = TokenId::Symbol;
@ -915,7 +915,7 @@ void CppHighlighter::roundCloseProc()
popIndents(IndentForParenthesis);
}
void CppHighlighter::roundOpenProc()
void CppSyntaxer::roundOpenProc()
{
mRun += 1;
mTokenId = TokenId::Symbol;
@ -923,7 +923,7 @@ void CppHighlighter::roundOpenProc()
pushIndents(IndentForParenthesis);
}
void CppHighlighter::semiColonProc()
void CppSyntaxer::semiColonProc()
{
mRun += 1;
mTokenId = TokenId::Symbol;
@ -934,7 +934,7 @@ void CppHighlighter::semiColonProc()
}
}
void CppHighlighter::slashProc()
void CppSyntaxer::slashProc()
{
if (mRun+1<mLineSize) {
switch(mLine[mRun+1].unicode()) {
@ -968,7 +968,7 @@ void CppHighlighter::slashProc()
mTokenId = TokenId::Symbol;
}
void CppHighlighter::backSlashProc()
void CppSyntaxer::backSlashProc()
{
if (mRun+1==mLineSize-1) {
mTokenId = TokenId::Symbol;
@ -978,7 +978,7 @@ void CppHighlighter::backSlashProc()
mRun+=1;
}
void CppHighlighter::spaceProc()
void CppSyntaxer::spaceProc()
{
mRun += 1;
mTokenId = TokenId::Space;
@ -987,7 +987,7 @@ void CppHighlighter::spaceProc()
mRange.state = RangeState::rsUnknown;
}
void CppHighlighter::squareCloseProc()
void CppSyntaxer::squareCloseProc()
{
mRun+=1;
mTokenId = TokenId::Symbol;
@ -997,7 +997,7 @@ void CppHighlighter::squareCloseProc()
popIndents(IndentForBracket);
}
void CppHighlighter::squareOpenProc()
void CppSyntaxer::squareOpenProc()
{
mRun+=1;
mTokenId = TokenId::Symbol;
@ -1005,7 +1005,7 @@ void CppHighlighter::squareOpenProc()
pushIndents(IndentForBracket);
}
void CppHighlighter::starProc()
void CppSyntaxer::starProc()
{
mTokenId = TokenId::Symbol;
if (mRun+1<mLineSize && mLine[mRun+1] == '=') {
@ -1015,7 +1015,7 @@ void CppHighlighter::starProc()
}
}
void CppHighlighter::stringEndProc()
void CppSyntaxer::stringEndProc()
{
mTokenId = TokenId::String;
if (mRun>=mLineSize) {
@ -1070,7 +1070,7 @@ void CppHighlighter::stringEndProc()
}
}
void CppHighlighter::stringEscapeSeqProc()
void CppSyntaxer::stringEscapeSeqProc()
{
mTokenId = TokenId::StringEscapeSeq;
mRun+=1;
@ -1162,7 +1162,7 @@ void CppHighlighter::stringEscapeSeqProc()
mRange.state = RangeState::rsString;
}
void CppHighlighter::stringProc()
void CppSyntaxer::stringProc()
{
if (mRun >= mLineSize) {
mRange.state = RangeState::rsUnknown;
@ -1217,7 +1217,7 @@ void CppHighlighter::stringProc()
mRange.state = RangeState::rsUnknown;
}
void CppHighlighter::stringStartProc()
void CppSyntaxer::stringStartProc()
{
mTokenId = TokenId::String;
mRun += 1;
@ -1228,19 +1228,19 @@ void CppHighlighter::stringStartProc()
stringProc();
}
void CppHighlighter::tildeProc()
void CppSyntaxer::tildeProc()
{
mRun+=1;
mTokenId = TokenId::Symbol;
}
void CppHighlighter::unknownProc()
void CppSyntaxer::unknownProc()
{
mRun+=1;
mTokenId = TokenId::Unknown;
}
void CppHighlighter::xorSymbolProc()
void CppSyntaxer::xorSymbolProc()
{
mTokenId = TokenId::Symbol;
if (mRun+1<mLineSize && mLine[mRun+1]=='=') {
@ -1250,7 +1250,7 @@ void CppHighlighter::xorSymbolProc()
}
}
void CppHighlighter::processChar()
void CppSyntaxer::processChar()
{
if (mRun>=mLineSize) {
nullProc();
@ -1371,7 +1371,7 @@ void CppHighlighter::processChar()
}
}
void CppHighlighter::popIndents(int indentType)
void CppSyntaxer::popIndents(int indentType)
{
while (!mRange.indents.isEmpty() && mRange.indents.back()!=indentType) {
mRange.indents.pop_back();
@ -1385,7 +1385,7 @@ void CppHighlighter::popIndents(int indentType)
}
}
void CppHighlighter::pushIndents(int indentType)
void CppSyntaxer::pushIndents(int indentType)
{
int idx = mRange.indents.length();
if (idx<mRange.firstIndentThisLine)
@ -1393,22 +1393,22 @@ void CppHighlighter::pushIndents(int indentType)
mRange.indents.push_back(indentType);
}
const QSet<QString> &CppHighlighter::customTypeKeywords() const
const QSet<QString> &CppSyntaxer::customTypeKeywords() const
{
return mCustomTypeKeywords;
}
void CppHighlighter::setCustomTypeKeywords(const QSet<QString> &newCustomTypeKeywords)
void CppSyntaxer::setCustomTypeKeywords(const QSet<QString> &newCustomTypeKeywords)
{
mCustomTypeKeywords = newCustomTypeKeywords;
}
bool CppHighlighter::supportBraceLevel()
bool CppSyntaxer::supportBraceLevel()
{
return true;
}
bool CppHighlighter::getTokenFinished() const
bool CppSyntaxer::getTokenFinished() const
{
if (mTokenId == TokenId::Comment
|| mTokenId == TokenId::String
@ -1418,7 +1418,7 @@ bool CppHighlighter::getTokenFinished() const
return true;
}
bool CppHighlighter::isLastLineCommentNotFinished(int state) const
bool CppSyntaxer::isLastLineCommentNotFinished(int state) const
{
return (state == RangeState::rsAnsiC ||
state == RangeState::rsAnsiCAsm ||
@ -1427,22 +1427,22 @@ bool CppHighlighter::isLastLineCommentNotFinished(int state) const
state == RangeState::rsCppComment);
}
bool CppHighlighter::isLastLineStringNotFinished(int state) const
bool CppSyntaxer::isLastLineStringNotFinished(int state) const
{
return state == RangeState::rsMultiLineString;
}
bool CppHighlighter::eol() const
bool CppSyntaxer::eol() const
{
return mTokenId == TokenId::Null;
}
QString CppHighlighter::getToken() const
QString CppSyntaxer::getToken() const
{
return mLine.mid(mTokenPos,mRun-mTokenPos);
}
const PTokenAttribute &CppHighlighter::getTokenAttribute() const
const PTokenAttribute &CppSyntaxer::getTokenAttribute() const
{
switch (mTokenId) {
case TokenId::Asm:
@ -1483,12 +1483,12 @@ const PTokenAttribute &CppHighlighter::getTokenAttribute() const
}
}
int CppHighlighter::getTokenPos()
int CppSyntaxer::getTokenPos()
{
return mTokenPos;
}
void CppHighlighter::next()
void CppSyntaxer::next()
{
mAsmStart = false;
mTokenPos = mRun;
@ -1574,7 +1574,7 @@ void CppHighlighter::next()
//qDebug()<<"1-1-1";
}
void CppHighlighter::setLine(const QString &newLine, int lineNumber)
void CppSyntaxer::setLine(const QString &newLine, int lineNumber)
{
mLine = newLine;
mLineSize = mLine.size();
@ -1588,12 +1588,12 @@ void CppHighlighter::setLine(const QString &newLine, int lineNumber)
next();
}
bool CppHighlighter::isKeyword(const QString &word)
bool CppSyntaxer::isKeyword(const QString &word)
{
return Keywords.contains(word) || mCustomTypeKeywords.contains(word);
}
void CppHighlighter::setState(const SyntaxerState& rangeState)
void CppSyntaxer::setState(const SyntaxerState& rangeState)
{
mRange = rangeState;
// current line's left / right parenthesis count should be reset before parsing each line
@ -1604,7 +1604,7 @@ void CppHighlighter::setState(const SyntaxerState& rangeState)
mRange.matchingIndents.clear();
}
void CppHighlighter::resetState()
void CppSyntaxer::resetState()
{
mRange.state = RangeState::rsUnknown;
mRange.braceLevel = 0;
@ -1620,34 +1620,34 @@ void CppHighlighter::resetState()
mAsmStart = false;
}
QString CppHighlighter::languageName()
QString CppSyntaxer::languageName()
{
return "cpp";
}
ProgrammingLanguage CppHighlighter::language()
ProgrammingLanguage CppSyntaxer::language()
{
return ProgrammingLanguage::Cpp;
}
SyntaxerState CppHighlighter::getState() const
SyntaxerState CppSyntaxer::getState() const
{
return mRange;
}
bool CppHighlighter::isIdentChar(const QChar &ch) const
bool CppSyntaxer::isIdentChar(const QChar &ch) const
{
return ch=='_' || ch.isDigit() || ch.isLetter();
}
QSet<QString> CppHighlighter::keywords() const
QSet<QString> CppSyntaxer::keywords() const
{
QSet<QString> set=Keywords;
set.unite(mCustomTypeKeywords);
return set;
}
QString CppHighlighter::foldString()
QString CppSyntaxer::foldString()
{
return "...}";
}

View File

@ -16,12 +16,12 @@
*/
#ifndef SYNEDITCPPHIGHLIGHTER_H
#define SYNEDITCPPHIGHLIGHTER_H
#include "base.h"
#include "syntaxer.h"
#include <QSet>
namespace QSynedit {
class CppHighlighter: public Highlighter
class CppSyntaxer: public Syntaxer
{
enum class TokenId {
Asm,
@ -54,7 +54,7 @@ class CppHighlighter: public Highlighter
};
public:
explicit CppHighlighter();
explicit CppSyntaxer();
const PTokenAttribute &asmAttribute() const;

View File

@ -1,9 +1,9 @@
#ifndef CUSTOMHIGHLIGHTERV1_H
#define CUSTOMHIGHLIGHTERV1_H
#include "base.h"
#include "syntaxer.h"
namespace QSynedit {
class CustomHighlighterV1:public Highlighter
class CustomHighlighterV1:public Syntaxer
{
public:
enum RangeState {

View File

@ -29,7 +29,7 @@ static const QSet<QString> GLSLStatementKeyWords {
"while"
};
const QSet<QString> GLSLHighlighter::Keywords {
const QSet<QString> GLSLSyntaxer::Keywords {
"const", "uniform", "buffer", "shared", "attribute", "varying",
"coherent", "volatile", "restrict", "readonly", "writeonly",
"atomic_uint",
@ -81,7 +81,7 @@ const QSet<QString> GLSLHighlighter::Keywords {
"struct"
};
GLSLHighlighter::GLSLHighlighter(): Highlighter()
GLSLSyntaxer::GLSLSyntaxer(): Syntaxer()
{
mAsmAttribute = std::make_shared<TokenAttribute>(SYNS_AttrAssembler,
TokenType::Embeded);
@ -131,77 +131,77 @@ GLSLHighlighter::GLSLHighlighter(): Highlighter()
resetState();
}
const PTokenAttribute &GLSLHighlighter::asmAttribute() const
const PTokenAttribute &GLSLSyntaxer::asmAttribute() const
{
return mAsmAttribute;
}
const PTokenAttribute &GLSLHighlighter::preprocessorAttribute() const
const PTokenAttribute &GLSLSyntaxer::preprocessorAttribute() const
{
return mPreprocessorAttribute;
}
const PTokenAttribute &GLSLHighlighter::invalidAttribute() const
const PTokenAttribute &GLSLSyntaxer::invalidAttribute() const
{
return mInvalidAttribute;
}
const PTokenAttribute &GLSLHighlighter::numberAttribute() const
const PTokenAttribute &GLSLSyntaxer::numberAttribute() const
{
return mNumberAttribute;
}
const PTokenAttribute &GLSLHighlighter::floatAttribute() const
const PTokenAttribute &GLSLSyntaxer::floatAttribute() const
{
return mFloatAttribute;
}
const PTokenAttribute &GLSLHighlighter::hexAttribute() const
const PTokenAttribute &GLSLSyntaxer::hexAttribute() const
{
return mHexAttribute;
}
const PTokenAttribute &GLSLHighlighter::octAttribute() const
const PTokenAttribute &GLSLSyntaxer::octAttribute() const
{
return mOctAttribute;
}
const PTokenAttribute &GLSLHighlighter::stringEscapeSequenceAttribute() const
const PTokenAttribute &GLSLSyntaxer::stringEscapeSequenceAttribute() const
{
return mStringEscapeSequenceAttribute;
}
const PTokenAttribute &GLSLHighlighter::charAttribute() const
const PTokenAttribute &GLSLSyntaxer::charAttribute() const
{
return mCharAttribute;
}
const PTokenAttribute &GLSLHighlighter::variableAttribute() const
const PTokenAttribute &GLSLSyntaxer::variableAttribute() const
{
return mVariableAttribute;
}
const PTokenAttribute &GLSLHighlighter::functionAttribute() const
const PTokenAttribute &GLSLSyntaxer::functionAttribute() const
{
return mFunctionAttribute;
}
const PTokenAttribute &GLSLHighlighter::classAttribute() const
const PTokenAttribute &GLSLSyntaxer::classAttribute() const
{
return mClassAttribute;
}
const PTokenAttribute &GLSLHighlighter::globalVarAttribute() const
const PTokenAttribute &GLSLSyntaxer::globalVarAttribute() const
{
return mGlobalVarAttribute;
}
const PTokenAttribute &GLSLHighlighter::localVarAttribute() const
const PTokenAttribute &GLSLSyntaxer::localVarAttribute() const
{
return mLocalVarAttribute;
}
GLSLHighlighter::TokenId GLSLHighlighter::getTokenId()
GLSLSyntaxer::TokenId GLSLSyntaxer::getTokenId()
{
if ((mRange.state == RangeState::rsAsm || mRange.state == RangeState::rsAsmBlock)
&& !mAsmStart && !(mTokenId == TokenId::Comment || mTokenId == TokenId::Space
@ -212,7 +212,7 @@ GLSLHighlighter::TokenId GLSLHighlighter::getTokenId()
}
}
void GLSLHighlighter::andSymbolProc()
void GLSLSyntaxer::andSymbolProc()
{
mTokenId = TokenId::Symbol;
switch (mLine[mRun+1].unicode()) {
@ -227,7 +227,7 @@ void GLSLHighlighter::andSymbolProc()
}
}
void GLSLHighlighter::ansiCppProc()
void GLSLSyntaxer::ansiCppProc()
{
mTokenId = TokenId::Comment;
if (mLine[mRun]==0) {
@ -246,7 +246,7 @@ void GLSLHighlighter::ansiCppProc()
}
}
void GLSLHighlighter::ansiCProc()
void GLSLSyntaxer::ansiCProc()
{
bool finishProcess = false;
mTokenId = TokenId::Comment;
@ -281,7 +281,7 @@ void GLSLHighlighter::ansiCProc()
}
}
void GLSLHighlighter::asciiCharProc()
void GLSLSyntaxer::asciiCharProc()
{
mTokenId = TokenId::Char;
do {
@ -297,13 +297,13 @@ void GLSLHighlighter::asciiCharProc()
mRange.state = RangeState::rsUnknown;
}
void GLSLHighlighter::atSymbolProc()
void GLSLSyntaxer::atSymbolProc()
{
mTokenId = TokenId::Unknown;
mRun+=1;
}
void GLSLHighlighter::braceCloseProc()
void GLSLSyntaxer::braceCloseProc()
{
mRun += 1;
mTokenId = TokenId::Symbol;
@ -325,7 +325,7 @@ void GLSLHighlighter::braceCloseProc()
popIndents(IndentForBrace);
}
void GLSLHighlighter::braceOpenProc()
void GLSLSyntaxer::braceOpenProc()
{
mRun += 1;
mTokenId = TokenId::Symbol;
@ -352,7 +352,7 @@ void GLSLHighlighter::braceOpenProc()
}
}
void GLSLHighlighter::colonProc()
void GLSLSyntaxer::colonProc()
{
mTokenId = TokenId::Symbol;
if (mLine[mRun+1]==':') {
@ -362,13 +362,13 @@ void GLSLHighlighter::colonProc()
}
}
void GLSLHighlighter::commaProc()
void GLSLSyntaxer::commaProc()
{
mRun+=1;
mTokenId = TokenId::Symbol;
}
void GLSLHighlighter::directiveProc()
void GLSLSyntaxer::directiveProc()
{
QString preContents = mLineString.left(mRun).trimmed();
if (!preContents.isEmpty()) { // '#' is not first non-space char on the line, treat it as an invalid char
@ -411,7 +411,7 @@ void GLSLHighlighter::directiveProc()
// } while (mLine[mRun]!=0);
}
void GLSLHighlighter::directiveEndProc()
void GLSLSyntaxer::directiveEndProc()
{
mTokenId = TokenId::Directive;
if (mLine[mRun] == 0) {
@ -443,7 +443,7 @@ void GLSLHighlighter::directiveEndProc()
} while (mLine[mRun]!=0);
}
void GLSLHighlighter::equalProc()
void GLSLSyntaxer::equalProc()
{
mTokenId = TokenId::Symbol;
if (mLine[mRun+1] == '=') {
@ -453,7 +453,7 @@ void GLSLHighlighter::equalProc()
}
}
void GLSLHighlighter::greaterProc()
void GLSLSyntaxer::greaterProc()
{
mTokenId = TokenId::Symbol;
switch (mLine[mRun + 1].unicode()) {
@ -472,7 +472,7 @@ void GLSLHighlighter::greaterProc()
}
}
void GLSLHighlighter::identProc()
void GLSLSyntaxer::identProc()
{
int wordEnd = mRun;
while (isIdentChar(mLine[wordEnd])) {
@ -490,7 +490,7 @@ void GLSLHighlighter::identProc()
}
}
void GLSLHighlighter::lowerProc()
void GLSLSyntaxer::lowerProc()
{
mTokenId = TokenId::Symbol;
switch(mLine[mRun+1].unicode()) {
@ -509,7 +509,7 @@ void GLSLHighlighter::lowerProc()
}
}
void GLSLHighlighter::minusProc()
void GLSLSyntaxer::minusProc()
{
mTokenId = TokenId::Symbol;
switch(mLine[mRun+1].unicode()) {
@ -531,7 +531,7 @@ void GLSLHighlighter::minusProc()
}
}
void GLSLHighlighter::modSymbolProc()
void GLSLSyntaxer::modSymbolProc()
{
mTokenId = TokenId::Symbol;
switch(mLine[mRun + 1].unicode()) {
@ -543,7 +543,7 @@ void GLSLHighlighter::modSymbolProc()
}
}
void GLSLHighlighter::notSymbolProc()
void GLSLSyntaxer::notSymbolProc()
{
mTokenId = TokenId::Symbol;
switch(mLine[mRun + 1].unicode()) {
@ -555,7 +555,7 @@ void GLSLHighlighter::notSymbolProc()
}
}
void GLSLHighlighter::nullProc()
void GLSLSyntaxer::nullProc()
{
if ((mRun-1>=0) && isSpaceChar(mLine[mRun-1]) &&
(mRange.state == RangeState::rsCppComment
@ -568,7 +568,7 @@ void GLSLHighlighter::nullProc()
mTokenId = TokenId::Null;
}
void GLSLHighlighter::numberProc()
void GLSLSyntaxer::numberProc()
{
int idx1; // token[1]
idx1 = mRun;
@ -738,7 +738,7 @@ void GLSLHighlighter::numberProc()
}
}
void GLSLHighlighter::orSymbolProc()
void GLSLSyntaxer::orSymbolProc()
{
mTokenId = TokenId::Symbol;
switch ( mLine[mRun+1].unicode()) {
@ -753,7 +753,7 @@ void GLSLHighlighter::orSymbolProc()
}
}
void GLSLHighlighter::plusProc()
void GLSLSyntaxer::plusProc()
{
mTokenId = TokenId::Symbol;
switch(mLine[mRun+1].unicode()){
@ -768,7 +768,7 @@ void GLSLHighlighter::plusProc()
}
}
void GLSLHighlighter::pointProc()
void GLSLSyntaxer::pointProc()
{
mTokenId = TokenId::Symbol;
if (mLine[mRun+1] == '*' ) {
@ -782,13 +782,13 @@ void GLSLHighlighter::pointProc()
}
}
void GLSLHighlighter::questionProc()
void GLSLSyntaxer::questionProc()
{
mTokenId = TokenId::Symbol;
mRun+=1;
}
void GLSLHighlighter::rawStringProc()
void GLSLSyntaxer::rawStringProc()
{
bool noEscaping = false;
if (mRange.state == RangeState::rsRawStringNotEscaping)
@ -814,7 +814,7 @@ void GLSLHighlighter::rawStringProc()
mRange.state = RangeState::rsUnknown;
}
void GLSLHighlighter::roundCloseProc()
void GLSLSyntaxer::roundCloseProc()
{
mRun += 1;
mTokenId = TokenId::Symbol;
@ -824,7 +824,7 @@ void GLSLHighlighter::roundCloseProc()
popIndents(IndentForParenthesis);
}
void GLSLHighlighter::roundOpenProc()
void GLSLSyntaxer::roundOpenProc()
{
mRun += 1;
mTokenId = TokenId::Symbol;
@ -832,7 +832,7 @@ void GLSLHighlighter::roundOpenProc()
pushIndents(IndentForParenthesis);
}
void GLSLHighlighter::semiColonProc()
void GLSLSyntaxer::semiColonProc()
{
mRun += 1;
mTokenId = TokenId::Symbol;
@ -843,7 +843,7 @@ void GLSLHighlighter::semiColonProc()
}
}
void GLSLHighlighter::slashProc()
void GLSLSyntaxer::slashProc()
{
switch(mLine[mRun+1].unicode()) {
case '/': // Cpp style comment
@ -876,7 +876,7 @@ void GLSLHighlighter::slashProc()
}
}
void GLSLHighlighter::spaceProc()
void GLSLSyntaxer::spaceProc()
{
mRun += 1;
mTokenId = TokenId::Space;
@ -885,7 +885,7 @@ void GLSLHighlighter::spaceProc()
mRange.state = RangeState::rsUnknown;
}
void GLSLHighlighter::squareCloseProc()
void GLSLSyntaxer::squareCloseProc()
{
mRun+=1;
mTokenId = TokenId::Symbol;
@ -895,7 +895,7 @@ void GLSLHighlighter::squareCloseProc()
popIndents(IndentForBracket);
}
void GLSLHighlighter::squareOpenProc()
void GLSLSyntaxer::squareOpenProc()
{
mRun+=1;
mTokenId = TokenId::Symbol;
@ -903,7 +903,7 @@ void GLSLHighlighter::squareOpenProc()
pushIndents(IndentForBracket);
}
void GLSLHighlighter::starProc()
void GLSLSyntaxer::starProc()
{
mTokenId = TokenId::Symbol;
if (mLine[mRun+1] == '=') {
@ -913,7 +913,7 @@ void GLSLHighlighter::starProc()
}
}
void GLSLHighlighter::stringEndProc()
void GLSLSyntaxer::stringEndProc()
{
mTokenId = TokenId::String;
if (mLine[mRun]==0) {
@ -965,7 +965,7 @@ void GLSLHighlighter::stringEndProc()
}
}
void GLSLHighlighter::stringEscapeSeqProc()
void GLSLSyntaxer::stringEscapeSeqProc()
{
mTokenId = TokenId::StringEscapeSeq;
mRun+=1;
@ -1047,7 +1047,7 @@ void GLSLHighlighter::stringEscapeSeqProc()
mRange.state = RangeState::rsString;
}
void GLSLHighlighter::stringProc()
void GLSLSyntaxer::stringProc()
{
if (mLine[mRun] == 0) {
mRange.state = RangeState::rsUnknown;
@ -1099,7 +1099,7 @@ void GLSLHighlighter::stringProc()
mRange.state = RangeState::rsUnknown;
}
void GLSLHighlighter::stringStartProc()
void GLSLSyntaxer::stringStartProc()
{
mTokenId = TokenId::String;
mRun += 1;
@ -1110,19 +1110,19 @@ void GLSLHighlighter::stringStartProc()
stringProc();
}
void GLSLHighlighter::tildeProc()
void GLSLSyntaxer::tildeProc()
{
mRun+=1;
mTokenId = TokenId::Symbol;
}
void GLSLHighlighter::unknownProc()
void GLSLSyntaxer::unknownProc()
{
mRun+=1;
mTokenId = TokenId::Unknown;
}
void GLSLHighlighter::xorSymbolProc()
void GLSLSyntaxer::xorSymbolProc()
{
mTokenId = TokenId::Symbol;
if (mLine[mRun+1]=='=') {
@ -1132,7 +1132,7 @@ void GLSLHighlighter::xorSymbolProc()
}
}
void GLSLHighlighter::processChar()
void GLSLSyntaxer::processChar()
{
switch(mLine[mRun].unicode()) {
case '&':
@ -1249,7 +1249,7 @@ void GLSLHighlighter::processChar()
}
}
void GLSLHighlighter::popIndents(int indentType)
void GLSLSyntaxer::popIndents(int indentType)
{
while (!mRange.indents.isEmpty() && mRange.indents.back()!=indentType) {
mRange.indents.pop_back();
@ -1263,7 +1263,7 @@ void GLSLHighlighter::popIndents(int indentType)
}
}
void GLSLHighlighter::pushIndents(int indentType)
void GLSLSyntaxer::pushIndents(int indentType)
{
int idx = mRange.indents.length();
if (idx<mRange.firstIndentThisLine)
@ -1271,7 +1271,7 @@ void GLSLHighlighter::pushIndents(int indentType)
mRange.indents.push_back(indentType);
}
bool GLSLHighlighter::getTokenFinished() const
bool GLSLSyntaxer::getTokenFinished() const
{
if (mTokenId == TokenId::Comment
|| mTokenId == TokenId::String
@ -1281,7 +1281,7 @@ bool GLSLHighlighter::getTokenFinished() const
return true;
}
bool GLSLHighlighter::isLastLineCommentNotFinished(int state) const
bool GLSLSyntaxer::isLastLineCommentNotFinished(int state) const
{
return (state == RangeState::rsAnsiC ||
state == RangeState::rsAnsiCAsm ||
@ -1290,22 +1290,22 @@ bool GLSLHighlighter::isLastLineCommentNotFinished(int state) const
state == RangeState::rsCppComment);
}
bool GLSLHighlighter::isLastLineStringNotFinished(int state) const
bool GLSLSyntaxer::isLastLineStringNotFinished(int state) const
{
return state == RangeState::rsMultiLineString;
}
bool GLSLHighlighter::eol() const
bool GLSLSyntaxer::eol() const
{
return mTokenId == TokenId::Null;
}
QString GLSLHighlighter::getToken() const
QString GLSLSyntaxer::getToken() const
{
return mLineString.mid(mTokenPos,mRun-mTokenPos);
}
const PTokenAttribute &GLSLHighlighter::getTokenAttribute() const
const PTokenAttribute &GLSLSyntaxer::getTokenAttribute() const
{
switch (mTokenId) {
case TokenId::Asm:
@ -1346,12 +1346,12 @@ const PTokenAttribute &GLSLHighlighter::getTokenAttribute() const
}
}
int GLSLHighlighter::getTokenPos()
int GLSLSyntaxer::getTokenPos()
{
return mTokenPos;
}
void GLSLHighlighter::next()
void GLSLSyntaxer::next()
{
mAsmStart = false;
mTokenPos = mRun;
@ -1409,7 +1409,7 @@ void GLSLHighlighter::next()
} while (mTokenId!=TokenId::Null && mRun<=mTokenPos);
}
void GLSLHighlighter::setLine(const QString &newLine, int lineNumber)
void GLSLSyntaxer::setLine(const QString &newLine, int lineNumber)
{
mLineString = newLine;
mLine = mLineString.data();
@ -1424,12 +1424,12 @@ void GLSLHighlighter::setLine(const QString &newLine, int lineNumber)
next();
}
bool GLSLHighlighter::isKeyword(const QString &word)
bool GLSLSyntaxer::isKeyword(const QString &word)
{
return Keywords.contains(word);
}
void GLSLHighlighter::setState(const SyntaxerState& rangeState)
void GLSLSyntaxer::setState(const SyntaxerState& rangeState)
{
mRange = rangeState;
// current line's left / right parenthesis count should be reset before parsing each line
@ -1441,7 +1441,7 @@ void GLSLHighlighter::setState(const SyntaxerState& rangeState)
mRange.matchingIndents.clear();
}
void GLSLHighlighter::resetState()
void GLSLSyntaxer::resetState()
{
mRange.state = RangeState::rsUnknown;
mRange.braceLevel = 0;
@ -1457,32 +1457,32 @@ void GLSLHighlighter::resetState()
mAsmStart = false;
}
QString GLSLHighlighter::languageName()
QString GLSLSyntaxer::languageName()
{
return "glsl";
}
ProgrammingLanguage GLSLHighlighter::language()
ProgrammingLanguage GLSLSyntaxer::language()
{
return ProgrammingLanguage::GLSL;
}
SyntaxerState GLSLHighlighter::getState() const
SyntaxerState GLSLSyntaxer::getState() const
{
return mRange;
}
bool GLSLHighlighter::isIdentChar(const QChar &ch) const
bool GLSLSyntaxer::isIdentChar(const QChar &ch) const
{
return ch=='_' || (ch>='a' && ch<='z') || (ch>='A' && ch<='Z') || (ch>='0' && ch<='9');
}
QSet<QString> GLSLHighlighter::keywords() const
QSet<QString> GLSLSyntaxer::keywords() const
{
return Keywords;
}
bool GLSLHighlighter::supportBraceLevel()
bool GLSLSyntaxer::supportBraceLevel()
{
return true;
}

View File

@ -16,12 +16,12 @@
*/
#ifndef SYNEDITGLSLHIGHLIGHTER_H
#define SYNEDITGLSLHIGHLIGHTER_H
#include "base.h"
#include "syntaxer.h"
#include <QSet>
namespace QSynedit {
class GLSLHighlighter: public Highlighter
class GLSLSyntaxer: public Syntaxer
{
enum class TokenId {
Asm,
@ -54,7 +54,7 @@ class GLSLHighlighter: public Highlighter
};
public:
explicit GLSLHighlighter();
explicit GLSLSyntaxer();
const PTokenAttribute &asmAttribute() const;

View File

@ -14,12 +14,12 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "makefilehighlighter.h"
#include "makefile.h"
#include "../Constants.h"
//#include <QDebug>
namespace QSynedit {
const QSet<QString> MakefileHighlighter::Directives {
const QSet<QString> MakefileSyntaxer::Directives {
"abspath",
"addprefix",
"addsuffix",
@ -180,7 +180,7 @@ const QSet<QString> MakefileHighlighter::Directives {
"YFLAGS",
};
MakefileHighlighter::MakefileHighlighter()
MakefileSyntaxer::MakefileSyntaxer()
{
mTargetAttribute = std::make_shared<TokenAttribute>(SYNS_AttrClass, TokenType::Identifier);
addAttribute(mTargetAttribute);
@ -196,27 +196,27 @@ MakefileHighlighter::MakefileHighlighter()
addAttribute(mExpressionAttribute);
}
void MakefileHighlighter::procSpace()
void MakefileSyntaxer::procSpace()
{
mTokenID = TokenId::Space;
while (mLine[mRun]!=0 && mLine[mRun]<=32)
mRun++;
}
void MakefileHighlighter::procNumber()
void MakefileSyntaxer::procNumber()
{
while (isNumberChar(mLine[mRun]))
mRun++;
mTokenID = TokenId::Number;
}
void MakefileHighlighter::procNull()
void MakefileSyntaxer::procNull()
{
mTokenID = TokenId::Null;
mState = RangeState::Unknown;
}
void MakefileHighlighter::procString(bool inExpression )
void MakefileSyntaxer::procString(bool inExpression )
{
mTokenID = TokenId::String;
while (mLine[mRun] != 0) {
@ -238,7 +238,7 @@ void MakefileHighlighter::procString(bool inExpression )
}
void MakefileHighlighter::procStringStart(StringStartType type,bool inExpression )
void MakefileSyntaxer::procStringStart(StringStartType type,bool inExpression )
{
mRun++;
pushState();
@ -253,7 +253,7 @@ void MakefileHighlighter::procStringStart(StringStartType type,bool inExpression
procString(inExpression);
}
void MakefileHighlighter::procExpressionStart(ExpressionStartType type)
void MakefileSyntaxer::procExpressionStart(ExpressionStartType type)
{
mRun+=2; //skip '$(' or '${'
pushState();
@ -268,20 +268,20 @@ void MakefileHighlighter::procExpressionStart(ExpressionStartType type)
mTokenID = TokenId::Expression;
}
void MakefileHighlighter::procExpressionEnd()
void MakefileSyntaxer::procExpressionEnd()
{
mTokenID = TokenId::Expression;
mRun+=1;
popState();
}
void MakefileHighlighter::procSymbol()
void MakefileSyntaxer::procSymbol()
{
mTokenID = TokenId::Symbol;
mRun+=1;
}
void MakefileHighlighter::procVariableExpression()
void MakefileSyntaxer::procVariableExpression()
{
mRun+=1; //skip $
while (isIdentStartChar(mLine[mRun]))
@ -289,7 +289,7 @@ void MakefileHighlighter::procVariableExpression()
mTokenID = TokenId::Variable;
}
void MakefileHighlighter::procAutoVariable()
void MakefileSyntaxer::procAutoVariable()
{
mRun+=1; //skip $
switch(mLine[mRun].unicode()) {
@ -311,14 +311,14 @@ void MakefileHighlighter::procAutoVariable()
}
}
void MakefileHighlighter::procAssignment()
void MakefileSyntaxer::procAssignment()
{
mTokenID = TokenId::Symbol;
mRun++;
mState = RangeState::Assignment;
}
void MakefileHighlighter::procDollar()
void MakefileSyntaxer::procDollar()
{
if (mLine[mRun+1]=='(') {
procExpressionStart(ExpressionStartType::Parenthesis);
@ -331,14 +331,14 @@ void MakefileHighlighter::procDollar()
}
}
void MakefileHighlighter::procComment()
void MakefileSyntaxer::procComment()
{
mRun++; //skip #
mRun = mLineString.length();
mTokenID = TokenId::Comment;
}
void MakefileHighlighter::procIdentifier()
void MakefileSyntaxer::procIdentifier()
{
int start = mRun;
while (isIdentChar(mLine[mRun])) {
@ -374,12 +374,12 @@ void MakefileHighlighter::procIdentifier()
}
void MakefileHighlighter::pushState()
void MakefileSyntaxer::pushState()
{
mStates.push_back(mState);
}
void MakefileHighlighter::popState()
void MakefileSyntaxer::popState()
{
if (!mStates.empty()) {
mState = mStates.back();
@ -387,7 +387,7 @@ void MakefileHighlighter::popState()
}
}
bool MakefileHighlighter::isIdentChar(const QChar &ch) const
bool MakefileSyntaxer::isIdentChar(const QChar &ch) const
{
if ((ch>='0') && (ch <= '9')) {
return true;
@ -411,27 +411,27 @@ bool MakefileHighlighter::isIdentChar(const QChar &ch) const
return false;
}
bool MakefileHighlighter::eol() const
bool MakefileSyntaxer::eol() const
{
return mTokenID == TokenId::Null;
}
QString MakefileHighlighter::languageName()
QString MakefileSyntaxer::languageName()
{
return "makefile";
}
ProgrammingLanguage MakefileHighlighter::language()
ProgrammingLanguage MakefileSyntaxer::language()
{
return ProgrammingLanguage::Makefile;
}
QString MakefileHighlighter::getToken() const
QString MakefileSyntaxer::getToken() const
{
return mLineString.mid(mTokenPos,mRun-mTokenPos);
}
const PTokenAttribute &MakefileHighlighter::getTokenAttribute() const
const PTokenAttribute &MakefileSyntaxer::getTokenAttribute() const
{
/*
Directive,
@ -467,12 +467,12 @@ const PTokenAttribute &MakefileHighlighter::getTokenAttribute() const
}
}
int MakefileHighlighter::getTokenPos()
int MakefileSyntaxer::getTokenPos()
{
return mTokenPos;
}
void MakefileHighlighter::next()
void MakefileSyntaxer::next()
{
mTokenPos = mRun;
if (mLine[mRun].unicode()==0) {
@ -638,7 +638,7 @@ void MakefileHighlighter::next()
}
}
void MakefileHighlighter::setLine(const QString &newLine, int lineNumber)
void MakefileSyntaxer::setLine(const QString &newLine, int lineNumber)
{
mLineString = newLine;
mLine = mLineString.data();
@ -647,41 +647,41 @@ void MakefileHighlighter::setLine(const QString &newLine, int lineNumber)
next();
}
bool MakefileHighlighter::getTokenFinished() const
bool MakefileSyntaxer::getTokenFinished() const
{
return true;
}
bool MakefileHighlighter::isLastLineCommentNotFinished(int /*state*/) const
bool MakefileSyntaxer::isLastLineCommentNotFinished(int /*state*/) const
{
return false;
}
bool MakefileHighlighter::isLastLineStringNotFinished(int /*state*/) const
bool MakefileSyntaxer::isLastLineStringNotFinished(int /*state*/) const
{
return false;
}
SyntaxerState MakefileHighlighter::getState() const
SyntaxerState MakefileSyntaxer::getState() const
{
SyntaxerState state;
state.state = (int)mState;
return state;
}
void MakefileHighlighter::setState(const SyntaxerState & rangeState)
void MakefileSyntaxer::setState(const SyntaxerState & rangeState)
{
mState = (RangeState)rangeState.state;
mStates.clear();
}
void MakefileHighlighter::resetState()
void MakefileSyntaxer::resetState()
{
mState = RangeState::Unknown;
mStates.clear();
}
QSet<QString> MakefileHighlighter::keywords() const
QSet<QString> MakefileSyntaxer::keywords() const
{
return Directives;
}

View File

@ -14,16 +14,16 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MAKEFILEHIGHLIGHTER_H
#define MAKEFILEHIGHLIGHTER_H
#ifndef MAKEFILE_H
#define MAKEFILE_H
#include "base.h"
#include "syntaxer.h"
#include <QVector>
namespace QSynedit {
class MakefileHighlighter : public Highlighter
class MakefileSyntaxer : public Syntaxer
{
enum class TokenId {
Null,
@ -66,7 +66,7 @@ class MakefileHighlighter : public Highlighter
public:
explicit MakefileHighlighter();
explicit MakefileSyntaxer();
static const QSet<QString> Directives;
private:
@ -156,4 +156,4 @@ public:
};
}
#endif // MAKEFILEHIGHLIGHTER_H
#endif // MAKEFILE_H

View File

@ -14,11 +14,11 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "base.h"
#include "syntaxer.h"
#include "../Constants.h"
namespace QSynedit {
Highlighter::Highlighter() :
Syntaxer::Syntaxer() :
mEnabled(true),
mWordBreakChars{ WordBreakChars }
{
@ -42,78 +42,78 @@ Highlighter::Highlighter() :
addAttribute(mSymbolAttribute);
}
const QMap<QString, PTokenAttribute>& Highlighter::attributes() const
const QMap<QString, PTokenAttribute>& Syntaxer::attributes() const
{
return mAttributes;
}
const QSet<QChar>& Highlighter::wordBreakChars() const
const QSet<QChar>& Syntaxer::wordBreakChars() const
{
return mWordBreakChars;
}
const PTokenAttribute& Highlighter::identifierAttribute() const
const PTokenAttribute& Syntaxer::identifierAttribute() const
{
return mIdentifierAttribute;
}
const PTokenAttribute &Highlighter::keywordAttribute() const
const PTokenAttribute &Syntaxer::keywordAttribute() const
{
return mKeywordAttribute;
}
const PTokenAttribute &Highlighter::commentAttribute() const
const PTokenAttribute &Syntaxer::commentAttribute() const
{
return mCommentAttribute;
}
const PTokenAttribute& Highlighter::stringAttribute() const
const PTokenAttribute& Syntaxer::stringAttribute() const
{
return mStringAttribute;
}
const PTokenAttribute& Highlighter::whitespaceAttribute() const
const PTokenAttribute& Syntaxer::whitespaceAttribute() const
{
return mWhitespaceAttribute;
}
const PTokenAttribute& Highlighter::symbolAttribute() const
const PTokenAttribute& Syntaxer::symbolAttribute() const
{
return mSymbolAttribute;
}
bool Highlighter::isKeyword(const QString &)
bool Syntaxer::isKeyword(const QString &)
{
return false;
}
void Highlighter::nextToEol()
void Syntaxer::nextToEol()
{
while (!eol())
next();
}
QSet<QString> Highlighter::keywords() const
QSet<QString> Syntaxer::keywords() const
{
return QSet<QString>();
}
QString Highlighter::foldString()
QString Syntaxer::foldString()
{
return " ... }";
}
bool Highlighter::supportBraceLevel()
bool Syntaxer::supportBraceLevel()
{
return false;
}
bool Highlighter::isSpaceChar(const QChar &ch)
bool Syntaxer::isSpaceChar(const QChar &ch)
{
return ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n';
}
bool Highlighter::isWordBreakChar(const QChar &ch)
bool Syntaxer::isWordBreakChar(const QChar &ch)
{
switch (ch.unicode()) {
case '.':
@ -147,7 +147,7 @@ bool Highlighter::isWordBreakChar(const QChar &ch)
}
}
bool Highlighter::isIdentChar(const QChar &ch) const
bool Syntaxer::isIdentChar(const QChar &ch) const
{
if (ch == '_') {
return true;
@ -164,32 +164,32 @@ bool Highlighter::isIdentChar(const QChar &ch) const
return false;
}
void Highlighter::addAttribute(PTokenAttribute attribute)
void Syntaxer::addAttribute(PTokenAttribute attribute)
{
mAttributes[attribute->name()]=attribute;
}
void Highlighter::clearAttributes()
void Syntaxer::clearAttributes()
{
mAttributes.clear();
}
int Highlighter::attributesCount() const
int Syntaxer::attributesCount() const
{
return mAttributes.size();
}
PTokenAttribute Highlighter::getAttribute(const QString& name) const
PTokenAttribute Syntaxer::getAttribute(const QString& name) const
{
return mAttributes.value(name,PTokenAttribute());
}
bool Highlighter::enabled() const
bool Syntaxer::enabled() const
{
return mEnabled;
}
void Highlighter::setEnabled(bool value)
void Syntaxer::setEnabled(bool value)
{
if (value != mEnabled) {
mEnabled = value;

View File

@ -14,8 +14,8 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef SYNHIGHLIGTERBASE_H
#define SYNHIGHLIGTERBASE_H
#ifndef QSYNEDIT_SYNTAXER_H
#define QSYNEDIT_SYNTAXER_H
#include <QColor>
#include <QObject>
@ -115,9 +115,9 @@ private:
typedef std::shared_ptr<TokenAttribute> PTokenAttribute;
class Highlighter {
class Syntaxer {
public:
explicit Highlighter();
explicit Syntaxer();
const QMap<QString, PTokenAttribute>& attributes() const;
@ -183,8 +183,7 @@ private:
QSet<QChar> mWordBreakChars;
};
using PHighlighter = std::shared_ptr<Highlighter>;
using HighlighterList = QVector<PHighlighter>;
using PSyntaxer = std::shared_ptr<Syntaxer>;
using SyntaxerList = QVector<PSyntaxer>;
}
#endif // SYNHIGHLIGTERBASE_H