From d946b9373e2cc9240504f074a8cab4d5ab1874b2 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 27 Sep 2022 14:01:38 +0800 Subject: [PATCH] refactor: clean up QSynedit --- RedPandaIDE/HighlighterManager.cpp | 48 +- RedPandaIDE/HighlighterManager.h | 12 +- RedPandaIDE/cpprefacter.cpp | 2 +- RedPandaIDE/editor.cpp | 238 ++--- RedPandaIDE/editor.h | 10 +- RedPandaIDE/parser/cppparser.cpp | 2 +- RedPandaIDE/parser/parserutils.h | 1 + RedPandaIDE/settings.cpp | 12 +- RedPandaIDE/settings.h | 12 +- .../settingsdialog/editorgeneralwidget.cpp | 8 +- RedPandaIDE/todoparser.cpp | 6 +- RedPandaIDE/widgets/filepropertiesdialog.cpp | 2 +- RedPandaIDE/widgets/searchdialog.cpp | 24 +- RedPandaIDE/widgets/searchdialog.h | 8 +- RedPandaIDE/widgets/searchresultview.cpp | 2 +- RedPandaIDE/widgets/searchresultview.h | 4 +- libs/qsynedit/qsynedit/CodeFolding.cpp | 47 +- libs/qsynedit/qsynedit/CodeFolding.h | 64 +- libs/qsynedit/qsynedit/Constants.cpp | 11 +- libs/qsynedit/qsynedit/Constants.h | 11 +- libs/qsynedit/qsynedit/KeyStrokes.cpp | 166 ++-- libs/qsynedit/qsynedit/KeyStrokes.h | 34 +- libs/qsynedit/qsynedit/MiscClasses.cpp | 90 +- libs/qsynedit/qsynedit/MiscClasses.h | 14 +- libs/qsynedit/qsynedit/MiscProcs.cpp | 24 +- libs/qsynedit/qsynedit/MiscProcs.h | 8 +- libs/qsynedit/qsynedit/Search.cpp | 14 +- libs/qsynedit/qsynedit/Search.h | 4 +- libs/qsynedit/qsynedit/SearchBase.cpp | 10 +- libs/qsynedit/qsynedit/SearchBase.h | 18 +- libs/qsynedit/qsynedit/SearchRegex.cpp | 24 +- libs/qsynedit/qsynedit/SearchRegex.h | 6 +- libs/qsynedit/qsynedit/SynEdit.cpp | 843 +++++++++--------- libs/qsynedit/qsynedit/SynEdit.h | 251 +++--- libs/qsynedit/qsynedit/TextBuffer.cpp | 18 +- libs/qsynedit/qsynedit/TextBuffer.h | 18 +- libs/qsynedit/qsynedit/TextPainter.cpp | 100 +-- libs/qsynedit/qsynedit/TextPainter.h | 8 +- libs/qsynedit/qsynedit/Types.h | 20 +- .../qsynedit/exporter/synexporter.cpp | 12 +- libs/qsynedit/qsynedit/exporter/synexporter.h | 20 +- .../qsynedit/exporter/synhtmlexporter.cpp | 26 +- .../qsynedit/exporter/synhtmlexporter.h | 20 +- .../qsynedit/exporter/synrtfexporter.cpp | 22 +- .../qsynedit/exporter/synrtfexporter.h | 6 +- libs/qsynedit/qsynedit/highlighter/asm.cpp | 182 ++-- libs/qsynedit/qsynedit/highlighter/asm.h | 26 +- libs/qsynedit/qsynedit/highlighter/base.cpp | 78 +- libs/qsynedit/qsynedit/highlighter/base.h | 82 +- .../qsynedit/highlighter/composition.cpp | 40 +- .../qsynedit/highlighter/composition.h | 32 +- libs/qsynedit/qsynedit/highlighter/cpp.cpp | 590 ++++++------ libs/qsynedit/qsynedit/highlighter/cpp.h | 86 +- libs/qsynedit/qsynedit/highlighter/glsl.cpp | 572 ++++++------ libs/qsynedit/qsynedit/highlighter/glsl.h | 86 +- 55 files changed, 2013 insertions(+), 2061 deletions(-) diff --git a/RedPandaIDE/HighlighterManager.cpp b/RedPandaIDE/HighlighterManager.cpp index 7ee79a71..73ab5e5d 100644 --- a/RedPandaIDE/HighlighterManager.cpp +++ b/RedPandaIDE/HighlighterManager.cpp @@ -30,7 +30,7 @@ HighlighterManager::HighlighterManager() } -QSynedit::PSynHighlighter HighlighterManager::getHighlighter(const QString &filename) +QSynedit::PHighlighter HighlighterManager::getHighlighter(const QString &filename) { QFileInfo info(filename); QString suffix = info.suffix(); @@ -43,13 +43,13 @@ QSynedit::PSynHighlighter HighlighterManager::getHighlighter(const QString &file } else if (suffix == "vs" || suffix == "fs" || suffix == "frag") { return getGLSLHighlighter(); } - return QSynedit::PSynHighlighter(); + return QSynedit::PHighlighter(); } -QSynedit::PSynHighlighter HighlighterManager::copyHighlighter(QSynedit::PSynHighlighter highlighter) +QSynedit::PHighlighter HighlighterManager::copyHighlighter(QSynedit::PHighlighter highlighter) { if (!highlighter) - return QSynedit::PSynHighlighter(); + return QSynedit::PHighlighter(); if (highlighter->getName() == SYN_HIGHLIGHTER_CPP) return getCppHighlighter(); else if (highlighter->getName() == SYN_HIGHLIGHTER_ASM) @@ -57,16 +57,16 @@ QSynedit::PSynHighlighter HighlighterManager::copyHighlighter(QSynedit::PSynHigh else if (highlighter->getName() == SYN_HIGHLIGHTER_GLSL) return getGLSLHighlighter(); //todo - return QSynedit::PSynHighlighter(); + return QSynedit::PHighlighter(); } -QSynedit::PSynHighlighter HighlighterManager::getCppHighlighter() +QSynedit::PHighlighter HighlighterManager::getCppHighlighter() { - QSynedit::SynEditCppHighlighter* highlighter = new QSynedit::SynEditCppHighlighter(); + QSynedit::CppHighlighter* highlighter = new QSynedit::CppHighlighter(); highlighter->asmAttribute()->setForeground(Qt::blue); highlighter->charAttribute()->setForeground(Qt::black); highlighter->commentAttribute()->setForeground(0x8C8C8C); - highlighter->commentAttribute()->setStyles(QSynedit::SynFontStyle::fsItalic); + highlighter->commentAttribute()->setStyles(QSynedit::FontStyle::fsItalic); highlighter->classAttribute()->setForeground(0x008080); highlighter->floatAttribute()->setForeground(Qt::darkMagenta); highlighter->functionAttribute()->setForeground(0x00627A); @@ -84,16 +84,16 @@ QSynedit::PSynHighlighter HighlighterManager::getCppHighlighter() highlighter->stringEscapeSequenceAttribute()->setForeground(Qt::red); highlighter->symbolAttribute()->setForeground(0xc10000); highlighter->variableAttribute()->setForeground(0x400080); - QSynedit::PSynHighlighter pHighlighter=std::make_shared(); + QSynedit::PHighlighter pHighlighter=std::make_shared(); return pHighlighter; } -QSynedit::PSynHighlighter HighlighterManager::getAsmHighlighter() +QSynedit::PHighlighter HighlighterManager::getAsmHighlighter() { - QSynedit::SynEditASMHighlighter* highlighter = new QSynedit::SynEditASMHighlighter(); - QSynedit::PSynHighlighter pHighlighter(highlighter); + QSynedit::ASMHighlighter* highlighter = new QSynedit::ASMHighlighter(); + QSynedit::PHighlighter pHighlighter(highlighter); highlighter->commentAttribute()->setForeground(0x8C8C8C); - highlighter->commentAttribute()->setStyles(QSynedit::SynFontStyle::fsItalic); + highlighter->commentAttribute()->setStyles(QSynedit::FontStyle::fsItalic); highlighter->identifierAttribute()->setForeground(0x080808); highlighter->keywordAttribute()->setForeground(0x0033b3); highlighter->numberAttribute()->setForeground(0x1750EB); @@ -103,14 +103,14 @@ QSynedit::PSynHighlighter HighlighterManager::getAsmHighlighter() return pHighlighter; } -QSynedit::PSynHighlighter HighlighterManager::getGLSLHighlighter() +QSynedit::PHighlighter HighlighterManager::getGLSLHighlighter() { - QSynedit::SynEditGLSLHighlighter* highlighter = new QSynedit::SynEditGLSLHighlighter(); - QSynedit::PSynHighlighter pHighlighter(highlighter); + QSynedit::GLSLHighlighter* highlighter = new QSynedit::GLSLHighlighter(); + QSynedit::PHighlighter pHighlighter(highlighter); highlighter->asmAttribute()->setForeground(Qt::blue); highlighter->charAttribute()->setForeground(Qt::black); highlighter->commentAttribute()->setForeground(0x8C8C8C); - highlighter->commentAttribute()->setStyles(QSynedit::SynFontStyle::fsItalic); + highlighter->commentAttribute()->setStyles(QSynedit::FontStyle::fsItalic); highlighter->classAttribute()->setForeground(0x008080); highlighter->floatAttribute()->setForeground(Qt::darkMagenta); highlighter->functionAttribute()->setForeground(0x00627A); @@ -131,7 +131,7 @@ QSynedit::PSynHighlighter HighlighterManager::getGLSLHighlighter() return pHighlighter; } -void HighlighterManager::applyColorScheme(QSynedit::PSynHighlighter highlighter, const QString &schemeName) +void HighlighterManager::applyColorScheme(QSynedit::PHighlighter highlighter, const QString &schemeName) { if (!highlighter) return; @@ -141,14 +141,14 @@ void HighlighterManager::applyColorScheme(QSynedit::PSynHighlighter highlighter, for (QString name: highlighter->attributes().keys()) { PColorSchemeItem item = pColorManager->getItem(schemeName,name); if (item) { - QSynedit::PSynHighlighterAttribute attr = highlighter->attributes()[name]; + QSynedit::PHighlighterAttribute attr = highlighter->attributes()[name]; attr->setBackground(item->background()); attr->setForeground(item->foreground()); - QSynedit::SynFontStyles styles = QSynedit::SynFontStyle::fsNone; - styles.setFlag(QSynedit::SynFontStyle::fsBold, item->bold()); - styles.setFlag(QSynedit::SynFontStyle::fsItalic, item->italic()); - styles.setFlag(QSynedit::SynFontStyle::fsUnderline, item->underlined()); - styles.setFlag(QSynedit::SynFontStyle::fsStrikeOut, item->strikeout()); + QSynedit::FontStyles styles = QSynedit::FontStyle::fsNone; + styles.setFlag(QSynedit::FontStyle::fsBold, item->bold()); + styles.setFlag(QSynedit::FontStyle::fsItalic, item->italic()); + styles.setFlag(QSynedit::FontStyle::fsUnderline, item->underlined()); + styles.setFlag(QSynedit::FontStyle::fsStrikeOut, item->strikeout()); attr->setStyles(styles); } } diff --git a/RedPandaIDE/HighlighterManager.h b/RedPandaIDE/HighlighterManager.h index 9f353130..160a9500 100644 --- a/RedPandaIDE/HighlighterManager.h +++ b/RedPandaIDE/HighlighterManager.h @@ -23,12 +23,12 @@ class HighlighterManager public: HighlighterManager(); - QSynedit::PSynHighlighter getHighlighter(const QString& filename); - QSynedit::PSynHighlighter copyHighlighter(QSynedit::PSynHighlighter highlighter); - QSynedit::PSynHighlighter getCppHighlighter(); - QSynedit::PSynHighlighter getAsmHighlighter(); - QSynedit::PSynHighlighter getGLSLHighlighter(); - void applyColorScheme(QSynedit::PSynHighlighter highlighter, const QString& schemeName); + QSynedit::PHighlighter getHighlighter(const QString& filename); + QSynedit::PHighlighter copyHighlighter(QSynedit::PHighlighter highlighter); + QSynedit::PHighlighter getCppHighlighter(); + QSynedit::PHighlighter getAsmHighlighter(); + QSynedit::PHighlighter getGLSLHighlighter(); + void applyColorScheme(QSynedit::PHighlighter highlighter, const QString& schemeName); }; extern HighlighterManager highlighterManager; diff --git a/RedPandaIDE/cpprefacter.cpp b/RedPandaIDE/cpprefacter.cpp index 2185fc77..281ba875 100644 --- a/RedPandaIDE/cpprefacter.cpp +++ b/RedPandaIDE/cpprefacter.cpp @@ -226,7 +226,7 @@ PSearchResultTreeItem CppRefacter::findOccurenceInFile( while (!editor.highlighter()->eol()) { int start = editor.highlighter()->getTokenPos() + 1; QString token = editor.highlighter()->getToken(); - QSynedit::PSynHighlighterAttribute attr = editor.highlighter()->getTokenAttribute(); + QSynedit::PHighlighterAttribute attr = editor.highlighter()->getTokenAttribute(); if (!attr || attr!=editor.highlighter()->commentAttribute()) { if (token == statement->command) { //same name symbol , test if the same statement; diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 0def8d35..ea036c2e 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -103,7 +103,7 @@ Editor::Editor(QWidget *parent, const QString& filename, mFilename = tr("untitled")+QString("%1").arg(getNewFileNumber()); } QFileInfo fileInfo(mFilename); - QSynedit::PSynHighlighter highlighter; + QSynedit::PHighlighter highlighter; if (!isNew) { loadFile(); highlighter = highlighterManager.getHighlighter(mFilename); @@ -148,7 +148,7 @@ Editor::Editor(QWidget *parent, const QString& filename, connect(this,&SynEdit::statusChanged,this,&Editor::onStatusChanged); connect(this,&SynEdit::gutterClicked,this,&Editor::onGutterClicked); - onStatusChanged(QSynedit::SynStatusChange::scOpenFile); + onStatusChanged(QSynedit::StatusChange::scOpenFile); setAttribute(Qt::WA_Hover,true); @@ -375,7 +375,7 @@ bool Editor::saveAs(const QString &name, bool fromProject){ } //update (reassign highlighter) - QSynedit::PSynHighlighter newHighlighter = HighlighterManager().getHighlighter(mFilename); + QSynedit::PHighlighter newHighlighter = HighlighterManager().getHighlighter(mFilename); if (newHighlighter) { setUseCodeFolding(true); } else { @@ -474,10 +474,10 @@ void Editor::setPageControl(QTabWidget *newPageControl) void Editor::undoSymbolCompletion(int pos) { - QSynedit::PSynHighlighterAttribute Attr; + QSynedit::PHighlighterAttribute Attr; QString Token; bool tokenFinished; - QSynedit::SynHighlighterTokenType tokenType; + QSynedit::TokenType tokenType; if (!highlighter()) return; @@ -485,7 +485,7 @@ void Editor::undoSymbolCompletion(int pos) return; if (!getHighlighterAttriAtRowCol(caretXY(), Token, tokenFinished, tokenType, Attr)) return; - if ((tokenType == QSynedit::SynHighlighterTokenType::Comment) && (!tokenFinished)) + if ((tokenType == QSynedit::TokenType::Comment) && (!tokenFinished)) return ; //convert caret x to string index; pos--; @@ -494,11 +494,11 @@ void Editor::undoSymbolCompletion(int pos) return; QChar DeletedChar = lineText().at(pos); QChar NextChar = lineText().at(pos+1); - if ((tokenType == QSynedit::SynHighlighterTokenType::Character) && (DeletedChar != '\'')) + if ((tokenType == QSynedit::TokenType::Character) && (DeletedChar != '\'')) return; - if (tokenType == QSynedit::SynHighlighterTokenType::StringEscapeSequence) + if (tokenType == QSynedit::TokenType::StringEscapeSequence) return; - if (tokenType == QSynedit::SynHighlighterTokenType::String) { + if (tokenType == QSynedit::TokenType::String) { if ((DeletedChar!='"') && (DeletedChar!='(')) return; if ((DeletedChar=='"') && (Token!="\"\"")) @@ -506,7 +506,7 @@ void Editor::undoSymbolCompletion(int pos) if ((DeletedChar=='(') && (!Token.startsWith("R\""))) return; } - if ((DeletedChar == '\'') && (tokenType == QSynedit::SynHighlighterTokenType::Number)) + if ((DeletedChar == '\'') && (tokenType == QSynedit::TokenType::Number)) return; if ((DeletedChar == '<') && !(mParser && mParser->isIncludeLine(lineText()))) @@ -517,7 +517,7 @@ void Editor::undoSymbolCompletion(int pos) (pSettings->editor().completeBrace() && (DeletedChar == '{') && (NextChar == '}')) || (pSettings->editor().completeSingleQuote() && (DeletedChar == '\'') && (NextChar == '\'')) || (pSettings->editor().completeDoubleQuote() && (DeletedChar == '\"') && (NextChar == '\"'))) { - commandProcessor(QSynedit::SynEditorCommand::ecDeleteChar); + commandProcessor(QSynedit::EditCommand::ecDeleteChar); } } @@ -716,7 +716,7 @@ void Editor::keyPressEvent(QKeyEvent *event) if (t.isEmpty()) return; - if (activeSelectionMode()==QSynedit::SynSelectionMode::Column) + if (activeSelectionMode()==QSynedit::SelectionMode::Column) return; QChar ch = t[0]; @@ -865,12 +865,12 @@ void Editor::onGutterPaint(QPainter &painter, int aLine, int X, int Y) } } -void Editor::onGetEditingAreas(int Line, QSynedit::SynEditingAreaList &areaList) +void Editor::onGetEditingAreas(int Line, QSynedit::EditingAreaList &areaList) { areaList.clear(); if (mTabStopBegin>=0 && mTabStopY == Line) { - QSynedit::PSynEditingArea p = make_shared(); - p->type = QSynedit::SynEditingAreaType::eatRectangleBorder; + QSynedit::PEditingArea p = make_shared(); + p->type = QSynedit::EditingAreaType::eatRectangleBorder; // int spaceCount = leftSpaces(mLineBeforeTabStop); // int spaceBefore = mLineBeforeTabStop.length()-TrimLeft(mLineBeforeTabStop).length(); p->beginX = mTabStopBegin; @@ -881,7 +881,7 @@ void Editor::onGetEditingAreas(int Line, QSynedit::SynEditingAreaList &areaList) PSyntaxIssueList lst = getSyntaxIssuesAtLine(Line); if (lst) { for (const PSyntaxIssue& issue: *lst) { - QSynedit::PSynEditingArea p=std::make_shared(); + QSynedit::PEditingArea p=std::make_shared(); p->beginX = issue->col; p->endX = issue->endCol; if (issue->issueType == CompileIssueType::Error) { @@ -889,7 +889,7 @@ void Editor::onGetEditingAreas(int Line, QSynedit::SynEditingAreaList &areaList) } else { p->color = mSyntaxWarningColor; } - p->type = QSynedit::SynEditingAreaType::eatWaveUnderLine; + p->type = QSynedit::EditingAreaType::eatWaveUnderLine; areaList.append(p); } } @@ -919,7 +919,7 @@ bool Editor::onGetSpecialLineColors(int Line, QColor &foreground, QColor &backgr return false; } -void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &token, QSynedit::PSynHighlighterAttribute attr, QSynedit::SynFontStyles &style, QColor &foreground, QColor &background) +void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &token, QSynedit::PHighlighterAttribute attr, QSynedit::FontStyles &style, QColor &foreground, QColor &background) { if (token.isEmpty()) return; @@ -936,7 +936,7 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to pos1++; pos2++; if (pos1>0 && pos2>0 && pos1foreground(); //background = item->background(); - style.setFlag(QSynedit::SynFontStyle::fsBold,item->bold()); - style.setFlag(QSynedit::SynFontStyle::fsItalic,item->italic()); - style.setFlag(QSynedit::SynFontStyle::fsUnderline,item->underlined()); - style.setFlag(QSynedit::SynFontStyle::fsStrikeOut,item->strikeout()); + style.setFlag(QSynedit::FontStyle::fsBold,item->bold()); + style.setFlag(QSynedit::FontStyle::fsItalic,item->italic()); + style.setFlag(QSynedit::FontStyle::fsUnderline,item->underlined()); + style.setFlag(QSynedit::FontStyle::fsStrikeOut,item->strikeout()); } else { foreground = highlighter()->identifierAttribute()->foreground(); } @@ -982,7 +982,7 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to QSynedit::BufferCoord p; if (pointToCharLine(mapFromGlobal(QCursor::pos()),p)) { if (line==p.line && (aChar<=p.ch && p.cheditor().copyHTMLUseBackground()); exporter.setFont(font()); - QSynedit::PSynHighlighter hl = highlighter(); + QSynedit::PHighlighter hl = highlighter(); if (!pSettings->editor().copyHTMLUseEditorColor()) { hl = highlighterManager.copyHighlighter(highlighter()); highlighterManager.applyColorScheme(hl,pSettings->editor().copyHTMLColorScheme()); @@ -1426,9 +1426,9 @@ void Editor::addSyntaxIssues(int line, int startChar, int endChar, CompileIssueT PSyntaxIssue pError; QSynedit::BufferCoord p; QString token; - QSynedit::SynHighlighterTokenType tokenType; + QSynedit::TokenType tokenType; int tokenKind,start; - QSynedit::PSynHighlighterAttribute attr; + QSynedit::PHighlighterAttribute attr; PSyntaxIssueList lst; if ((line<1) || (line>document()->count())) return; @@ -1537,18 +1537,18 @@ Editor::PSyntaxIssue Editor::getSyntaxIssueAtPosition(const QSynedit::BufferCoor return PSyntaxIssue(); } -void Editor::onStatusChanged(QSynedit::SynStatusChanges changes) +void Editor::onStatusChanged(QSynedit::StatusChanges changes) { - if ((!changes.testFlag(QSynedit::SynStatusChange::scReadOnly) - && !changes.testFlag(QSynedit::SynStatusChange::scInsertMode) + if ((!changes.testFlag(QSynedit::StatusChange::scReadOnly) + && !changes.testFlag(QSynedit::StatusChange::scInsertMode) && (document()->count()!=mLineCount) && (document()->count()!=0) && ((mLineCount>0) || (document()->count()>1))) || (mCurrentLineModified - && !changes.testFlag(QSynedit::SynStatusChange::scReadOnly) - && changes.testFlag(QSynedit::SynStatusChange::scCaretY))) { + && !changes.testFlag(QSynedit::StatusChange::scReadOnly) + && changes.testFlag(QSynedit::StatusChange::scCaretY))) { mCurrentLineModified = false; - if (!changes.testFlag(QSynedit::SynStatusChange::scOpenFile)) + if (!changes.testFlag(QSynedit::StatusChange::scOpenFile)) reparse(); // if (pSettings->codeCompletion().clearWhenEditorHidden() // && changes.testFlag(SynStatusChange::scOpenFile)) { @@ -1569,8 +1569,8 @@ void Editor::onStatusChanged(QSynedit::SynStatusChanges changes) mCanAutoSave = true; } - if (changes.testFlag(QSynedit::SynStatusChange::scCaretX) - || changes.testFlag(QSynedit::SynStatusChange::scCaretY)) { + if (changes.testFlag(QSynedit::StatusChange::scCaretX) + || changes.testFlag(QSynedit::StatusChange::scCaretY)) { if (mTabStopBegin >=0) { if (mTabStopY==caretY()) { if (mLineAfterTabStop.isEmpty()) { @@ -1615,7 +1615,7 @@ void Editor::onStatusChanged(QSynedit::SynStatusChanges changes) coord.ch = ch+1; coord.line = caretY(); } - QSynedit::PSynHighlighterAttribute attr; + QSynedit::PHighlighterAttribute attr; QString token; if (getHighlighterAttriAtRowCol(coord,token,attr) && attr == highlighter()->symbolAttribute()) { @@ -1633,7 +1633,7 @@ void Editor::onStatusChanged(QSynedit::SynStatusChanges changes) } // scSelection includes anything caret related - if (changes.testFlag(QSynedit::SynStatusChange::scSelection)) { + if (changes.testFlag(QSynedit::StatusChange::scSelection)) { if (!selAvail() && pSettings->editor().highlightCurrentWord()) { mCurrentHighlightedWord = wordAtCursor(); } else if (selAvail() && blockBegin() == wordStart() @@ -1665,7 +1665,7 @@ void Editor::onStatusChanged(QSynedit::SynStatusChanges changes) pMainWindow->updateEditorActions(); - if (changes.testFlag(QSynedit::SynStatusChange::scCaretY) && mParentPageControl) { + if (changes.testFlag(QSynedit::StatusChange::scCaretY) && mParentPageControl) { pMainWindow->caretList().addCaret(this,caretY(),caretX()); pMainWindow->updateCaretActions(); } @@ -1766,42 +1766,42 @@ bool Editor::notParsed() void Editor::insertLine() { - ExecuteCommand(QSynedit::SynEditorCommand::ecInsertLine,QChar(),nullptr); + ExecuteCommand(QSynedit::EditCommand::ecInsertLine,QChar(),nullptr); } void Editor::deleteWord() { - ExecuteCommand(QSynedit::SynEditorCommand::ecDeleteWord,QChar(),nullptr); + ExecuteCommand(QSynedit::EditCommand::ecDeleteWord,QChar(),nullptr); } void Editor::deleteToWordStart() { - ExecuteCommand(QSynedit::SynEditorCommand::ecDeleteWordStart,QChar(),nullptr); + ExecuteCommand(QSynedit::EditCommand::ecDeleteWordStart,QChar(),nullptr); } void Editor::deleteToWordEnd() { - ExecuteCommand(QSynedit::SynEditorCommand::ecDeleteWordEnd,QChar(),nullptr); + ExecuteCommand(QSynedit::EditCommand::ecDeleteWordEnd,QChar(),nullptr); } void Editor::deleteLine() { - ExecuteCommand(QSynedit::SynEditorCommand::ecDeleteLine,QChar(),nullptr); + ExecuteCommand(QSynedit::EditCommand::ecDeleteLine,QChar(),nullptr); } void Editor::duplicateLine() { - ExecuteCommand(QSynedit::SynEditorCommand::ecDuplicateLine,QChar(),nullptr); + ExecuteCommand(QSynedit::EditCommand::ecDuplicateLine,QChar(),nullptr); } void Editor::deleteToEOL() { - ExecuteCommand(QSynedit::SynEditorCommand::ecDeleteEOL,QChar(),nullptr); + ExecuteCommand(QSynedit::EditCommand::ecDeleteEOL,QChar(),nullptr); } void Editor::deleteToBOL() { - ExecuteCommand(QSynedit::SynEditorCommand::ecDeleteBOL,QChar(),nullptr); + ExecuteCommand(QSynedit::EditCommand::ecDeleteBOL,QChar(),nullptr); } QStringList Editor::getOwnerExpressionAndMemberAtPositionForCompletion( @@ -1823,7 +1823,7 @@ QStringList Editor::getExpressionAtPosition( int ch = pos.ch-1; int symbolMatchingLevel = 0; LastSymbolType lastSymbolType=LastSymbolType::None; - QSynedit::PSynHighlighter highlighter; + QSynedit::PHighlighter highlighter; if (isNew()) highlighter = highlighterManager.getCppHighlighter(); else @@ -1848,7 +1848,7 @@ QStringList Editor::getExpressionAtPosition( if (start>ch) { break; } - QSynedit::PSynHighlighterAttribute attr = highlighter->getTokenAttribute(); + QSynedit::PHighlighterAttribute attr = highlighter->getTokenAttribute(); if ( (line == pos.line-1) && (start<=ch) && (ch<=endPos)) { if (attr==highlighter->commentAttribute() || attr == highlighter->stringAttribute()) { @@ -2088,14 +2088,14 @@ bool Editor::handleSymbolCompletion(QChar key) } else { QSynedit::BufferCoord HighlightPos = QSynedit::BufferCoord{caretX()-1, caretY()}; // Check if that line is highlighted as comment - QSynedit::PSynHighlighterAttribute Attr; + QSynedit::PHighlighterAttribute Attr; QString Token; bool tokenFinished; - QSynedit::SynHighlighterTokenType tokenType; + QSynedit::TokenType tokenType; if (getHighlighterAttriAtRowCol(HighlightPos, Token, tokenFinished, tokenType,Attr)) { - if ((tokenType == QSynedit::SynHighlighterTokenType::Comment) && (!tokenFinished)) + if ((tokenType == QSynedit::TokenType::Comment) && (!tokenFinished)) return false; - if ((tokenType == QSynedit::SynHighlighterTokenType::String) && (!tokenFinished) + if ((tokenType == QSynedit::TokenType::String) && (!tokenFinished) && (key!='\'') && (key!='\"') && (key!='(') && (key!=')')) return false; if (( key=='<' || key =='>') && (mParser && !mParser->isIncludeLine(lineText()))) @@ -2191,17 +2191,17 @@ bool Editor::handleParentheseCompletion() QString text=selText(); beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::SynEditorCommand::ecChar,'('); + commandProcessor(QSynedit::EditCommand::ecChar,'('); setSelText(text); - commandProcessor(QSynedit::SynEditorCommand::ecChar,')'); + commandProcessor(QSynedit::EditCommand::ecChar,')'); endUndoBlock(); endUpdate(); } else { beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::SynEditorCommand::ecChar,'('); + commandProcessor(QSynedit::EditCommand::ecChar,'('); QSynedit::BufferCoord oldCaret = caretXY(); - commandProcessor(QSynedit::SynEditorCommand::ecChar,')'); + commandProcessor(QSynedit::EditCommand::ecChar,')'); setCaretXY(oldCaret); endUndoBlock(); endUpdate(); @@ -2228,7 +2228,7 @@ bool Editor::handleParentheseSkip() if (document()->count()==0) return false; if (highlighter()) { - QSynedit::SynRangeState lastLineState = document()->ranges(document()->count()-1); + QSynedit::HighlighterState lastLineState = document()->ranges(document()->count()-1); if (lastLineState.parenthesisLevel==0) { setCaretXY( QSynedit::BufferCoord{caretX() + 1, caretY()}); // skip over return true; @@ -2252,17 +2252,17 @@ bool Editor::handleBracketCompletion() QString text=selText(); beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::SynEditorCommand::ecChar,'['); + commandProcessor(QSynedit::EditCommand::ecChar,'['); setSelText(text); - commandProcessor(QSynedit::SynEditorCommand::ecChar,']'); + commandProcessor(QSynedit::EditCommand::ecChar,']'); endUndoBlock(); endUpdate(); } else { beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::SynEditorCommand::ecChar,'['); + commandProcessor(QSynedit::EditCommand::ecChar,'['); QSynedit::BufferCoord oldCaret = caretXY(); - commandProcessor(QSynedit::SynEditorCommand::ecChar,']'); + commandProcessor(QSynedit::EditCommand::ecChar,']'); setCaretXY(oldCaret); endUndoBlock(); endUpdate(); @@ -2279,7 +2279,7 @@ bool Editor::handleBracketSkip() if (document()->count()==0) return false; if (highlighter()) { - QSynedit::SynRangeState lastLineState = document()->ranges(document()->count()-1); + QSynedit::HighlighterState lastLineState = document()->ranges(document()->count()-1); if (lastLineState.bracketLevel==0) { setCaretXY( QSynedit::BufferCoord{caretX() + 1, caretY()}); // skip over return true; @@ -2300,14 +2300,14 @@ bool Editor::handleMultilineCommentCompletion() QString text=selText(); beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::SynEditorCommand::ecChar,'*'); + commandProcessor(QSynedit::EditCommand::ecChar,'*'); QSynedit::BufferCoord oldCaret; if (text.isEmpty()) oldCaret = caretXY(); else setSelText(text); - commandProcessor(QSynedit::SynEditorCommand::ecChar,'*'); - commandProcessor(QSynedit::SynEditorCommand::ecChar,'/'); + commandProcessor(QSynedit::EditCommand::ecChar,'*'); + commandProcessor(QSynedit::EditCommand::ecChar,'/'); if (text.isEmpty()) setCaretXY(oldCaret); endUndoBlock(); @@ -2328,16 +2328,16 @@ bool Editor::handleBraceCompletion() QString text=selText(); beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::SynEditorCommand::ecChar,'{'); + commandProcessor(QSynedit::EditCommand::ecChar,'{'); QSynedit::BufferCoord oldCaret; if (text.isEmpty()) { oldCaret = caretXY(); } else { - commandProcessor(QSynedit::SynEditorCommand::ecInsertLine); + commandProcessor(QSynedit::EditCommand::ecInsertLine); setSelText(text); - commandProcessor(QSynedit::SynEditorCommand::ecInsertLine); + commandProcessor(QSynedit::EditCommand::ecInsertLine); } - commandProcessor(QSynedit::SynEditorCommand::ecChar,'}'); + commandProcessor(QSynedit::EditCommand::ecChar,'}'); if ( ( (s.startsWith("struct") || s.startsWith("class") @@ -2348,7 +2348,7 @@ bool Editor::handleBraceCompletion() || s.startsWith("enum") ) && !s.contains(';') ) || s.endsWith('=')) { - commandProcessor(QSynedit::SynEditorCommand::ecChar,';'); + commandProcessor(QSynedit::EditCommand::ecChar,';'); } if (text.isEmpty()) setCaretXY(oldCaret); @@ -2365,11 +2365,11 @@ bool Editor::handleBraceSkip() if (document()->count()==0) return false; if (highlighter()) { - QSynedit::SynRangeState lastLineState = document()->ranges(document()->count()-1); + QSynedit::HighlighterState lastLineState = document()->ranges(document()->count()-1); if (lastLineState.braceLevel==0) { bool oldInsertMode = insertMode(); setInsertMode(false); //set mode to overwrite - commandProcessor(QSynedit::SynEditorCommand::ecChar,'}'); + commandProcessor(QSynedit::EditCommand::ecChar,'}'); setInsertMode(oldInsertMode); return true; } @@ -2378,7 +2378,7 @@ bool Editor::handleBraceSkip() if (pos.line != 0) { bool oldInsertMode = insertMode(); setInsertMode(false); //set mode to overwrite - commandProcessor(QSynedit::SynEditorCommand::ecChar,'}'); + commandProcessor(QSynedit::EditCommand::ecChar,'}'); setInsertMode(oldInsertMode); return true; } @@ -2401,9 +2401,9 @@ bool Editor::handleSingleQuoteCompletion() QString text=selText(); beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::SynEditorCommand::ecChar,'\''); + commandProcessor(QSynedit::EditCommand::ecChar,'\''); setSelText(text); - commandProcessor(QSynedit::SynEditorCommand::ecChar,'\''); + commandProcessor(QSynedit::EditCommand::ecChar,'\''); endUndoBlock(); endUpdate(); return true; @@ -2412,9 +2412,9 @@ bool Editor::handleSingleQuoteCompletion() // insert '' beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::SynEditorCommand::ecChar,'\''); + commandProcessor(QSynedit::EditCommand::ecChar,'\''); QSynedit::BufferCoord oldCaret = caretXY(); - commandProcessor(QSynedit::SynEditorCommand::ecChar,'\''); + commandProcessor(QSynedit::EditCommand::ecChar,'\''); setCaretXY(oldCaret); endUndoBlock(); endUpdate(); @@ -2441,9 +2441,9 @@ bool Editor::handleDoubleQuoteCompletion() QString text=selText(); beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::SynEditorCommand::ecChar,'"'); + commandProcessor(QSynedit::EditCommand::ecChar,'"'); setSelText(text); - commandProcessor(QSynedit::SynEditorCommand::ecChar,'"'); + commandProcessor(QSynedit::EditCommand::ecChar,'"'); endUndoBlock(); endUpdate(); return true; @@ -2452,9 +2452,9 @@ bool Editor::handleDoubleQuoteCompletion() // insert "" beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::SynEditorCommand::ecChar,'"'); + commandProcessor(QSynedit::EditCommand::ecChar,'"'); QSynedit::BufferCoord oldCaret = caretXY(); - commandProcessor(QSynedit::SynEditorCommand::ecChar,'"'); + commandProcessor(QSynedit::EditCommand::ecChar,'"'); setCaretXY(oldCaret); endUndoBlock(); endUpdate(); @@ -2474,9 +2474,9 @@ bool Editor::handleGlobalIncludeCompletion() return false; beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::SynEditorCommand::ecChar,'<'); + commandProcessor(QSynedit::EditCommand::ecChar,'<'); QSynedit::BufferCoord oldCaret = caretXY(); - commandProcessor(QSynedit::SynEditorCommand::ecChar,'>'); + commandProcessor(QSynedit::EditCommand::ecChar,'>'); setCaretXY(oldCaret); endUpdate(); endUndoBlock(); @@ -2515,7 +2515,7 @@ bool Editor::handleCodeCompletion(QChar key) showCompletion("",false); return true; case ':': - ExecuteCommand(QSynedit::SynEditorCommand::ecChar,':',nullptr); + ExecuteCommand(QSynedit::EditCommand::ecChar,':',nullptr); //setSelText(key); if ((caretX() > 2) && (lineText().length() >= 2) && (lineText()[caretX() - 3] == ':')) @@ -2550,7 +2550,7 @@ void Editor::initParser() resetCppParser(mParser); mParser->setEnabled( pSettings->codeCompletion().enabled() && - (highlighter() && highlighter()->getClass() == QSynedit::SynHighlighterClass::CppHighlighter)); + (highlighter() && highlighter()->getClass() == QSynedit::HighlighterClass::CppHighlighter)); } Editor::QuoteStatus Editor::getQuoteStatus() @@ -2678,8 +2678,8 @@ void Editor::reparse() { if (!highlighter()) return; - if (highlighter()->language() != QSynedit::SynHighlighterLanguage::Cpp - && highlighter()->language() != QSynedit::SynHighlighterLanguage::GLSL) + if (highlighter()->language() != QSynedit::HighlighterLanguage::Cpp + && highlighter()->language() != QSynedit::HighlighterLanguage::GLSL) return; if (mParser) mParser->setEnabled(pSettings->codeCompletion().enabled()); @@ -2843,7 +2843,7 @@ void Editor::exportAsRTF(const QString &rtfFilename) exporter.setExportAsText(true); exporter.setUseBackground(pSettings->editor().copyRTFUseBackground()); exporter.setFont(font()); - QSynedit::PSynHighlighter hl = highlighter(); + QSynedit::PHighlighter hl = highlighter(); if (!pSettings->editor().copyRTFUseEditorColor()) { hl = highlighterManager.copyHighlighter(highlighter()); highlighterManager.applyColorScheme(hl,pSettings->editor().copyRTFColorScheme()); @@ -2868,7 +2868,7 @@ void Editor::exportAsHTML(const QString &htmlFilename) exporter.setExportAsText(false); exporter.setUseBackground(pSettings->editor().copyHTMLUseBackground()); exporter.setFont(font()); - QSynedit::PSynHighlighter hl = highlighter(); + QSynedit::PHighlighter hl = highlighter(); if (!pSettings->editor().copyHTMLUseEditorColor()) { hl = highlighterManager.copyHighlighter(highlighter()); highlighterManager.applyColorScheme(hl,pSettings->editor().copyHTMLColorScheme()); @@ -2905,28 +2905,28 @@ void Editor::showCompletion(const QString& preWord,bool autoComplete) QString word=""; QString s; - QSynedit::PSynHighlighterAttribute attr; + QSynedit::PHighlighterAttribute attr; bool tokenFinished; - QSynedit::SynHighlighterTokenType tokenType; + QSynedit::TokenType tokenType; QSynedit::BufferCoord pBeginPos, pEndPos; if (getHighlighterAttriAtRowCol( QSynedit::BufferCoord{caretX() - 1, caretY()}, s, tokenFinished,tokenType, attr)) { - if (tokenType == QSynedit::SynHighlighterTokenType::PreprocessDirective) {//Preprocessor + if (tokenType == QSynedit::TokenType::PreprocessDirective) {//Preprocessor word = getWordAtPosition(this,caretXY(),pBeginPos,pEndPos, WordPurpose::wpDirective); if (!word.startsWith('#')) { word = ""; } - } else if (tokenType == QSynedit::SynHighlighterTokenType::Comment) { //Comment, javadoc tag + } else if (tokenType == QSynedit::TokenType::Comment) { //Comment, javadoc tag word = getWordAtPosition(this,caretXY(),pBeginPos,pEndPos, WordPurpose::wpJavadoc); if (!word.startsWith('@')) { return; } } else if ( - (tokenType != QSynedit::SynHighlighterTokenType::Symbol) && - (tokenType != QSynedit::SynHighlighterTokenType::Space) && - (tokenType != QSynedit::SynHighlighterTokenType::Keyword) && - (tokenType != QSynedit::SynHighlighterTokenType::Identifier) + (tokenType != QSynedit::TokenType::Symbol) && + (tokenType != QSynedit::TokenType::Space) && + (tokenType != QSynedit::TokenType::Keyword) && + (tokenType != QSynedit::TokenType::Identifier) ) { return; } @@ -2971,7 +2971,7 @@ void Editor::showCompletion(const QString& preWord,bool autoComplete) QSet keywords; if (highlighter()) { - if (highlighter()->language() != QSynedit::SynHighlighterLanguage::Cpp ) { + if (highlighter()->language() != QSynedit::HighlighterLanguage::Cpp ) { keywords = highlighter()->keywords(); } else if (mUseCppSyntax) { foreach (const QString& keyword, CppKeywords.keys()) { @@ -3256,7 +3256,7 @@ bool Editor::onCompletionKeyPressed(QKeyEvent *event) return true; case Qt::Key_Backspace: ExecuteCommand( - QSynedit::SynEditorCommand::ecDeleteLastChar, + QSynedit::EditCommand::ecDeleteLastChar, QChar(), nullptr); // Simulate backspace in editor if (purpose == WordPurpose::wpCompletion) { phrase = getWordForCompletionSearch(caretXY(), mCompletionPopup->memberOperator()=="::"); @@ -3318,7 +3318,7 @@ bool Editor::onHeaderCompletionKeyPressed(QKeyEvent *event) switch (event->key()) { case Qt::Key_Backspace: ExecuteCommand( - QSynedit::SynEditorCommand::ecDeleteLastChar, + QSynedit::EditCommand::ecDeleteLastChar, QChar(), nullptr); // Simulate backspace in editor phrase = getWordAtPosition(this,caretXY(), pBeginPos,pEndPos, @@ -3389,7 +3389,7 @@ Editor::TipType Editor::getTipType(QPoint point, QSynedit::BufferCoord& pos) return TipType::Error; } - QSynedit::PSynHighlighterAttribute attr; + QSynedit::PHighlighterAttribute attr; QString s; // Only allow hand tips in highlighted areas @@ -3589,7 +3589,7 @@ void Editor::updateFunctionTip(bool showTip) while(!highlighter()->eol()) { int start = highlighter()->getTokenPos(); QString token = highlighter()->getToken(); - QSynedit::PSynHighlighterAttribute attr = highlighter()->getTokenAttribute(); + QSynedit::PHighlighterAttribute attr = highlighter()->getTokenAttribute(); if (start>=currentChar) break; @@ -3798,7 +3798,7 @@ void Editor::popUserCodeInTabStops() } } -void Editor::onExportedFormatToken(QSynedit::PSynHighlighter syntaxHighlighter, int Line, int column, const QString &token, QSynedit::PSynHighlighterAttribute& attr) +void Editor::onExportedFormatToken(QSynedit::PHighlighter syntaxHighlighter, int Line, int column, const QString &token, QSynedit::PHighlighterAttribute& attr) { if (!syntaxHighlighter) return; @@ -3826,7 +3826,7 @@ void Editor::onExportedFormatToken(QSynedit::PSynHighlighter syntaxHighlighter, kind = StatementKind::skVariable; } } - QSynedit::SynEditCppHighlighter* cppHighlighter = dynamic_cast(syntaxHighlighter.get()); + QSynedit::CppHighlighter* cppHighlighter = dynamic_cast(syntaxHighlighter.get()); switch(kind) { case StatementKind::skFunction: case StatementKind::skConstructor: @@ -4312,9 +4312,9 @@ void Editor::reformat() addLeftTopToUndo(); addCaretToUndo(); - QSynedit::SynEditorOptions oldOptions = getOptions(); - QSynedit::SynEditorOptions newOptions = oldOptions; - newOptions.setFlag(QSynedit::SynEditorOption::eoAutoIndent,false); + QSynedit::EditorOptions oldOptions = getOptions(); + QSynedit::EditorOptions newOptions = oldOptions; + newOptions.setFlag(QSynedit::EditorOption::eoAutoIndent,false); setOptions(newOptions); replaceAll(QString::fromUtf8(newContent)); setCaretXY(mOldCaret); @@ -4333,7 +4333,7 @@ void Editor::checkSyntaxInBack() return; if (!highlighter()) return; - if (highlighter()->language()!=QSynedit::SynHighlighterLanguage::Cpp) + if (highlighter()->language()!=QSynedit::HighlighterLanguage::Cpp) return; if(pSettings->editor().syntaxCheck()) pMainWindow->checkSyntaxInBack(this); @@ -4470,7 +4470,7 @@ void Editor::setActiveBreakpointFocus(int Line, bool setFocus) void Editor::applySettings() { - QSynedit::SynEditorOptions options = QSynedit::eoAltSetsColumnMode | + QSynedit::EditorOptions options = QSynedit::eoAltSetsColumnMode | QSynedit::eoDragDropEditing | QSynedit::eoDropFiles | QSynedit::eoKeepCaretX | QSynedit::eoTabsToSpaces | QSynedit::eoRightMouseMovesCursor | QSynedit::eoScrollByOneLess | QSynedit::eoTabIndent | QSynedit::eoHideShowScrollbars | QSynedit::eoGroupUndo; @@ -4515,7 +4515,7 @@ void Editor::applySettings() // Set gutter properties gutter().setLeftOffset(pointToPixel(pSettings->editor().fontSize()) + pSettings->editor().gutterLeftOffset()); gutter().setRightOffset(pSettings->editor().gutterRightOffset()); - gutter().setBorderStyle(QSynedit::SynGutterBorderStyle::None); + gutter().setBorderStyle(QSynedit::GutterBorderStyle::None); gutter().setUseFontStyle(pSettings->editor().gutterUseCustomFont()); if (pSettings->editor().gutterUseCustomFont()) { f=QFont(pSettings->editor().gutterFontName()); @@ -4551,30 +4551,30 @@ void Editor::applySettings() invalidate(); } -static QSynedit::PSynHighlighterAttribute createRainbowAttribute(const QString& attrName, const QString& schemeName, const QString& schemeItemName) { +static QSynedit::PHighlighterAttribute createRainbowAttribute(const QString& attrName, const QString& schemeName, const QString& schemeItemName) { PColorSchemeItem item = pColorManager->getItem(schemeName,schemeItemName); if (item) { - QSynedit::PSynHighlighterAttribute attr = std::make_shared(attrName); + QSynedit::PHighlighterAttribute attr = std::make_shared(attrName); attr->setForeground(item->foreground()); attr->setBackground(item->background()); return attr; } - return QSynedit::PSynHighlighterAttribute(); + return QSynedit::PHighlighterAttribute(); } void Editor::applyColorScheme(const QString& schemeName) { - QSynedit::SynEditorOptions options = getOptions(); - options.setFlag(QSynedit::SynEditorOption::eoShowRainbowColor, pSettings->editor().rainbowParenthesis()); + QSynedit::EditorOptions options = getOptions(); + options.setFlag(QSynedit::EditorOption::eoShowRainbowColor, pSettings->editor().rainbowParenthesis()); setOptions(options); highlighterManager.applyColorScheme(highlighter(),schemeName); if (pSettings->editor().rainbowParenthesis()) { - QSynedit::PSynHighlighterAttribute attr0 =createRainbowAttribute(SYNS_AttrSymbol, + QSynedit::PHighlighterAttribute attr0 =createRainbowAttribute(SYNS_AttrSymbol, schemeName,COLOR_SCHEME_BRACE_1); - QSynedit::PSynHighlighterAttribute attr1 =createRainbowAttribute(SYNS_AttrSymbol, + QSynedit::PHighlighterAttribute attr1 =createRainbowAttribute(SYNS_AttrSymbol, schemeName,COLOR_SCHEME_BRACE_2); - QSynedit::PSynHighlighterAttribute attr2 =createRainbowAttribute(SYNS_AttrSymbol, + QSynedit::PHighlighterAttribute attr2 =createRainbowAttribute(SYNS_AttrSymbol, schemeName,COLOR_SCHEME_BRACE_3); - QSynedit::PSynHighlighterAttribute attr3 =createRainbowAttribute(SYNS_AttrSymbol, + QSynedit::PHighlighterAttribute attr3 =createRainbowAttribute(SYNS_AttrSymbol, schemeName,COLOR_SCHEME_BRACE_4); setRainbowAttrs(attr0,attr1,attr2,attr3); } diff --git a/RedPandaIDE/editor.h b/RedPandaIDE/editor.h index 6747a631..a119c3c5 100644 --- a/RedPandaIDE/editor.h +++ b/RedPandaIDE/editor.h @@ -230,7 +230,7 @@ signals: void renamed(const QString& oldName, const QString& newName, bool firstSave); void fileSaved(const QString& filename, bool inProject); private slots: - void onStatusChanged(QSynedit::SynStatusChanges changes); + void onStatusChanged(QSynedit::StatusChanges changes); void onGutterClicked(Qt::MouseButton button, int x, int y, int line); void onTipEvalValueReady(const QString& value); void onLinesDeleted(int first,int count); @@ -284,8 +284,8 @@ private: void updateFunctionTip(bool showTip); void clearUserCodeInTabStops(); void popUserCodeInTabStops(); - void onExportedFormatToken(QSynedit::PSynHighlighter syntaxHighlighter, int Line, int column, const QString& token, - QSynedit::PSynHighlighterAttribute &attr); + void onExportedFormatToken(QSynedit::PHighlighter syntaxHighlighter, int Line, int column, const QString& token, + QSynedit::PHighlighterAttribute &attr); void onScrollBarValueChanged(); private: QByteArray mEncodingOption; // the encoding type set by the user @@ -347,7 +347,7 @@ protected: // SynEdit interface protected: void onGutterPaint(QPainter &painter, int aLine, int X, int Y) override; - void onGetEditingAreas(int Line, QSynedit::SynEditingAreaList &areaList) override; + void onGetEditingAreas(int Line, QSynedit::EditingAreaList &areaList) override; // SynEdit interface protected: @@ -355,7 +355,7 @@ protected: // SynEdit interface protected: - void onPreparePaintHighlightToken(int line, int aChar, const QString &token, QSynedit::PSynHighlighterAttribute attr, QSynedit::SynFontStyles &style, QColor &foreground, QColor &background) override; + void onPreparePaintHighlightToken(int line, int aChar, const QString &token, QSynedit::PHighlighterAttribute attr, QSynedit::FontStyles &style, QColor &foreground, QColor &background) override; // QObject interface public: diff --git a/RedPandaIDE/parser/cppparser.cpp b/RedPandaIDE/parser/cppparser.cpp index 0a4375e3..27711bfc 100644 --- a/RedPandaIDE/parser/cppparser.cpp +++ b/RedPandaIDE/parser/cppparser.cpp @@ -4138,7 +4138,7 @@ PStatement CppParser::doParseEvalTypeInfo( QString s = type; // qDebug()<<"eval type info"< usingList; // using namespaces QString noNameArgs;// Args without name + // fields for code completion int usageCount; //Usage Count int matchPosTotal; // total of matched positions diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 4c9df72f..ad7b32c1 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -1255,8 +1255,8 @@ void Settings::Editor::doLoad() mEnhanceHomeKey = boolValue("enhance_home_key", true); mEnhanceEndKey = boolValue("enhance_end_key",true); mKeepCaretX = boolValue("keep_caret_x",true); - mCaretForInsert = static_cast( intValue("caret_for_insert",static_cast(QSynedit::SynEditCaretType::ctVerticalLine))); - mCaretForOverwrite = static_cast( intValue("caret_for_overwrite",static_cast(QSynedit::SynEditCaretType::ctBlock))); + mCaretForInsert = static_cast( intValue("caret_for_insert",static_cast(QSynedit::EditCaretType::ctVerticalLine))); + mCaretForOverwrite = static_cast( intValue("caret_for_overwrite",static_cast(QSynedit::EditCaretType::ctBlock))); mCaretUseTextColor = boolValue("caret_use_text_color",true); mCaretColor = colorValue("caret_color",Qt::yellow); @@ -1382,22 +1382,22 @@ void Settings::Editor::doLoad() mShowFunctionTips = boolValue("show_function_tips",true); } -QSynedit::SynEditCaretType Settings::Editor::caretForOverwrite() const +QSynedit::EditCaretType Settings::Editor::caretForOverwrite() const { return mCaretForOverwrite; } -void Settings::Editor::setCaretForOverwrite(const QSynedit::SynEditCaretType &caretForOverwrite) +void Settings::Editor::setCaretForOverwrite(const QSynedit::EditCaretType &caretForOverwrite) { mCaretForOverwrite = caretForOverwrite; } -QSynedit::SynEditCaretType Settings::Editor::caretForInsert() const +QSynedit::EditCaretType Settings::Editor::caretForInsert() const { return mCaretForInsert; } -void Settings::Editor::setCaretForInsert(const QSynedit::SynEditCaretType &caretForInsert) +void Settings::Editor::setCaretForInsert(const QSynedit::EditCaretType &caretForInsert) { mCaretForInsert = caretForInsert; } diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h index 0ede6e28..362db218 100644 --- a/RedPandaIDE/settings.h +++ b/RedPandaIDE/settings.h @@ -143,11 +143,11 @@ public: bool enhanceEndKey() const; void setEnhanceEndKey(bool enhanceEndKey); - QSynedit::SynEditCaretType caretForInsert() const; - void setCaretForInsert(const QSynedit::SynEditCaretType &caretForInsert); + QSynedit::EditCaretType caretForInsert() const; + void setCaretForInsert(const QSynedit::EditCaretType &caretForInsert); - QSynedit::SynEditCaretType caretForOverwrite() const; - void setCaretForOverwrite(const QSynedit::SynEditCaretType &caretForOverwrite); + QSynedit::EditCaretType caretForOverwrite() const; + void setCaretForOverwrite(const QSynedit::EditCaretType &caretForOverwrite); QColor caretColor() const; void setCaretColor(const QColor &caretColor); @@ -380,8 +380,8 @@ public: bool mEnhanceHomeKey; bool mEnhanceEndKey; bool mKeepCaretX; - QSynedit::SynEditCaretType mCaretForInsert; - QSynedit::SynEditCaretType mCaretForOverwrite; + QSynedit::EditCaretType mCaretForInsert; + QSynedit::EditCaretType mCaretForOverwrite; bool mCaretUseTextColor; QColor mCaretColor; diff --git a/RedPandaIDE/settingsdialog/editorgeneralwidget.cpp b/RedPandaIDE/settingsdialog/editorgeneralwidget.cpp index 89cf95ed..bc3eb11b 100644 --- a/RedPandaIDE/settingsdialog/editorgeneralwidget.cpp +++ b/RedPandaIDE/settingsdialog/editorgeneralwidget.cpp @@ -40,15 +40,15 @@ EditorGeneralWidget::~EditorGeneralWidget() delete ui; } -static void setCaretTypeIndex(QComboBox* combo, QSynedit::SynEditCaretType caretType) { +static void setCaretTypeIndex(QComboBox* combo, QSynedit::EditCaretType caretType) { int t = static_cast(caretType); combo->setCurrentIndex(t); } -static QSynedit::SynEditCaretType getCaretTypeIndex(QComboBox* combo) { +static QSynedit::EditCaretType getCaretTypeIndex(QComboBox* combo) { if (combo->currentIndex()<0) - return QSynedit::SynEditCaretType::ctVerticalLine; - return static_cast(combo->currentIndex()); + return QSynedit::EditCaretType::ctVerticalLine; + return static_cast(combo->currentIndex()); } void EditorGeneralWidget::doLoad() { diff --git a/RedPandaIDE/todoparser.cpp b/RedPandaIDE/todoparser.cpp index 67a89970..980f76e1 100644 --- a/RedPandaIDE/todoparser.cpp +++ b/RedPandaIDE/todoparser.cpp @@ -63,7 +63,7 @@ TodoThread::TodoThread(const QString& filename, QObject *parent): QThread(parent void TodoThread::run() { - QSynedit::PSynHighlighter highlighter = highlighterManager.getCppHighlighter(); + QSynedit::PHighlighter highlighter = highlighterManager.getCppHighlighter(); emit parseStarted(mFilename); auto action = finally([this]{ emit parseFinished(); @@ -72,13 +72,13 @@ void TodoThread::run() if (!pMainWindow->editorList()->getContentFromOpenedEditor(mFilename,lines)) { return; } - QSynedit::PSynHighlighterAttribute commentAttr = highlighter->getAttribute(SYNS_AttrComment); + QSynedit::PHighlighterAttribute commentAttr = highlighter->getAttribute(SYNS_AttrComment); highlighter->resetState(); for (int i =0;isetLine(lines[i],i); while (!highlighter->eol()) { - QSynedit::PSynHighlighterAttribute attr; + QSynedit::PHighlighterAttribute attr; attr = highlighter->getTokenAttribute(); if (attr == commentAttr) { QString token = highlighter->getToken(); diff --git a/RedPandaIDE/widgets/filepropertiesdialog.cpp b/RedPandaIDE/widgets/filepropertiesdialog.cpp index 1f687452..fef7b75a 100644 --- a/RedPandaIDE/widgets/filepropertiesdialog.cpp +++ b/RedPandaIDE/widgets/filepropertiesdialog.cpp @@ -56,7 +56,7 @@ void FilePropertiesDialog::calcFile(Editor *editor, while (jgetHighlighterAttriAtRowCol(QSynedit::BufferCoord{j+1,i+1}, token,attr)) { // if it is preprocessor... diff --git a/RedPandaIDE/widgets/searchdialog.cpp b/RedPandaIDE/widgets/searchdialog.cpp index ab591336..c7a3de25 100644 --- a/RedPandaIDE/widgets/searchdialog.cpp +++ b/RedPandaIDE/widgets/searchdialog.cpp @@ -44,8 +44,8 @@ SearchDialog::SearchDialog(QWidget *parent) : ui->dialogLayout->insertWidget(0,mTabBar); connect(mTabBar,&QTabBar::currentChanged,this, &SearchDialog::onTabChanged); mSearchOptions&=0; - mBasicSearchEngine= QSynedit::PSynSearchBase(new QSynedit::SynSearch()); - mRegexSearchEngine= QSynedit::PSynSearchBase(new QSynedit::SynSearchRegex()); + mBasicSearchEngine= QSynedit::PSynSearchBase(new QSynedit::BasicSearcher()); + mRegexSearchEngine= QSynedit::PSynSearchBase(new QSynedit::RegexSearcher()); } SearchDialog::~SearchDialog() @@ -87,7 +87,7 @@ void SearchDialog::findInFiles(const QString &text) show(); } -void SearchDialog::findInFiles(const QString &keyword, SearchFileScope scope, QSynedit::SynSearchOptions options) +void SearchDialog::findInFiles(const QString &keyword, SearchFileScope scope, QSynedit::SearchOptions options) { mTabBar->setCurrentIndex(2); @@ -283,18 +283,18 @@ void SearchDialog::on_btnExecute_clicked() QMessageBox::Yes|QMessageBox::YesAll|QMessageBox::No|QMessageBox::Cancel, QMessageBox::Yes)) { case QMessageBox::Yes: - return QSynedit::SynSearchAction::Replace; + return QSynedit::SearchAction::Replace; case QMessageBox::YesAll: - return QSynedit::SynSearchAction::ReplaceAll; + return QSynedit::SearchAction::ReplaceAll; case QMessageBox::No: - return QSynedit::SynSearchAction::Skip; + return QSynedit::SearchAction::Skip; case QMessageBox::Cancel: - return QSynedit::SynSearchAction::Exit; + return QSynedit::SearchAction::Exit; default: - return QSynedit::SynSearchAction::Exit; + return QSynedit::SearchAction::Exit; } } else { - return QSynedit::SynSearchAction::ReplaceAll; + return QSynedit::SearchAction::ReplaceAll; } }, [](){ @@ -402,8 +402,8 @@ void SearchDialog::on_btnExecute_clicked() } int SearchDialog::execute(QSynedit::SynEdit *editor, const QString &sSearch, const QString &sReplace, - QSynedit::SynSearchMathedProc matchCallback, - QSynedit::SynSearchConfirmAroundProc confirmAroundCallback) + QSynedit::SearchMathedProc matchCallback, + QSynedit::SearchConfirmAroundProc confirmAroundCallback) { if (editor==nullptr) return 0; @@ -452,7 +452,7 @@ std::shared_ptr SearchDialog::batchFindInEditor(QSynedit:: item->text = e->document()->getString(Line-1); item->text.replace('\t',' '); parentItem->results.append(item); - return QSynedit::SynSearchAction::Skip; + return QSynedit::SearchAction::Skip; }); // restore diff --git a/RedPandaIDE/widgets/searchdialog.h b/RedPandaIDE/widgets/searchdialog.h index e3200bc3..c1ddd094 100644 --- a/RedPandaIDE/widgets/searchdialog.h +++ b/RedPandaIDE/widgets/searchdialog.h @@ -46,7 +46,7 @@ public: void findNext(); void findPrevious(); void findInFiles(const QString& text); - void findInFiles(const QString& keyword, SearchFileScope scope, QSynedit::SynSearchOptions options); + void findInFiles(const QString& keyword, SearchFileScope scope, QSynedit::SearchOptions options); void replace(const QString& sFind, const QString& sReplace); QSynedit::PSynSearchBase searchEngine() const; @@ -62,13 +62,13 @@ private slots: private: int execute(QSynedit::SynEdit* editor, const QString& sSearch, const QString& sReplace, - QSynedit::SynSearchMathedProc matchCallback = nullptr, - QSynedit::SynSearchConfirmAroundProc confirmAroundCallback = nullptr); + QSynedit::SearchMathedProc matchCallback = nullptr, + QSynedit::SearchConfirmAroundProc confirmAroundCallback = nullptr); std::shared_ptr batchFindInEditor(QSynedit::SynEdit * editor,const QString& filename, const QString& keyword); private: Ui::SearchDialog *ui; QTabBar *mTabBar; - QSynedit::SynSearchOptions mSearchOptions; + QSynedit::SearchOptions mSearchOptions; QSynedit::PSynSearchBase mSearchEngine; QSynedit::PSynSearchBase mBasicSearchEngine; QSynedit::PSynSearchBase mRegexSearchEngine; diff --git a/RedPandaIDE/widgets/searchresultview.cpp b/RedPandaIDE/widgets/searchresultview.cpp index 190da707..f30a6f12 100644 --- a/RedPandaIDE/widgets/searchresultview.cpp +++ b/RedPandaIDE/widgets/searchresultview.cpp @@ -20,7 +20,7 @@ #include #include "mainwindow.h" -PSearchResults SearchResultModel::addSearchResults(const QString &keyword, QSynedit::SynSearchOptions options, SearchFileScope scope) +PSearchResults SearchResultModel::addSearchResults(const QString &keyword, QSynedit::SearchOptions options, SearchFileScope scope) { int index=-1; for (int i=0;i(); + PCodeFoldingDefine region = std::make_shared(); region->addEnding = addEnding; region->openSymbol = openSymbol; region->closeSymbol = closeSymbol; @@ -36,12 +36,12 @@ PSynEditFoldRegion SynEditFoldRegions::add(bool addEnding, const QChar &openSymb return region; } -PSynEditFoldRegion SynEditFoldRegions::get(int index) +PCodeFoldingDefine CodeFoldingDefines::get(int index) { return fRegions.at(index); } -SynEditCodeFolding::SynEditCodeFolding(): +CodeFoldingOptions::CodeFoldingOptions(): indentGuides(true), fillIndents(false), showCollapsedLine(true), @@ -53,9 +53,9 @@ SynEditCodeFolding::SynEditCodeFolding(): } -bool SynEditFoldRange::parentCollapsed() +bool CodeFoldingRange::parentCollapsed() { - PSynEditFoldRange parentFold = parent; + PCodeFoldingRange parentFold = parent; // Find first parent that is collapsed while (parentFold) { if (parentFold->collapsed) { @@ -66,13 +66,16 @@ bool SynEditFoldRange::parentCollapsed() return false; } -void SynEditFoldRange::move(int count) +void CodeFoldingRange::move(int count) { fromLine += count; toLine += count; } -SynEditFoldRange::SynEditFoldRange(PSynEditFoldRange aParent, PSynEditFoldRanges aAllFold, int aFromLine, PSynEditFoldRegion aFoldRegion, int aToLine): +CodeFoldingRange::CodeFoldingRange(PCodeFoldingRange aParent, + PCodeFoldingRanges aAllFold, + int aFromLine, + PCodeFoldingDefine aFoldRegion, int aToLine): fromLine(aFromLine), toLine(aToLine), linesCollapsed(0), @@ -82,37 +85,37 @@ SynEditFoldRange::SynEditFoldRange(PSynEditFoldRange aParent, PSynEditFoldRanges hintMarkLeft(0), parent(aParent) { - subFoldRanges = std::make_shared(); + subFoldRanges = std::make_shared(); } -PSynEditFoldRange SynEditFoldRanges::range(int index) +PCodeFoldingRange CodeFoldingRanges::range(int index) { return mRanges[index]; } -void SynEditFoldRanges::clear() +void CodeFoldingRanges::clear() { mRanges.clear(); } -int SynEditFoldRanges::count() const +int CodeFoldingRanges::count() const { return mRanges.size(); } -SynEditFoldRanges::SynEditFoldRanges() +CodeFoldingRanges::CodeFoldingRanges() { } -PSynEditFoldRange SynEditFoldRanges::addByParts(PSynEditFoldRange aParent, - PSynEditFoldRanges aAllFold, +PCodeFoldingRange CodeFoldingRanges::addByParts(PCodeFoldingRange aParent, + PCodeFoldingRanges aAllFold, int aFromLine, - PSynEditFoldRegion aFoldRegion, + PCodeFoldingDefine aFoldRegion, int aToLine) { - PSynEditFoldRange range=std::make_shared(aParent,aAllFold, aFromLine,aFoldRegion,aToLine); + PCodeFoldingRange range=std::make_shared(aParent,aAllFold, aFromLine,aFoldRegion,aToLine); mRanges.append(range); if (aAllFold && aAllFold.get()!=this) { aAllFold->add(range); @@ -120,22 +123,22 @@ PSynEditFoldRange SynEditFoldRanges::addByParts(PSynEditFoldRange aParent, return range; } -void SynEditFoldRanges::insert(int index, PSynEditFoldRange range) +void CodeFoldingRanges::insert(int index, PCodeFoldingRange range) { mRanges.insert(index,range); } -void SynEditFoldRanges::remove(int index) +void CodeFoldingRanges::remove(int index) { mRanges.remove(index); } -void SynEditFoldRanges::add(PSynEditFoldRange foldRange) +void CodeFoldingRanges::add(PCodeFoldingRange foldRange) { mRanges.push_back(foldRange); } -PSynEditFoldRange SynEditFoldRanges::operator[](int index) const +PCodeFoldingRange CodeFoldingRanges::operator[](int index) const { return mRanges[index]; } diff --git a/libs/qsynedit/qsynedit/CodeFolding.h b/libs/qsynedit/qsynedit/CodeFolding.h index 5585aa6c..066a8511 100644 --- a/libs/qsynedit/qsynedit/CodeFolding.h +++ b/libs/qsynedit/qsynedit/CodeFolding.h @@ -22,77 +22,77 @@ #include namespace QSynedit { -struct SynEditFoldRegion; -typedef std::shared_ptr PSynEditFoldRegion; +struct CodeFoldingDefine; +using PCodeFoldingDefine = std::shared_ptr ; -class SynEditFoldRegions { +class CodeFoldingDefines { private: - std::vector fRegions; + std::vector fRegions; public: int count(); - PSynEditFoldRegion add(bool addEnding, const QChar& openSymbol, const QChar& closeSymbol, const QString& highlight); - PSynEditFoldRegion get(int index); + PCodeFoldingDefine add(bool addEnding, const QChar& openSymbol, const QChar& closeSymbol, const QString& highlight); + PCodeFoldingDefine get(int index); }; -typedef std::shared_ptr PSynFoldRegions; +typedef std::shared_ptr PSynFoldRegions; -struct SynEditFoldRegion { +struct CodeFoldingDefine { bool addEnding; - SynEditFoldRegions subFoldRegions; + CodeFoldingDefines subFoldRegions; QChar openSymbol; QChar closeSymbol; QString highlight; }; -struct SynEditCodeFolding { +struct CodeFoldingOptions { bool indentGuides; bool fillIndents; bool showCollapsedLine; QColor collapsedLineColor; QColor folderBarLinesColor; QColor indentGuidesColor; - SynEditFoldRegions foldRegions; - SynEditCodeFolding(); + CodeFoldingDefines foldRegions; + CodeFoldingOptions(); }; -class SynEditFoldRange; -typedef std::shared_ptr PSynEditFoldRange; -class SynEditFoldRanges; -typedef std::shared_ptr PSynEditFoldRanges; +class CodeFoldingRange; +typedef std::shared_ptr PCodeFoldingRange; +class CodeFoldingRanges; +typedef std::shared_ptr PCodeFoldingRanges; -class SynEditFoldRanges{ +class CodeFoldingRanges{ private: - QVector mRanges; + QVector mRanges; public: - PSynEditFoldRange range(int index); + PCodeFoldingRange range(int index); void clear(); int count() const; - SynEditFoldRanges(); - PSynEditFoldRange addByParts(PSynEditFoldRange aParent, PSynEditFoldRanges aAllFold, - int aFromLine, PSynEditFoldRegion aFoldRegion, int aToLine); + CodeFoldingRanges(); + PCodeFoldingRange addByParts(PCodeFoldingRange aParent, PCodeFoldingRanges aAllFold, + int aFromLine, PCodeFoldingDefine aFoldRegion, int aToLine); - void insert(int index, PSynEditFoldRange range); + void insert(int index, PCodeFoldingRange range); void remove(int index); - void add(PSynEditFoldRange foldRange); - PSynEditFoldRange operator[](int index) const; + void add(PCodeFoldingRange foldRange); + PCodeFoldingRange operator[](int index) const; }; // A single fold -class SynEditFoldRange { +class CodeFoldingRange { public: int fromLine; // Beginning line int toLine; // End line int linesCollapsed; // Number of collapsed lines - PSynEditFoldRanges subFoldRanges; // Sub fold ranges + PCodeFoldingRanges subFoldRanges; // Sub fold ranges bool collapsed; // Is collapsed? - PSynEditFoldRanges allFoldRanges;// TAllFoldRanges pointer - PSynEditFoldRegion foldRegion; // FoldRegion + PCodeFoldingRanges allFoldRanges;// TAllFoldRanges pointer + PCodeFoldingDefine foldRegion; // FoldRegion int hintMarkLeft; - PSynEditFoldRange parent; + PCodeFoldingRange parent; bool parentCollapsed(); void move(int count); - explicit SynEditFoldRange(PSynEditFoldRange aParent, PSynEditFoldRanges aAllFold, - int aFromLine, PSynEditFoldRegion aFoldRegion, int aToLine); + explicit CodeFoldingRange(PCodeFoldingRange aParent, PCodeFoldingRanges aAllFold, + int aFromLine, PCodeFoldingDefine aFoldRegion, int aToLine); }; } diff --git a/libs/qsynedit/qsynedit/Constants.cpp b/libs/qsynedit/qsynedit/Constants.cpp index a4422a33..7f84ebc3 100644 --- a/libs/qsynedit/qsynedit/Constants.cpp +++ b/libs/qsynedit/qsynedit/Constants.cpp @@ -17,12 +17,11 @@ #include "Constants.h" namespace QSynedit { -const QSet SynWordBreakChars{'.', ',', ';', ':', +const QSet WordBreakChars{'.', ',', ';', ':', '"', '\'', '!', '?', '[', ']', '(', ')', '{', '}', '^', '-', '=', '+', '-', '*', '/', '\\', '|'}; -const QChar SynTabChar('\t'); -const QChar SynTabGlyph(0x2192); -const QChar SynSpaceGlyph('.'); -const QChar SynLineBreakGlyph(0x2193); -const QChar SynSoftBreakGlyph(0x2193); +const QChar TabGlyph(0x2192); +const QChar SpaceGlyph('.'); +const QChar LineBreakGlyph(0x2193); +const QChar SoftBreakGlyph(0x2193); } diff --git a/libs/qsynedit/qsynedit/Constants.h b/libs/qsynedit/qsynedit/Constants.h index 1d95c420..0387fb7d 100644 --- a/libs/qsynedit/qsynedit/Constants.h +++ b/libs/qsynedit/qsynedit/Constants.h @@ -21,12 +21,11 @@ namespace QSynedit { -extern const QSet SynWordBreakChars; -extern const QChar SynTabChar; -extern const QChar SynSpaceGlyph; -extern const QChar SynTabGlyph; -extern const QChar SynLineBreakGlyph; -extern const QChar SynSoftBreakGlyph; +extern const QSet WordBreakChars; +extern const QChar SpaceGlyph; +extern const QChar TabGlyph; +extern const QChar LineBreakGlyph; +extern const QChar SoftBreakGlyph; #define MAX_SCROLL 65535 diff --git a/libs/qsynedit/qsynedit/KeyStrokes.cpp b/libs/qsynedit/qsynedit/KeyStrokes.cpp index b4c18bcc..a24f5b41 100644 --- a/libs/qsynedit/qsynedit/KeyStrokes.cpp +++ b/libs/qsynedit/qsynedit/KeyStrokes.cpp @@ -18,16 +18,16 @@ #include "MiscProcs.h" namespace QSynedit { -SynEditKeyStroke::SynEditKeyStroke() +EditKeyStroke::EditKeyStroke() { mKey = 0; mKeyModifiers = Qt::NoModifier; mKey2 = 0; mKeyModifiers2 = Qt::NoModifier; - mCommand = SynEditorCommand::ecNone; + mCommand = EditCommand::ecNone; } -QKeySequence SynEditKeyStroke::keySequence() const +QKeySequence EditKeyStroke::keySequence() const { if (mKey2 == 0) { return QKeySequence(mKey + mKeyModifiers); @@ -36,7 +36,7 @@ QKeySequence SynEditKeyStroke::keySequence() const } } -void SynEditKeyStroke::setKeySequence(QKeySequence &keySequence) +void EditKeyStroke::setKeySequence(QKeySequence &keySequence) { if (keySequence.isEmpty()) return; @@ -49,64 +49,64 @@ void SynEditKeyStroke::setKeySequence(QKeySequence &keySequence) } } -int SynEditKeyStroke::key() const +int EditKeyStroke::key() const { return mKey; } -void SynEditKeyStroke::setKey(int key) +void EditKeyStroke::setKey(int key) { mKey = key; } -Qt::KeyboardModifiers SynEditKeyStroke::keyModifiers() const +Qt::KeyboardModifiers EditKeyStroke::keyModifiers() const { return mKeyModifiers; } -void SynEditKeyStroke::setKeyModifiers(const Qt::KeyboardModifiers &keyModifiers) +void EditKeyStroke::setKeyModifiers(const Qt::KeyboardModifiers &keyModifiers) { mKeyModifiers = keyModifiers; } -int SynEditKeyStroke::key2() const +int EditKeyStroke::key2() const { return mKey2; } -void SynEditKeyStroke::setKey2(int key2) +void EditKeyStroke::setKey2(int key2) { mKey2 = key2; } -Qt::KeyboardModifiers SynEditKeyStroke::keyModifiers2() const +Qt::KeyboardModifiers EditKeyStroke::keyModifiers2() const { return mKeyModifiers2; } -void SynEditKeyStroke::setKeyModifiers2(const Qt::KeyboardModifiers &keyModifiers2) +void EditKeyStroke::setKeyModifiers2(const Qt::KeyboardModifiers &keyModifiers2) { mKeyModifiers2 = keyModifiers2; } -SynEditorCommand SynEditKeyStroke::command() const +EditCommand EditKeyStroke::command() const { return mCommand; } -void SynEditKeyStroke::setCommand(const SynEditorCommand &command) +void EditKeyStroke::setCommand(const EditCommand &command) { mCommand = command; } -SynKeyError::SynKeyError(const QString &reason):BaseError(reason) +KeyError::KeyError(const QString &reason):BaseError(reason) { } -PSynEditKeyStroke SynEditKeyStrokes::add(SynEditorCommand command, int key, Qt::KeyboardModifiers modifiers) +PEditKeyStroke EditKeyStrokes::add(EditCommand command, int key, Qt::KeyboardModifiers modifiers) { - PSynEditKeyStroke keyStroke = std::make_shared(); + PEditKeyStroke keyStroke = std::make_shared(); keyStroke->setKey(key); keyStroke->setKeyModifiers(modifiers); keyStroke->setCommand(command); @@ -114,40 +114,40 @@ PSynEditKeyStroke SynEditKeyStrokes::add(SynEditorCommand command, int key, Qt:: return keyStroke; } -PSynEditKeyStroke SynEditKeyStrokes::findCommand(SynEditorCommand command) +PEditKeyStroke EditKeyStrokes::findCommand(EditCommand command) { - for (PSynEditKeyStroke& keyStroke:mList) { + for (PEditKeyStroke& keyStroke:mList) { if (keyStroke->command() == command) return keyStroke; } - return PSynEditKeyStroke(); + return PEditKeyStroke(); } -PSynEditKeyStroke SynEditKeyStrokes::findKeycode(int key, Qt::KeyboardModifiers modifiers) +PEditKeyStroke EditKeyStrokes::findKeycode(int key, Qt::KeyboardModifiers modifiers) { - for (PSynEditKeyStroke& keyStroke:mList) { + for (PEditKeyStroke& keyStroke:mList) { if (keyStroke->key() == key && keyStroke->keyModifiers() == (modifiers & ~ Qt::KeypadModifier) && keyStroke->key2()==0) return keyStroke; } - return PSynEditKeyStroke(); + return PEditKeyStroke(); } -PSynEditKeyStroke SynEditKeyStrokes::findKeycode2(int key, Qt::KeyboardModifiers modifiers, +PEditKeyStroke EditKeyStrokes::findKeycode2(int key, Qt::KeyboardModifiers modifiers, int key2, Qt::KeyboardModifiers modifiers2) { - for (PSynEditKeyStroke& keyStroke:mList) { + for (PEditKeyStroke& keyStroke:mList) { if (keyStroke->key() == key && keyStroke->keyModifiers()==(modifiers & ~ Qt::KeypadModifier) && keyStroke->key2()==key2 && keyStroke->keyModifiers2()== (modifiers2 & ~ Qt::KeypadModifier)) return keyStroke; } - return PSynEditKeyStroke(); + return PEditKeyStroke(); } -PSynEditKeyStroke SynEditKeyStrokes::findKeySequence(const QKeySequence &keySeq) +PEditKeyStroke EditKeyStrokes::findKeySequence(const QKeySequence &keySeq) { switch (keySeq.count()) { case 1: { @@ -169,75 +169,75 @@ PSynEditKeyStroke SynEditKeyStrokes::findKeySequence(const QKeySequence &keySeq) return findKeycode2(key,modifiers,key2,modifiers2); } default: - return PSynEditKeyStroke(); + return PEditKeyStroke(); } } -void SynEditKeyStrokes::clear() +void EditKeyStrokes::clear() { return mList.clear(); } -void SynEditKeyStrokes::resetDefaults() +void EditKeyStrokes::resetDefaults() { clear(); - add(SynEditorCommand::ecUp, Qt::Key_Up, Qt::NoModifier); - add(SynEditorCommand::ecSelUp, Qt::Key_Up, Qt::ShiftModifier); - add(SynEditorCommand::ecSelUp, Qt::Key_Up, Qt::ShiftModifier | Qt::AltModifier); - add(SynEditorCommand::ecScrollUp, Qt::Key_Up, Qt::ControlModifier); - add(SynEditorCommand::ecDown, Qt::Key_Down, Qt::NoModifier); - add(SynEditorCommand::ecSelDown, Qt::Key_Down, Qt::ShiftModifier); - add(SynEditorCommand::ecSelDown, Qt::Key_Down, Qt::ShiftModifier | Qt::AltModifier); - add(SynEditorCommand::ecScrollDown, Qt::Key_Down, Qt::ControlModifier); - add(SynEditorCommand::ecLeft, Qt::Key_Left, Qt::NoModifier); - add(SynEditorCommand::ecSelLeft, Qt::Key_Left, Qt::ShiftModifier); - add(SynEditorCommand::ecWordLeft, Qt::Key_Left, Qt::ControlModifier); - add(SynEditorCommand::ecSelWordLeft, Qt::Key_Left, Qt::ShiftModifier|Qt::ControlModifier); - add(SynEditorCommand::ecRight, Qt::Key_Right, Qt::NoModifier); - add(SynEditorCommand::ecSelRight, Qt::Key_Right, Qt::ShiftModifier); - add(SynEditorCommand::ecWordRight, Qt::Key_Right, Qt::ControlModifier); - add(SynEditorCommand::ecSelWordRight, Qt::Key_Right, Qt::ShiftModifier|Qt::ControlModifier); + add(EditCommand::ecUp, Qt::Key_Up, Qt::NoModifier); + add(EditCommand::ecSelUp, Qt::Key_Up, Qt::ShiftModifier); + add(EditCommand::ecSelUp, Qt::Key_Up, Qt::ShiftModifier | Qt::AltModifier); + add(EditCommand::ecScrollUp, Qt::Key_Up, Qt::ControlModifier); + add(EditCommand::ecDown, Qt::Key_Down, Qt::NoModifier); + add(EditCommand::ecSelDown, Qt::Key_Down, Qt::ShiftModifier); + add(EditCommand::ecSelDown, Qt::Key_Down, Qt::ShiftModifier | Qt::AltModifier); + add(EditCommand::ecScrollDown, Qt::Key_Down, Qt::ControlModifier); + add(EditCommand::ecLeft, Qt::Key_Left, Qt::NoModifier); + add(EditCommand::ecSelLeft, Qt::Key_Left, Qt::ShiftModifier); + add(EditCommand::ecWordLeft, Qt::Key_Left, Qt::ControlModifier); + add(EditCommand::ecSelWordLeft, Qt::Key_Left, Qt::ShiftModifier|Qt::ControlModifier); + add(EditCommand::ecRight, Qt::Key_Right, Qt::NoModifier); + add(EditCommand::ecSelRight, Qt::Key_Right, Qt::ShiftModifier); + add(EditCommand::ecWordRight, Qt::Key_Right, Qt::ControlModifier); + add(EditCommand::ecSelWordRight, Qt::Key_Right, Qt::ShiftModifier|Qt::ControlModifier); // add(SynEditorCommand::ecExpandSelection, Qt::Key_Right, Qt::ShiftModifier|Qt::AltModifier); // add(SynEditorCommand::ecShrinkSelection, Qt::Key_Left, Qt::ShiftModifier | Qt::AltModifier); - add(SynEditorCommand::ecPageDown, Qt::Key_PageDown, Qt::NoModifier); - add(SynEditorCommand::ecSelPageDown, Qt::Key_PageDown, Qt::ShiftModifier); - add(SynEditorCommand::ecPageBottom, Qt::Key_PageDown, Qt::ControlModifier); - add(SynEditorCommand::ecSelPageBottom, Qt::Key_PageDown, Qt::ShiftModifier|Qt::ControlModifier); - add(SynEditorCommand::ecPageUp, Qt::Key_PageUp, Qt::NoModifier); - add(SynEditorCommand::ecSelPageUp, Qt::Key_PageUp, Qt::ShiftModifier); - add(SynEditorCommand::ecPageTop, Qt::Key_PageUp, Qt::ControlModifier); - add(SynEditorCommand::ecSelPageTop, Qt::Key_PageUp, Qt::ShiftModifier|Qt::ControlModifier); - add(SynEditorCommand::ecLineStart, Qt::Key_Home, Qt::NoModifier); - add(SynEditorCommand::ecSelLineStart, Qt::Key_Home, Qt::ShiftModifier); - add(SynEditorCommand::ecEditorStart, Qt::Key_Home, Qt::ControlModifier); - add(SynEditorCommand::ecSelEditorStart, Qt::Key_Home, Qt::ShiftModifier|Qt::ControlModifier); - add(SynEditorCommand::ecLineEnd, Qt::Key_End, Qt::NoModifier); - add(SynEditorCommand::ecSelLineEnd, Qt::Key_End, Qt::ShiftModifier); - add(SynEditorCommand::ecEditorEnd, Qt::Key_End, Qt::ControlModifier); - add(SynEditorCommand::ecSelEditorEnd, Qt::Key_End, Qt::ShiftModifier|Qt::ControlModifier); - add(SynEditorCommand::ecToggleMode, Qt::Key_Insert, Qt::NoModifier); + add(EditCommand::ecPageDown, Qt::Key_PageDown, Qt::NoModifier); + add(EditCommand::ecSelPageDown, Qt::Key_PageDown, Qt::ShiftModifier); + add(EditCommand::ecPageBottom, Qt::Key_PageDown, Qt::ControlModifier); + add(EditCommand::ecSelPageBottom, Qt::Key_PageDown, Qt::ShiftModifier|Qt::ControlModifier); + add(EditCommand::ecPageUp, Qt::Key_PageUp, Qt::NoModifier); + add(EditCommand::ecSelPageUp, Qt::Key_PageUp, Qt::ShiftModifier); + add(EditCommand::ecPageTop, Qt::Key_PageUp, Qt::ControlModifier); + add(EditCommand::ecSelPageTop, Qt::Key_PageUp, Qt::ShiftModifier|Qt::ControlModifier); + add(EditCommand::ecLineStart, Qt::Key_Home, Qt::NoModifier); + add(EditCommand::ecSelLineStart, Qt::Key_Home, Qt::ShiftModifier); + add(EditCommand::ecEditorStart, Qt::Key_Home, Qt::ControlModifier); + add(EditCommand::ecSelEditorStart, Qt::Key_Home, Qt::ShiftModifier|Qt::ControlModifier); + add(EditCommand::ecLineEnd, Qt::Key_End, Qt::NoModifier); + add(EditCommand::ecSelLineEnd, Qt::Key_End, Qt::ShiftModifier); + add(EditCommand::ecEditorEnd, Qt::Key_End, Qt::ControlModifier); + add(EditCommand::ecSelEditorEnd, Qt::Key_End, Qt::ShiftModifier|Qt::ControlModifier); + add(EditCommand::ecToggleMode, Qt::Key_Insert, Qt::NoModifier); // add(SynEditorCommand::ecCopy, Qt::Key_Insert, Qt::ControlModifier); // add(SynEditorCommand::ecCut, Qt::Key_Delete, Qt::ShiftModifier); // add(SynEditorCommand::ecPaste, Qt::Key_Insert, Qt::ShiftModifier); - add(SynEditorCommand::ecDeleteChar, Qt::Key_Delete, Qt::NoModifier); - add(SynEditorCommand::ecDeleteLastChar, Qt::Key_Backspace, Qt::NoModifier); + add(EditCommand::ecDeleteChar, Qt::Key_Delete, Qt::NoModifier); + add(EditCommand::ecDeleteLastChar, Qt::Key_Backspace, Qt::NoModifier); // add(SynEditorCommand::ecDeleteLastChar, Qt::Key_Backspace, Qt::ShiftModifier); // add(SynEditorCommand::ecDeleteWordStart, Qt::Key_Backspace, Qt::ControlModifier); // add(SynEditorCommand::ecDeleteWordEnd, Qt::Key_Delete, Qt::ControlModifier); // add(SynEditorCommand::ecUndo, Qt::Key_Backspace, Qt::AltModifier); // add(SynEditorCommand::ecRedo, Qt::Key_Backspace, Qt::AltModifier|Qt::ShiftModifier); - add(SynEditorCommand::ecLineBreak, Qt::Key_Return, Qt::NoModifier); - add(SynEditorCommand::ecLineBreak, Qt::Key_Return, Qt::ShiftModifier); - add(SynEditorCommand::ecLineBreakAtEnd, Qt::Key_Return, Qt::ControlModifier); - add(SynEditorCommand::ecLineBreak, Qt::Key_Enter, Qt::NoModifier); - add(SynEditorCommand::ecLineBreak, Qt::Key_Enter, Qt::ShiftModifier); - add(SynEditorCommand::ecLineBreakAtEnd, Qt::Key_Enter, Qt::ControlModifier); + add(EditCommand::ecLineBreak, Qt::Key_Return, Qt::NoModifier); + add(EditCommand::ecLineBreak, Qt::Key_Return, Qt::ShiftModifier); + add(EditCommand::ecLineBreakAtEnd, Qt::Key_Return, Qt::ControlModifier); + add(EditCommand::ecLineBreak, Qt::Key_Enter, Qt::NoModifier); + add(EditCommand::ecLineBreak, Qt::Key_Enter, Qt::ShiftModifier); + add(EditCommand::ecLineBreakAtEnd, Qt::Key_Enter, Qt::ControlModifier); // add(SynEditorCommand::ecTab, Qt::Key_Tab, Qt::NoModifier); // add(SynEditorCommand::ecShiftTab, Qt::Key_Backtab, Qt::ShiftModifier); // add(SynEditorCommand::ecShiftTab, Qt::Key_Tab, Qt::ShiftModifier); - add(SynEditorCommand::ecContextHelp, Qt::Key_F1, Qt::NoModifier); + add(EditCommand::ecContextHelp, Qt::Key_F1, Qt::NoModifier); // add(SynEditorCommand::ecSelectAll, Qt::Key_A, Qt::ControlModifier); // add(SynEditorCommand::ecCopy, Qt::Key_C, Qt::ControlModifier); @@ -260,21 +260,21 @@ void SynEditKeyStrokes::resetDefaults() // add(SynEditorCommand::ecMatchBracket, Qt::Key_B, Qt::ControlModifier | Qt::ShiftModifier); } -void SynEditKeyStrokes::setExtraKeyStrokes() +void EditKeyStrokes::setExtraKeyStrokes() { - add(SynEditorCommand::ecDeleteWordStart, Qt::Key_Backspace, Qt::ControlModifier); - add(SynEditorCommand::ecDeleteWordEnd, Qt::Key_Delete, Qt::ControlModifier); + add(EditCommand::ecDeleteWordStart, Qt::Key_Backspace, Qt::ControlModifier); + add(EditCommand::ecDeleteWordEnd, Qt::Key_Delete, Qt::ControlModifier); - add(SynEditorCommand::ecDuplicateLine, Qt::Key_D, Qt::ControlModifier); - add(SynEditorCommand::ecDeleteLine, Qt::Key_E, Qt::ControlModifier); + add(EditCommand::ecDuplicateLine, Qt::Key_D, Qt::ControlModifier); + add(EditCommand::ecDeleteLine, Qt::Key_E, Qt::ControlModifier); - add(SynEditorCommand::ecSelectAll, Qt::Key_A, Qt::ControlModifier); - add(SynEditorCommand::ecCopy, Qt::Key_C, Qt::ControlModifier); - add(SynEditorCommand::ecPaste, Qt::Key_V, Qt::ControlModifier); - add(SynEditorCommand::ecCut, Qt::Key_X, Qt::ControlModifier); + add(EditCommand::ecSelectAll, Qt::Key_A, Qt::ControlModifier); + add(EditCommand::ecCopy, Qt::Key_C, Qt::ControlModifier); + add(EditCommand::ecPaste, Qt::Key_V, Qt::ControlModifier); + add(EditCommand::ecCut, Qt::Key_X, Qt::ControlModifier); - add(SynEditorCommand::ecUndo, Qt::Key_Z, Qt::ControlModifier); - add(SynEditorCommand::ecRedo, Qt::Key_Y, Qt::ControlModifier); + add(EditCommand::ecUndo, Qt::Key_Z, Qt::ControlModifier); + add(EditCommand::ecRedo, Qt::Key_Y, Qt::ControlModifier); } } diff --git a/libs/qsynedit/qsynedit/KeyStrokes.h b/libs/qsynedit/qsynedit/KeyStrokes.h index a202e158..bbe1a876 100644 --- a/libs/qsynedit/qsynedit/KeyStrokes.h +++ b/libs/qsynedit/qsynedit/KeyStrokes.h @@ -38,7 +38,7 @@ namespace QSynedit { // valid, while the ecEditXXX commands are ignored when the editor is in // read-only mode -enum class SynEditorCommand { +enum class EditCommand { ecNone = 0, // Nothing. Useful for user event to handle command ecViewCommandFirst = 0, ecViewCommandLast = 500, @@ -175,15 +175,15 @@ enum class SynEditorCommand { }; -class SynKeyError: public BaseError { +class KeyError: public BaseError { public: - explicit SynKeyError(const QString& reason); + explicit KeyError(const QString& reason); }; -class SynEditKeyStroke +class EditKeyStroke { public: - explicit SynEditKeyStroke(); + explicit EditKeyStroke(); QKeySequence keySequence() const; void setKeySequence(QKeySequence& keySequence); int key() const; @@ -198,34 +198,34 @@ public: Qt::KeyboardModifiers keyModifiers2() const; void setKeyModifiers2(const Qt::KeyboardModifiers &keyModifiers2); - SynEditorCommand command() const; - void setCommand(const SynEditorCommand &command); + EditCommand command() const; + void setCommand(const EditCommand &command); private: int mKey; // Virtual keycode, i.e. VK_xxx Qt::KeyboardModifiers mKeyModifiers; int mKey2; Qt::KeyboardModifiers mKeyModifiers2; - SynEditorCommand mCommand; + EditCommand mCommand; }; -using PSynEditKeyStroke = std::shared_ptr; -using SynEditKeyStrokeList = QList; +using PEditKeyStroke = std::shared_ptr; +using EditKeyStrokeList = QList; -class SynEditKeyStrokes { +class EditKeyStrokes { public: - PSynEditKeyStroke add(SynEditorCommand command, int key, Qt::KeyboardModifiers modifiers); - PSynEditKeyStroke findCommand(SynEditorCommand command); - PSynEditKeyStroke findKeycode(int key, Qt::KeyboardModifiers modifiers); - PSynEditKeyStroke findKeycode2(int key, Qt::KeyboardModifiers modifiers, + PEditKeyStroke add(EditCommand command, int key, Qt::KeyboardModifiers modifiers); + PEditKeyStroke findCommand(EditCommand command); + PEditKeyStroke findKeycode(int key, Qt::KeyboardModifiers modifiers); + PEditKeyStroke findKeycode2(int key, Qt::KeyboardModifiers modifiers, int key2, Qt::KeyboardModifiers modifiers2); - PSynEditKeyStroke findKeySequence(const QKeySequence& keySeq); + PEditKeyStroke findKeySequence(const QKeySequence& keySeq); void clear(); void resetDefaults(); void setExtraKeyStrokes(); private: - SynEditKeyStrokeList mList; + EditKeyStrokeList mList; }; } diff --git a/libs/qsynedit/qsynedit/MiscClasses.cpp b/libs/qsynedit/qsynedit/MiscClasses.cpp index 6c686478..6821c718 100644 --- a/libs/qsynedit/qsynedit/MiscClasses.cpp +++ b/libs/qsynedit/qsynedit/MiscClasses.cpp @@ -19,7 +19,7 @@ namespace QSynedit { -SynGutter::SynGutter(QObject *parent): +Gutter::Gutter(QObject *parent): QObject(parent) { mFont = QFont("Courier New",10); @@ -35,7 +35,7 @@ SynGutter::SynGutter(QObject *parent): mUseFontStyle = true; mAutoSize = true; mAutoSizeDigitCount = mDigitCount; - mBorderStyle = SynGutterBorderStyle::Middle; + mBorderStyle = GutterBorderStyle::Middle; mLineNumberStart = 1; mGradient = false; mGradientStartColor = Qt::transparent; @@ -43,12 +43,12 @@ SynGutter::SynGutter(QObject *parent): mGradientSteps = 48; } -QFont SynGutter::font() const +QFont Gutter::font() const { return mFont; } -void SynGutter::setFont(const QFont &font) +void Gutter::setFont(const QFont &font) { if (mFont != font) { mFont = font; @@ -56,12 +56,12 @@ void SynGutter::setFont(const QFont &font) } } -bool SynGutter::autoSize() const +bool Gutter::autoSize() const { return mAutoSize; } -void SynGutter::setAutoSize(bool value) +void Gutter::setAutoSize(bool value) { if (mAutoSize != value) { mAutoSize = value; @@ -69,27 +69,27 @@ void SynGutter::setAutoSize(bool value) } } -void SynGutter::setChanged() +void Gutter::setChanged() { emit changed(); } -const QColor &SynGutter::activeLineTextColor() const +const QColor &Gutter::activeLineTextColor() const { return mActiveLineTextColor; } -void SynGutter::setActiveLineTextColor(const QColor &newActiveLineTextColor) +void Gutter::setActiveLineTextColor(const QColor &newActiveLineTextColor) { mActiveLineTextColor = newActiveLineTextColor; } -QColor SynGutter::textColor() const +QColor Gutter::textColor() const { return mTextColor; } -void SynGutter::setTextColor(const QColor &value) +void Gutter::setTextColor(const QColor &value) { if (mTextColor!=value) { mTextColor = value; @@ -97,7 +97,7 @@ void SynGutter::setTextColor(const QColor &value) } } -void SynGutter::autoSizeDigitCount(int linesCount) +void Gutter::autoSizeDigitCount(int linesCount) { if (mVisible && mAutoSize && mShowLineNumbers) { linesCount += (mLineNumberStart - 1); @@ -109,7 +109,7 @@ void SynGutter::autoSizeDigitCount(int linesCount) } } -QString SynGutter::formatLineNumber(int line) +QString Gutter::formatLineNumber(int line) { line += (mLineNumberStart - 1); QString result = QString::number(line); @@ -120,7 +120,7 @@ QString SynGutter::formatLineNumber(int line) } } -int SynGutter::realGutterWidth(int charWidth) +int Gutter::realGutterWidth(int charWidth) { if (!mVisible) { return 0; @@ -131,12 +131,12 @@ int SynGutter::realGutterWidth(int charWidth) return mLeftOffset + mRightOffset; } -bool SynGutter::visible() const +bool Gutter::visible() const { return mVisible; } -void SynGutter::setVisible(bool visible) +void Gutter::setVisible(bool visible) { if (mVisible!=visible) { mVisible = visible; @@ -144,12 +144,12 @@ void SynGutter::setVisible(bool visible) } } -bool SynGutter::useFontStyle() const +bool Gutter::useFontStyle() const { return mUseFontStyle; } -void SynGutter::setUseFontStyle(bool useFontStyle) +void Gutter::setUseFontStyle(bool useFontStyle) { if (mUseFontStyle!=useFontStyle) { mUseFontStyle = useFontStyle; @@ -157,12 +157,12 @@ void SynGutter::setUseFontStyle(bool useFontStyle) } } -bool SynGutter::showLineNumbers() const +bool Gutter::showLineNumbers() const { return mShowLineNumbers; } -void SynGutter::setShowLineNumbers(bool showLineNumbers) +void Gutter::setShowLineNumbers(bool showLineNumbers) { if (mShowLineNumbers!=showLineNumbers) { mShowLineNumbers = showLineNumbers; @@ -170,12 +170,12 @@ void SynGutter::setShowLineNumbers(bool showLineNumbers) } } -int SynGutter::rightOffset() const +int Gutter::rightOffset() const { return mRightOffset; } -void SynGutter::setRightOffset(int rightOffset) +void Gutter::setRightOffset(int rightOffset) { int value = std::max(0, rightOffset); if (mRightOffset != value) { @@ -184,12 +184,12 @@ void SynGutter::setRightOffset(int rightOffset) } } -int SynGutter::lineNumberStart() const +int Gutter::lineNumberStart() const { return mLineNumberStart; } -void SynGutter::setLineNumberStart(int lineNumberStart) +void Gutter::setLineNumberStart(int lineNumberStart) { int value = std::max(0,lineNumberStart); if (mLineNumberStart!=value) { @@ -198,17 +198,17 @@ void SynGutter::setLineNumberStart(int lineNumberStart) } } -bool SynGutter::zeroStart() +bool Gutter::zeroStart() { return mLineNumberStart == 0; } -int SynGutter::leftOffset() const +int Gutter::leftOffset() const { return mLeftOffset; } -void SynGutter::setLeftOffset(int leftOffset) +void Gutter::setLeftOffset(int leftOffset) { int value = std::max(0,leftOffset); if (mLeftOffset != value) { @@ -217,12 +217,12 @@ void SynGutter::setLeftOffset(int leftOffset) } } -bool SynGutter::leadingZeros() const +bool Gutter::leadingZeros() const { return mLeadingZeros; } -void SynGutter::setLeadingZeros(bool value) +void Gutter::setLeadingZeros(bool value) { if (mLeadingZeros!=value) { mLeadingZeros = value; @@ -230,12 +230,12 @@ void SynGutter::setLeadingZeros(bool value) } } -int SynGutter::gradientSteps() const +int Gutter::gradientSteps() const { return mGradientSteps; } -void SynGutter::setGradientSteps(int value) +void Gutter::setGradientSteps(int value) { if (mGradientSteps!=value) { mGradientSteps = value; @@ -245,12 +245,12 @@ void SynGutter::setGradientSteps(int value) } } -QColor SynGutter::gradientEndColor() const +QColor Gutter::gradientEndColor() const { return mGradientEndColor; } -void SynGutter::setGradientEndColor(const QColor &value) +void Gutter::setGradientEndColor(const QColor &value) { if (mGradientEndColor!=value) { mGradientEndColor = value; @@ -258,12 +258,12 @@ void SynGutter::setGradientEndColor(const QColor &value) } } -QColor SynGutter::gradientStartColor() const +QColor Gutter::gradientStartColor() const { return mGradientStartColor; } -void SynGutter::setGradientStartColor(const QColor &value) +void Gutter::setGradientStartColor(const QColor &value) { if (mGradientStartColor!=value) { mGradientStartColor = value; @@ -271,12 +271,12 @@ void SynGutter::setGradientStartColor(const QColor &value) } } -bool SynGutter::gradient() const +bool Gutter::gradient() const { return mGradient; } -void SynGutter::setGradient(bool value) +void Gutter::setGradient(bool value) { if (mGradient!=value){ mGradient = value; @@ -284,12 +284,12 @@ void SynGutter::setGradient(bool value) } } -SynGutterBorderStyle SynGutter::borderStyle() const +GutterBorderStyle Gutter::borderStyle() const { return mBorderStyle; } -void SynGutter::setBorderStyle(const SynGutterBorderStyle &value) +void Gutter::setBorderStyle(const GutterBorderStyle &value) { if (mBorderStyle!=value) { mBorderStyle = value; @@ -297,12 +297,12 @@ void SynGutter::setBorderStyle(const SynGutterBorderStyle &value) } } -int SynGutter::digitCount() const +int Gutter::digitCount() const { return mDigitCount; } -void SynGutter::setDigitCount(int value) +void Gutter::setDigitCount(int value) { if (mDigitCount != value ) { mDigitCount = value; @@ -310,12 +310,12 @@ void SynGutter::setDigitCount(int value) } } -QColor SynGutter::color() const +QColor Gutter::color() const { return mColor; } -void SynGutter::setColor(const QColor &value) +void Gutter::setColor(const QColor &value) { if (mColor!=value) { mColor = value; @@ -323,12 +323,12 @@ void SynGutter::setColor(const QColor &value) } } -QColor SynGutter::borderColor() const +QColor Gutter::borderColor() const { return mBorderColor; } -void SynGutter::setBorderColor(const QColor &value) +void Gutter::setBorderColor(const QColor &value) { if (mBorderColor!=value) { mBorderColor = value; diff --git a/libs/qsynedit/qsynedit/MiscClasses.h b/libs/qsynedit/qsynedit/MiscClasses.h index cbf3019c..2b496415 100644 --- a/libs/qsynedit/qsynedit/MiscClasses.h +++ b/libs/qsynedit/qsynedit/MiscClasses.h @@ -24,16 +24,16 @@ namespace QSynedit { -enum class SynGutterBorderStyle { +enum class GutterBorderStyle { None, Middle, Right }; -class SynGutter : public QObject { +class Gutter : public QObject { Q_OBJECT public: - explicit SynGutter(QObject* parent = nullptr); + explicit Gutter(QObject* parent = nullptr); QFont font() const; void setFont(const QFont &value); @@ -49,8 +49,8 @@ public: int digitCount() const; void setDigitCount(int value); - SynGutterBorderStyle borderStyle() const; - void setBorderStyle(const SynGutterBorderStyle &value); + GutterBorderStyle borderStyle() const; + void setBorderStyle(const GutterBorderStyle &value); bool gradient() const; void setGradient(bool value); @@ -118,13 +118,13 @@ private: int mLineNumberStart; int mRightOffset; bool mShowLineNumbers; - SynGutterBorderStyle mBorderStyle; + GutterBorderStyle mBorderStyle; bool mUseFontStyle; bool mVisible; int mAutoSizeDigitCount; }; -using PSynGutter = std::shared_ptr; +using PSynGutter = std::shared_ptr; } diff --git a/libs/qsynedit/qsynedit/MiscProcs.cpp b/libs/qsynedit/qsynedit/MiscProcs.cpp index a0eb83e8..3be7a781 100644 --- a/libs/qsynedit/qsynedit/MiscProcs.cpp +++ b/libs/qsynedit/qsynedit/MiscProcs.cpp @@ -42,11 +42,11 @@ int getEOL(const QString &Line, int start) return Line.size(); } -bool internalEnumHighlighterAttris(PSynHighlighter Highlighter, +bool internalEnumHighlighterAttris(PHighlighter Highlighter, bool SkipDuplicates, HighlighterAttriProc highlighterAttriProc, std::initializer_list& Params, - SynHighlighterList& HighlighterList) { + HighlighterList& HighlighterList) { bool Result = true; if (HighlighterList.indexOf(Highlighter)>0) { if (SkipDuplicates) @@ -54,10 +54,10 @@ bool internalEnumHighlighterAttris(PSynHighlighter Highlighter, } else { HighlighterList.append(Highlighter); } - if (Highlighter->getClass() == SynHighlighterClass::Composition) { + if (Highlighter->getClass() == HighlighterClass::Composition) { //todo: handle composition highlighter } else if (Highlighter) { - for (PSynHighlighterAttribute pAttr: Highlighter->attributes()){ + for (PHighlighterAttribute pAttr: Highlighter->attributes()){ QString UniqueAttriName = Highlighter->getName() + QString("%1").arg(HighlighterList.indexOf(Highlighter)) + '.' + pAttr->name(); @@ -70,7 +70,7 @@ bool internalEnumHighlighterAttris(PSynHighlighter Highlighter, return Result; } -bool enumHighlighterAttributes(PSynHighlighter Highlighter, bool SkipDuplicates, +bool enumHighlighterAttributes(PHighlighter Highlighter, bool SkipDuplicates, HighlighterAttriProc highlighterAttriProc, std::initializer_list Params) { @@ -78,7 +78,7 @@ bool enumHighlighterAttributes(PSynHighlighter Highlighter, bool SkipDuplicates, return false; } - SynHighlighterList HighlighterList; + HighlighterList HighlighterList; return internalEnumHighlighterAttris(Highlighter, SkipDuplicates, highlighterAttriProc, Params, HighlighterList); } @@ -89,13 +89,13 @@ int mulDiv(int a, int b, int c) return a*b/c; } -SynFontStyles getFontStyles(const QFont &font) +FontStyles getFontStyles(const QFont &font) { - SynFontStyles styles; - styles.setFlag(SynFontStyle::fsBold, font.bold()); - styles.setFlag(SynFontStyle::fsItalic, font.italic()); - styles.setFlag(SynFontStyle::fsUnderline, font.underline()); - styles.setFlag(SynFontStyle::fsStrikeOut, font.strikeOut()); + FontStyles styles; + styles.setFlag(FontStyle::fsBold, font.bold()); + styles.setFlag(FontStyle::fsItalic, font.italic()); + styles.setFlag(FontStyle::fsUnderline, font.underline()); + styles.setFlag(FontStyle::fsStrikeOut, font.strikeOut()); return styles; } diff --git a/libs/qsynedit/qsynedit/MiscProcs.h b/libs/qsynedit/qsynedit/MiscProcs.h index 07578c2f..0a4854cc 100644 --- a/libs/qsynedit/qsynedit/MiscProcs.h +++ b/libs/qsynedit/qsynedit/MiscProcs.h @@ -46,18 +46,18 @@ QStringList splitStrings(const QString& text); int calSpanLines(const BufferCoord& startPos, const BufferCoord& endPos); -using HighlighterAttriProc = std::function 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 enumHighlighterAttributes(PSynHighlighter Highlighter, +bool enumHighlighterAttributes(PHighlighter Highlighter, bool SkipDuplicates, HighlighterAttriProc highlighterAttriProc, std::initializer_list Params); -SynFontStyles getFontStyles(const QFont& font); +FontStyles getFontStyles(const QFont& font); /** * Find the first occurency of word char in s, starting from startPos diff --git a/libs/qsynedit/qsynedit/Search.cpp b/libs/qsynedit/qsynedit/Search.cpp index 31a492a0..36661dfa 100644 --- a/libs/qsynedit/qsynedit/Search.cpp +++ b/libs/qsynedit/qsynedit/Search.cpp @@ -18,31 +18,31 @@ namespace QSynedit { -SynSearch::SynSearch(QObject *parent):SynSearchBase(parent) +BasicSearcher::BasicSearcher(QObject *parent):BaseSearcher(parent) { } -int SynSearch::length(int aIndex) +int BasicSearcher::length(int aIndex) { if (aIndex<0 || aIndex >= mResults.length()) return 0; return pattern().length(); } -int SynSearch::result(int aIndex) +int BasicSearcher::result(int aIndex) { if (aIndex<0 || aIndex >= mResults.length()) return -1; return mResults[aIndex]; } -int SynSearch::resultCount() +int BasicSearcher::resultCount() { return mResults.count(); } -int SynSearch::findAll(const QString &text) +int BasicSearcher::findAll(const QString &text) { mResults.clear(); if (pattern().isEmpty()) @@ -74,12 +74,12 @@ int SynSearch::findAll(const QString &text) return mResults.size(); } -QString SynSearch::replace(const QString &, const QString &aReplacement) +QString BasicSearcher::replace(const QString &, const QString &aReplacement) { return aReplacement; } -bool SynSearch::isDelimitChar(QChar ch) +bool BasicSearcher::isDelimitChar(QChar ch) { return !(ch == '_' || ch.isLetterOrNumber()); } diff --git a/libs/qsynedit/qsynedit/Search.h b/libs/qsynedit/qsynedit/Search.h index b40c67f0..127ad3db 100644 --- a/libs/qsynedit/qsynedit/Search.h +++ b/libs/qsynedit/qsynedit/Search.h @@ -20,11 +20,11 @@ namespace QSynedit { -class SynSearch : public SynSearchBase +class BasicSearcher : public BaseSearcher { Q_OBJECT public: - explicit SynSearch(QObject* parent = nullptr); + explicit BasicSearcher(QObject* parent = nullptr); // SynSearchBase interface public: diff --git a/libs/qsynedit/qsynedit/SearchBase.cpp b/libs/qsynedit/qsynedit/SearchBase.cpp index 9255eaef..85573906 100644 --- a/libs/qsynedit/qsynedit/SearchBase.cpp +++ b/libs/qsynedit/qsynedit/SearchBase.cpp @@ -17,27 +17,27 @@ #include "SearchBase.h" namespace QSynedit { -SynSearchBase::SynSearchBase(QObject *parent) : QObject(parent) +BaseSearcher::BaseSearcher(QObject *parent) : QObject(parent) { } -QString SynSearchBase::pattern() +QString BaseSearcher::pattern() { return mPattern; } -void SynSearchBase::setPattern(const QString &value) +void BaseSearcher::setPattern(const QString &value) { mPattern = value; } -SynSearchOptions SynSearchBase::options() const +SearchOptions BaseSearcher::options() const { return mOptions; } -void SynSearchBase::setOptions(const SynSearchOptions &options) +void BaseSearcher::setOptions(const SearchOptions &options) { mOptions = options; } diff --git a/libs/qsynedit/qsynedit/SearchBase.h b/libs/qsynedit/qsynedit/SearchBase.h index 0d5dac92..62d5d9c8 100644 --- a/libs/qsynedit/qsynedit/SearchBase.h +++ b/libs/qsynedit/qsynedit/SearchBase.h @@ -22,7 +22,7 @@ namespace QSynedit { -enum SynSearchOption { +enum SearchOption { ssoMatchCase = 0x0001, ssoWholeWord = 0x0002, ssoBackwards = 0x0004, @@ -32,14 +32,14 @@ enum SynSearchOption { ssoRegExp = 0x0080 }; -Q_DECLARE_FLAGS(SynSearchOptions, SynSearchOption) -Q_DECLARE_OPERATORS_FOR_FLAGS(SynSearchOptions) +Q_DECLARE_FLAGS(SearchOptions, SearchOption) +Q_DECLARE_OPERATORS_FOR_FLAGS(SearchOptions) -class SynSearchBase : public QObject +class BaseSearcher : public QObject { Q_OBJECT public: - explicit SynSearchBase(QObject *parent = nullptr); + explicit BaseSearcher(QObject *parent = nullptr); QString pattern(); virtual void setPattern(const QString& value); virtual int length(int aIndex) = 0; @@ -47,15 +47,15 @@ public: virtual int resultCount() = 0; virtual int findAll(const QString& text) = 0; virtual QString replace(const QString& aOccurrence, const QString& aReplacement) = 0; - SynSearchOptions options() const; - virtual void setOptions(const SynSearchOptions &options); + SearchOptions options() const; + virtual void setOptions(const SearchOptions &options); private: QString mPattern; - SynSearchOptions mOptions; + SearchOptions mOptions; }; -using PSynSearchBase = std::shared_ptr; +using PSynSearchBase = std::shared_ptr; } diff --git a/libs/qsynedit/qsynedit/SearchRegex.cpp b/libs/qsynedit/qsynedit/SearchRegex.cpp index 48bdfbda..612c089f 100644 --- a/libs/qsynedit/qsynedit/SearchRegex.cpp +++ b/libs/qsynedit/qsynedit/SearchRegex.cpp @@ -20,31 +20,31 @@ namespace QSynedit { -SynSearchRegex::SynSearchRegex(QObject* parent):SynSearchBase(parent) +RegexSearcher::RegexSearcher(QObject* parent):BaseSearcher(parent) { } -int SynSearchRegex::length(int aIndex) +int RegexSearcher::length(int aIndex) { if (aIndex<0 || aIndex >= mResults.length()) return -1; return mLengths[aIndex]; } -int SynSearchRegex::result(int aIndex) +int RegexSearcher::result(int aIndex) { if (aIndex<0 || aIndex >= mResults.length()) return -1; return mResults[aIndex]; } -int SynSearchRegex::resultCount() +int RegexSearcher::resultCount() { return mResults.size(); } -int SynSearchRegex::findAll(const QString &text) +int RegexSearcher::findAll(const QString &text) { if (pattern().isEmpty()) return 0; @@ -59,28 +59,28 @@ int SynSearchRegex::findAll(const QString &text) return mResults.size(); } -QString SynSearchRegex::replace(const QString &aOccurrence, const QString &aReplacement) +QString RegexSearcher::replace(const QString &aOccurrence, const QString &aReplacement) { QString s=aOccurrence; return s.replace(mRegex,aReplacement); } -void SynSearchRegex::setPattern(const QString &value) +void RegexSearcher::setPattern(const QString &value) { - SynSearchBase::setPattern(value); + BaseSearcher::setPattern(value); mRegex.setPattern(value); updateRegexOptions(); } -void SynSearchRegex::setOptions(const SynSearchOptions &options) +void RegexSearcher::setOptions(const SearchOptions &options) { - SynSearchBase::setOptions(options); + BaseSearcher::setOptions(options); updateRegexOptions(); } -void SynSearchRegex::updateRegexOptions() +void RegexSearcher::updateRegexOptions() { - if (options().testFlag(SynSearchOption::ssoMatchCase)) { + if (options().testFlag(SearchOption::ssoMatchCase)) { mRegex.setPatternOptions( mRegex.patternOptions() & ~QRegularExpression::CaseInsensitiveOption); diff --git a/libs/qsynedit/qsynedit/SearchRegex.h b/libs/qsynedit/qsynedit/SearchRegex.h index 8b1da602..a0d2fd38 100644 --- a/libs/qsynedit/qsynedit/SearchRegex.h +++ b/libs/qsynedit/qsynedit/SearchRegex.h @@ -21,11 +21,11 @@ #include namespace QSynedit { -class SynSearchRegex : public SynSearchBase +class RegexSearcher : public BaseSearcher { Q_OBJECT public: - explicit SynSearchRegex(QObject* parent=nullptr); + explicit RegexSearcher(QObject* parent=nullptr); // SynSearchBase interface public: @@ -35,7 +35,7 @@ public: int findAll(const QString &text) override; QString replace(const QString &aOccurrence, const QString &aReplacement) override; void setPattern(const QString &value) override; - void setOptions(const SynSearchOptions &options) override; + void setOptions(const SearchOptions &options) override; private: void updateRegexOptions(); private: diff --git a/libs/qsynedit/qsynedit/SynEdit.cpp b/libs/qsynedit/qsynedit/SynEdit.cpp index 307b2282..2ead2620 100644 --- a/libs/qsynedit/qsynedit/SynEdit.cpp +++ b/libs/qsynedit/qsynedit/SynEdit.cpp @@ -75,9 +75,7 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent), mDocument->connect(mDocument.get(), &SynDocument::putted, this, &SynEdit::onLinesPutted); mGutterWidth = 0; - mScrollBars = SynScrollStyle::ssBoth; - - + mScrollBars = ScrollStyle::ssBoth; mUndoList = std::make_shared(); mUndoList->connect(mUndoList.get(), &SynEditUndoList::addedUndo, this, &SynEdit::onUndoAdded); @@ -99,7 +97,7 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent), mMouseSelectionScrollSpeed = 1; mGutter.setRightOffset(21); - mGutter.connect(&mGutter, &SynGutter::changed, this, &SynEdit::onGutterChanged); + mGutter.connect(&mGutter, &Gutter::changed, this, &SynEdit::onGutterChanged); mGutterWidth = mGutter.realGutterWidth(charWidth()); //ControlStyle := ControlStyle + [csOpaque, csSetCaption, csNeedsBorderPaint]; //Height := 150; @@ -112,10 +110,10 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent), this->setFrameShape(QFrame::Panel); this->setFrameShadow(QFrame::Sunken); this->setLineWidth(1); - mInsertCaret = SynEditCaretType::ctVerticalLine; - mOverwriteCaret = SynEditCaretType::ctBlock; - mSelectionMode = SynSelectionMode::Normal; - mActiveSelectionMode = SynSelectionMode::Normal; + mInsertCaret = EditCaretType::ctVerticalLine; + mOverwriteCaret = EditCaretType::ctBlock; + mSelectionMode = SelectionMode::Normal; + mActiveSelectionMode = SelectionMode::Normal; mReadOnly = false; //stop qt to auto fill background @@ -145,9 +143,6 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent), //mScrollTimer->setInterval(100); connect(mScrollTimer, &QTimer::timeout,this, &SynEdit::onScrollTimeout); - mScrollHintColor = Qt::yellow; - mScrollHintFormat = SynScrollHintFormat::shfTopLineOnly; - qreal dpr=devicePixelRatioF(); mContentImage = std::make_shared(clientWidth()*dpr,clientHeight()*dpr,QImage::Format_ARGB32); mContentImage->setDevicePixelRatio(dpr); @@ -232,18 +227,14 @@ void SynEdit::setCaretXY(const BufferCoord &value) void SynEdit::setCaretXYEx(bool CallEnsureCursorPosVisible, BufferCoord value) { - bool vTriggerPaint=true; //how to test it? - - if (vTriggerPaint) - doOnPaintTransient(SynTransientType::ttBefore); int nMaxX; if (value.line > mDocument->count()) value.line = mDocument->count(); - if (mActiveSelectionMode!=SynSelectionMode::Column) { + if (mActiveSelectionMode!=SelectionMode::Column) { if (value.line < 1) { // this is just to make sure if Lines stringlist should be empty value.line = 1; - if (!mOptions.testFlag(SynEditorOption::eoScrollPastEol)) { + if (!mOptions.testFlag(EditorOption::eoScrollPastEol)) { nMaxX = 1; } else { nMaxX = getDisplayStringAtLine(value.line).length()+1; @@ -266,7 +257,7 @@ void SynEdit::setCaretXYEx(bool CallEnsureCursorPosVisible, BufferCoord value) // simply include the flags, fPaintLock is > 0 if (mCaretX != value.ch) { mCaretX = value.ch; - mStatusChanges.setFlag(SynStatusChange::scCaretX); + mStatusChanges.setFlag(StatusChange::scCaretX); invalidateLine(mCaretY); } if (mCaretY != value.line) { @@ -276,7 +267,7 @@ void SynEdit::setCaretXYEx(bool CallEnsureCursorPosVisible, BufferCoord value) invalidateGutterLine(mCaretY); invalidateLine(oldCaretY); invalidateGutterLine(oldCaretY); - mStatusChanges.setFlag(SynStatusChange::scCaretY); + mStatusChanges.setFlag(StatusChange::scCaretY); } // Call UpdateLastCaretX before DecPaintLock because the event handler it // calls could raise an exception, and we don't want fLastCaretX to be @@ -284,8 +275,8 @@ void SynEdit::setCaretXYEx(bool CallEnsureCursorPosVisible, BufferCoord value) updateLastCaretX(); if (CallEnsureCursorPosVisible) ensureCursorPosVisible(); - mStateFlags.setFlag(SynStateFlag::sfCaretChanged); - mStateFlags.setFlag(SynStateFlag::sfScrollbarChanged); + mStateFlags.setFlag(StateFlag::sfCaretChanged); + mStateFlags.setFlag(StateFlag::sfScrollbarChanged); } else { // Also call UpdateLastCaretX if the caret didn't move. Apps don't know // anything about fLastCaretX and they shouldn't need to. So, to avoid any @@ -296,8 +287,6 @@ void SynEdit::setCaretXYEx(bool CallEnsureCursorPosVisible, BufferCoord value) // restore it afterward as appropriate. updateLastCaretX(); } - if (vTriggerPaint) - doOnPaintTransient(SynTransientType::ttAfter); } @@ -307,7 +296,7 @@ void SynEdit::setCaretXYCentered(const BufferCoord &value) auto action = finally([this] { decPaintLock(); }); - mStatusChanges.setFlag(SynStatusChange::scSelection); + mStatusChanges.setFlag(StatusChange::scSelection); setCaretXYEx(false,value); if (selAvail()) invalidateSelection(); @@ -320,7 +309,7 @@ void SynEdit::setCaretXYCentered(const BufferCoord &value) void SynEdit::uncollapseAroundLine(int line) { while (true) { // Open up the closed folds around the focused line until we can see the line we're looking for - PSynEditFoldRange fold = foldHidesLine(line); + PCodeFoldingRange fold = foldHidesLine(line); if (fold) uncollapse(fold); else @@ -328,7 +317,7 @@ void SynEdit::uncollapseAroundLine(int line) } } -PSynEditFoldRange SynEdit::foldHidesLine(int line) +PCodeFoldingRange SynEdit::foldHidesLine(int line) { return foldAroundLineEx(line, true, false, true); } @@ -368,14 +357,14 @@ int SynEdit::maxScrollWidth() const return std::max(maxLen-mCharsInWindow+1, 1); } -bool SynEdit::getHighlighterAttriAtRowCol(const BufferCoord &pos, QString &token, PSynHighlighterAttribute &attri) +bool SynEdit::getHighlighterAttriAtRowCol(const BufferCoord &pos, QString &token, PHighlighterAttribute &attri) { - SynHighlighterTokenType tmpType; + TokenType tmpType; int tmpKind, tmpStart; return getHighlighterAttriAtRowColEx(pos, token, tmpType, tmpKind,tmpStart, attri); } -bool SynEdit::getHighlighterAttriAtRowCol(const BufferCoord &pos, QString &token, bool &tokenFinished, SynHighlighterTokenType &tokenType, PSynHighlighterAttribute &attri) +bool SynEdit::getHighlighterAttriAtRowCol(const BufferCoord &pos, QString &token, bool &tokenFinished, TokenType &tokenType, PHighlighterAttribute &attri) { int posX, posY, endPos, start; QString line; @@ -408,12 +397,12 @@ bool SynEdit::getHighlighterAttriAtRowCol(const BufferCoord &pos, QString &token } } token = ""; - attri = PSynHighlighterAttribute(); + attri = PHighlighterAttribute(); tokenFinished = false; return false; } -bool SynEdit::getHighlighterAttriAtRowColEx(const BufferCoord &pos, QString &token, SynHighlighterTokenType &tokenType, SynTokenKind &tokenKind, int &start, PSynHighlighterAttribute &attri) +bool SynEdit::getHighlighterAttriAtRowColEx(const BufferCoord &pos, QString &token, TokenType &tokenType, TokenKind &tokenKind, int &start, PHighlighterAttribute &attri) { int posX, posY, endPos; QString line; @@ -443,9 +432,9 @@ bool SynEdit::getHighlighterAttriAtRowColEx(const BufferCoord &pos, QString &tok } } token = ""; - attri = PSynHighlighterAttribute(); + attri = PHighlighterAttribute(); tokenKind = 0; - tokenType = SynHighlighterTokenType::Default; + tokenType = TokenType::Default; return false; } @@ -502,7 +491,7 @@ BufferCoord SynEdit::getMatchingBracketEx(BufferCoord APoint) QChar Test, BracketInc, BracketDec; int NumBrackets; QString vDummy; - PSynHighlighterAttribute attr; + PHighlighterAttribute attr; BufferCoord p; bool isCommentOrStringOrChar; int nBrackets = sizeof(Brackets) / sizeof(QChar); @@ -674,7 +663,7 @@ void SynEdit::invalidateGutterLines(int FirstLine, int LastLine) return; if (FirstLine == -1 && LastLine == -1) { rcInval = QRect(0, 0, mGutterWidth, clientHeight()); - if (mStateFlags.testFlag(SynStateFlag::sfLinesChanging)) + if (mStateFlags.testFlag(StateFlag::sfLinesChanging)) mInvalidateRect = mInvalidateRect.united(rcInval); else invalidateRect(rcInval); @@ -695,7 +684,7 @@ void SynEdit::invalidateGutterLines(int FirstLine, int LastLine) if (LastLine >= FirstLine) { rcInval = {0, mTextHeight * (FirstLine - mTopLine), mGutterWidth, mTextHeight * (LastLine - mTopLine + 1)}; - if (mStateFlags.testFlag(SynStateFlag::sfLinesChanging)) { + if (mStateFlags.testFlag(StateFlag::sfLinesChanging)) { mInvalidateRect = mInvalidateRect.united(rcInval); } else { invalidateRect(rcInval); @@ -917,7 +906,7 @@ int SynEdit::foldRowToLine(int Row) const { int result = Row; for (int i=0;icollapsed && !range->parentCollapsed() && range->fromLine < result) { result += range->linesCollapsed; } @@ -929,7 +918,7 @@ int SynEdit::foldLineToRow(int Line) const { int result = Line; for (int i=mAllFoldRanges.count()-1;i>=0;i--) { - PSynEditFoldRange range =mAllFoldRanges[i]; + PCodeFoldingRange range =mAllFoldRanges[i]; if (range->collapsed && !range->parentCollapsed()) { // Line is found after fold if (range->toLine < Line) @@ -969,7 +958,7 @@ void SynEdit::invalidateLine(int Line) mTextHeight * (Line - mTopLine), clientWidth(), mTextHeight}; - if (mStateFlags.testFlag(SynStateFlag::sfLinesChanging)) + if (mStateFlags.testFlag(StateFlag::sfLinesChanging)) mInvalidateRect = mInvalidateRect.united(rcInval); else invalidateRect(rcInval); @@ -986,7 +975,7 @@ void SynEdit::invalidateLines(int FirstLine, int LastLine) if (FirstLine == -1 && LastLine == -1) { QRect rcInval = clientRect(); rcInval.setLeft(rcInval.left()+mGutterWidth); - if (mStateFlags.testFlag(SynStateFlag::sfLinesChanging)) { + if (mStateFlags.testFlag(StateFlag::sfLinesChanging)) { mInvalidateRect = mInvalidateRect.united(rcInval); } else { invalidateRect(rcInval); @@ -1021,7 +1010,7 @@ void SynEdit::invalidateLines(int FirstLine, int LastLine) mTextHeight * (FirstLine - mTopLine), clientWidth(), mTextHeight * (LastLine - mTopLine + 1) }; - if (mStateFlags.testFlag(SynStateFlag::sfLinesChanging)) + if (mStateFlags.testFlag(StateFlag::sfLinesChanging)) mInvalidateRect = mInvalidateRect.united(rcInval); else invalidateRect(rcInval); @@ -1066,7 +1055,7 @@ bool SynEdit::selAvail() const if (mBlockBegin.ch == mBlockEnd.ch && mBlockBegin.line == mBlockEnd.line) return false; // start line != end line or start char != end char - if (mActiveSelectionMode==SynSelectionMode::Column) { + if (mActiveSelectionMode==SelectionMode::Column) { if (mBlockBegin.line != mBlockEnd.line) { DisplayCoord coordBegin = bufferToDisplayPos(mBlockBegin); DisplayCoord coordEnd = bufferToDisplayPos(mBlockEnd); @@ -1079,7 +1068,7 @@ bool SynEdit::selAvail() const bool SynEdit::colSelAvail() const { - if (mActiveSelectionMode != SynSelectionMode::Column) + if (mActiveSelectionMode != SelectionMode::Column) return false; if (mBlockBegin.ch == mBlockEnd.ch && mBlockBegin.line == mBlockEnd.line) return false; @@ -1216,7 +1205,7 @@ void SynEdit::processGutterClick(QMouseEvent *event) // Check if we clicked on a folding thing if (mUseCodeFolding) { - PSynEditFoldRange foldRange = foldStartAtLine(Line); + PCodeFoldingRange foldRange = foldStartAtLine(Line); if (foldRange) { // See if we actually clicked on the rectangle... //rect.Left := Gutter.RealGutterWidth(CharWidth) - Gutter.RightOffset; @@ -1253,7 +1242,7 @@ int SynEdit::findIndentsStartLine(int line, QVector indents) if (line<0 || line>=mDocument->count()) return -1; while (line>=1) { - SynRangeState range = mDocument->ranges(line); + HighlighterState range = mDocument->ranges(line); QVector newIndents = range.indents.mid(range.firstIndentThisLine); int i = 0; int len = indents.length(); @@ -1281,7 +1270,7 @@ BufferCoord SynEdit::getPreviousLeftBrace(int x, int y) { QChar Test; QString vDummy; - PSynHighlighterAttribute attr; + PHighlighterAttribute attr; BufferCoord p; bool isCommentOrStringOrChar; BufferCoord Result{0,0}; @@ -1364,9 +1353,9 @@ bool SynEdit::isPointInSelection(const BufferCoord &Value) const BufferCoord ptEnd = blockEnd(); if ((Value.line >= ptBegin.line) && (Value.line <= ptEnd.line) && ((ptBegin.line != ptEnd.line) || (ptBegin.ch != ptEnd.ch))) { - if (mActiveSelectionMode == SynSelectionMode::Line) + if (mActiveSelectionMode == SelectionMode::Line) return true; - else if (mActiveSelectionMode == SynSelectionMode::Column) { + else if (mActiveSelectionMode == SelectionMode::Column) { if (ptBegin.ch > ptEnd.ch) return (Value.ch >= ptEnd.ch) && (Value.ch < ptBegin.ch); else if (ptBegin.ch < ptEnd.ch) @@ -1552,7 +1541,7 @@ void SynEdit::doShrinkSelection(const BufferCoord &pos) int SynEdit::findCommentStartLine(int searchStartLine) { int commentStartLine = searchStartLine; - SynRangeState range; + HighlighterState range; while (commentStartLine>=1) { range = mDocument->ranges(commentStartLine-1); if (!mHighlighter->isLastLineCommentNotFinished(range.state)){ @@ -1590,7 +1579,7 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent) if (startLine>=1) { //calculate the indents of last statement; indentSpaces = leftSpaces(startLineText); - SynRangeState rangePreceeding = mDocument->ranges(startLine-1); + HighlighterState rangePreceeding = mDocument->ranges(startLine-1); mHighlighter->setState(rangePreceeding); if (addIndent) { // QString trimmedS = s.trimmed(); @@ -1602,9 +1591,9 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent) } else { statePrePre = 0; } - SynRangeState rangeAfterFirstToken = mHighlighter->getRangeState(); + HighlighterState rangeAfterFirstToken = mHighlighter->getState(); QString firstToken = mHighlighter->getToken(); - PSynHighlighterAttribute attr = mHighlighter->getTokenAttribute(); + PHighlighterAttribute attr = mHighlighter->getTokenAttribute(); if (attr == mHighlighter->keywordAttribute() && lineText.endsWith(':') && ( @@ -1615,7 +1604,7 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent) // public: private: protecte: case: should indents like it's parent statement mHighlighter->setState(rangePreceeding); mHighlighter->setLine("}",line-1); - rangeAfterFirstToken = mHighlighter->getRangeState(); + rangeAfterFirstToken = mHighlighter->getState(); firstToken = mHighlighter->getToken(); attr = mHighlighter->getTokenAttribute(); } @@ -1636,13 +1625,13 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent) matchingIndents = rangeAfterFirstToken.matchingIndents; indentAdded = true; l = startLine; - } else if (mHighlighter->getClass() == SynHighlighterClass::CppHighlighter + } else if (mHighlighter->getClass() == HighlighterClass::CppHighlighter && trimmedLineText.startsWith('#') - && attr == ((SynEditCppHighlighter *)mHighlighter.get())->preprocessorAttribute()) { + && attr == ((CppHighlighter *)mHighlighter.get())->preprocessorAttribute()) { indentAdded = true; indentSpaces=0; l=0; - } else if (mHighlighter->getClass() == SynHighlighterClass::CppHighlighter + } else if (mHighlighter->getClass() == HighlighterClass::CppHighlighter && mHighlighter->isLastLineCommentNotFinished(rangePreceeding.state) ) { // last line is a not finished comment, @@ -1652,7 +1641,7 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent) // the line the comment beginning , and add 1 additional space additionIndent = 1; int commentStartLine = findCommentStartLine(startLine-1); - SynRangeState range; + HighlighterState range; indentSpaces = leftSpaces(mDocument->getString(commentStartLine-1)); range = mDocument->ranges(commentStartLine-1); matchingIndents = range.matchingIndents; @@ -1662,7 +1651,7 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent) //indents according to the beginning of the comment and 2 additional space additionIndent = 0; int commentStartLine = findCommentStartLine(startLine-1); - SynRangeState range; + HighlighterState range; indentSpaces = leftSpaces(mDocument->getString(commentStartLine-1))+2; range = mDocument->ranges(commentStartLine-1); matchingIndents = range.matchingIndents; @@ -1676,7 +1665,7 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent) // the preceeding line is the end of comment // we should use the indents of the start line of the comment int commentStartLine = findCommentStartLine(startLine-2); - SynRangeState range; + HighlighterState range; indentSpaces = leftSpaces(mDocument->getString(commentStartLine-1)); range = mDocument->ranges(commentStartLine-1); matchingIndents = range.matchingIndents; @@ -1692,7 +1681,7 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent) ) { // find the indent's start line, and use it's indent as the default indent; while (l>=1) { - SynRangeState range = mDocument->ranges(l-1); + HighlighterState range = mDocument->ranges(l-1); QVector newIndents = range.indents.mid(range.firstIndentThisLine); int i = 0; int len = matchingIndents.length(); @@ -1737,7 +1726,7 @@ int SynEdit::calcIndentSpaces(int line, const QString& lineText, bool addIndent) if (!indentAdded && !startLineText.isEmpty()) { BufferCoord coord; QString token; - PSynHighlighterAttribute attr; + PHighlighterAttribute attr; coord.line = startLine; coord.ch = document()->getString(startLine-1).length(); if (getHighlighterAttriAtRowCol(coord,token,attr) @@ -1765,7 +1754,7 @@ void SynEdit::doSelectAll() } setCaretAndSelection(caretXY(), BufferCoord{1, 1}, LastPt); // Selection should have changed... - emit statusChanged(SynStatusChange::scSelection); + emit statusChanged(StatusChange::scSelection); } void SynEdit::doComment() @@ -1774,7 +1763,6 @@ void SynEdit::doComment() int endLine; if (mReadOnly) return; - doOnPaintTransient(SynTransientType::ttBefore); mUndoList->beginBlock(); auto action = finally([this]{ mUndoList->endBlock(); @@ -1792,7 +1780,7 @@ void SynEdit::doComment() mUndoList->addChange(SynChangeReason::Insert, BufferCoord{1, i + 1}, BufferCoord{3, i + 1}, - QStringList(), SynSelectionMode::Normal); + QStringList(), SelectionMode::Normal); } // When grouping similar commands, process one comment action per undo/redo mUndoList->addGroupBreak(); @@ -1817,7 +1805,6 @@ void SynEdit::doUncomment() changeText.append("//"); if (mReadOnly) return; - doOnPaintTransient(SynTransientType::ttBefore); mUndoList->beginBlock(); auto action = finally([this]{ mUndoList->endBlock(); @@ -1842,7 +1829,7 @@ void SynEdit::doUncomment() mUndoList->addChange(SynChangeReason::Delete, BufferCoord{j+1, i + 1}, BufferCoord{j + 3, i + 1}, - changeText, SynSelectionMode::Normal); + changeText, SelectionMode::Normal); // Move begin of selection if ((i == origBlockBegin.line - 1) && (origBlockBegin.ch > 1)) origBlockBegin.ch-=2; @@ -1867,7 +1854,6 @@ void SynEdit::doToggleComment() bool allCommented = true; if (mReadOnly) return; - doOnPaintTransient(SynTransientType::ttBefore); mUndoList->beginBlock(); auto action = finally([this]{ mUndoList->endBlock(); @@ -1912,7 +1898,6 @@ void SynEdit::doToggleBlockComment() QString s; if (mReadOnly) return; - doOnPaintTransient(SynTransientType::ttBefore); QString text=selText().trimmed(); if (text.length()>4 && text.startsWith("/*") && text.endsWith("*/")) { @@ -1972,7 +1957,7 @@ void SynEdit::doMouseScroll(bool isDragging) } BufferCoord vCaret = displayToBufferPos(C); if ((caretX() != vCaret.ch) || (caretY() != vCaret.line)) { - if (mActiveSelectionMode == SynSelectionMode::Column) { + if (mActiveSelectionMode == SelectionMode::Column) { int startLine=std::min(mBlockBegin.line,mBlockEnd.line); startLine = std::min(startLine,vCaret.line); int endLine=std::max(mBlockBegin.line,mBlockEnd.line); @@ -2003,7 +1988,7 @@ void SynEdit::doMouseScroll(bool isDragging) } else setBlockEnd(caretXY()); - if (mOptions.testFlag(SynEditorOption::eoGroupUndo)) + if (mOptions.testFlag(EditorOption::eoGroupUndo)) mUndoList->addGroupBreak(); } if (isDragging) { @@ -2018,7 +2003,7 @@ void SynEdit::doMouseScroll(bool isDragging) QString SynEdit::getDisplayStringAtLine(int line) const { QString s = mDocument->getString(line-1); - PSynEditFoldRange foldRange = foldStartAtLine(line); + PCodeFoldingRange foldRange = foldStartAtLine(line); if ((foldRange) && foldRange->collapsed) { return s+highlighter()->foldString(); } @@ -2029,13 +2014,11 @@ void SynEdit::doDeleteLastChar() { if (mReadOnly) return ; - doOnPaintTransientEx(SynTransientType::ttBefore, true); auto action = finally([this]{ ensureCursorPosVisible(); - doOnPaintTransientEx(SynTransientType::ttAfter, true); }); - if (mActiveSelectionMode==SynSelectionMode::Column) { + if (mActiveSelectionMode==SelectionMode::Column) { BufferCoord start=blockBegin(); BufferCoord end=blockEnd(); if (!selAvail()) { @@ -2116,13 +2099,11 @@ void SynEdit::doDeleteCurrentChar() if (mReadOnly) { return; } - doOnPaintTransient(SynTransientType::ttBefore); auto action = finally([this]{ ensureCursorPosVisible(); - doOnPaintTransient(SynTransientType::ttAfter); }); - if (mActiveSelectionMode==SynSelectionMode::Column) { + if (mActiveSelectionMode==SelectionMode::Column) { BufferCoord start=blockBegin(); BufferCoord end=blockEnd(); if (!selAvail()) { @@ -2244,10 +2225,9 @@ void SynEdit::doDeleteFromBOL() void SynEdit::doDeleteLine() { if (!mReadOnly && (mDocument->count() > 0)) { - PSynEditFoldRange foldRange=foldStartAtLine(mCaretY); + PCodeFoldingRange foldRange=foldStartAtLine(mCaretY); if (foldRange && foldRange->collapsed) return; - doOnPaintTransient(SynTransientType::ttBefore); mUndoList->beginBlock(); addCaretToUndo(); addSelectionToUndo(); @@ -2260,7 +2240,7 @@ void SynEdit::doDeleteLine() mUndoList->addChange(SynChangeReason::Delete, BufferCoord{1, mCaretY}, BufferCoord{helper.length() + 1, mCaretY}, - helper, SynSelectionMode::Normal); + helper, SelectionMode::Normal); } else { QString s = mDocument->getString(mCaretY-2); mDocument->deleteAt(mCaretY - 1); @@ -2268,7 +2248,7 @@ void SynEdit::doDeleteLine() mUndoList->addChange(SynChangeReason::Delete, BufferCoord{s.length()+1, mCaretY-1}, BufferCoord{helper.length() + 1, mCaretY}, - helper, SynSelectionMode::Normal); + helper, SelectionMode::Normal); doLinesDeleted(mCaretY, 1); mCaretY--; } @@ -2278,12 +2258,11 @@ void SynEdit::doDeleteLine() mUndoList->addChange(SynChangeReason::Delete, BufferCoord{1, mCaretY}, BufferCoord{helper.length() + 1, mCaretY}, - helper, SynSelectionMode::Normal); + helper, SelectionMode::Normal); doLinesDeleted(mCaretY, 1); } mUndoList->endBlock(); internalSetCaretXY(BufferCoord{1, mCaretY}); // like seen in the Delphi editor - doOnPaintTransient(SynTransientType::ttAfter); } } @@ -2299,30 +2278,28 @@ void SynEdit::doSelecteLine() void SynEdit::doDuplicateLine() { if (!mReadOnly && (mDocument->count() > 0)) { - PSynEditFoldRange foldRange=foldStartAtLine(mCaretY); + PCodeFoldingRange foldRange=foldStartAtLine(mCaretY); if (foldRange && foldRange->collapsed) return; QString s = lineText(); - doOnPaintTransient(SynTransientType::ttBefore); mDocument->insert(mCaretY, lineText()); doLinesInserted(mCaretY + 1, 1); mUndoList->beginBlock(); addCaretToUndo(); mUndoList->addChange(SynChangeReason::LineBreak, BufferCoord{s.length()+1,mCaretY}, - BufferCoord{s.length()+1,mCaretY}, QStringList(), SynSelectionMode::Normal); + BufferCoord{s.length()+1,mCaretY}, QStringList(), SelectionMode::Normal); mUndoList->addChange(SynChangeReason::Insert, BufferCoord{1,mCaretY+1}, - BufferCoord{s.length()+1,mCaretY+1}, QStringList(), SynSelectionMode::Normal); + BufferCoord{s.length()+1,mCaretY+1}, QStringList(), SelectionMode::Normal); mUndoList->endBlock(); internalSetCaretXY(BufferCoord{1, mCaretY}); // like seen in the Delphi editor - doOnPaintTransient(SynTransientType::ttAfter); } } void SynEdit::doMoveSelUp() { - if (mActiveSelectionMode == SynSelectionMode::Column) + if (mActiveSelectionMode == SelectionMode::Column) return; if (!mReadOnly && (mDocument->count() > 0) && (blockBegin().line > 1)) { if (!mUndoing) { @@ -2332,7 +2309,7 @@ void SynEdit::doMoveSelUp() } BufferCoord origBlockBegin = blockBegin(); BufferCoord origBlockEnd = blockEnd(); - PSynEditFoldRange foldRange=foldStartAtLine(origBlockEnd.line); + PCodeFoldingRange foldRange=foldStartAtLine(origBlockEnd.line); if (foldRange && foldRange->collapsed) return; // for (int line=origBlockBegin.Line;line<=origBlockEnd.Line;line++) { @@ -2341,8 +2318,6 @@ void SynEdit::doMoveSelUp() // return; // } - doOnPaintTransient(SynTransientType::ttBefore); - // Delete line above selection QString s = mDocument->getString(origBlockBegin.line - 2); // before start, 0 based mDocument->deleteAt(origBlockBegin.line - 2); // before start, 0 based @@ -2362,17 +2337,15 @@ void SynEdit::doMoveSelUp() origBlockBegin, origBlockEnd, QStringList(), - SynSelectionMode::Normal); + SelectionMode::Normal); mUndoList->endBlock(); } - - doOnPaintTransient(SynTransientType::ttAfter); } } void SynEdit::doMoveSelDown() { - if (mActiveSelectionMode == SynSelectionMode::Column) + if (mActiveSelectionMode == SelectionMode::Column) return; if (!mReadOnly && (mDocument->count() > 0) && (blockEnd().line < mDocument->count())) { if (!mUndoing) { @@ -2383,12 +2356,10 @@ void SynEdit::doMoveSelDown() BufferCoord origBlockBegin = blockBegin(); BufferCoord origBlockEnd = blockEnd(); - PSynEditFoldRange foldRange=foldStartAtLine(origBlockEnd.line); + PCodeFoldingRange foldRange=foldStartAtLine(origBlockEnd.line); if (foldRange && foldRange->collapsed) return; - doOnPaintTransient(SynTransientType::ttBefore); - // Delete line below selection QString s = mDocument->getString(origBlockEnd.line); // after end, 0 based mDocument->deleteAt(origBlockEnd.line); // after end, 0 based @@ -2410,11 +2381,10 @@ void SynEdit::doMoveSelDown() origBlockBegin, origBlockEnd, QStringList(), - SynSelectionMode::Normal); + SelectionMode::Normal); mUndoList->endBlock(); } - doOnPaintTransient(SynTransientType::ttAfter); } } @@ -2446,7 +2416,7 @@ void SynEdit::insertLine(bool moveCaret) QString Temp = lineText(); if (mCaretX>lineText().length()+1) { - PSynEditFoldRange foldRange = foldStartAtLine(mCaretY); + PCodeFoldingRange foldRange = foldStartAtLine(mCaretY); if ((foldRange) && foldRange->collapsed) { QString s = Temp+highlighter()->foldString(); if (mCaretX > s.length()) { @@ -2466,7 +2436,7 @@ void SynEdit::insertLine(bool moveCaret) QString Temp2 = Temp; QString Temp3; - PSynHighlighterAttribute Attr; + PHighlighterAttribute Attr; // This is sloppy, but the Right Thing would be to track the column of markers // too, so they could be moved depending on whether they are after the caret... @@ -2475,7 +2445,7 @@ void SynEdit::insertLine(bool moveCaret) QString rightLineText = lineText().mid(mCaretX-1); if (!mUndoing) mUndoList->addChange(SynChangeReason::LineBreak, caretXY(), caretXY(), QStringList(rightLineText), - SynSelectionMode::Normal); + SelectionMode::Normal); bool notInComment=true; properSetLine(mCaretY-1,leftLineText); //update range stated for line mCaretY @@ -2487,11 +2457,11 @@ void SynEdit::insertLine(bool moveCaret) } mHighlighter->setLine(leftLineText, mCaretY-1); mHighlighter->nextToEol(); - mDocument->setRange(mCaretY-1,mHighlighter->getRangeState()); + mDocument->setRange(mCaretY-1,mHighlighter->getState()); notInComment = !mHighlighter->isLastLineCommentNotFinished( - mHighlighter->getRangeState().state) + mHighlighter->getState().state) && !mHighlighter->isLastLineStringNotFinished( - mHighlighter->getRangeState().state); + mHighlighter->getState().state); } int indentSpaces = 0; if (mOptions.testFlag(eoAutoIndent)) { @@ -2514,7 +2484,7 @@ void SynEdit::insertLine(bool moveCaret) mDocument->insert(mCaretY, indentSpacesForRightLineText); nLinesInserted++; mUndoList->addChange(SynChangeReason::LineBreak, caretXY(), caretXY(), QStringList(), - SynSelectionMode::Normal); + SelectionMode::Normal); } //insert new line in middle of "{" and "}" if (notInComment && @@ -2526,7 +2496,7 @@ void SynEdit::insertLine(bool moveCaret) mDocument->insert(mCaretY, indentSpacesForRightLineText); nLinesInserted++; mUndoList->addChange(SynChangeReason::LineBreak, caretXY(), caretXY(), QStringList(), - SynSelectionMode::Normal); + SelectionMode::Normal); } } if (moveCaret) @@ -2541,7 +2511,7 @@ void SynEdit::insertLine(bool moveCaret) void SynEdit::doTabKey() { - if (mActiveSelectionMode == SynSelectionMode::Column) { + if (mActiveSelectionMode == SelectionMode::Column) { doAddChar('\t'); return; } @@ -2630,7 +2600,7 @@ bool SynEdit::canDoBlockIndent() return false; } - if (mActiveSelectionMode == SynSelectionMode::Normal) { + if (mActiveSelectionMode == SelectionMode::Normal) { QString s = mDocument->getString(BB.line-1).mid(0,BB.ch-1); if (!s.trimmed().isEmpty()) return false; @@ -2641,7 +2611,7 @@ bool SynEdit::canDoBlockIndent() return false; } } - if (mActiveSelectionMode == SynSelectionMode::Column) { + if (mActiveSelectionMode == SelectionMode::Column) { int startCol = charToColumn(BB.line,BB.ch); int endCol = charToColumn(BE.line,BE.ch); for (int i = BB.line; i<=BE.line;i++) { @@ -2670,7 +2640,7 @@ QRect SynEdit::calculateCaretRect() const coord.Column = charToColumn(sLine,mCaretX+mInputPreeditString.length()); } int rows=1; - if (mActiveSelectionMode == SynSelectionMode::Column) { + if (mActiveSelectionMode == SelectionMode::Column) { int startRow = lineToRow(std::min(blockBegin().line, blockEnd().line)); int endRow = lineToRow(std::max(blockBegin().line, blockEnd().line)); coord.Row = startRow; @@ -2681,7 +2651,7 @@ QRect SynEdit::calculateCaretRect() const if (mCaretY <= mDocument->count() && mCaretX <= mDocument->getString(mCaretY-1).length()) { caretWidth = charColumns(getDisplayStringAtLine(mCaretY)[mCaretX-1])*mCharWidth; } - if (mActiveSelectionMode == SynSelectionMode::Column) { + if (mActiveSelectionMode == SelectionMode::Column) { return QRect(caretPos.x(),caretPos.y(),caretWidth, mTextHeight*(rows)); } else { @@ -2702,7 +2672,7 @@ QRect SynEdit::calculateInputCaretRect() const mTextHeight); } -void SynEdit::clearAreaList(SynEditingAreaList areaList) +void SynEdit::clearAreaList(EditingAreaList areaList) { areaList.clear(); } @@ -2791,7 +2761,7 @@ void SynEdit::doBlockIndent() x = 1; } else { e = BE.line; - if (mOptions.testFlag(SynEditorOption::eoTabsToSpaces)) + if (mOptions.testFlag(EditorOption::eoTabsToSpaces)) x = caretX() + tabWidth(); else x = caretX() + 1; @@ -2809,7 +2779,7 @@ void SynEdit::doBlockIndent() mUndoList->addChange(SynChangeReason::Caret, oldCaretPos, oldCaretPos,QStringList(), activeSelectionMode()); mUndoList->addChange(SynChangeReason::Selection,mBlockBegin,mBlockEnd,QStringList(), activeSelectionMode()); int ch; - if (mActiveSelectionMode == SynSelectionMode::Column) + if (mActiveSelectionMode == SelectionMode::Column) ch = std::min(BB.ch, BE.ch); else ch = 1; @@ -2823,7 +2793,7 @@ void SynEdit::doBlockIndent() BufferCoord{line.length(), i}, BufferCoord{line.length()+spaces.length(), i}, QStringList(), - SynSelectionMode::Normal); + SelectionMode::Normal); line+=spaces; } else { mUndoList->addChange( @@ -2831,7 +2801,7 @@ void SynEdit::doBlockIndent() BufferCoord{ch, i}, BufferCoord{ch+spaces.length(), i}, QStringList(), - SynSelectionMode::Normal); + SelectionMode::Normal); line = line.left(ch-1)+spaces+line.mid(ch-1); } properSetLine(i-1,line); @@ -2897,7 +2867,7 @@ void SynEdit::doBlockUnindent() BufferCoord{1,i}, BufferCoord{charsToDelete+1,i}, QStringList(line.left(charsToDelete)), - SynSelectionMode::Normal); + SelectionMode::Normal); } // restore selection //adjust the x position of orgcaretpos appropriately @@ -2919,7 +2889,7 @@ void SynEdit::doAddChar(QChar AChar) //mCaretX will change after setSelLength; if (mInserting == false && !selAvail()) { switch(mActiveSelectionMode) { - case SynSelectionMode::Column: { + case SelectionMode::Column: { //we can't use blockBegin()/blockEnd() BufferCoord start=mBlockBegin; BufferCoord end=mBlockEnd; @@ -2930,7 +2900,7 @@ void SynEdit::doAddChar(QChar AChar) setBlockEnd(end); } break; - case SynSelectionMode::Line: + case SelectionMode::Line: //do nothing; break; default: @@ -2956,10 +2926,10 @@ void SynEdit::doAddChar(QChar AChar) int oldCaretX=mCaretX-1; int oldCaretY=mCaretY; // auto - if (mActiveSelectionMode==SynSelectionMode::Normal + if (mActiveSelectionMode==SelectionMode::Normal && mOptions.testFlag(eoAutoIndent) && mHighlighter - && mHighlighter->getClass()==SynHighlighterClass::CppHighlighter + && mHighlighter->getClass()==HighlighterClass::CppHighlighter && (oldCaretY<=mDocument->count()) ) { //unindent if ':' at end of the line @@ -2978,14 +2948,14 @@ void SynEdit::doAddChar(QChar AChar) BufferCoord{1, oldCaretY}, BufferCoord{line.length()+1, oldCaretY}, QStringList(line), - SynSelectionMode::Normal + SelectionMode::Normal ); mUndoList->addChange( SynChangeReason::Insert, BufferCoord{1, oldCaretY}, BufferCoord{newLine.length()+1, oldCaretY}, QStringList(), - SynSelectionMode::Normal + SelectionMode::Normal ); } } @@ -3004,14 +2974,14 @@ void SynEdit::doAddChar(QChar AChar) BufferCoord{1, oldCaretY}, BufferCoord{line.length()+1, oldCaretY}, QStringList(line), - SynSelectionMode::Normal + SelectionMode::Normal ); mUndoList->addChange( SynChangeReason::Insert, BufferCoord{1, oldCaretY}, BufferCoord{newLine.length()+1, oldCaretY}, QStringList(), - SynSelectionMode::Normal + SelectionMode::Normal ); } } @@ -3034,14 +3004,14 @@ void SynEdit::doAddChar(QChar AChar) BufferCoord{1, oldCaretY}, BufferCoord{left.length()+1, oldCaretY}, QStringList(left), - SynSelectionMode::Normal + SelectionMode::Normal ); mUndoList->addChange( SynChangeReason::Insert, BufferCoord{1, oldCaretY}, BufferCoord{newLeft.length()+1, oldCaretY}, QStringList(""), - SynSelectionMode::Normal + SelectionMode::Normal ); } @@ -3074,7 +3044,7 @@ void SynEdit::doCopyToClipboard() bool selected=selAvail(); if (!selected) doSelecteLine(); - bool ChangeTrim = (mActiveSelectionMode == SynSelectionMode::Column) && + bool ChangeTrim = (mActiveSelectionMode == SelectionMode::Column) && mOptions.testFlag(eoTrimTrailingSpaces); QString sText; { @@ -3108,7 +3078,6 @@ void SynEdit::doPasteFromClipboard() QString text = clipboard->text(); if (text.isEmpty()) return; - doOnPaintTransient(SynTransientType::ttBefore); mUndoList->beginBlock(); // if (selAvail()) { // mUndoList->AddChange( @@ -3142,11 +3111,11 @@ void SynEdit::decPaintLock() Q_ASSERT(mPaintLock > 0); mPaintLock--; if (mPaintLock == 0 ) { - if (mStateFlags.testFlag(SynStateFlag::sfScrollbarChanged)) { + if (mStateFlags.testFlag(StateFlag::sfScrollbarChanged)) { updateScrollbars(); ensureCursorPosVisible(); } - if (mStateFlags.testFlag(SynStateFlag::sfCaretChanged)) + if (mStateFlags.testFlag(StateFlag::sfCaretChanged)) updateCaret(); if (mStatusChanges!=0) doOnStatusChange(mStatusChanges); @@ -3185,10 +3154,6 @@ void SynEdit::synFontChanged() onSizeOrFontChanged(true); } -void SynEdit::doOnPaintTransient(SynTransientType TransientType) -{ - doOnPaintTransientEx(TransientType, false); -} void SynEdit::updateLastCaretX() { @@ -3259,21 +3224,21 @@ void SynEdit::internalSetCaretY(int Value) internalSetCaretXY(BufferCoord{mCaretX,Value}); } -void SynEdit::setStatusChanged(SynStatusChanges changes) +void SynEdit::setStatusChanged(StatusChanges changes) { mStatusChanges = mStatusChanges | changes; if (mPaintLock == 0) doOnStatusChange(mStatusChanges); } -void SynEdit::doOnStatusChange(SynStatusChanges) +void SynEdit::doOnStatusChange(StatusChanges) { - if (mStatusChanges.testFlag(SynStatusChange::scCaretX) - || mStatusChanges.testFlag(SynStatusChange::scCaretY)) { + if (mStatusChanges.testFlag(StatusChange::scCaretX) + || mStatusChanges.testFlag(StatusChange::scCaretY)) { qApp->inputMethod()->update(Qt::ImCursorPosition); } emit statusChanged(mStatusChanges); - mStatusChanges = SynStatusChange::scNone; + mStatusChanges = StatusChange::scNone; } void SynEdit::updateScrollbars() @@ -3281,10 +3246,10 @@ void SynEdit::updateScrollbars() int nMaxScroll; int nMin,nMax,nPage,nPos; if (mPaintLock!=0) { - mStateFlags.setFlag(SynStateFlag::sfScrollbarChanged); + mStateFlags.setFlag(StateFlag::sfScrollbarChanged); } else { - mStateFlags.setFlag(SynStateFlag::sfScrollbarChanged,false); - if (mScrollBars != SynScrollStyle::ssNone) { + mStateFlags.setFlag(StateFlag::sfScrollbarChanged,false); + if (mScrollBars != ScrollStyle::ssNone) { if (mOptions.testFlag(eoHideShowScrollbars)) { setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAsNeeded); setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAsNeeded); @@ -3292,7 +3257,7 @@ void SynEdit::updateScrollbars() setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAlwaysOn); setVerticalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAlwaysOn); } - if (mScrollBars == SynScrollStyle::ssBoth || mScrollBars == SynScrollStyle::ssHorizontal) { + if (mScrollBars == ScrollStyle::ssBoth || mScrollBars == ScrollStyle::ssHorizontal) { nMaxScroll = maxScrollWidth(); if (nMaxScroll <= MAX_SCROLL) { nMin = 1; @@ -3313,7 +3278,7 @@ void SynEdit::updateScrollbars() } else setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy::ScrollBarAlwaysOn); - if (mScrollBars == SynScrollStyle::ssBoth || mScrollBars == SynScrollStyle::ssVertical) { + if (mScrollBars == ScrollStyle::ssBoth || mScrollBars == ScrollStyle::ssVertical) { nMaxScroll = maxScrollHeight(); if (nMaxScroll <= MAX_SCROLL) { nMin = 1; @@ -3342,17 +3307,17 @@ void SynEdit::updateScrollbars() void SynEdit::updateCaret() { - mStateFlags.setFlag(SynStateFlag::sfCaretChanged,false); + mStateFlags.setFlag(StateFlag::sfCaretChanged,false); invalidateRect(calculateCaretRect()); } void SynEdit::recalcCharExtent() { - SynFontStyle styles[] = {SynFontStyle::fsBold, SynFontStyle::fsItalic, SynFontStyle::fsStrikeOut, SynFontStyle::fsUnderline}; + FontStyle styles[] = {FontStyle::fsBold, FontStyle::fsItalic, FontStyle::fsStrikeOut, FontStyle::fsUnderline}; bool hasStyles[] = {false,false,false,false}; int size = 4; if (mHighlighter && mHighlighter->attributes().count()>0) { - for (const PSynHighlighterAttribute& attribute: mHighlighter->attributes()) { + for (const PHighlighterAttribute& attribute: mHighlighter->attributes()) { for (int i=0;istyles().testFlag(styles[i])) hasStyles[i] = true; @@ -3459,12 +3424,12 @@ void SynEdit::updateModifiedStatus() setModified(mModified); // qDebug()<= mDocument->count()) return Result; @@ -3477,7 +3442,7 @@ int SynEdit::scanFrom(int Index, int canStopIndex) do { mHighlighter->setLine(mDocument->getString(Result), Result); mHighlighter->nextToEol(); - iRange = mHighlighter->getRangeState(); + iRange = mHighlighter->getState(); if (Result > canStopIndex){ if (mDocument->ranges(Result).state == iRange.state && mDocument->ranges(Result).braceLevel == iRange.braceLevel @@ -3514,7 +3479,7 @@ void SynEdit::rescanRange(int line) } mHighlighter->setLine(mDocument->getString(line), line); mHighlighter->nextToEol(); - SynRangeState iRange = mHighlighter->getRangeState(); + HighlighterState iRange = mHighlighter->getState(); mDocument->setRange(line,iRange); } @@ -3525,14 +3490,14 @@ void SynEdit::rescanRanges() for (int i =0;icount();i++) { mHighlighter->setLine(mDocument->getString(i), i); mHighlighter->nextToEol(); - mDocument->setRange(i, mHighlighter->getRangeState()); + mDocument->setRange(i, mHighlighter->getState()); } } if (mUseCodeFolding) rescanFolds(); } -void SynEdit::uncollapse(PSynEditFoldRange FoldRange) +void SynEdit::uncollapse(PCodeFoldingRange FoldRange) { FoldRange->linesCollapsed = 0; FoldRange->collapsed = false; @@ -3545,7 +3510,7 @@ void SynEdit::uncollapse(PSynEditFoldRange FoldRange) updateScrollbars(); } -void SynEdit::collapse(PSynEditFoldRange FoldRange) +void SynEdit::collapse(PCodeFoldingRange FoldRange) { FoldRange->linesCollapsed = FoldRange->toLine - FoldRange->fromLine; FoldRange->collapsed = true; @@ -3569,7 +3534,7 @@ void SynEdit::foldOnListInserted(int Line, int Count) { // Delete collapsed inside selection for (int i = mAllFoldRanges.count()-1;i>=0;i--) { - PSynEditFoldRange range = mAllFoldRanges[i]; + PCodeFoldingRange range = mAllFoldRanges[i]; if (range->fromLine == Line - 1) {// insertion starts at fold line if (range->collapsed) uncollapse(range); @@ -3582,7 +3547,7 @@ void SynEdit::foldOnListDeleted(int Line, int Count) { // Delete collapsed inside selection for (int i = mAllFoldRanges.count()-1;i>=0;i--) { - PSynEditFoldRange range = mAllFoldRanges[i]; + PCodeFoldingRange range = mAllFoldRanges[i]; if (range->fromLine == Line && Count == 1) {// open up because we are messing with the starting line if (range->collapsed) uncollapse(range); @@ -3608,7 +3573,7 @@ void SynEdit::rescanFolds() invalidateGutter(); } -static void null_deleter(SynEditFoldRanges *) {} +static void null_deleter(CodeFoldingRanges *) {} void SynEdit::rescanForFoldRanges() { @@ -3621,18 +3586,18 @@ void SynEdit::rescanForFoldRanges() // Did we leave any collapsed folds and are we viewing a code file? if (mAllFoldRanges.count() > 0) { - SynEditFoldRanges ranges=mAllFoldRanges; + CodeFoldingRanges ranges=mAllFoldRanges; mAllFoldRanges.clear(); // Add folds to a separate list - PSynEditFoldRanges TemporaryAllFoldRanges = std::make_shared(); + PCodeFoldingRanges TemporaryAllFoldRanges = std::make_shared(); scanForFoldRanges(TemporaryAllFoldRanges); // Combine new with old folds, preserve parent order for (int i = 0; i< TemporaryAllFoldRanges->count();i++) { - PSynEditFoldRange tempFoldRange=TemporaryAllFoldRanges->range(i); + PCodeFoldingRange tempFoldRange=TemporaryAllFoldRanges->range(i); int j=0; while (j range(i)->fromLine<fromLine; if (tempFoldRange->fromLine == foldRange->fromLine && tempFoldRange->toLine == foldRange->toLine) { @@ -3651,17 +3616,17 @@ void SynEdit::rescanForFoldRanges() } else { // We ended up with no folds after deleting, just pass standard data... - PSynEditFoldRanges temp(&mAllFoldRanges, null_deleter); + PCodeFoldingRanges temp(&mAllFoldRanges, null_deleter); scanForFoldRanges(temp); } } -void SynEdit::scanForFoldRanges(PSynEditFoldRanges TopFoldRanges) +void SynEdit::scanForFoldRanges(PCodeFoldingRanges TopFoldRanges) { - PSynEditFoldRanges parentFoldRanges = TopFoldRanges; + PCodeFoldingRanges parentFoldRanges = TopFoldRanges; // Recursively scan for folds (all types) for (int i= 0 ; i< mCodeFolding.foldRegions.count() ; i++ ) { - findSubFoldRange(TopFoldRanges, i,parentFoldRanges,PSynEditFoldRange()); + findSubFoldRange(TopFoldRanges, i,parentFoldRanges,PCodeFoldingRange()); } } @@ -3686,7 +3651,7 @@ int SynEdit::lineHasChar(int Line, int startChar, QChar character, const QString QString token; while (!mHighlighter->eol()) { token = mHighlighter->getToken(); - PSynHighlighterAttribute attr = mHighlighter->getTokenAttribute(); + PHighlighterAttribute attr = mHighlighter->getTokenAttribute(); if (token == character && attr->name()==highlighterAttrName) return mHighlighter->getTokenPos(); mHighlighter->next(); @@ -3695,9 +3660,9 @@ int SynEdit::lineHasChar(int Line, int startChar, QChar character, const QString return -1; } -void SynEdit::findSubFoldRange(PSynEditFoldRanges TopFoldRanges, int FoldIndex,PSynEditFoldRanges& parentFoldRanges, PSynEditFoldRange Parent) +void SynEdit::findSubFoldRange(PCodeFoldingRanges TopFoldRanges, int FoldIndex,PCodeFoldingRanges& parentFoldRanges, PCodeFoldingRange Parent) { - PSynEditFoldRange CollapsedFold; + PCodeFoldingRange CollapsedFold; int Line = 0; QString CurLine; if (!mHighlighter) @@ -3756,7 +3721,7 @@ void SynEdit::findSubFoldRange(PSynEditFoldRanges TopFoldRanges, int FoldIndex,P while (!mHighlighter->eol()) { token = mHighlighter->getToken(); pos = mHighlighter->getTokenPos()+token.length(); - PSynHighlighterAttribute attr = mHighlighter->getTokenAttribute(); + PHighlighterAttribute attr = mHighlighter->getTokenAttribute(); // We've found a starting character and it have proper highlighting (ignore stuff inside comments...) if (token == mCodeFolding.foldRegions.get(FoldIndex)->openSymbol && attr->name()==mCodeFolding.foldRegions.get(FoldIndex)->highlight) { // And ignore lines with both opening and closing chars in them @@ -3801,7 +3766,7 @@ void SynEdit::findSubFoldRange(PSynEditFoldRanges TopFoldRanges, int FoldIndex,P } } -PSynEditFoldRange SynEdit::collapsedFoldStartAtLine(int Line) +PCodeFoldingRange SynEdit::collapsedFoldStartAtLine(int Line) { for (int i = 0; i< mAllFoldRanges.count() - 1; i++ ) { if (mAllFoldRanges[i]->fromLine == Line && mAllFoldRanges[i]->collapsed) { @@ -3810,12 +3775,7 @@ PSynEditFoldRange SynEdit::collapsedFoldStartAtLine(int Line) break; // sorted by line. don't bother scanning further } } - return PSynEditFoldRange(); -} - -void SynEdit::doOnPaintTransientEx(SynTransientType , bool ) -{ - //todo: we can't draw to canvas outside paintEvent + return PCodeFoldingRange(); } void SynEdit::initializeCaret() @@ -3823,22 +3783,22 @@ void SynEdit::initializeCaret() //showCaret(); } -PSynEditFoldRange SynEdit::foldStartAtLine(int Line) const +PCodeFoldingRange SynEdit::foldStartAtLine(int Line) const { for (int i = 0; ifromLine == Line ){ return range; } else if (range->fromLine>Line) break; // sorted by line. don't bother scanning further } - return PSynEditFoldRange(); + return PCodeFoldingRange(); } bool SynEdit::foldCollapsedBetween(int startLine, int endLine) const { for (int i = 0; i=range->fromLine && range->fromLine<=endLine && (range->collapsed || range->parentCollapsed())){ return true; @@ -3892,20 +3852,20 @@ QString SynEdit::substringByColumns(const QString &s, int startColumn, int &colL return result; } -PSynEditFoldRange SynEdit::foldAroundLine(int Line) +PCodeFoldingRange SynEdit::foldAroundLine(int Line) { return foldAroundLineEx(Line,false,false,false); } -PSynEditFoldRange SynEdit::foldAroundLineEx(int Line, bool WantCollapsed, bool AcceptFromLine, bool AcceptToLine) +PCodeFoldingRange SynEdit::foldAroundLineEx(int Line, bool WantCollapsed, bool AcceptFromLine, bool AcceptToLine) { // Check global list - PSynEditFoldRange Result = checkFoldRange(&mAllFoldRanges, Line, WantCollapsed, AcceptFromLine, AcceptToLine); + PCodeFoldingRange Result = checkFoldRange(&mAllFoldRanges, Line, WantCollapsed, AcceptFromLine, AcceptToLine); // Found an item in the top level list? if (Result) { while (true) { - PSynEditFoldRange ResultChild = checkFoldRange(Result->subFoldRanges.get(), Line, WantCollapsed, AcceptFromLine, AcceptToLine); + PCodeFoldingRange ResultChild = checkFoldRange(Result->subFoldRanges.get(), Line, WantCollapsed, AcceptFromLine, AcceptToLine); if (!ResultChild) break; Result = ResultChild; // repeat for this one @@ -3914,10 +3874,10 @@ PSynEditFoldRange SynEdit::foldAroundLineEx(int Line, bool WantCollapsed, bool A return Result; } -PSynEditFoldRange SynEdit::checkFoldRange(SynEditFoldRanges *FoldRangeToCheck, int Line, bool WantCollapsed, bool AcceptFromLine, bool AcceptToLine) +PCodeFoldingRange SynEdit::checkFoldRange(CodeFoldingRanges *FoldRangeToCheck, int Line, bool WantCollapsed, bool AcceptFromLine, bool AcceptToLine) { for (int i = 0; i< FoldRangeToCheck->count(); i++) { - PSynEditFoldRange range = (*FoldRangeToCheck)[i]; + PCodeFoldingRange range = (*FoldRangeToCheck)[i]; if (((range->fromLine < Line) || ((range->fromLine <= Line) && AcceptFromLine)) && ((range->toLine > Line) || ((range->toLine >= Line) && AcceptToLine))) { if (range->collapsed == WantCollapsed) { @@ -3925,19 +3885,19 @@ PSynEditFoldRange SynEdit::checkFoldRange(SynEditFoldRanges *FoldRangeToCheck, i } } } - return PSynEditFoldRange(); + return PCodeFoldingRange(); } -PSynEditFoldRange SynEdit::foldEndAtLine(int Line) +PCodeFoldingRange SynEdit::foldEndAtLine(int Line) { for (int i = 0; itoLine == Line ){ return range; } else if (range->fromLine>Line) break; // sorted by line. don't bother scanning further } - return PSynEditFoldRange(); + return PCodeFoldingRange(); } void SynEdit::paintCaret(QPainter &painter, const QRect rcClip) @@ -3945,7 +3905,7 @@ void SynEdit::paintCaret(QPainter &painter, const QRect rcClip) if (m_blinkStatus!=1) return; painter.setClipRect(rcClip); - SynEditCaretType ct; + EditCaretType ct; if (this->mInserting) { ct = mInsertCaret; } else { @@ -3958,7 +3918,7 @@ void SynEdit::paintCaret(QPainter &painter, const QRect rcClip) caretColor = mCaretColor; } switch(ct) { - case SynEditCaretType::ctVerticalLine: { + case EditCaretType::ctVerticalLine: { QRect caretRC; int size = std::max(1, mTextHeight/15); caretRC.setLeft(rcClip.left()+1); @@ -3968,7 +3928,7 @@ void SynEdit::paintCaret(QPainter &painter, const QRect rcClip) painter.fillRect(caretRC,caretColor); break; } - case SynEditCaretType::ctHorizontalLine: { + case EditCaretType::ctHorizontalLine: { QRect caretRC; int size = std::max(1,mTextHeight/15); caretRC.setLeft(rcClip.left()); @@ -3978,10 +3938,10 @@ void SynEdit::paintCaret(QPainter &painter, const QRect rcClip) painter.fillRect(caretRC,caretColor); break; } - case SynEditCaretType::ctBlock: + case EditCaretType::ctBlock: painter.fillRect(rcClip, caretColor); break; - case SynEditCaretType::ctHalfBlock: + case EditCaretType::ctHalfBlock: QRect rc=rcClip; rc.setTop(rcClip.top()+rcClip.height() / 2); painter.fillRect(rcClip, caretColor); @@ -3994,11 +3954,11 @@ int SynEdit::textOffset() const return mGutterWidth + 2 - (mLeftChar-1)*mCharWidth; } -SynEditorCommand SynEdit::TranslateKeyCode(int key, Qt::KeyboardModifiers modifiers) +EditCommand SynEdit::TranslateKeyCode(int key, Qt::KeyboardModifiers modifiers) { - PSynEditKeyStroke keyStroke = mKeyStrokes.findKeycode2(mLastKey,mLastKeyModifiers, + PEditKeyStroke keyStroke = mKeyStrokes.findKeycode2(mLastKey,mLastKeyModifiers, key, modifiers); - SynEditorCommand cmd=SynEditorCommand::ecNone; + EditCommand cmd=EditCommand::ecNone; if (keyStroke) cmd = keyStroke->command(); else { @@ -4006,7 +3966,7 @@ SynEditorCommand SynEdit::TranslateKeyCode(int key, Qt::KeyboardModifiers modifi if (keyStroke) cmd = keyStroke->command(); } - if (cmd == SynEditorCommand::ecNone) { + if (cmd == EditCommand::ecNone) { mLastKey = key; mLastKeyModifiers = modifiers; } else { @@ -4022,17 +3982,17 @@ void SynEdit::onSizeOrFontChanged(bool bFont) if (mCharWidth != 0) { mCharsInWindow = std::max(clientWidth() - mGutterWidth - 2, 0) / mCharWidth; mLinesInWindow = clientHeight() / mTextHeight; - bool scrollBarChangedSettings = mStateFlags.testFlag(SynStateFlag::sfScrollbarChanged); + bool scrollBarChangedSettings = mStateFlags.testFlag(StateFlag::sfScrollbarChanged); if (bFont) { if (mGutter.showLineNumbers()) onGutterChanged(); else updateScrollbars(); - mStateFlags.setFlag(SynStateFlag::sfCaretChanged,false); + mStateFlags.setFlag(StateFlag::sfCaretChanged,false); invalidate(); } else updateScrollbars(); - mStateFlags.setFlag(SynStateFlag::sfScrollbarChanged,scrollBarChangedSettings); + mStateFlags.setFlag(StateFlag::sfScrollbarChanged,scrollBarChangedSettings); //if (!mOptions.testFlag(SynEditorOption::eoScrollPastEol)) setLeftChar(mLeftChar); //if (!mOptions.testFlag(SynEditorOption::eoScrollPastEof)) @@ -4052,6 +4012,16 @@ void SynEdit::onScrolled(int) invalidate(); } +ScrollStyle SynEdit::scrollBars() const +{ + return mScrollBars; +} + +void SynEdit::setScrollBars(ScrollStyle newScrollBars) +{ + mScrollBars = newScrollBars; +} + int SynEdit::mouseSelectionScrollSpeed() const { return mMouseSelectionScrollSpeed; @@ -4105,22 +4075,22 @@ void SynEdit::setMouseWheelScrollSpeed(int newMouseWheelScrollSpeed) mMouseWheelScrollSpeed = newMouseWheelScrollSpeed; } -const PSynHighlighterAttribute &SynEdit::rainbowAttr3() const +const PHighlighterAttribute &SynEdit::rainbowAttr3() const { return mRainbowAttr3; } -const PSynHighlighterAttribute &SynEdit::rainbowAttr2() const +const PHighlighterAttribute &SynEdit::rainbowAttr2() const { return mRainbowAttr2; } -const PSynHighlighterAttribute &SynEdit::rainbowAttr1() const +const PHighlighterAttribute &SynEdit::rainbowAttr1() const { return mRainbowAttr1; } -const PSynHighlighterAttribute &SynEdit::rainbowAttr0() const +const PHighlighterAttribute &SynEdit::rainbowAttr0() const { return mRainbowAttr0; } @@ -4198,27 +4168,27 @@ void SynEdit::setReadOnly(bool readOnly) } } -SynGutter& SynEdit::gutter() +Gutter& SynEdit::gutter() { return mGutter; } -SynEditCaretType SynEdit::insertCaret() const +EditCaretType SynEdit::insertCaret() const { return mInsertCaret; } -void SynEdit::setInsertCaret(const SynEditCaretType &insertCaret) +void SynEdit::setInsertCaret(const EditCaretType &insertCaret) { mInsertCaret = insertCaret; } -SynEditCaretType SynEdit::overwriteCaret() const +EditCaretType SynEdit::overwriteCaret() const { return mOverwriteCaret; } -void SynEdit::setOverwriteCaret(const SynEditCaretType &overwriteCaret) +void SynEdit::setOverwriteCaret(const EditCaretType &overwriteCaret) { mOverwriteCaret = overwriteCaret; } @@ -4254,12 +4224,12 @@ void SynEdit::setTabWidth(int newTabWidth) } } -SynEditorOptions SynEdit::getOptions() const +EditorOptions SynEdit::getOptions() const { return mOptions; } -void SynEdit::setOptions(const SynEditorOptions &Value) +void SynEdit::setOptions(const EditorOptions &Value) { if (Value != mOptions) { //bool bSetDrag = mOptions.testFlag(eoDropFiles) != Value.testFlag(eoDropFiles); @@ -4298,7 +4268,7 @@ void SynEdit::doAddStr(const QString &s) { if (mInserting == false && !selAvail()) { switch(mActiveSelectionMode) { - case SynSelectionMode::Column: { + case SelectionMode::Column: { //we can't use blockBegin()/blockEnd() BufferCoord start=blockBegin(); BufferCoord end=blockEnd(); @@ -4309,7 +4279,7 @@ void SynEdit::doAddStr(const QString &s) setBlockEnd(end); } break; - case SynSelectionMode::Line: + case SelectionMode::Line: //do nothing; break; default: @@ -4646,7 +4616,7 @@ void SynEdit::doRedoItem() item->changeEndPos(),item->changeText(), item->changeSelMode(),item->changeNumber()); setCaretAndSelection(CaretPt, CaretPt, CaretPt); - commandProcessor(SynEditorCommand::ecLineBreak); + commandProcessor(EditCommand::ecLineBreak); break; } default: @@ -4675,12 +4645,12 @@ void SynEdit::doZoomOut() setFont(newFont); } -SynSelectionMode SynEdit::selectionMode() const +SelectionMode SynEdit::selectionMode() const { return mSelectionMode; } -void SynEdit::setSelectionMode(SynSelectionMode value) +void SynEdit::setSelectionMode(SelectionMode value) { if (mSelectionMode!=value) { mSelectionMode = value; @@ -4700,8 +4670,8 @@ QString SynEdit::selText() int Last = blockEnd().line - 1; switch(mActiveSelectionMode) { - case SynSelectionMode::Normal:{ - PSynEditFoldRange foldRange = foldStartAtLine(blockEnd().line); + case SelectionMode::Normal:{ + PCodeFoldingRange foldRange = foldStartAtLine(blockEnd().line); QString s = mDocument->getString(Last); if ((foldRange) && foldRange->collapsed && ColTo>s.length()) { s=s+highlighter()->foldString(); @@ -4723,7 +4693,7 @@ QString SynEdit::selText() return result; } } - case SynSelectionMode::Column: + case SelectionMode::Column: { First = blockBegin().line; ColFrom = charToColumn(blockBegin().line, blockBegin().ch); @@ -4744,7 +4714,7 @@ QString SynEdit::selText() } return result; } - case SynSelectionMode::Line: + case SelectionMode::Line: { QString result; // If block selection includes LastLine, @@ -4763,7 +4733,7 @@ QString SynEdit::selText() return ""; } -QStringList SynEdit::getContent(BufferCoord startPos, BufferCoord endPos, SynSelectionMode mode) const +QStringList SynEdit::getContent(BufferCoord startPos, BufferCoord endPos, SelectionMode mode) const { QStringList result; if (startPos==endPos) { @@ -4779,8 +4749,8 @@ QStringList SynEdit::getContent(BufferCoord startPos, BufferCoord endPos, SynSel int Last = endPos.line - 1; switch(mode) { - case SynSelectionMode::Normal:{ - PSynEditFoldRange foldRange = foldStartAtLine(endPos.line); + case SelectionMode::Normal:{ + PCodeFoldingRange foldRange = foldStartAtLine(endPos.line); QString s = mDocument->getString(Last); if ((foldRange) && foldRange->collapsed && ColTo>s.length()) { s=s+highlighter()->foldString(); @@ -4800,7 +4770,7 @@ QStringList SynEdit::getContent(BufferCoord startPos, BufferCoord endPos, SynSel result.append(mDocument->getString(Last).left(ColTo-1)); } break; - case SynSelectionMode::Column: + case SelectionMode::Column: First = blockBegin().line; ColFrom = charToColumn(blockBegin().line, blockBegin().ch); Last = blockEnd().line; @@ -4816,7 +4786,7 @@ QStringList SynEdit::getContent(BufferCoord startPos, BufferCoord endPos, SynSel result.append(s.mid(l-1,r-l)); } break; - case SynSelectionMode::Line: + case SelectionMode::Line: // If block selection includes LastLine, // line break code(s) of the last line will not be added. for (int i= First; i<=Last - 1;i++) { @@ -4847,7 +4817,7 @@ void SynEdit::setUseCodeFolding(bool value) } } -SynEditCodeFolding &SynEdit::codeFolding() +CodeFoldingOptions &SynEdit::codeFolding() { return mCodeFolding; } @@ -4856,7 +4826,7 @@ QString SynEdit::displayLineText() { if (mCaretY >= 1 && mCaretY <= mDocument->count()) { QString s= mDocument->getString(mCaretY - 1); - PSynEditFoldRange foldRange = foldStartAtLine(mCaretY); + PCodeFoldingRange foldRange = foldStartAtLine(mCaretY); if ((foldRange) && foldRange->collapsed) { return s+highlighter()->foldString(); } @@ -4879,14 +4849,14 @@ void SynEdit::setLineText(const QString s) mDocument->putString(mCaretY-1,s); } -PSynHighlighter SynEdit::highlighter() const +PHighlighter SynEdit::highlighter() const { return mHighlighter; } -void SynEdit::setHighlighter(const PSynHighlighter &highlighter) +void SynEdit::setHighlighter(const PHighlighter &highlighter) { - PSynHighlighter oldHighlighter= mHighlighter; + PHighlighter oldHighlighter= mHighlighter; mHighlighter = highlighter; if (oldHighlighter && mHighlighter && oldHighlighter->language() == highlighter->language()) { @@ -4912,11 +4882,11 @@ bool SynEdit::empty() return mDocument->empty(); } -void SynEdit::commandProcessor(SynEditorCommand Command, QChar AChar, void *pData) +void SynEdit::commandProcessor(EditCommand Command, QChar AChar, void *pData) { // first the program event handler gets a chance to process the command onProcessCommand(Command, AChar, pData); - if (Command != SynEditorCommand::ecNone) + if (Command != EditCommand::ecNone) ExecuteCommand(Command, AChar, pData); onCommandProcessed(Command, AChar, pData); } @@ -4932,7 +4902,7 @@ void SynEdit::moveCaretHorz(int DX, bool isSelection) bool bChangeY=true; if (bChangeY && (DX == -1) && (ptO.ch == 1) && (ptO.line > 1)) { // end of previous line - if (mActiveSelectionMode==SynSelectionMode::Column) { + if (mActiveSelectionMode==SelectionMode::Column) { return; } int row = lineToRow(ptDst.line); @@ -4944,7 +4914,7 @@ void SynEdit::moveCaretHorz(int DX, bool isSelection) } } else if (bChangeY && (DX == 1) && (ptO.ch > nLineLen) && (ptO.line < mDocument->count())) { // start of next line - if (mActiveSelectionMode==SynSelectionMode::Column) { + if (mActiveSelectionMode==SelectionMode::Column) { return; } int row = lineToRow(ptDst.line); @@ -4964,9 +4934,9 @@ void SynEdit::moveCaretHorz(int DX, bool isSelection) // set caret and block begin / end incPaintLock(); if (mOptions.testFlag(eoAltSetsColumnMode) && - (mActiveSelectionMode != SynSelectionMode::Line)) { + (mActiveSelectionMode != SelectionMode::Line)) { if (qApp->keyboardModifiers().testFlag(Qt::AltModifier) && !mReadOnly) { - setActiveSelectionMode(SynSelectionMode::Column); + setActiveSelectionMode(SelectionMode::Column); } else setActiveSelectionMode(selectionMode()); } @@ -4995,7 +4965,7 @@ void SynEdit::moveCaretVert(int DY, bool isSelection) } BufferCoord vDstLineChar = displayToBufferPos(ptDst); - if (mActiveSelectionMode==SynSelectionMode::Column) { + if (mActiveSelectionMode==SelectionMode::Column) { QString s=mDocument->getString(vDstLineChar.line-1); int cols=stringColumns(s,0); if (cols+1keyboardModifiers().testFlag(Qt::AltModifier) && !mReadOnly) - setActiveSelectionMode(SynSelectionMode::Column); + setActiveSelectionMode(SelectionMode::Column); else setActiveSelectionMode(selectionMode()); } @@ -5024,7 +4994,7 @@ void SynEdit::moveCaretVert(int DY, bool isSelection) void SynEdit::moveCaretAndSelection(const BufferCoord &ptBefore, const BufferCoord &ptAfter, bool isSelection) { - if (mOptions.testFlag(SynEditorOption::eoGroupUndo)) { + if (mOptions.testFlag(EditorOption::eoGroupUndo)) { mUndoList->addGroupBreak(); } @@ -5043,7 +5013,7 @@ void SynEdit::moveCaretToLineStart(bool isSelection) { int newX; // home key enhancement - if (mOptions.testFlag(SynEditorOption::eoEnhanceHomeKey)) { + if (mOptions.testFlag(EditorOption::eoEnhanceHomeKey)) { QString s = mDocument->getString(mCaretY - 1); int first_nonblank = 0; @@ -5066,7 +5036,7 @@ void SynEdit::moveCaretToLineStart(bool isSelection) void SynEdit::moveCaretToLineEnd(bool isSelection) { int vNewX; - if (mOptions.testFlag(SynEditorOption::eoEnhanceEndKey)) { + if (mOptions.testFlag(EditorOption::eoEnhanceEndKey)) { QString vText = displayLineText(); int vLastNonBlank = vText.length()-1; int vMinX = 0; @@ -5097,7 +5067,7 @@ void SynEdit::setSelTextPrimitive(const QStringList &text) setSelTextPrimitiveEx(mActiveSelectionMode, text); } -void SynEdit::setSelTextPrimitiveEx(SynSelectionMode mode, const QStringList &text) +void SynEdit::setSelTextPrimitiveEx(SelectionMode mode, const QStringList &text) { incPaintLock(); bool groupUndo=false; @@ -5109,7 +5079,7 @@ void SynEdit::setSelTextPrimitiveEx(SynSelectionMode mode, const QStringList &te groupUndo=true; } doDeleteText(startPos,endPos,activeSelectionMode()); - if (mode == SynSelectionMode::Column) { + if (mode == SelectionMode::Column) { int colBegin = charToColumn(startPos.line,startPos.ch); int colEnd = charToColumn(endPos.line,endPos.ch); if (colBeginendBlock(); } decPaintLock(); - setStatusChanged(SynStatusChange::scSelection); + setStatusChanged(StatusChange::scSelection); } void SynEdit::doSetSelText(const QString &value) @@ -5152,8 +5122,8 @@ void SynEdit::doSetSelText(const QString &value) setSelTextPrimitive(splitStrings(value)); } -int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynSearchOptions sOptions, PSynSearchBase searchEngine, - SynSearchMathedProc matchedCallback, SynSearchConfirmAroundProc confirmAroundCallback) +int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SearchOptions sOptions, PSynSearchBase searchEngine, + SearchMathedProc matchedCallback, SearchConfirmAroundProc confirmAroundCallback) { if (!searchEngine) return 0; @@ -5176,10 +5146,10 @@ int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynS ptStart = blockBegin(); ptEnd = blockEnd(); // search the whole line in the line selection mode - if (mActiveSelectionMode == SynSelectionMode::Line) { + if (mActiveSelectionMode == SelectionMode::Line) { ptStart.ch = 1; ptEnd.ch = mDocument->getString(ptEnd.line - 1).length(); - } else if (mActiveSelectionMode == SynSelectionMode::Column) { + } else if (mActiveSelectionMode == SelectionMode::Column) { // make sure the start column is smaller than the end column if (ptStart.ch > ptEnd.ch) std::swap(ptStart.ch,ptEnd.ch); @@ -5212,18 +5182,16 @@ int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynS searchEngine->setPattern(sSearch); // search while the current search position is inside of the search range bool dobatchReplace = false; - doOnPaintTransient(SynTransientType::ttBefore); { auto action = finally([&,this]{ if (dobatchReplace) { decPaintLock(); mUndoList->endBlock(); } - doOnPaintTransient(SynTransientType::ttAfter); }); int i; // If it's a search only we can leave the procedure now. - SynSearchAction searchAction = SynSearchAction::Exit; + SearchAction searchAction = SearchAction::Exit; while ((ptCurrent.line >= ptStart.line) && (ptCurrent.line <= ptEnd.line)) { int nInLine = searchEngine->findAll(mDocument->getString(ptCurrent.line - 1)); int iResultOffset = 0; @@ -5246,12 +5214,12 @@ int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynS bool isInValidSearchRange = true; int first = nFound; int last = nFound + nSearchLen; - if ((mActiveSelectionMode == SynSelectionMode::Normal) + if ((mActiveSelectionMode == SelectionMode::Normal) || !sOptions.testFlag(ssoSelectedOnly)) { if (((ptCurrent.line == ptStart.line) && (first < ptStart.ch)) || ((ptCurrent.line == ptEnd.line) && (last > ptEnd.ch))) isInValidSearchRange = false; - } else if (mActiveSelectionMode == SynSelectionMode::Column) { + } else if (mActiveSelectionMode == SelectionMode::Column) { // solves bug in search/replace when smColumn mode active and no selection isInValidSearchRange = ((first >= ptStart.ch) && (last <= ptEnd.ch)) || (ptEnd.ch - ptStart.ch < 1); @@ -5280,20 +5248,20 @@ int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynS searchAction = matchedCallback(sSearch,replaceText,ptCurrent.line, nFound,nSearchLen); } - if (searchAction==SynSearchAction::Exit) { + if (searchAction==SearchAction::Exit) { return result; - } else if (searchAction == SynSearchAction::Skip) { + } else if (searchAction == SearchAction::Skip) { continue; - } else if (searchAction == SynSearchAction::Replace - || searchAction == SynSearchAction::ReplaceAll) { + } else if (searchAction == SearchAction::Replace + || searchAction == SearchAction::ReplaceAll) { if (!dobatchReplace && - (searchAction == SynSearchAction::ReplaceAll) ){ + (searchAction == SearchAction::ReplaceAll) ){ incPaintLock(); mUndoList->beginBlock(); dobatchReplace = true; } - bool oldAutoIndent = mOptions.testFlag(SynEditorOption::eoAutoIndent); - mOptions.setFlag(SynEditorOption::eoAutoIndent,false); + bool oldAutoIndent = mOptions.testFlag(EditorOption::eoAutoIndent); + mOptions.setFlag(EditorOption::eoAutoIndent,false); doSetSelText(replaceText); nReplaceLen = caretX() - nFound; // fix the caret position and the remaining results @@ -5301,13 +5269,13 @@ int SynEdit::searchReplace(const QString &sSearch, const QString &sReplace, SynS internalSetCaretX(nFound + nReplaceLen); if ((nSearchLen != nReplaceLen)) { iResultOffset += nReplaceLen - nSearchLen; - if ((mActiveSelectionMode != SynSelectionMode::Column) && (caretY() == ptEnd.line)) { + if ((mActiveSelectionMode != SelectionMode::Column) && (caretY() == ptEnd.line)) { ptEnd.ch+=nReplaceLen - nSearchLen; setBlockEnd(ptEnd); } } } - mOptions.setFlag(SynEditorOption::eoAutoIndent,oldAutoIndent); + mOptions.setFlag(EditorOption::eoAutoIndent,oldAutoIndent); } } // search next / previous line @@ -5379,12 +5347,12 @@ void SynEdit::properSetLine(int ALine, const QString &ALineText, bool notify) } } -void SynEdit::doDeleteText(BufferCoord startPos, BufferCoord endPos, SynSelectionMode mode) +void SynEdit::doDeleteText(BufferCoord startPos, BufferCoord endPos, SelectionMode mode) { bool UpdateMarks = false; int MarkOffset = 0; - if (mode == SynSelectionMode::Normal) { - PSynEditFoldRange foldRange = foldStartAtLine(endPos.line); + if (mode == SelectionMode::Normal) { + PCodeFoldingRange foldRange = foldStartAtLine(endPos.line); QString s = mDocument->getString(endPos.line-1); if ((foldRange) && foldRange->collapsed && endPos.ch>s.length()) { QString newS=s+highlighter()->foldString(); @@ -5400,7 +5368,7 @@ void SynEdit::doDeleteText(BufferCoord startPos, BufferCoord endPos, SynSelectio } QStringList deleted=getContent(startPos,endPos,mode); switch(mode) { - case SynSelectionMode::Normal: + case SelectionMode::Normal: if (mDocument->count() > 0) { // Create a string that contains everything on the first line up // to the selection mark, and everything on the last line after @@ -5421,7 +5389,7 @@ void SynEdit::doDeleteText(BufferCoord startPos, BufferCoord endPos, SynSelectio // } } break; - case SynSelectionMode::Column: + case SelectionMode::Column: { int First = startPos.line - 1; int ColFrom = charToColumn(startPos.line, startPos.ch); @@ -5445,7 +5413,7 @@ void SynEdit::doDeleteText(BufferCoord startPos, BufferCoord endPos, SynSelectio // updating is needed here. break; } - case SynSelectionMode::Line: + case SelectionMode::Line: if (endPos.line == mDocument->count()) { mDocument->putString(endPos.line - 1,""); mDocument->deleteLines(startPos.line-1,endPos.line-startPos.line); @@ -5472,14 +5440,14 @@ void SynEdit::doDeleteText(BufferCoord startPos, BufferCoord endPos, SynSelectio void SynEdit::doInsertText(const BufferCoord& pos, const QStringList& text, - SynSelectionMode mode, int startLine, int endLine) { + SelectionMode mode, int startLine, int endLine) { if (text.isEmpty()) return; if (startLine>endLine) std::swap(startLine,endLine); - if (mode == SynSelectionMode::Normal) { - PSynEditFoldRange foldRange = foldStartAtLine(pos.line); + if (mode == SelectionMode::Normal) { + PCodeFoldingRange foldRange = foldStartAtLine(pos.line); QString s = mDocument->getString(pos.line-1); if ((foldRange) && foldRange->collapsed && pos.ch>s.length()+1) return; @@ -5487,15 +5455,15 @@ void SynEdit::doInsertText(const BufferCoord& pos, int insertedLines = 0; BufferCoord newPos; switch(mode){ - case SynSelectionMode::Normal: + case SelectionMode::Normal: insertedLines = doInsertTextByNormalMode(pos,text, newPos); doLinesInserted(pos.line+1, insertedLines); break; - case SynSelectionMode::Column: + case SelectionMode::Column: insertedLines = doInsertTextByColumnMode(pos,text, newPos, startLine,endLine); doLinesInserted(endLine-insertedLines+1,insertedLines); break; - case SynSelectionMode::Line: + case SelectionMode::Line: insertedLines = doInsertTextByLineMode(pos,text, newPos); doLinesInserted(pos.line, insertedLines); break; @@ -5594,7 +5562,7 @@ int SynEdit::doInsertTextByNormalMode(const BufferCoord& pos, const QStringList& mUndoList->addChange( SynChangeReason::Insert, pos,newPos, - QStringList(),SynSelectionMode::Normal); + QStringList(),SelectionMode::Normal); } return result; } @@ -5628,7 +5596,7 @@ int SynEdit::doInsertTextByColumnMode(const BufferCoord& pos, const QStringList& mUndoList->addChange(SynChangeReason::LineBreak, lineBreakPos, lineBreakPos, - QStringList(), SynSelectionMode::Normal); + QStringList(), SelectionMode::Normal); } } else { tempString = mDocument->getString(line - 1); @@ -5649,7 +5617,7 @@ int SynEdit::doInsertTextByColumnMode(const BufferCoord& pos, const QStringList& BufferCoord{insertPos, line}, BufferCoord{insertPos+str.length(), line}, QStringList(), - SynSelectionMode::Normal); + SelectionMode::Normal); } if (iaddChange( SynChangeReason::Insert, BufferCoord{1,pos.line},newPos, - QStringList(),SynSelectionMode::Line); + QStringList(),SelectionMode::Line); } return Result; } @@ -5700,18 +5668,16 @@ void SynEdit::deleteFromTo(const BufferCoord &start, const BufferCoord &end) { if (mReadOnly) return; - doOnPaintTransient(SynTransientType::ttBefore); if ((start.ch != end.ch) || (start.line != end.line)) { mUndoList->beginBlock(); addCaretToUndo(); addSelectionToUndo(); setBlockBegin(start); setBlockEnd(end); - doDeleteText(start,end,SynSelectionMode::Normal); + doDeleteText(start,end,SelectionMode::Normal); mUndoList->endBlock(); internalSetCaretXY(start); } - doOnPaintTransient(SynTransientType::ttAfter); } bool SynEdit::onGetSpecialLineColors(int, QColor &, QColor &) @@ -5719,7 +5685,7 @@ bool SynEdit::onGetSpecialLineColors(int, QColor &, QColor &) return false; } -void SynEdit::onGetEditingAreas(int, SynEditingAreaList &) +void SynEdit::onGetEditingAreas(int, EditingAreaList &) { } @@ -5740,22 +5706,22 @@ void SynEdit::onPaint(QPainter &) } void SynEdit::onPreparePaintHighlightToken(int , int , const QString &, - PSynHighlighterAttribute , SynFontStyles &, QColor &, QColor &) + PHighlighterAttribute , FontStyles &, QColor &, QColor &) { } -void SynEdit::onProcessCommand(SynEditorCommand , QChar , void *) +void SynEdit::onProcessCommand(EditCommand , QChar , void *) { } -void SynEdit::onCommandProcessed(SynEditorCommand , QChar , void *) +void SynEdit::onCommandProcessed(EditCommand , QChar , void *) { } -void SynEdit::ExecuteCommand(SynEditorCommand Command, QChar AChar, void *pData) +void SynEdit::ExecuteCommand(EditCommand Command, QChar AChar, void *pData) { hideCaret(); incPaintLock(); @@ -5766,43 +5732,43 @@ void SynEdit::ExecuteCommand(SynEditorCommand Command, QChar AChar, void *pData) }); switch(Command) { //horizontal caret movement or selection - case SynEditorCommand::ecLeft: - case SynEditorCommand::ecSelLeft: - moveCaretHorz(-1, Command == SynEditorCommand::ecSelLeft); + case EditCommand::ecLeft: + case EditCommand::ecSelLeft: + moveCaretHorz(-1, Command == EditCommand::ecSelLeft); break; - case SynEditorCommand::ecRight: - case SynEditorCommand::ecSelRight: - moveCaretHorz(1, Command == SynEditorCommand::ecSelRight); + case EditCommand::ecRight: + case EditCommand::ecSelRight: + moveCaretHorz(1, Command == EditCommand::ecSelRight); break; - case SynEditorCommand::ecPageLeft: - case SynEditorCommand::ecSelPageLeft: - moveCaretHorz(-mCharsInWindow, Command == SynEditorCommand::ecSelPageLeft); + case EditCommand::ecPageLeft: + case EditCommand::ecSelPageLeft: + moveCaretHorz(-mCharsInWindow, Command == EditCommand::ecSelPageLeft); break; - case SynEditorCommand::ecPageRight: - case SynEditorCommand::ecSelPageRight: - moveCaretHorz(mCharsInWindow, Command == SynEditorCommand::ecSelPageRight); + case EditCommand::ecPageRight: + case EditCommand::ecSelPageRight: + moveCaretHorz(mCharsInWindow, Command == EditCommand::ecSelPageRight); break; - case SynEditorCommand::ecLineStart: - case SynEditorCommand::ecSelLineStart: - moveCaretToLineStart(Command == SynEditorCommand::ecSelLineStart); + case EditCommand::ecLineStart: + case EditCommand::ecSelLineStart: + moveCaretToLineStart(Command == EditCommand::ecSelLineStart); break; - case SynEditorCommand::ecLineEnd: - case SynEditorCommand::ecSelLineEnd: - moveCaretToLineEnd(Command == SynEditorCommand::ecSelLineEnd); + case EditCommand::ecLineEnd: + case EditCommand::ecSelLineEnd: + moveCaretToLineEnd(Command == EditCommand::ecSelLineEnd); break; // vertical caret movement or selection - case SynEditorCommand::ecUp: - case SynEditorCommand::ecSelUp: - moveCaretVert(-1, Command == SynEditorCommand::ecSelUp); + case EditCommand::ecUp: + case EditCommand::ecSelUp: + moveCaretVert(-1, Command == EditCommand::ecSelUp); break; - case SynEditorCommand::ecDown: - case SynEditorCommand::ecSelDown: - moveCaretVert(1, Command == SynEditorCommand::ecSelDown); + case EditCommand::ecDown: + case EditCommand::ecSelDown: + moveCaretVert(1, Command == EditCommand::ecSelDown); break; - case SynEditorCommand::ecPageUp: - case SynEditorCommand::ecSelPageUp: - case SynEditorCommand::ecPageDown: - case SynEditorCommand::ecSelPageDown: + case EditCommand::ecPageUp: + case EditCommand::ecSelPageUp: + case EditCommand::ecPageDown: + case EditCommand::ecSelPageDown: { int counter = mLinesInWindow; if (mOptions.testFlag(eoHalfPageScroll)) @@ -5812,108 +5778,108 @@ void SynEdit::ExecuteCommand(SynEditorCommand Command, QChar AChar, void *pData) } if (counter<0) break; - if (Command == SynEditorCommand::ecPageUp || Command == SynEditorCommand::ecSelPageUp) { + if (Command == EditCommand::ecPageUp || Command == EditCommand::ecSelPageUp) { counter = -counter; } - moveCaretVert(counter, Command == SynEditorCommand::ecSelPageUp || Command == SynEditorCommand::ecSelPageDown); + moveCaretVert(counter, Command == EditCommand::ecSelPageUp || Command == EditCommand::ecSelPageDown); break; } - case SynEditorCommand::ecPageTop: - case SynEditorCommand::ecSelPageTop: - moveCaretVert(mTopLine-mCaretY, Command == SynEditorCommand::ecSelPageTop); + case EditCommand::ecPageTop: + case EditCommand::ecSelPageTop: + moveCaretVert(mTopLine-mCaretY, Command == EditCommand::ecSelPageTop); break; - case SynEditorCommand::ecPageBottom: - case SynEditorCommand::ecSelPageBottom: - moveCaretVert(mTopLine+mLinesInWindow-1-mCaretY, Command == SynEditorCommand::ecSelPageBottom); + case EditCommand::ecPageBottom: + case EditCommand::ecSelPageBottom: + moveCaretVert(mTopLine+mLinesInWindow-1-mCaretY, Command == EditCommand::ecSelPageBottom); break; - case SynEditorCommand::ecEditorStart: - case SynEditorCommand::ecSelEditorStart: - moveCaretVert(1-mCaretY, Command == SynEditorCommand::ecSelEditorStart); - moveCaretToLineStart(Command == SynEditorCommand::ecSelEditorStart); + case EditCommand::ecEditorStart: + case EditCommand::ecSelEditorStart: + moveCaretVert(1-mCaretY, Command == EditCommand::ecSelEditorStart); + moveCaretToLineStart(Command == EditCommand::ecSelEditorStart); break; - case SynEditorCommand::ecEditorEnd: - case SynEditorCommand::ecSelEditorEnd: + case EditCommand::ecEditorEnd: + case EditCommand::ecSelEditorEnd: if (!mDocument->empty()) { - moveCaretVert(mDocument->count()-mCaretY, Command == SynEditorCommand::ecSelEditorEnd); - moveCaretToLineEnd(Command == SynEditorCommand::ecSelEditorEnd); + moveCaretVert(mDocument->count()-mCaretY, Command == EditCommand::ecSelEditorEnd); + moveCaretToLineEnd(Command == EditCommand::ecSelEditorEnd); } break; // goto special line / column position - case SynEditorCommand::ecGotoXY: - case SynEditorCommand::ecSelGotoXY: + case EditCommand::ecGotoXY: + case EditCommand::ecSelGotoXY: if (pData) - moveCaretAndSelection(caretXY(), *((BufferCoord *)(pData)), Command == SynEditorCommand::ecSelGotoXY); + moveCaretAndSelection(caretXY(), *((BufferCoord *)(pData)), Command == EditCommand::ecSelGotoXY); break; // word selection - case SynEditorCommand::ecWordLeft: - case SynEditorCommand::ecSelWordLeft: + case EditCommand::ecWordLeft: + case EditCommand::ecSelWordLeft: { BufferCoord CaretNew = prevWordPos(); - moveCaretAndSelection(caretXY(), CaretNew, Command == SynEditorCommand::ecSelWordLeft); + moveCaretAndSelection(caretXY(), CaretNew, Command == EditCommand::ecSelWordLeft); break; } - case SynEditorCommand::ecWordRight: - case SynEditorCommand::ecSelWordRight: + case EditCommand::ecWordRight: + case EditCommand::ecSelWordRight: { BufferCoord CaretNew = nextWordPos(); - moveCaretAndSelection(caretXY(), CaretNew, Command == SynEditorCommand::ecSelWordRight); + moveCaretAndSelection(caretXY(), CaretNew, Command == EditCommand::ecSelWordRight); break; } - case SynEditorCommand::ecSelWord: + case EditCommand::ecSelWord: setSelWord(); break; - case SynEditorCommand::ecSelectAll: + case EditCommand::ecSelectAll: doSelectAll(); break; - case SynEditorCommand::ecExpandSelection: + case EditCommand::ecExpandSelection: doExpandSelection(caretXY()); break; - case SynEditorCommand::ecShrinkSelection: + case EditCommand::ecShrinkSelection: doShrinkSelection(caretXY()); break; - case SynEditorCommand::ecDeleteLastChar: + case EditCommand::ecDeleteLastChar: doDeleteLastChar(); break; - case SynEditorCommand::ecDeleteChar: + case EditCommand::ecDeleteChar: doDeleteCurrentChar(); break; - case SynEditorCommand::ecDeleteWord: + case EditCommand::ecDeleteWord: doDeleteWord(); break; - case SynEditorCommand::ecDeleteEOL: + case EditCommand::ecDeleteEOL: doDeleteToEOL(); break; - case SynEditorCommand::ecDeleteWordStart: + case EditCommand::ecDeleteWordStart: doDeleteToWordStart(); break; - case SynEditorCommand::ecDeleteWordEnd: + case EditCommand::ecDeleteWordEnd: doDeleteToWordEnd(); break; - case SynEditorCommand::ecDeleteBOL: + case EditCommand::ecDeleteBOL: doDeleteFromBOL(); break; - case SynEditorCommand::ecDeleteLine: + case EditCommand::ecDeleteLine: doDeleteLine(); break; - case SynEditorCommand::ecDuplicateLine: + case EditCommand::ecDuplicateLine: doDuplicateLine(); break; - case SynEditorCommand::ecMoveSelUp: + case EditCommand::ecMoveSelUp: doMoveSelUp(); break; - case SynEditorCommand::ecMoveSelDown: + case EditCommand::ecMoveSelDown: doMoveSelDown(); break; - case SynEditorCommand::ecClearAll: + case EditCommand::ecClearAll: clearAll(); break; - case SynEditorCommand::ecInsertLine: + case EditCommand::ecInsertLine: insertLine(false); break; - case SynEditorCommand::ecLineBreak: + case EditCommand::ecLineBreak: insertLine(true); break; - case SynEditorCommand::ecLineBreakAtEnd: + case EditCommand::ecLineBreakAtEnd: mUndoList->beginBlock(); addCaretToUndo(); addSelectionToUndo(); @@ -5921,92 +5887,92 @@ void SynEdit::ExecuteCommand(SynEditorCommand Command, QChar AChar, void *pData) insertLine(true); mUndoList->endBlock(); break; - case SynEditorCommand::ecTab: + case EditCommand::ecTab: doTabKey(); break; - case SynEditorCommand::ecShiftTab: + case EditCommand::ecShiftTab: doShiftTabKey(); break; - case SynEditorCommand::ecChar: + case EditCommand::ecChar: doAddChar(AChar); break; - case SynEditorCommand::ecInsertMode: + case EditCommand::ecInsertMode: if (!mReadOnly) setInsertMode(true); break; - case SynEditorCommand::ecOverwriteMode: + case EditCommand::ecOverwriteMode: if (!mReadOnly) setInsertMode(false); break; - case SynEditorCommand::ecToggleMode: + case EditCommand::ecToggleMode: if (!mReadOnly) { setInsertMode(!mInserting); } break; - case SynEditorCommand::ecCut: + case EditCommand::ecCut: if (!mReadOnly) doCutToClipboard(); break; - case SynEditorCommand::ecCopy: + case EditCommand::ecCopy: doCopyToClipboard(); break; - case SynEditorCommand::ecPaste: + case EditCommand::ecPaste: if (!mReadOnly) doPasteFromClipboard(); break; - case SynEditorCommand::ecImeStr: - case SynEditorCommand::ecString: + case EditCommand::ecImeStr: + case EditCommand::ecString: if (!mReadOnly) doAddStr(*((QString*)pData)); break; - case SynEditorCommand::ecUndo: + case EditCommand::ecUndo: if (!mReadOnly) doUndo(); break; - case SynEditorCommand::ecRedo: + case EditCommand::ecRedo: if (!mReadOnly) doRedo(); break; - case SynEditorCommand::ecZoomIn: + case EditCommand::ecZoomIn: doZoomIn(); break; - case SynEditorCommand::ecZoomOut: + case EditCommand::ecZoomOut: doZoomOut(); break; - case SynEditorCommand::ecComment: + case EditCommand::ecComment: doComment(); break; - case SynEditorCommand::ecUncomment: + case EditCommand::ecUncomment: doUncomment(); break; - case SynEditorCommand::ecToggleComment: + case EditCommand::ecToggleComment: doToggleComment(); break; - case SynEditorCommand::ecToggleBlockComment: + case EditCommand::ecToggleBlockComment: doToggleBlockComment(); break; - case SynEditorCommand::ecNormalSelect: - setSelectionMode(SynSelectionMode::Normal); + case EditCommand::ecNormalSelect: + setSelectionMode(SelectionMode::Normal); break; - case SynEditorCommand::ecLineSelect: - setSelectionMode(SynSelectionMode::Line); + case EditCommand::ecLineSelect: + setSelectionMode(SelectionMode::Line); break; - case SynEditorCommand::ecColumnSelect: - setSelectionMode(SynSelectionMode::Column); + case EditCommand::ecColumnSelect: + setSelectionMode(SelectionMode::Column); break; - case SynEditorCommand::ecScrollLeft: + case EditCommand::ecScrollLeft: horizontalScrollBar()->setValue(horizontalScrollBar()->value()-mMouseWheelScrollSpeed); break; - case SynEditorCommand::ecScrollRight: + case EditCommand::ecScrollRight: horizontalScrollBar()->setValue(horizontalScrollBar()->value()+mMouseWheelScrollSpeed); break; - case SynEditorCommand::ecScrollUp: + case EditCommand::ecScrollUp: verticalScrollBar()->setValue(verticalScrollBar()->value()-mMouseWheelScrollSpeed); break; - case SynEditorCommand::ecScrollDown: + case EditCommand::ecScrollDown: verticalScrollBar()->setValue(verticalScrollBar()->value()+mMouseWheelScrollSpeed); break; - case SynEditorCommand::ecMatchBracket: + case EditCommand::ecMatchBracket: { BufferCoord coord = getMatchingBracket(); if (coord.ch!=0 && coord.line!=0) @@ -6051,7 +6017,7 @@ bool SynEdit::isIdentChar(const QChar &ch) } } -void SynEdit::setRainbowAttrs(const PSynHighlighterAttribute &attr0, const PSynHighlighterAttribute &attr1, const PSynHighlighterAttribute &attr2, const PSynHighlighterAttribute &attr3) +void SynEdit::setRainbowAttrs(const PHighlighterAttribute &attr0, const PHighlighterAttribute &attr1, const PHighlighterAttribute &attr2, const PHighlighterAttribute &attr3) { mRainbowAttr0 = attr0; mRainbowAttr1 = attr1; @@ -6148,7 +6114,6 @@ void SynEdit::paintEvent(QPaintEvent *event) //PluginsAfterPaint(Canvas, rcClip, nL1, nL2); // If there is a custom paint handler call it. onPaint(painter); - doOnPaintTransient(SynTransientType::ttAfter); QRectF cacheRC; qreal dpr = mContentImage->devicePixelRatioF(); cacheRC.setLeft(rcClip.left()*dpr); @@ -6232,14 +6197,14 @@ void SynEdit::keyPressEvent(QKeyEvent *event) setBlockEnd(caretXY()); event->accept(); } else { - SynEditorCommand cmd=TranslateKeyCode(event->key(),event->modifiers()); - if (cmd!=SynEditorCommand::ecNone) { + EditCommand cmd=TranslateKeyCode(event->key(),event->modifiers()); + if (cmd!=EditCommand::ecNone) { commandProcessor(cmd,QChar(),nullptr); event->accept(); } else if (!event->text().isEmpty()) { QChar c = event->text().at(0); if (c=='\t' || c.isPrint()) { - commandProcessor(SynEditorCommand::ecChar,c,nullptr); + commandProcessor(EditCommand::ecChar,c,nullptr); event->accept(); } } @@ -6279,22 +6244,22 @@ void SynEdit::mousePressEvent(QMouseEvent *event) mMouseDownPos = event->pos(); } computeCaret(); - mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false); + mStateFlags.setFlag(StateFlag::sfWaitForDragging,false); if (bWasSel && mOptions.testFlag(eoDragDropEditing) && (X >= mGutterWidth + 2) - && (mSelectionMode == SynSelectionMode::Normal) && isPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))) ) { + && (mSelectionMode == SelectionMode::Normal) && isPointInSelection(displayToBufferPos(pixelsToRowColumn(X, Y))) ) { bStartDrag = true; } if (bStartDrag && !mReadOnly) { - mStateFlags.setFlag(SynStateFlag::sfWaitForDragging); + mStateFlags.setFlag(StateFlag::sfWaitForDragging); } else { if (event->modifiers() == Qt::ShiftModifier) { //BlockBegin and BlockEnd are restored to their original position in the //code from above and SetBlockEnd will take care of proper invalidation setBlockEnd(caretXY()); } else if (mOptions.testFlag(eoAltSetsColumnMode) && - (mActiveSelectionMode != SynSelectionMode::Line)) { + (mActiveSelectionMode != SelectionMode::Line)) { if (event->modifiers() == Qt::AltModifier && !mReadOnly) - setActiveSelectionMode(SynSelectionMode::Column); + setActiveSelectionMode(SelectionMode::Column); else setActiveSelectionMode(selectionMode()); //Selection mode must be set before calling SetBlockBegin @@ -6304,7 +6269,7 @@ void SynEdit::mousePressEvent(QMouseEvent *event) } } if (oldCaret!=caretXY()) { - if (mOptions.testFlag(SynEditorOption::eoGroupUndo)) + if (mOptions.testFlag(EditorOption::eoGroupUndo)) mUndoList->addGroupBreak(); } } @@ -6320,17 +6285,17 @@ void SynEdit::mouseReleaseEvent(QMouseEvent *event) } BufferCoord oldCaret=caretXY(); - if (mStateFlags.testFlag(SynStateFlag::sfWaitForDragging) && - !mStateFlags.testFlag(SynStateFlag::sfDblClicked)) { + if (mStateFlags.testFlag(StateFlag::sfWaitForDragging) && + !mStateFlags.testFlag(StateFlag::sfDblClicked)) { computeCaret(); if (! (event->modifiers() & Qt::ShiftModifier)) setBlockBegin(caretXY()); setBlockEnd(caretXY()); - mStateFlags.setFlag(SynStateFlag::sfWaitForDragging, false); + mStateFlags.setFlag(StateFlag::sfWaitForDragging, false); } - mStateFlags.setFlag(SynStateFlag::sfDblClicked,false); + mStateFlags.setFlag(StateFlag::sfDblClicked,false); if (oldCaret!=caretXY()) { - if (mOptions.testFlag(SynEditorOption::eoGroupUndo)) + if (mOptions.testFlag(EditorOption::eoGroupUndo)) mUndoList->addGroupBreak(); } } @@ -6340,10 +6305,10 @@ void SynEdit::mouseMoveEvent(QMouseEvent *event) QAbstractScrollArea::mouseMoveEvent(event); mMouseMoved = true; Qt::MouseButtons buttons = event->buttons(); - if (mStateFlags.testFlag(SynStateFlag::sfWaitForDragging) + if (mStateFlags.testFlag(StateFlag::sfWaitForDragging) && !mReadOnly) { if ( ( event->pos() - mMouseDownPos).manhattanLength()>=QApplication::startDragDistance()) { - mStateFlags.setFlag(SynStateFlag::sfWaitForDragging,false); + mStateFlags.setFlag(StateFlag::sfWaitForDragging,false); QDrag *drag = new QDrag(this); QMimeData *mimeData = new QMimeData; @@ -6354,9 +6319,9 @@ void SynEdit::mouseMoveEvent(QMouseEvent *event) } } else if (buttons == Qt::LeftButton) { if (mOptions.testFlag(eoAltSetsColumnMode) && - (mActiveSelectionMode != SynSelectionMode::Line) ) { + (mActiveSelectionMode != SelectionMode::Line) ) { if (event->modifiers() == Qt::AltModifier && !mReadOnly) - setActiveSelectionMode(SynSelectionMode::Column); + setActiveSelectionMode(SelectionMode::Column); else setActiveSelectionMode(selectionMode()); } @@ -6371,7 +6336,7 @@ void SynEdit::mouseDoubleClickEvent(QMouseEvent *event) QPoint ptMouse = event->pos(); if (ptMouse.x() >= mGutterWidth + 2) { setSelWord(); - mStateFlags.setFlag(SynStateFlag::sfDblClicked); + mStateFlags.setFlag(StateFlag::sfDblClicked); } } @@ -6383,7 +6348,7 @@ void SynEdit::inputMethodEvent(QInputMethodEvent *event) QString oldString = mInputPreeditString; mInputPreeditString = event->preeditString(); if (oldString!=mInputPreeditString) { - if (mActiveSelectionMode==SynSelectionMode::Column) { + if (mActiveSelectionMode==SelectionMode::Column) { BufferCoord selBegin = blockBegin(); BufferCoord selEnd = blockEnd(); invalidateLines(selBegin.line,selEnd.line); @@ -6392,7 +6357,7 @@ void SynEdit::inputMethodEvent(QInputMethodEvent *event) } QString s = event->commitString(); if (!s.isEmpty()) { - commandProcessor(SynEditorCommand::ecImeStr,QChar(),&s); + commandProcessor(EditCommand::ecImeStr,QChar(),&s); // for (QChar ch:s) { // CommandProcessor(SynEditorCommand::ecChar,ch); // } @@ -6575,7 +6540,7 @@ void SynEdit::setModified(bool Value) { if (Value) { mLastModifyTime = QDateTime::currentDateTime(); - emit statusChanged(SynStatusChange::scModified); + emit statusChanged(StatusChange::scModified); } if (Value != mModified) { mModified = Value; @@ -6584,12 +6549,12 @@ void SynEdit::setModified(bool Value) mUndoList->clear(); mRedoList->clear(); } else { - if (mOptions.testFlag(SynEditorOption::eoGroupUndo)) { + if (mOptions.testFlag(EditorOption::eoGroupUndo)) { mUndoList->addGroupBreak(); } mUndoList->setInitialState(); } - emit statusChanged(SynStatusChange::scModifyChanged); + emit statusChanged(StatusChange::scModifyChanged); } } @@ -6630,11 +6595,11 @@ void SynEdit::onBookMarkOptionsChanged() void SynEdit::onLinesChanged() { - SynSelectionMode vOldMode; - mStateFlags.setFlag(SynStateFlag::sfLinesChanging, false); + SelectionMode vOldMode; + mStateFlags.setFlag(StateFlag::sfLinesChanging, false); updateScrollbars(); - if (mActiveSelectionMode == SynSelectionMode::Column) { + if (mActiveSelectionMode == SelectionMode::Column) { BufferCoord oldBlockStart = blockBegin(); BufferCoord oldBlockEnd = blockEnd(); int colEnd = charToColumn(mCaretY,mCaretX); @@ -6660,7 +6625,7 @@ void SynEdit::onLinesChanged() void SynEdit::onLinesChanging() { - mStateFlags.setFlag(SynStateFlag::sfLinesChanging); + mStateFlags.setFlag(StateFlag::sfLinesChanging); } void SynEdit::onLinesCleared() @@ -6676,7 +6641,7 @@ void SynEdit::onLinesCleared() // scroll to start of text setTopLine(1); setLeftChar(1); - mStatusChanges.setFlag(SynStatusChange::scAll); + mStatusChanges.setFlag(StatusChange::scAll); } void SynEdit::onLinesDeleted(int index, int count) @@ -6726,12 +6691,12 @@ void SynEdit::onUndoAdded() onChanged(); } -SynSelectionMode SynEdit::activeSelectionMode() const +SelectionMode SynEdit::activeSelectionMode() const { return mActiveSelectionMode; } -void SynEdit::setActiveSelectionMode(const SynSelectionMode &Value) +void SynEdit::setActiveSelectionMode(const SelectionMode &Value) { if (mActiveSelectionMode != Value) { if (selAvail()) @@ -6739,13 +6704,13 @@ void SynEdit::setActiveSelectionMode(const SynSelectionMode &Value) mActiveSelectionMode = Value; if (selAvail()) invalidateSelection(); - setStatusChanged(SynStatusChange::scSelection); + setStatusChanged(StatusChange::scSelection); } } BufferCoord SynEdit::blockEnd() const { - if (mActiveSelectionMode==SynSelectionMode::Column) + if (mActiveSelectionMode==SelectionMode::Column) return mBlockEnd; if ((mBlockEnd.line < mBlockBegin.line) || ((mBlockEnd.line == mBlockBegin.line) && (mBlockEnd.ch < mBlockBegin.ch))) @@ -6758,7 +6723,7 @@ void SynEdit::setBlockEnd(BufferCoord Value) { //setActiveSelectionMode(mSelectionMode); Value.line = minMax(Value.line, 1, mDocument->count()); - if (mActiveSelectionMode == SynSelectionMode::Normal) { + if (mActiveSelectionMode == SelectionMode::Normal) { if (Value.line >= 1 && Value.line <= mDocument->count()) Value.ch = std::min(Value.ch, getDisplayStringAtLine(Value.line).length() + 1); else @@ -6770,7 +6735,7 @@ void SynEdit::setBlockEnd(BufferCoord Value) Value.ch = minMax(Value.ch, 1, maxLen+1); } if (Value.ch != mBlockEnd.ch || Value.line != mBlockEnd.line) { - if (mActiveSelectionMode == SynSelectionMode::Column && Value.ch != mBlockEnd.ch) { + if (mActiveSelectionMode == SelectionMode::Column && Value.ch != mBlockEnd.ch) { invalidateLines( std::min(mBlockBegin.line, std::min(mBlockEnd.line, Value.line)), std::max(mBlockBegin.line, std::max(mBlockEnd.line, Value.line))); @@ -6778,10 +6743,10 @@ void SynEdit::setBlockEnd(BufferCoord Value) } else { int nLine = mBlockEnd.line; mBlockEnd = Value; - if (mActiveSelectionMode != SynSelectionMode::Column || mBlockBegin.ch != mBlockEnd.ch) + if (mActiveSelectionMode != SelectionMode::Column || mBlockBegin.ch != mBlockEnd.ch) invalidateLines(nLine, mBlockEnd.line); } - setStatusChanged(SynStatusChange::scSelection); + setStatusChanged(StatusChange::scSelection); } } @@ -6842,7 +6807,7 @@ void SynEdit::setSelText(const QString &text) BufferCoord SynEdit::blockBegin() const { - if (mActiveSelectionMode==SynSelectionMode::Column) + if (mActiveSelectionMode==SelectionMode::Column) return mBlockBegin; if ((mBlockEnd.line < mBlockBegin.line) || ((mBlockEnd.line == mBlockBegin.line) && (mBlockEnd.ch < mBlockBegin.ch))) @@ -6857,7 +6822,7 @@ void SynEdit::setBlockBegin(BufferCoord value) bool SelChanged; //setActiveSelectionMode(mSelectionMode); value.line = minMax(value.line, 1, mDocument->count()); - if (mActiveSelectionMode == SynSelectionMode::Normal) { + if (mActiveSelectionMode == SelectionMode::Normal) { if (value.line >= 1 && value.line <= mDocument->count()) value.ch = std::min(value.ch, getDisplayStringAtLine(value.line).length() + 1); else @@ -6888,7 +6853,7 @@ void SynEdit::setBlockBegin(BufferCoord value) mBlockEnd = value; } if (SelChanged) - setStatusChanged(SynStatusChange::scSelection); + setStatusChanged(StatusChange::scSelection); } int SynEdit::leftChar() const @@ -6903,7 +6868,7 @@ void SynEdit::setLeftChar(int Value) Value = std::min(Value,maxScrollWidth()); if (Value != mLeftChar) { horizontalScrollBar()->setValue(Value); - setStatusChanged(SynStatusChange::scLeftChar); + setStatusChanged(StatusChange::scLeftChar); } } @@ -6927,7 +6892,7 @@ void SynEdit::setTopLine(int Value) Value = std::max(Value, 1); if (Value != mTopLine) { verticalScrollBar()->setValue(Value); - setStatusChanged(SynStatusChange::scTopLine); + setStatusChanged(StatusChange::scTopLine); } } diff --git a/libs/qsynedit/qsynedit/SynEdit.h b/libs/qsynedit/qsynedit/SynEdit.h index 4019e453..c463c0e2 100644 --- a/libs/qsynedit/qsynedit/SynEdit.h +++ b/libs/qsynedit/qsynedit/SynEdit.h @@ -33,24 +33,15 @@ namespace QSynedit { -enum class SynFontSmoothMethod { - None, AntiAlias, ClearType -}; - - -enum class SynScrollHintFormat { - shfTopLineOnly, shfTopToBottom -}; - -enum class SynScrollStyle { +enum class ScrollStyle { ssNone, ssHorizontal, ssVertical, ssBoth }; -enum class SynEditCaretType { +enum class EditCaretType { ctVerticalLine=0, ctHorizontalLine=1, ctHalfBlock=2, ctBlock=3 }; -enum SynStatusChange { +enum StatusChange { scNone = 0, scAll = 0x0001, scCaretX = 0x0002, @@ -65,10 +56,10 @@ enum SynStatusChange { scModified = 0x0400 }; -Q_DECLARE_FLAGS(SynStatusChanges, SynStatusChange) -Q_DECLARE_OPERATORS_FOR_FLAGS(SynStatusChanges) +Q_DECLARE_FLAGS(StatusChanges, StatusChange) +Q_DECLARE_OPERATORS_FOR_FLAGS(StatusChanges) -enum class SynStateFlag { +enum class StateFlag { sfCaretChanged = 0x0001, sfScrollbarChanged = 0x0002, sfLinesChanging = 0x0004, @@ -78,11 +69,11 @@ enum class SynStateFlag { sfWaitForDragging = 0x0040 }; -Q_DECLARE_FLAGS(SynStateFlags,SynStateFlag) +Q_DECLARE_FLAGS(StateFlags,StateFlag) -Q_DECLARE_OPERATORS_FOR_FLAGS(SynStateFlags) +Q_DECLARE_OPERATORS_FOR_FLAGS(StateFlags) -enum SynEditorOption { +enum EditorOption { eoAltSetsColumnMode = 0x00000001, //Holding down the Alt Key will put the selection mode into columnar format eoAutoIndent = 0x00000002, //Will auto calculate the indent when input eoLigatureSupport = 0x00000004, //Support ligaures in fonts like fira code @@ -115,11 +106,11 @@ enum SynEditorOption { // eoNoCaret = 0x00000800, //Makes it so the caret is never visible }; -Q_DECLARE_FLAGS(SynEditorOptions, SynEditorOption) +Q_DECLARE_FLAGS(EditorOptions, EditorOption) -Q_DECLARE_OPERATORS_FOR_FLAGS(SynEditorOptions) +Q_DECLARE_OPERATORS_FOR_FLAGS(EditorOptions) -enum class SynSearchAction { +enum class SearchAction { Replace, ReplaceAll, Skip, @@ -128,27 +119,23 @@ enum class SynSearchAction { -enum class SynTransientType { +enum class TransientType { ttBefore, ttAfter }; -enum class SynScrollBarKind { - sbHorizontal, sbVertical -}; - /* using SynPaintTransientProc = std::function; */ -using SynProcessCommandProc = std::function; -using SynMouseCursorProc = std::function; -using SynPaintProc = std::function; +using ProcessCommandProc = std::function; +using MouseCursorProc = std::function; +using PaintProc = std::function; //using SynPreparePaintHighlightTokenProc = std::function; -using SynSearchMathedProc = std::function; +using SearchMathedProc = std::function; -using SynSearchConfirmAroundProc = std::function; +using SearchConfirmAroundProc = std::function; class SynEdit; using PSynEdit = std::shared_ptr; @@ -230,7 +217,7 @@ public: BufferCoord prevWordPos(); BufferCoord prevWordPosEx(const BufferCoord& XY); - void commandProcessor(SynEditorCommand Command, QChar AChar = QChar(), void * pData = nullptr); + void commandProcessor(EditCommand Command, QChar AChar = QChar(), void * pData = nullptr); //Caret void showCaret(); void hideCaret(); @@ -248,25 +235,25 @@ public: void collapseAll(); void unCollpaseAll(); void uncollapseAroundLine(int line); - PSynEditFoldRange foldHidesLine(int line); + PCodeFoldingRange foldHidesLine(int line); void setSelLength(int Value); void setSelText(const QString& text); - int searchReplace(const QString& sSearch, const QString& sReplace, SynSearchOptions options, - PSynSearchBase searchEngine, SynSearchMathedProc matchedCallback = nullptr, - SynSearchConfirmAroundProc confirmAroundCallback = nullptr); + int searchReplace(const QString& sSearch, const QString& sReplace, SearchOptions options, + PSynSearchBase searchEngine, SearchMathedProc matchedCallback = nullptr, + SearchConfirmAroundProc confirmAroundCallback = nullptr); int maxScrollWidth() const; int maxScrollHeight() const; bool getHighlighterAttriAtRowCol(const BufferCoord& pos, QString& token, - PSynHighlighterAttribute& attri); + PHighlighterAttribute& attri); bool getHighlighterAttriAtRowCol(const BufferCoord& pos, QString& token, - bool& tokenFinished, SynHighlighterTokenType& tokenType, - PSynHighlighterAttribute& attri); + bool& tokenFinished, TokenType& tokenType, + PHighlighterAttribute& attri); bool getHighlighterAttriAtRowColEx(const BufferCoord& pos, QString& token, - SynHighlighterTokenType& tokenType, SynTokenKind &tokenKind, int &start, - PSynHighlighterAttribute& attri); + TokenType& tokenType, TokenKind &tokenKind, int &start, + PHighlighterAttribute& attri); void beginUndoBlock(); void endUndoBlock(); @@ -280,26 +267,26 @@ public: } //Commands - virtual void cutToClipboard() { commandProcessor(SynEditorCommand::ecCut);} - virtual void copyToClipboard() { commandProcessor(SynEditorCommand::ecCopy);} - virtual void pasteFromClipboard() { commandProcessor(SynEditorCommand::ecPaste);} - virtual void undo() { commandProcessor(SynEditorCommand::ecUndo);} - virtual void redo() { commandProcessor(SynEditorCommand::ecRedo);} - virtual void zoomIn() { commandProcessor(SynEditorCommand::ecZoomIn);} - virtual void zoomOut() { commandProcessor(SynEditorCommand::ecZoomOut);} + virtual void cutToClipboard() { commandProcessor(EditCommand::ecCut);} + virtual void copyToClipboard() { commandProcessor(EditCommand::ecCopy);} + virtual void pasteFromClipboard() { commandProcessor(EditCommand::ecPaste);} + virtual void undo() { commandProcessor(EditCommand::ecUndo);} + virtual void redo() { commandProcessor(EditCommand::ecRedo);} + virtual void zoomIn() { commandProcessor(EditCommand::ecZoomIn);} + virtual void zoomOut() { commandProcessor(EditCommand::ecZoomOut);} virtual void selectAll() { - commandProcessor(SynEditorCommand::ecSelectAll); + commandProcessor(EditCommand::ecSelectAll); } virtual void selectWord() { - commandProcessor(SynEditorCommand::ecSelWord); + commandProcessor(EditCommand::ecSelWord); } - virtual void tab() { commandProcessor(SynEditorCommand::ecTab);} - virtual void shifttab() { commandProcessor(SynEditorCommand::ecShiftTab);} - virtual void toggleComment() { commandProcessor(SynEditorCommand::ecToggleComment);} - virtual void toggleBlockComment() { commandProcessor(SynEditorCommand::ecToggleBlockComment);} - virtual void matchBracket() { commandProcessor(SynEditorCommand::ecMatchBracket);} - virtual void moveSelUp(){ commandProcessor(SynEditorCommand::ecMoveSelUp);} - virtual void moveSelDown(){ commandProcessor(SynEditorCommand::ecMoveSelDown);} + virtual void tab() { commandProcessor(EditCommand::ecTab);} + virtual void shifttab() { commandProcessor(EditCommand::ecShiftTab);} + virtual void toggleComment() { commandProcessor(EditCommand::ecToggleComment);} + virtual void toggleBlockComment() { commandProcessor(EditCommand::ecToggleBlockComment);} + virtual void matchBracket() { commandProcessor(EditCommand::ecMatchBracket);} + virtual void moveSelUp(){ commandProcessor(EditCommand::ecMoveSelUp);} + virtual void moveSelDown(){ commandProcessor(EditCommand::ecMoveSelDown);} virtual void beginUpdate(); virtual void endUpdate(); @@ -315,10 +302,10 @@ public: bool pointToLine(const QPoint& point, int& line); bool isIdentChar(const QChar& ch); - void setRainbowAttrs(const PSynHighlighterAttribute &attr0, - const PSynHighlighterAttribute &attr1, - const PSynHighlighterAttribute &attr2, - const PSynHighlighterAttribute &attr3); + void setRainbowAttrs(const PHighlighterAttribute &attr0, + const PHighlighterAttribute &attr1, + const PHighlighterAttribute &attr2, + const PHighlighterAttribute &attr3); void updateMouseCursor(); @@ -339,8 +326,8 @@ public: void setBlockBegin(BufferCoord value); void setBlockEnd(BufferCoord Value); - SynSelectionMode activeSelectionMode() const; - void setActiveSelectionMode(const SynSelectionMode &Value); + SelectionMode activeSelectionMode() const; + void setActiveSelectionMode(const SelectionMode &Value); int charsInWindow() const; @@ -354,13 +341,13 @@ public: bool modified() const; void setModified(bool Value); - PSynHighlighter highlighter() const; - void setHighlighter(const PSynHighlighter &highlighter); + PHighlighter highlighter() const; + void setHighlighter(const PHighlighter &highlighter); bool useCodeFolding() const; void setUseCodeFolding(bool value); - SynEditCodeFolding & codeFolding(); + CodeFoldingOptions & codeFolding(); QString displayLineText(); QString lineText() const; @@ -369,17 +356,17 @@ public: const PSynDocument& document() const; bool empty(); - SynSelectionMode selectionMode() const; - void setSelectionMode(SynSelectionMode value); + SelectionMode selectionMode() const; + void setSelectionMode(SelectionMode value); QString selText(); - QStringList getContent(BufferCoord startPos, BufferCoord endPos, SynSelectionMode mode) const; + QStringList getContent(BufferCoord startPos, BufferCoord endPos, SelectionMode mode) const; QString lineBreak(); - SynEditorOptions getOptions() const; - void setOptions(const SynEditorOptions &Value); + EditorOptions getOptions() const; + void setOptions(const EditorOptions &Value); int tabWidth() const { return mDocument->tabWidth(); } void setTabWidth(int tabWidth); @@ -390,13 +377,13 @@ public: QColor activeLineColor() const; void setActiveLineColor(const QColor &activeLineColor); - SynEditCaretType overwriteCaret() const; - void setOverwriteCaret(const SynEditCaretType &overwriteCaret); + EditCaretType overwriteCaret() const; + void setOverwriteCaret(const EditCaretType &overwriteCaret); - SynEditCaretType insertCaret() const; - void setInsertCaret(const SynEditCaretType &insertCaret); + EditCaretType insertCaret() const; + void setInsertCaret(const EditCaretType &insertCaret); - SynGutter& gutter(); + Gutter& gutter(); bool readOnly() const; void setReadOnly(bool readOnly); @@ -424,13 +411,13 @@ public: bool caretUseTextColor() const; void setCaretUseTextColor(bool newCaretUseTextColor); - const PSynHighlighterAttribute &rainbowAttr0() const; + const PHighlighterAttribute &rainbowAttr0() const; - const PSynHighlighterAttribute &rainbowAttr1() const; + const PHighlighterAttribute &rainbowAttr1() const; - const PSynHighlighterAttribute &rainbowAttr2() const; + const PHighlighterAttribute &rainbowAttr2() const; - const PSynHighlighterAttribute &rainbowAttr3() const; + const PHighlighterAttribute &rainbowAttr3() const; int mouseWheelScrollSpeed() const; void setMouseWheelScrollSpeed(int newMouseWheelScrollSpeed); @@ -463,8 +450,7 @@ signals: // void contextHelp(const QString& word); -// void scrolled(SynScrollBarKind ScrollBar); - void statusChanged(SynStatusChanges changes); + void statusChanged(StatusChanges changes); void fontChanged(); void tabSizeChanged(); @@ -472,21 +458,21 @@ signals: protected: virtual bool onGetSpecialLineColors(int Line, QColor& foreground, QColor& backgroundColor) ; - virtual void onGetEditingAreas(int Line, SynEditingAreaList& areaList); + virtual void onGetEditingAreas(int Line, EditingAreaList& areaList); virtual void onGutterGetText(int aLine, QString& aText); virtual void onGutterPaint(QPainter& painter, int aLine, int X, int Y); virtual void onPaint(QPainter& painter); virtual void onPreparePaintHighlightToken(int line, - int aChar, const QString& token, PSynHighlighterAttribute attr, - SynFontStyles& style, QColor& foreground, QColor& background); - virtual void onProcessCommand(SynEditorCommand Command, QChar AChar, void * pData); - virtual void onCommandProcessed(SynEditorCommand Command, QChar AChar, void * pData); - virtual void ExecuteCommand(SynEditorCommand Command, QChar AChar, void * pData); + int aChar, const QString& token, PHighlighterAttribute attr, + FontStyles& style, QColor& foreground, QColor& background); + virtual void onProcessCommand(EditCommand Command, QChar AChar, void * pData); + virtual void onCommandProcessed(EditCommand Command, QChar AChar, void * pData); + virtual void ExecuteCommand(EditCommand Command, QChar AChar, void * pData); virtual void onEndFirstPaintLock(); virtual void onBeginFirstPaintLock(); private: - void clearAreaList(SynEditingAreaList areaList); + void clearAreaList(EditingAreaList areaList); void computeCaret(); void computeScroll(bool isDragging); @@ -498,7 +484,7 @@ private: int clientLeft(); QRect clientRect(); void synFontChanged(); - void doOnPaintTransient(SynTransientType TransientType); + void doSetSelText(const QString& value); void updateLastCaretX(); @@ -509,8 +495,8 @@ private: void internalSetCaretXY(const BufferCoord& Value); void internalSetCaretX(int Value); void internalSetCaretY(int Value); - void setStatusChanged(SynStatusChanges changes); - void doOnStatusChange(SynStatusChanges changes); + void setStatusChanged(StatusChanges changes); + void doOnStatusChange(StatusChanges changes); void updateScrollbars(); void updateCaret(); void recalcCharExtent(); @@ -519,30 +505,29 @@ private: int scanFrom(int Index, int canStopIndex); void rescanRange(int line); void rescanRanges(); - void uncollapse(PSynEditFoldRange FoldRange); - void collapse(PSynEditFoldRange FoldRange); + void uncollapse(PCodeFoldingRange FoldRange); + void collapse(PCodeFoldingRange FoldRange); void foldOnListInserted(int Line, int Count); void foldOnListDeleted(int Line, int Count); void foldOnListCleared(); void rescanFolds(); // rescan for folds void rescanForFoldRanges(); - void scanForFoldRanges(PSynEditFoldRanges TopFoldRanges); + void scanForFoldRanges(PCodeFoldingRanges TopFoldRanges); int lineHasChar(int Line, int startChar, QChar character, const QString& highlighterAttrName); - void findSubFoldRange(PSynEditFoldRanges TopFoldRanges,int FoldIndex,PSynEditFoldRanges& parentFoldRanges, PSynEditFoldRange Parent); - PSynEditFoldRange collapsedFoldStartAtLine(int Line); - void doOnPaintTransientEx(SynTransientType TransientType, bool Lock); + void findSubFoldRange(PCodeFoldingRanges TopFoldRanges,int FoldIndex,PCodeFoldingRanges& parentFoldRanges, PCodeFoldingRange Parent); + PCodeFoldingRange collapsedFoldStartAtLine(int Line); void initializeCaret(); - PSynEditFoldRange foldStartAtLine(int Line) const; + PCodeFoldingRange foldStartAtLine(int Line) const; bool foldCollapsedBetween(int startLine, int endLine) const; QString substringByColumns(const QString& s, int startColumn, int& colLen); - PSynEditFoldRange foldAroundLine(int Line); - PSynEditFoldRange foldAroundLineEx(int Line, bool WantCollapsed, bool AcceptFromLine, bool AcceptToLine); - PSynEditFoldRange checkFoldRange(SynEditFoldRanges* FoldRangeToCheck,int Line, bool WantCollapsed, bool AcceptFromLine, bool AcceptToLine); - PSynEditFoldRange foldEndAtLine(int Line); + PCodeFoldingRange foldAroundLine(int Line); + PCodeFoldingRange foldAroundLineEx(int Line, bool WantCollapsed, bool AcceptFromLine, bool AcceptToLine); + PCodeFoldingRange checkFoldRange(CodeFoldingRanges* FoldRangeToCheck,int Line, bool WantCollapsed, bool AcceptFromLine, bool AcceptToLine); + PCodeFoldingRange foldEndAtLine(int Line); void paintCaret(QPainter& painter, const QRect rcClip); int textOffset() const; - SynEditorCommand TranslateKeyCode(int key, Qt::KeyboardModifiers modifiers); + EditCommand TranslateKeyCode(int key, Qt::KeyboardModifiers modifiers); /** * Move the caret to right DX columns * @param DX @@ -556,15 +541,15 @@ private: void moveCaretToLineEnd(bool isSelection); void setSelectedTextEmpty(); void setSelTextPrimitive(const QStringList& text); - void setSelTextPrimitiveEx(SynSelectionMode PasteMode, + void setSelTextPrimitiveEx(SelectionMode PasteMode, const QStringList& text); void doLinesDeleted(int FirstLine, int Count); void doLinesInserted(int FirstLine, int Count); void properSetLine(int ALine, const QString& ALineText, bool notify = true); //primitive edit operations - void doDeleteText(BufferCoord startPos, BufferCoord endPos, SynSelectionMode mode); - void doInsertText(const BufferCoord& pos, const QStringList& text, SynSelectionMode mode, int startLine, int endLine); + void doDeleteText(BufferCoord startPos, BufferCoord endPos, SelectionMode mode); + void doInsertText(const BufferCoord& pos, const QStringList& text, SelectionMode mode, int startLine, int endLine); int doInsertTextByNormalMode(const BufferCoord& pos, const QStringList& text, BufferCoord &newPos); int doInsertTextByColumnMode(const BufferCoord& pos, const QStringList& text, BufferCoord &newPos, int startLine, int endLine); int doInsertTextByLineMode(const BufferCoord& pos, const QStringList& text, BufferCoord &newPos); @@ -651,8 +636,8 @@ private slots: private: std::shared_ptr mContentImage; - SynEditFoldRanges mAllFoldRanges; - SynEditCodeFolding mCodeFolding; + CodeFoldingRanges mAllFoldRanges; + CodeFoldingOptions mCodeFolding; bool mUseCodeFolding; bool mAlwaysShowCaret; BufferCoord mBlockBegin; @@ -664,7 +649,6 @@ private: int mCharWidth; QFont mFontDummy; QFont mFontForNonAscii; - SynFontSmoothMethod mFontSmoothing; bool mMouseMoved; bool mInserting; @@ -676,21 +660,19 @@ private: bool mReadOnly; int mRightEdge; QColor mRightEdgeColor; - QColor mScrollHintColor; - SynScrollHintFormat mScrollHintFormat; - SynScrollStyle mScrollBars; + ScrollStyle mScrollBars; int mTextHeight; int mTopLine; - PSynHighlighter mHighlighter; + PHighlighter mHighlighter; QColor mSelectedForeground; QColor mSelectedBackground; QColor mForegroundColor; QColor mBackgroundColor; QColor mCaretColor; - PSynHighlighterAttribute mRainbowAttr0; - PSynHighlighterAttribute mRainbowAttr1; - PSynHighlighterAttribute mRainbowAttr2; - PSynHighlighterAttribute mRainbowAttr3; + PHighlighterAttribute mRainbowAttr0; + PHighlighterAttribute mRainbowAttr1; + PHighlighterAttribute mRainbowAttr2; + PHighlighterAttribute mRainbowAttr3; bool mCaretUseTextColor; QColor mActiveLineColor; @@ -699,22 +681,22 @@ private: QPoint mMouseDownPos; bool mHideSelection; int mMouseWheelAccumulator; - SynEditCaretType mOverwriteCaret; - SynEditCaretType mInsertCaret; + EditCaretType mOverwriteCaret; + EditCaretType mInsertCaret; QPoint mCaretOffset; - SynEditKeyStrokes mKeyStrokes; + EditKeyStrokes mKeyStrokes; bool mModified; QDateTime mLastModifyTime; int mExtraLineSpacing; - SynSelectionMode mSelectionMode; - SynSelectionMode mActiveSelectionMode; //mode of the active selection + SelectionMode mSelectionMode; + SelectionMode mActiveSelectionMode; //mode of the active selection bool mWantReturns; bool mWantTabs; - SynGutter mGutter; + Gutter mGutter; QRect mInvalidateRect; - SynStateFlags mStateFlags; - SynEditorOptions mOptions; - SynStatusChanges mStatusChanges; + StateFlags mStateFlags; + EditorOptions mOptions; + StatusChanges mStatusChanges; int mLastKey; Qt::KeyboardModifiers mLastKeyModifiers; //fSearchEngine: TSynEditSearchCustom; @@ -733,12 +715,12 @@ private: int mPainterLock; // lock counter to prevent repaint while painting bool mUndoing; // event handlers - SynProcessCommandProc mOnCommandProcessed; - SynMouseCursorProc mOnMouseCursor; - SynPaintProc mOnPaint; + ProcessCommandProc mOnCommandProcessed; + MouseCursorProc mOnMouseCursor; + PaintProc mOnPaint; // SynPreparePaintHighlightTokenProc mOnPaintHighlightToken; - SynProcessCommandProc mOnProcessingCommand; - SynProcessCommandProc mOnProcessingUserCommand; + ProcessCommandProc mOnProcessingCommand; + ProcessCommandProc mOnProcessingUserCommand; // SynSpecialLineColorsProc mOnSpecialLineColors; // SynEditingAreasProc mOnEditingAreas; @@ -796,6 +778,9 @@ protected: int mouseSelectionScrollSpeed() const; void setMouseSelectionScrollSpeed(int newMouseSelectionScrollSpeed); + ScrollStyle scrollBars() const; + void setScrollBars(ScrollStyle newScrollBars); + protected: void dragEnterEvent(QDragEnterEvent *event) override; void dropEvent(QDropEvent *event) override; diff --git a/libs/qsynedit/qsynedit/TextBuffer.cpp b/libs/qsynedit/qsynedit/TextBuffer.cpp index 7e922a98..bcc48070 100644 --- a/libs/qsynedit/qsynedit/TextBuffer.cpp +++ b/libs/qsynedit/qsynedit/TextBuffer.cpp @@ -153,7 +153,7 @@ QString SynDocument::lineBreak() const return "\n"; } -SynRangeState SynDocument::ranges(int Index) +HighlighterState SynDocument::ranges(int Index) { QMutexLocker locker(&mMutex); if (Index>=0 && Index < mLines.size()) { @@ -161,7 +161,7 @@ SynRangeState SynDocument::ranges(int Index) } else { ListIndexOutOfBounds(Index); } - return SynRangeState(); + return HighlighterState(); } void SynDocument::insertItem(int Index, const QString &s) @@ -196,7 +196,7 @@ void SynDocument::setAppendNewLineAtEOF(bool appendNewLineAtEOF) mAppendNewLineAtEOF = appendNewLineAtEOF; } -void SynDocument::setRange(int Index, const SynRangeState& ARange) +void SynDocument::setRange(int Index, const HighlighterState& ARange) { QMutexLocker locker(&mMutex); if (Index<0 || Index>=mLines.count()) { @@ -839,7 +839,7 @@ SynEditUndoList::SynEditUndoList():QObject() void SynEditUndoList::addChange(SynChangeReason reason, const BufferCoord &startPos, const BufferCoord &endPos, const QStringList& changeText, - SynSelectionMode selMode) + SelectionMode selMode) { int changeNumber; if (inBlock()) { @@ -861,7 +861,7 @@ void SynEditUndoList::addChange(SynChangeReason reason, const BufferCoord &start } } -void SynEditUndoList::restoreChange(SynChangeReason AReason, const BufferCoord &AStart, const BufferCoord &AEnd, const QStringList &ChangeText, SynSelectionMode SelMode, size_t changeNumber) +void SynEditUndoList::restoreChange(SynChangeReason AReason, const BufferCoord &AStart, const BufferCoord &AEnd, const QStringList &ChangeText, SelectionMode SelMode, size_t changeNumber) { PSynEditUndoItem newItem = std::make_shared(AReason, SelMode,AStart,AEnd,ChangeText, @@ -890,7 +890,7 @@ void SynEditUndoList::addGroupBreak() return; if (lastChangeReason() != SynChangeReason::GroupBreak) { - addChange(SynChangeReason::GroupBreak, {0,0}, {0,0}, QStringList(), SynSelectionMode::Normal); + addChange(SynChangeReason::GroupBreak, {0,0}, {0,0}, QStringList(), SelectionMode::Normal); } } @@ -1054,7 +1054,7 @@ void SynEditUndoList::ensureMaxEntries() } } -SynSelectionMode SynEditUndoItem::changeSelMode() const +SelectionMode SynEditUndoItem::changeSelMode() const { return mChangeSelMode; } @@ -1079,7 +1079,7 @@ size_t SynEditUndoItem::changeNumber() const return mChangeNumber; } -SynEditUndoItem::SynEditUndoItem(SynChangeReason reason, SynSelectionMode selMode, +SynEditUndoItem::SynEditUndoItem(SynChangeReason reason, SelectionMode selMode, BufferCoord startPos, BufferCoord endPos, const QStringList& text, int number) { @@ -1101,7 +1101,7 @@ SynEditRedoList::SynEditRedoList() } -void SynEditRedoList::addRedo(SynChangeReason AReason, const BufferCoord &AStart, const BufferCoord &AEnd, const QStringList &ChangeText, SynSelectionMode SelMode, size_t changeNumber) +void SynEditRedoList::addRedo(SynChangeReason AReason, const BufferCoord &AStart, const BufferCoord &AEnd, const QStringList &ChangeText, SelectionMode SelMode, size_t changeNumber) { PSynEditUndoItem newItem = std::make_shared( AReason, diff --git a/libs/qsynedit/qsynedit/TextBuffer.h b/libs/qsynedit/qsynedit/TextBuffer.h index c2dda8df..054eca3d 100644 --- a/libs/qsynedit/qsynedit/TextBuffer.h +++ b/libs/qsynedit/qsynedit/TextBuffer.h @@ -39,7 +39,7 @@ typedef int SynEditStringFlags; struct SynDocumentLine { QString fString; - SynRangeState fRange; + HighlighterState fRange; int fColumns; // public: @@ -70,8 +70,8 @@ public: int rightBraces(int Index); int lengthOfLongestLine(); QString lineBreak() const; - SynRangeState ranges(int Index); - void setRange(int Index, const SynRangeState& ARange); + HighlighterState ranges(int Index); + void setRange(int Index, const HighlighterState& ARange); QString getString(int Index); int count(); QString text(); @@ -174,21 +174,21 @@ enum class SynChangeReason { class SynEditUndoItem { private: SynChangeReason mChangeReason; - SynSelectionMode mChangeSelMode; + SelectionMode mChangeSelMode; BufferCoord mChangeStartPos; BufferCoord mChangeEndPos; QStringList mChangeText; size_t mChangeNumber; public: SynEditUndoItem(SynChangeReason reason, - SynSelectionMode selMode, + SelectionMode selMode, BufferCoord startPos, BufferCoord endPos, const QStringList& text, int number); SynChangeReason changeReason() const; - SynSelectionMode changeSelMode() const; + SelectionMode changeSelMode() const; BufferCoord changeStartPos() const; BufferCoord changeEndPos() const; QStringList changeText() const; @@ -203,10 +203,10 @@ public: explicit SynEditUndoList(); void addChange(SynChangeReason AReason, const BufferCoord& AStart, const BufferCoord& AEnd, - const QStringList& ChangeText, SynSelectionMode SelMode); + const QStringList& ChangeText, SelectionMode SelMode); void restoreChange(SynChangeReason AReason, const BufferCoord& AStart, const BufferCoord& AEnd, - const QStringList& ChangeText, SynSelectionMode SelMode, size_t changeNumber); + const QStringList& ChangeText, SelectionMode SelMode, size_t changeNumber); void restoreChange(PSynEditUndoItem item); @@ -259,7 +259,7 @@ public: explicit SynEditRedoList(); void addRedo(SynChangeReason AReason, const BufferCoord& AStart, const BufferCoord& AEnd, - const QStringList& ChangeText, SynSelectionMode SelMode, size_t changeNumber); + const QStringList& ChangeText, SelectionMode SelMode, size_t changeNumber); void addRedo(PSynEditUndoItem item); void clear(); diff --git a/libs/qsynedit/qsynedit/TextPainter.cpp b/libs/qsynedit/qsynedit/TextPainter.cpp index 72ab4fab..f0be92e9 100644 --- a/libs/qsynedit/qsynedit/TextPainter.cpp +++ b/libs/qsynedit/qsynedit/TextPainter.cpp @@ -135,7 +135,7 @@ void SynEditTextPainter::paintGutter(const QRect& clip) if (edit->mGutter.activeLineTextColor().isValid()) { if ( (edit->mCaretY==vLine) || - (edit->mActiveSelectionMode == SynSelectionMode::Column && vLine >= selectionStart.line && vLine <= selectionEnd.line) + (edit->mActiveSelectionMode == SelectionMode::Column && vLine >= selectionStart.line && vLine <= selectionEnd.line) ) painter->setPen(edit->mGutter.activeLineTextColor()); else @@ -195,7 +195,7 @@ void SynEditTextPainter::paintGutter(const QRect& clip) rcFold.top() + rcFold.height() / 2); } // Any fold ranges beginning on this line? - PSynEditFoldRange FoldRange = edit->foldStartAtLine(vLine); + PCodeFoldingRange FoldRange = edit->foldStartAtLine(vLine); if (FoldRange) { // Draw the bottom part of a line if (!FoldRange->collapsed) { @@ -307,7 +307,7 @@ void SynEditTextPainter::computeSelectionInfo() } // In the column selection mode sort the begin and end of the selection, // this makes the painting code simpler. - if (edit->mActiveSelectionMode == SynSelectionMode::Column && vSelStart.Column > vSelEnd.Column) + if (edit->mActiveSelectionMode == SelectionMode::Column && vSelStart.Column > vSelEnd.Column) std::swap(vSelStart.Column, vSelEnd.Column); } } @@ -360,7 +360,7 @@ void SynEditTextPainter::paintToken(const QString &token, int tokenCols, int col for (int i=0;itabWidth() - ((columnsBefore+tokenColLen) % edit->tabWidth()); } else { charCols = edit->charColumns(token[i]); @@ -411,7 +411,7 @@ void SynEditTextPainter::paintToken(const QString &token, int tokenCols, int col } } -void SynEditTextPainter::paintEditAreas(const SynEditingAreaList &areaList) +void SynEditTextPainter::paintEditAreas(const EditingAreaList &areaList) { QRect rc; int x1,x2; @@ -420,7 +420,7 @@ void SynEditTextPainter::paintEditAreas(const SynEditingAreaList &areaList) rc=rcLine; rc.setBottom(rc.bottom()-1); setDrawingColors(false); - for (const PSynEditingArea& p:areaList) { + for (const PEditingArea& p:areaList) { if (p->beginX > LastCol) continue; if (p->endX < FirstCol) @@ -438,13 +438,13 @@ void SynEditTextPainter::paintEditAreas(const SynEditingAreaList &areaList) painter->setPen(p->color); painter->setBrush(Qt::NoBrush); switch(p->type) { - case SynEditingAreaType::eatRectangleBorder: + case EditingAreaType::eatRectangleBorder: painter->drawRect(rc); break; - case SynEditingAreaType::eatUnderLine: + case EditingAreaType::eatUnderLine: painter->drawLine(rc.left(),rc.bottom(),rc.right(),rc.bottom()); break; - case SynEditingAreaType::eatWaveUnderLine: + case EditingAreaType::eatWaveUnderLine: offset=3; int lastX=rc.left(); int lastY=rc.bottom()-offset; @@ -498,16 +498,16 @@ void SynEditTextPainter::paintHighlightToken(bool bFillToEOL) // if (bSpecialLine && edit->mOptions.testFlag(eoSpecialLineDefaultFg)) // colFG = TokenAccu.FG; QFont font = edit->font(); - font.setBold(TokenAccu.Style & SynFontStyle::fsBold); - font.setItalic(TokenAccu.Style & SynFontStyle::fsItalic); - font.setStrikeOut(TokenAccu.Style & SynFontStyle::fsStrikeOut); - font.setUnderline(TokenAccu.Style & SynFontStyle::fsUnderline); + font.setBold(TokenAccu.Style & FontStyle::fsBold); + font.setItalic(TokenAccu.Style & FontStyle::fsItalic); + font.setStrikeOut(TokenAccu.Style & FontStyle::fsStrikeOut); + font.setUnderline(TokenAccu.Style & FontStyle::fsUnderline); painter->setFont(font); QFont nonAsciiFont = edit->fontForNonAscii(); - nonAsciiFont.setBold(TokenAccu.Style & SynFontStyle::fsBold); - nonAsciiFont.setItalic(TokenAccu.Style & SynFontStyle::fsItalic); - nonAsciiFont.setStrikeOut(TokenAccu.Style & SynFontStyle::fsStrikeOut); - nonAsciiFont.setUnderline(TokenAccu.Style & SynFontStyle::fsUnderline); + nonAsciiFont.setBold(TokenAccu.Style & FontStyle::fsBold); + nonAsciiFont.setItalic(TokenAccu.Style & FontStyle::fsItalic); + nonAsciiFont.setStrikeOut(TokenAccu.Style & FontStyle::fsStrikeOut); + nonAsciiFont.setUnderline(TokenAccu.Style & FontStyle::fsUnderline); // Paint the chars if (bComplexToken) { @@ -548,7 +548,7 @@ void SynEditTextPainter::paintHighlightToken(bool bFillToEOL) if (rcToken.left() < nX1) { setDrawingColors(false); rcToken.setRight(nX1); -// if (TokenAccu.Len != 0 && TokenAccu.Style != SynFontStyle::fsNone) +// if (TokenAccu.Len != 0 && TokenAccu.Style != FontStyle::fsNone) // AdjustEndRect(); painter->fillRect(rcToken,painter->brush()); rcToken.setLeft(nX1); @@ -567,7 +567,7 @@ void SynEditTextPainter::paintHighlightToken(bool bFillToEOL) } else { setDrawingColors(bLineSelected); rcToken.setRight(rcLine.right()); -// if (TokenAccu.Len != 0 && TokenAccu.Style != SynFontStyle::fsNone) +// if (TokenAccu.Len != 0 && TokenAccu.Style != FontStyle::fsNone) // AdjustEndRect(); painter->fillRect(rcToken,painter->brush()); } @@ -594,11 +594,11 @@ bool SynEditTextPainter::tokenIsSpaces(bool &bSpacesTest, const QString& token, // record. This will paint any chars already stored if there is // a (visible) change in the attributes. void SynEditTextPainter::addHighlightToken(const QString &Token, int columnsBefore, - int tokenColumns, int cLine, PSynHighlighterAttribute p_Attri) + int tokenColumns, int cLine, PHighlighterAttribute p_Attri) { bool bCanAppend; QColor foreground, background; - SynFontStyles style; + FontStyles style; bool bSpacesTest,bIsSpaces; if (p_Attri) { @@ -629,7 +629,7 @@ void SynEditTextPainter::addHighlightToken(const QString &Token, int columnsBefo bSpacesTest = false; if (TokenAccu.Columns > 0) { // font style must be the same or token is only spaces - if (TokenAccu.Style == style || ( (style & SynFontStyle::fsUnderline) == (TokenAccu.Style & fsUnderline) + if (TokenAccu.Style == style || ( (style & FontStyle::fsUnderline) == (TokenAccu.Style & fsUnderline) && tokenIsSpaces(bSpacesTest,Token,bIsSpaces)) ) { if ( // background color must be the same and @@ -706,12 +706,12 @@ void SynEditTextPainter::paintFoldAttributes() indentLevel++ ; if (edit->mHighlighter) { if (edit->mCodeFolding.indentGuides) { - PSynHighlighterAttribute attr = edit->mHighlighter->symbolAttribute(); + PHighlighterAttribute attr = edit->mHighlighter->symbolAttribute(); getBraceColorAttr(indentLevel,attr); paintColor = attr->foreground(); } if (edit->mCodeFolding.fillIndents) { - PSynHighlighterAttribute attr = edit->mHighlighter->symbolAttribute(); + PHighlighterAttribute attr = edit->mHighlighter->symbolAttribute(); getBraceColorAttr(indentLevel,attr); gradientStart=attr->foreground(); attr = edit->mHighlighter->symbolAttribute(); @@ -752,7 +752,7 @@ void SynEditTextPainter::paintFoldAttributes() if (edit->mCodeFolding.showCollapsedLine) { painter->setPen(edit->mCodeFolding.collapsedLineColor); for (int i=0; i< edit->mAllFoldRanges.count();i++) { - PSynEditFoldRange range = edit->mAllFoldRanges[i]; + PCodeFoldingRange range = edit->mAllFoldRanges[i]; if (range->collapsed && !range->parentCollapsed() && (range->fromLine <= vLastLine) && (range->fromLine >= vFirstLine) ) { // Get starting and end points @@ -764,13 +764,13 @@ void SynEditTextPainter::paintFoldAttributes() } -void SynEditTextPainter::getBraceColorAttr(int level, PSynHighlighterAttribute &attr) +void SynEditTextPainter::getBraceColorAttr(int level, PHighlighterAttribute &attr) { - if (!edit->mOptions.testFlag(SynEditorOption::eoShowRainbowColor)) + if (!edit->mOptions.testFlag(EditorOption::eoShowRainbowColor)) return; if (attr != edit->mHighlighter->symbolAttribute()) return; - PSynHighlighterAttribute oldAttr = attr; + PHighlighterAttribute oldAttr = attr; switch(level % 4) { case 0: attr = edit->mRainbowAttr0; @@ -796,12 +796,12 @@ void SynEditTextPainter::paintLines() QString sLine; // the current line QString sToken; // highlighter token info int nTokenColumnsBefore, nTokenColumnLen; - PSynHighlighterAttribute attr; + PHighlighterAttribute attr; int vFirstChar; int vLastChar; - SynEditingAreaList areaList; - PSynEditFoldRange foldRange; - PSynHighlighterAttribute preeditAttr; + EditingAreaList areaList; + PCodeFoldingRange foldRange; + PHighlighterAttribute preeditAttr; int nFold; QString sFold; @@ -822,7 +822,7 @@ void SynEditTextPainter::paintLines() // Get the line. sLine = edit->mDocument->getString(vLine - 1); // determine whether will be painted with ActiveLineColor - if (edit->mActiveSelectionMode == SynSelectionMode::Column) { + if (edit->mActiveSelectionMode == SelectionMode::Column) { bCurrentLine = (vLine >= selectionBegin.line && vLine <= selectionEnd.line); } else { bCurrentLine = (edit->mCaretY == vLine); @@ -860,8 +860,8 @@ void SynEditTextPainter::paintLines() // selection mode and a good start for the smNormal mode. nLineSelStart = FirstCol; nLineSelEnd = LastCol + 1; - if ((edit->mActiveSelectionMode == SynSelectionMode::Column) || - ((edit->mActiveSelectionMode == SynSelectionMode::Normal) && (cRow == vSelStart.Row)) ) { + if ((edit->mActiveSelectionMode == SelectionMode::Column) || + ((edit->mActiveSelectionMode == SelectionMode::Normal) && (cRow == vSelStart.Row)) ) { int ch = edit->columnToChar(vLine,vSelStart.Column); ch = edit->charToColumn(vLine,ch); if (ch > LastCol) { @@ -872,8 +872,8 @@ void SynEditTextPainter::paintLines() bComplexLine = true; } } - if ( (edit->mActiveSelectionMode == SynSelectionMode::Column) || - ((edit->mActiveSelectionMode == SynSelectionMode::Normal) && (cRow == vSelEnd.Row)) ) { + if ( (edit->mActiveSelectionMode == SelectionMode::Column) || + ((edit->mActiveSelectionMode == SelectionMode::Normal) && (cRow == vSelEnd.Row)) ) { int ch = edit->columnToChar(vLine,vSelEnd.Column); int col = edit->charToColumn(vLine,ch); if (colmDocument->lineColumns(vLine-1); } if (edit->mOptions.testFlag(eoShowSpecialChars) && (!bLineSelected) && (!bSpecialLine) && (nTokenColumnLen < vLastChar)) { - sToken = sToken + SynLineBreakGlyph; - nTokenColumnLen += edit->charColumns(SynLineBreakGlyph); + sToken = sToken + LineBreakGlyph; + nTokenColumnLen += edit->charColumns(LineBreakGlyph); } if (bComplexLine) { setDrawingColors(true); @@ -925,12 +925,12 @@ void SynEditTextPainter::paintLines() } //Paint editingAreaBorders if (bCurrentLine && edit->mInputPreeditString.length()>0) { - PSynEditingArea area = std::make_shared(); + PEditingArea area = std::make_shared(); int col = edit->charToColumn(edit->mCaretY,edit->mCaretX); int ch = edit->columnToChar(vLine,col); area->beginX = edit->charToColumn(sLine,ch); area->endX = edit->charToColumn(sLine,ch + edit->mInputPreeditString.length()); - area->type = SynEditingAreaType::eatUnderLine; + area->type = EditingAreaType::eatUnderLine; area->color = colFG; areaList.append(area); paintEditAreas(areaList); @@ -981,7 +981,7 @@ void SynEditTextPainter::paintLines() || sToken == "(" || sToken == "{" ) { - SynRangeState rangeState = edit->mHighlighter->getRangeState(); + HighlighterState rangeState = edit->mHighlighter->getState(); getBraceColorAttr(rangeState.bracketLevel +rangeState.braceLevel +rangeState.parenthesisLevel @@ -990,7 +990,7 @@ void SynEditTextPainter::paintLines() || sToken == ")" || sToken == "}" ){ - SynRangeState rangeState = edit->mHighlighter->getRangeState(); + HighlighterState rangeState = edit->mHighlighter->getState(); getBraceColorAttr(rangeState.bracketLevel +rangeState.braceLevel +rangeState.parenthesisLevel+1, @@ -1028,15 +1028,15 @@ void SynEditTextPainter::paintLines() if (nTokenColumnLen > 0) { sToken = edit->substringByColumns(sLine,nTokenColumnsBefore+1,nTokenColumnLen); addHighlightToken(sToken, nTokenColumnsBefore - (vFirstChar - FirstCol), - nTokenColumnLen, vLine, PSynHighlighterAttribute()); + nTokenColumnLen, vLine, PHighlighterAttribute()); } } // Draw LineBreak glyph. if (edit->mOptions.testFlag(eoShowSpecialChars) && (!bLineSelected) && (!bSpecialLine) && (edit->mDocument->lineColumns(vLine-1) < vLastChar)) { - addHighlightToken(SynLineBreakGlyph, + addHighlightToken(LineBreakGlyph, edit->mDocument->lineColumns(vLine-1) - (vFirstChar - FirstCol), - edit->charColumns(SynLineBreakGlyph),vLine, edit->mHighlighter->whitespaceAttribute()); + edit->charColumns(LineBreakGlyph),vLine, edit->mHighlighter->whitespaceAttribute()); } } @@ -1046,7 +1046,7 @@ void SynEditTextPainter::paintLines() sFold = edit->highlighter()->foldString(); nFold = edit->stringColumns(sFold,edit->mDocument->lineColumns(vLine-1)); attr = edit->mHighlighter->symbolAttribute(); - getBraceColorAttr(edit->mHighlighter->getRangeState().braceLevel,attr); + getBraceColorAttr(edit->mHighlighter->getState().braceLevel,attr); addHighlightToken(sFold,edit->mDocument->lineColumns(vLine-1) - (vFirstChar - FirstCol) , nFold, vLine, attr); } @@ -1056,7 +1056,7 @@ void SynEditTextPainter::paintLines() paintHighlightToken(true); //Paint editingAreaBorders - foreach (const PSynEditingArea& area, areaList) { + foreach (const PEditingArea& area, areaList) { if (bCurrentLine && edit->mInputPreeditString.length()>0) { if (area->beginX > edit->mCaretX) { area->beginX+=edit->mInputPreeditString.length(); @@ -1069,12 +1069,12 @@ void SynEditTextPainter::paintLines() area->endX = edit->charToColumn(sLine,area->endX); } if (bCurrentLine && edit->mInputPreeditString.length()>0) { - PSynEditingArea area = std::make_shared(); + PEditingArea area = std::make_shared(); int col = edit->charToColumn(edit->mCaretY,edit->mCaretX); int ch = edit->columnToChar(vLine,col); area->beginX = edit->charToColumn(sLine,ch); area->endX = edit->charToColumn(sLine,ch + edit->mInputPreeditString.length()); - area->type = SynEditingAreaType::eatUnderLine; + area->type = EditingAreaType::eatUnderLine; if (preeditAttr) { area->color = preeditAttr->foreground(); } else { diff --git a/libs/qsynedit/qsynedit/TextPainter.h b/libs/qsynedit/qsynedit/TextPainter.h index 0ac31b8b..ea85e680 100644 --- a/libs/qsynedit/qsynedit/TextPainter.h +++ b/libs/qsynedit/qsynedit/TextPainter.h @@ -34,7 +34,7 @@ class SynEditTextPainter QString s; QColor FG; QColor BG; - SynFontStyles Style; + FontStyles Style; }; public: @@ -51,14 +51,14 @@ private: void paintToken(const QString& token, int tokenLen, int columnsBefore, int first, int last, bool isSelection, const QFont& font, const QFont& fontForNonAscii); - void paintEditAreas(const SynEditingAreaList& areaList); + void paintEditAreas(const EditingAreaList& areaList); void paintHighlightToken(bool bFillToEOL); bool tokenIsSpaces(bool& bSpacesTest, const QString& token, bool& bIsSpaces); void addHighlightToken(const QString& token, int columnsBefore, int tokenColumns, - int cLine, PSynHighlighterAttribute p_Attri); + int cLine, PHighlighterAttribute p_Attri); void paintFoldAttributes(); - void getBraceColorAttr(int level, PSynHighlighterAttribute &attr); + void getBraceColorAttr(int level, PHighlighterAttribute &attr); void paintLines(); private: diff --git a/libs/qsynedit/qsynedit/Types.h b/libs/qsynedit/qsynedit/Types.h index dace15fa..69e5dfee 100644 --- a/libs/qsynedit/qsynedit/Types.h +++ b/libs/qsynedit/qsynedit/Types.h @@ -24,7 +24,7 @@ namespace QSynedit { -enum class SynSelectionMode {Normal, Line, Column}; +enum class SelectionMode {Normal, Line, Column}; struct BufferCoord { int ch; @@ -42,7 +42,7 @@ struct DisplayCoord { int Row; }; -enum SynFontStyle { +enum FontStyle { fsNone = 0, fsBold = 0x0001, fsItalic = 0x0002, @@ -50,27 +50,27 @@ enum SynFontStyle { fsStrikeOut = 0x0008 }; -Q_DECLARE_FLAGS(SynFontStyles,SynFontStyle) +Q_DECLARE_FLAGS(FontStyles,FontStyle) -Q_DECLARE_OPERATORS_FOR_FLAGS(SynFontStyles) +Q_DECLARE_OPERATORS_FOR_FLAGS(FontStyles) -enum class SynEditingAreaType { +enum class EditingAreaType { eatRectangleBorder, eatWaveUnderLine, eatUnderLine }; -struct SynEditingArea { +struct EditingArea { int beginX; int endX; QColor color; - SynEditingAreaType type; + EditingAreaType type; }; -using PSynEditingArea = std::shared_ptr; -using SynEditingAreaList = QList; -using PSynEditingAreaList = std::shared_ptr; +using PEditingArea = std::shared_ptr; +using EditingAreaList = QList; +using PEditingAreaList = std::shared_ptr; } diff --git a/libs/qsynedit/qsynedit/exporter/synexporter.cpp b/libs/qsynedit/qsynedit/exporter/synexporter.cpp index 4c48cdb5..f2ffe454 100644 --- a/libs/qsynedit/qsynedit/exporter/synexporter.cpp +++ b/libs/qsynedit/qsynedit/exporter/synexporter.cpp @@ -40,7 +40,7 @@ SynExporter::SynExporter(const QByteArray charset):mCharset(charset) void SynExporter::clear() { mBuffer.clear(); - mLastStyle = SynFontStyle::fsNone; + mLastStyle = FontStyle::fsNone; mLastBG = QGuiApplication::palette().color(QPalette::Base); mLastFG = QGuiApplication::palette().color(QPalette::Text); } @@ -90,7 +90,7 @@ void SynExporter::ExportRange(PSynDocument ALines, BufferCoord Start, BufferCoor // export the line mHighlighter->setLine(Line, i); while (!mHighlighter->eol()) { - PSynHighlighterAttribute attri = mHighlighter->getTokenAttribute(); + PHighlighterAttribute attri = mHighlighter->getTokenAttribute(); int startPos = mHighlighter->getTokenPos(); QString token = mHighlighter->getToken(); if (i==Start.line && (startPos+token.length() < Start.ch)) { @@ -166,12 +166,12 @@ void SynExporter::setFont(const QFont &font) mFont = font; } -PSynHighlighter SynExporter::highlighter() const +PHighlighter SynExporter::highlighter() const { return mHighlighter; } -void SynExporter::setHighlighter(PSynHighlighter Value) +void SynExporter::setHighlighter(PHighlighter Value) { if (mHighlighter != Value) { mHighlighter = Value; @@ -338,7 +338,7 @@ static QColor ValidatedColor(const QColor& color, const QColor& defaultColor) { else return defaultColor; } -void SynExporter::SetTokenAttribute(PSynHighlighterAttribute Attri) +void SynExporter::SetTokenAttribute(PHighlighterAttribute Attri) { if (mFirstAttribute) { mFirstAttribute = false; @@ -354,7 +354,7 @@ void SynExporter::SetTokenAttribute(PSynHighlighterAttribute Attri) bool ChangedFG = (mLastFG != ValidatedColor(Attri->foreground(), mForegroundColor)); if (ChangedBG || ChangedFG || (mLastStyle != Attri->styles())) { // which font style bits are to reset? - SynFontStyles ChangedStyles = mLastStyle & ~(Attri->styles()); + FontStyles ChangedStyles = mLastStyle & ~(Attri->styles()); FormatAttributeDone(ChangedBG, ChangedFG, ChangedStyles); // which font style bits are to set? ChangedStyles = Attri->styles() & ~(mLastStyle); diff --git a/libs/qsynedit/qsynedit/exporter/synexporter.h b/libs/qsynedit/qsynedit/exporter/synexporter.h index 07a8e71a..62ed0d71 100644 --- a/libs/qsynedit/qsynedit/exporter/synexporter.h +++ b/libs/qsynedit/qsynedit/exporter/synexporter.h @@ -21,8 +21,8 @@ #include "../SynEdit.h" namespace QSynedit { -using FormatTokenHandler = std::function; +using FormatTokenHandler = std::function; class SynExporter { @@ -69,8 +69,8 @@ public: QFont font() const; void setFont(const QFont &font); - PSynHighlighter highlighter() const; - void setHighlighter(PSynHighlighter Value); + PHighlighter highlighter() const; + void setHighlighter(PHighlighter Value); QString title() const; void setTitle(const QString &Value); @@ -112,10 +112,10 @@ protected: QString mDefaultFilter; bool mExportAsText; QFont mFont; - PSynHighlighter mHighlighter; + PHighlighter mHighlighter; QColor mLastBG; QColor mLastFG; - SynFontStyles mLastStyle; + FontStyles mLastStyle; QMap mReplaceReserved; QString mTitle; bool mUseBackground; @@ -156,7 +156,7 @@ protected: * @param FontStylesChanged */ virtual void FormatAttributeDone(bool BackgroundChanged, bool ForegroundChanged, - SynFontStyles FontStylesChanged) = 0; + FontStyles FontStylesChanged) = 0; /** * @brief Has to be overridden in descendant classes to add the opening format @@ -167,7 +167,7 @@ protected: * @param FontStylesChanged */ virtual void FormatAttributeInit(bool BackgroundChanged, bool ForegroundChanged, - SynFontStyles FontStylesChanged) = 0; + FontStyles FontStylesChanged) = 0; /** * @brief Has to be overridden in descendant classes to add the closing format * strings to the output buffer after the last token has been written. @@ -182,7 +182,7 @@ protected: * @param FontStylesChanged */ virtual void FormatBeforeFirstAttribute(bool BackgroundChanged, bool ForegroundChanged, - SynFontStyles FontStylesChanged) = 0; + FontStyles FontStylesChanged) = 0; /** * @brief Can be overridden in descendant classes to add the formatted text of * the actual token text to the output buffer. @@ -236,7 +236,7 @@ protected: * added to the output buffer. * @param Attri */ - virtual void SetTokenAttribute(PSynHighlighterAttribute Attri); + virtual void SetTokenAttribute(PHighlighterAttribute Attri); QTextCodec *getCodec(); private: diff --git a/libs/qsynedit/qsynedit/exporter/synhtmlexporter.cpp b/libs/qsynedit/qsynedit/exporter/synhtmlexporter.cpp index 43fd701f..97476879 100644 --- a/libs/qsynedit/qsynedit/exporter/synhtmlexporter.cpp +++ b/libs/qsynedit/qsynedit/exporter/synhtmlexporter.cpp @@ -45,7 +45,7 @@ void SynHTMLExporter::setCreateHTMLFragment(bool createHTMLFragment) mCreateHTMLFragment = createHTMLFragment; } -QString SynHTMLExporter::AttriToCSS(PSynHighlighterAttribute Attri, const QString &UniqueAttriName) +QString SynHTMLExporter::AttriToCSS(PHighlighterAttribute Attri, const QString &UniqueAttriName) { QString StyleName = MakeValidName(UniqueAttriName); @@ -55,19 +55,19 @@ QString SynHTMLExporter::AttriToCSS(PSynHighlighterAttribute Attri, const QStrin if (Attri->foreground().isValid()) Result += "color: " + ColorToHTML(Attri->foreground()) + "; "; - if (Attri->styles().testFlag(SynFontStyle::fsBold)) + if (Attri->styles().testFlag(FontStyle::fsBold)) Result += "font-weight: bold; "; - if (Attri->styles().testFlag(SynFontStyle::fsItalic)) + if (Attri->styles().testFlag(FontStyle::fsItalic)) Result += "font-style: italic; "; - if (Attri->styles().testFlag(SynFontStyle::fsUnderline)) + if (Attri->styles().testFlag(FontStyle::fsUnderline)) Result += "text-decoration: underline; "; - if (Attri->styles().testFlag(SynFontStyle::fsStrikeOut)) + if (Attri->styles().testFlag(FontStyle::fsStrikeOut)) Result += "text-decoration: line-through; "; Result += "}"; return Result; } -bool SynHTMLExporter::AttriToCSSCallback(PSynHighlighter , PSynHighlighterAttribute Attri, const QString& UniqueAttriName, QList params) +bool SynHTMLExporter::AttriToCSSCallback(PHighlighter , PHighlighterAttribute Attri, const QString& UniqueAttriName, QList params) { QString& styles = *static_cast(params[0]); styles.append(AttriToCSS(Attri,UniqueAttriName) + lineBreak()); @@ -79,7 +79,7 @@ QString SynHTMLExporter::ColorToHTML(const QColor &AColor) return AColor.name(); } -QString SynHTMLExporter::GetStyleName(PSynHighlighter Highlighter, PSynHighlighterAttribute Attri) +QString SynHTMLExporter::GetStyleName(PHighlighter Highlighter, PHighlighterAttribute Attri) { QString result; enumHighlighterAttributes(Highlighter,false, @@ -104,9 +104,9 @@ QString SynHTMLExporter::MakeValidName(const QString &Name) return Result; } -bool SynHTMLExporter::StyleNameCallback(PSynHighlighter /*Highlighter*/, PSynHighlighterAttribute Attri, const QString& UniqueAttriName, QList params) +bool SynHTMLExporter::StyleNameCallback(PHighlighter /*Highlighter*/, PHighlighterAttribute Attri, const QString& UniqueAttriName, QList params) { - PSynHighlighterAttribute& AttriToFind = *static_cast(params[0]); + PHighlighterAttribute& AttriToFind = *static_cast(params[0]); QString& StyleName = *static_cast(params[1]); if (Attri == AttriToFind) { @@ -117,12 +117,12 @@ bool SynHTMLExporter::StyleNameCallback(PSynHighlighter /*Highlighter*/, PSynHig return true; } -void SynHTMLExporter::FormatAttributeDone(bool , bool , SynFontStyles ) +void SynHTMLExporter::FormatAttributeDone(bool , bool , FontStyles ) { AddData(""); } -void SynHTMLExporter::FormatAttributeInit(bool , bool , SynFontStyles ) +void SynHTMLExporter::FormatAttributeInit(bool , bool , FontStyles ) { QString StyleName = GetStyleName(mHighlighter, mLastAttri); AddData(QString("").arg(StyleName)); @@ -133,7 +133,7 @@ void SynHTMLExporter::FormatAfterLastAttribute() AddData(""); } -void SynHTMLExporter::FormatBeforeFirstAttribute(bool, bool, SynFontStyles) +void SynHTMLExporter::FormatBeforeFirstAttribute(bool, bool, FontStyles) { QString StyleName = GetStyleName(mHighlighter, mLastAttri); AddData(QString("").arg(StyleName)); @@ -222,7 +222,7 @@ QString SynHTMLExporter::GetHeader() return Result; } -void SynHTMLExporter::SetTokenAttribute(PSynHighlighterAttribute Attri) +void SynHTMLExporter::SetTokenAttribute(PHighlighterAttribute Attri) { mLastAttri = Attri; SynExporter::SetTokenAttribute(Attri); diff --git a/libs/qsynedit/qsynedit/exporter/synhtmlexporter.h b/libs/qsynedit/qsynedit/exporter/synhtmlexporter.h index 8db4754b..d20b6f82 100644 --- a/libs/qsynedit/qsynedit/exporter/synhtmlexporter.h +++ b/libs/qsynedit/qsynedit/exporter/synhtmlexporter.h @@ -30,28 +30,28 @@ public: protected: bool mCreateHTMLFragment; private: - PSynHighlighterAttribute mLastAttri; - QString AttriToCSS(PSynHighlighterAttribute Attri, const QString& UniqueAttriName); - bool AttriToCSSCallback(PSynHighlighter Highlighter, PSynHighlighterAttribute Attri, + PHighlighterAttribute mLastAttri; + QString AttriToCSS(PHighlighterAttribute Attri, const QString& UniqueAttriName); + bool AttriToCSSCallback(PHighlighter Highlighter, PHighlighterAttribute Attri, const QString& UniqueAttriName, QList params); QString ColorToHTML(const QColor &AColor); - QString GetStyleName(PSynHighlighter Highlighter, - PSynHighlighterAttribute Attri); + QString GetStyleName(PHighlighter Highlighter, + PHighlighterAttribute Attri); QString MakeValidName(const QString &Name); - bool StyleNameCallback(PSynHighlighter Highlighter, PSynHighlighterAttribute Attri, + bool StyleNameCallback(PHighlighter Highlighter, PHighlighterAttribute Attri, const QString& UniqueAttriName, QList params); // SynExporter interface protected: - void FormatAttributeDone(bool BackgroundChanged, bool ForegroundChanged, SynFontStyles FontStylesChanged); - void FormatAttributeInit(bool BackgroundChanged, bool ForegroundChanged, SynFontStyles FontStylesChanged); + void FormatAttributeDone(bool BackgroundChanged, bool ForegroundChanged, FontStyles FontStylesChanged); + void FormatAttributeInit(bool BackgroundChanged, bool ForegroundChanged, FontStyles FontStylesChanged); void FormatAfterLastAttribute(); - void FormatBeforeFirstAttribute(bool BackgroundChanged, bool ForegroundChanged, SynFontStyles FontStylesChanged); + void FormatBeforeFirstAttribute(bool BackgroundChanged, bool ForegroundChanged, FontStyles FontStylesChanged); void FormatNewLine(); QString GetFooter(); QString GetFormatName(); QString GetHeader(); - void SetTokenAttribute(PSynHighlighterAttribute Attri); + void SetTokenAttribute(PHighlighterAttribute Attri); }; } #endif // SYNHTMLEXPORTER_H diff --git a/libs/qsynedit/qsynedit/exporter/synrtfexporter.cpp b/libs/qsynedit/qsynedit/exporter/synrtfexporter.cpp index 1e82feb5..aa75940e 100644 --- a/libs/qsynedit/qsynedit/exporter/synrtfexporter.cpp +++ b/libs/qsynedit/qsynedit/exporter/synrtfexporter.cpp @@ -55,28 +55,28 @@ QString SynRTFExporter::GetFontTable() return Result; } -void SynRTFExporter::FormatAttributeDone(bool , bool , SynFontStyles FontStylesChanged) +void SynRTFExporter::FormatAttributeDone(bool , bool , FontStyles FontStylesChanged) { // nothing to do about the color, but reset the font style - if (FontStylesChanged.testFlag(SynFontStyle::fsBold)) { + if (FontStylesChanged.testFlag(FontStyle::fsBold)) { mAttributesChanged = true; AddData("\\b0"); } - if (FontStylesChanged.testFlag(SynFontStyle::fsItalic)) { + if (FontStylesChanged.testFlag(FontStyle::fsItalic)) { mAttributesChanged = true; AddData("\\i0"); } - if (FontStylesChanged.testFlag(SynFontStyle::fsUnderline)) { + if (FontStylesChanged.testFlag(FontStyle::fsUnderline)) { mAttributesChanged = true; AddData("\\ul0"); } - if (FontStylesChanged.testFlag(SynFontStyle::fsStrikeOut)) { + if (FontStylesChanged.testFlag(FontStyle::fsStrikeOut)) { mAttributesChanged = true; AddData("\\strike0"); } } -void SynRTFExporter::FormatAttributeInit(bool BackgroundChanged, bool ForegroundChanged, SynFontStyles FontStylesChanged) +void SynRTFExporter::FormatAttributeInit(bool BackgroundChanged, bool ForegroundChanged, FontStyles FontStylesChanged) { // background color if (BackgroundChanged) { @@ -93,19 +93,19 @@ void SynRTFExporter::FormatAttributeInit(bool BackgroundChanged, bool Foreground } // font styles // nothing to do about the color, but reset the font style - if (FontStylesChanged.testFlag(SynFontStyle::fsBold)) { + if (FontStylesChanged.testFlag(FontStyle::fsBold)) { mAttributesChanged = true; AddData("\\b0"); } - if (FontStylesChanged.testFlag(SynFontStyle::fsItalic)) { + if (FontStylesChanged.testFlag(FontStyle::fsItalic)) { mAttributesChanged = true; AddData("\\i0"); } - if (FontStylesChanged.testFlag(SynFontStyle::fsUnderline)) { + if (FontStylesChanged.testFlag(FontStyle::fsUnderline)) { mAttributesChanged = true; AddData("\\ul0"); } - if (FontStylesChanged.testFlag(SynFontStyle::fsStrikeOut)) { + if (FontStylesChanged.testFlag(FontStyle::fsStrikeOut)) { mAttributesChanged = true; AddData("\\strike0"); } @@ -120,7 +120,7 @@ void SynRTFExporter::FormatAfterLastAttribute() // no need to reset the font style here... } -void SynRTFExporter::FormatBeforeFirstAttribute(bool BackgroundChanged, bool ForegroundChanged, SynFontStyles FontStylesChanged) +void SynRTFExporter::FormatBeforeFirstAttribute(bool BackgroundChanged, bool ForegroundChanged, FontStyles FontStylesChanged) { FormatAttributeInit(BackgroundChanged, ForegroundChanged, FontStylesChanged); } diff --git a/libs/qsynedit/qsynedit/exporter/synrtfexporter.h b/libs/qsynedit/qsynedit/exporter/synrtfexporter.h index 7bb644f3..46026554 100644 --- a/libs/qsynedit/qsynedit/exporter/synrtfexporter.h +++ b/libs/qsynedit/qsynedit/exporter/synrtfexporter.h @@ -34,10 +34,10 @@ private: // SynExporter interface protected: - void FormatAttributeDone(bool BackgroundChanged, bool ForegroundChanged, SynFontStyles FontStylesChanged) override; - void FormatAttributeInit(bool BackgroundChanged, bool ForegroundChanged, SynFontStyles FontStylesChanged) override; + void FormatAttributeDone(bool BackgroundChanged, bool ForegroundChanged, FontStyles FontStylesChanged) override; + void FormatAttributeInit(bool BackgroundChanged, bool ForegroundChanged, FontStyles FontStylesChanged) override; void FormatAfterLastAttribute() override; - void FormatBeforeFirstAttribute(bool BackgroundChanged, bool ForegroundChanged, SynFontStyles FontStylesChanged) override; + void FormatBeforeFirstAttribute(bool BackgroundChanged, bool ForegroundChanged, FontStyles FontStylesChanged) override; void FormatNewLine() override; QString GetFooter() override; QString GetFormatName() override; diff --git a/libs/qsynedit/qsynedit/highlighter/asm.cpp b/libs/qsynedit/qsynedit/highlighter/asm.cpp index 57e05acd..f3a7df44 100644 --- a/libs/qsynedit/qsynedit/highlighter/asm.cpp +++ b/libs/qsynedit/qsynedit/highlighter/asm.cpp @@ -19,7 +19,7 @@ namespace QSynedit { -const QSet SynEditASMHighlighter::Keywords { +const QSet ASMHighlighter::Keywords { "aaa","aad","aam","adc","add","and","arpl","bound","bsf","bsr","bswap","bt","btc","btr","bts", "call","cbw","cdq","clc","cld","cli","clts","cmc","cmp","cmps","cmpsb","cmpsd","cmpsw", "cmpxchg","cwd","cwde","daa","das","dec","div","emms","enter","f2xm1","fabs","fadd","faddp","fbld", @@ -55,56 +55,56 @@ const QSet SynEditASMHighlighter::Keywords { -SynEditASMHighlighter::SynEditASMHighlighter() +ASMHighlighter::ASMHighlighter() { - mCommentAttribute = std::make_shared(SYNS_AttrComment); - mCommentAttribute->setStyles(SynFontStyle::fsItalic); + mCommentAttribute = std::make_shared(SYNS_AttrComment); + mCommentAttribute->setStyles(FontStyle::fsItalic); addAttribute(mCommentAttribute); - mIdentifierAttribute = std::make_shared(SYNS_AttrIdentifier); + mIdentifierAttribute = std::make_shared(SYNS_AttrIdentifier); addAttribute(mIdentifierAttribute); - mKeywordAttribute = std::make_shared(SYNS_AttrReservedWord); - mKeywordAttribute->setStyles(SynFontStyle::fsBold); + mKeywordAttribute = std::make_shared(SYNS_AttrReservedWord); + mKeywordAttribute->setStyles(FontStyle::fsBold); addAttribute(mKeywordAttribute); - mNumberAttribute = std::make_shared(SYNS_AttrNumber); + mNumberAttribute = std::make_shared(SYNS_AttrNumber); addAttribute(mNumberAttribute); - mWhitespaceAttribute = std::make_shared(SYNS_AttrSpace); + mWhitespaceAttribute = std::make_shared(SYNS_AttrSpace); addAttribute(mWhitespaceAttribute); - mStringAttribute = std::make_shared(SYNS_AttrString); + mStringAttribute = std::make_shared(SYNS_AttrString); addAttribute(mStringAttribute); - mSymbolAttribute = std::make_shared(SYNS_AttrSymbol); + mSymbolAttribute = std::make_shared(SYNS_AttrSymbol); addAttribute(mSymbolAttribute); } -PSynHighlighterAttribute SynEditASMHighlighter::numberAttribute() +PHighlighterAttribute ASMHighlighter::numberAttribute() { return mNumberAttribute; } -void SynEditASMHighlighter::CommentProc() +void ASMHighlighter::CommentProc() { - mTokenID = TokenKind::Comment; + mTokenID = TokenId::Comment; do { mRun++; } while (! (mLine[mRun]==0 || mLine[mRun] == '\r' || mLine[mRun]=='\n')); } -void SynEditASMHighlighter::CRProc() +void ASMHighlighter::CRProc() { - mTokenID = TokenKind::Space; + mTokenID = TokenId::Space; mRun++; if (mLine[mRun] == '\n') mRun++; } -void SynEditASMHighlighter::GreaterProc() +void ASMHighlighter::GreaterProc() { mRun++; - mTokenID = TokenKind::Symbol; + mTokenID = TokenId::Symbol; if (mLine[mRun] == '=') mRun++; } -void SynEditASMHighlighter::IdentProc() +void ASMHighlighter::IdentProc() { int start = mRun; while (isIdentChar(mLine[mRun])) { @@ -112,35 +112,35 @@ void SynEditASMHighlighter::IdentProc() } QString s = mLineString.mid(start,mRun-start); if (Keywords.contains(s)) { - mTokenID = TokenKind::Key; + mTokenID = TokenId::Key; } else { - mTokenID = TokenKind::Identifier; + mTokenID = TokenId::Identifier; } } -void SynEditASMHighlighter::LFProc() +void ASMHighlighter::LFProc() { - mTokenID = TokenKind::Space; + mTokenID = TokenId::Space; mRun++; } -void SynEditASMHighlighter::LowerProc() +void ASMHighlighter::LowerProc() { mRun++; - mTokenID = TokenKind::Symbol; + mTokenID = TokenId::Symbol; if (mLine[mRun]=='=' || mLine[mRun]== '>') mRun++; } -void SynEditASMHighlighter::NullProc() +void ASMHighlighter::NullProc() { - mTokenID = TokenKind::Null; + mTokenID = TokenId::Null; } -void SynEditASMHighlighter::NumberProc() +void ASMHighlighter::NumberProc() { mRun++; - mTokenID = TokenKind::Number; + mTokenID = TokenId::Number; while (true) { QChar ch = mLine[mRun]; if (!((ch>='0' && ch<='9') || (ch=='.') || (ch >= 'a' && ch<='f') @@ -150,9 +150,9 @@ void SynEditASMHighlighter::NumberProc() } } -void SynEditASMHighlighter::SingleQuoteStringProc() +void ASMHighlighter::SingleQuoteStringProc() { - mTokenID = TokenKind::String; + mTokenID = TokenId::String; if ((mRun+2 < mLineString.size()) && (mLine[mRun + 1] == '\'') && (mLine[mRun + 2] == '\'')) mRun += 2; while (true) { @@ -164,23 +164,23 @@ void SynEditASMHighlighter::SingleQuoteStringProc() mRun++; } -void SynEditASMHighlighter::SlashProc() +void ASMHighlighter::SlashProc() { mRun++; if (mLine[mRun] == '/') { - mTokenID = TokenKind::Comment; + mTokenID = TokenId::Comment; while (true) { mRun++; if (mLine[mRun] == 0 || mLine[mRun] == '\r' || mLine[mRun] == '\n') break; } } else - mTokenID = TokenKind::Symbol; + mTokenID = TokenId::Symbol; } -void SynEditASMHighlighter::SpaceProc() +void ASMHighlighter::SpaceProc() { - mTokenID = TokenKind::Space; + mTokenID = TokenId::Space; while (true) { mRun++; if (mLine[mRun] == 0 || mLine[mRun] == '\r' || mLine[mRun] == '\n') @@ -190,9 +190,9 @@ void SynEditASMHighlighter::SpaceProc() } } -void SynEditASMHighlighter::StringProc() +void ASMHighlighter::StringProc() { - mTokenID = TokenKind::String; + mTokenID = TokenId::String; if ((mRun+2 < mLineString.size()) && (mLine[mRun + 1] == '\"') && (mLine[mRun + 2] == '\"')) mRun += 2; while (true) { @@ -206,95 +206,95 @@ void SynEditASMHighlighter::StringProc() mRun++; } -void SynEditASMHighlighter::SymbolProc() +void ASMHighlighter::SymbolProc() { mRun++; - mTokenID = TokenKind::Symbol; + mTokenID = TokenId::Symbol; } -void SynEditASMHighlighter::UnknownProc() +void ASMHighlighter::UnknownProc() { mRun++; - mTokenID = TokenKind::Unknown; + mTokenID = TokenId::Unknown; } -bool SynEditASMHighlighter::eol() const +bool ASMHighlighter::eol() const { - return mTokenID == TokenKind::Null; + return mTokenID == TokenId::Null; } -QString SynEditASMHighlighter::languageName() +QString ASMHighlighter::languageName() { return "asm"; } -SynHighlighterLanguage SynEditASMHighlighter::language() +HighlighterLanguage ASMHighlighter::language() { - return SynHighlighterLanguage::Asssembly; + return HighlighterLanguage::Asssembly; } -QString SynEditASMHighlighter::getToken() const +QString ASMHighlighter::getToken() const { return mLineString.mid(mTokenPos,mRun-mTokenPos); } -PSynHighlighterAttribute SynEditASMHighlighter::getTokenAttribute() const +PHighlighterAttribute ASMHighlighter::getTokenAttribute() const { switch(mTokenID) { - case TokenKind::Comment: + case TokenId::Comment: return mCommentAttribute; - case TokenKind::Identifier: + case TokenId::Identifier: return mIdentifierAttribute; - case TokenKind::Key: + case TokenId::Key: return mKeywordAttribute; - case TokenKind::Number: + case TokenId::Number: return mNumberAttribute; - case TokenKind::Space: + case TokenId::Space: return mWhitespaceAttribute; - case TokenKind::String: + case TokenId::String: return mStringAttribute; - case TokenKind::Symbol: + case TokenId::Symbol: return mSymbolAttribute; - case TokenKind::Unknown: + case TokenId::Unknown: return mIdentifierAttribute; } - return PSynHighlighterAttribute(); + return PHighlighterAttribute(); } -SynTokenKind SynEditASMHighlighter::getTokenKind() +TokenKind ASMHighlighter::getTokenKind() { return mTokenID; } -SynHighlighterTokenType SynEditASMHighlighter::getTokenType() +TokenType ASMHighlighter::getTokenType() { switch(mTokenID) { - case TokenKind::Comment: - return SynHighlighterTokenType::Comment; - case TokenKind::Identifier: - return SynHighlighterTokenType::Identifier; - case TokenKind::Key: - return SynHighlighterTokenType::Keyword; - case TokenKind::Number: - return SynHighlighterTokenType::Number; - case TokenKind::Space: - return SynHighlighterTokenType::Space; - case TokenKind::String: - return SynHighlighterTokenType::String; - case TokenKind::Symbol: - return SynHighlighterTokenType::Symbol; - case TokenKind::Unknown: - return SynHighlighterTokenType::Default; + case TokenId::Comment: + return TokenType::Comment; + case TokenId::Identifier: + return TokenType::Identifier; + case TokenId::Key: + return TokenType::Keyword; + case TokenId::Number: + return TokenType::Number; + case TokenId::Space: + return TokenType::Space; + case TokenId::String: + return TokenType::String; + case TokenId::Symbol: + return TokenType::Symbol; + case TokenId::Unknown: + return TokenType::Default; } - return SynHighlighterTokenType::Default; + return TokenType::Default; } -int SynEditASMHighlighter::getTokenPos() +int ASMHighlighter::getTokenPos() { return mTokenPos; } -void SynEditASMHighlighter::next() +void ASMHighlighter::next() { mTokenPos = mRun; switch(mLine[mRun].unicode()) { @@ -355,7 +355,7 @@ void SynEditASMHighlighter::next() } } -void SynEditASMHighlighter::setLine(const QString &newLine, int lineNumber) +void ASMHighlighter::setLine(const QString &newLine, int lineNumber) { mLineString = newLine; mLine = mLineString.data(); @@ -364,47 +364,47 @@ void SynEditASMHighlighter::setLine(const QString &newLine, int lineNumber) next(); } -SynHighlighterClass SynEditASMHighlighter::getClass() const +HighlighterClass ASMHighlighter::getClass() const { - return SynHighlighterClass::CppHighlighter; + return HighlighterClass::CppHighlighter; } -QString SynEditASMHighlighter::getName() const +QString ASMHighlighter::getName() const { return SYN_HIGHLIGHTER_CPP; } -bool SynEditASMHighlighter::getTokenFinished() const +bool ASMHighlighter::getTokenFinished() const { return true; } -bool SynEditASMHighlighter::isLastLineCommentNotFinished(int /*state*/) const +bool ASMHighlighter::isLastLineCommentNotFinished(int /*state*/) const { return true; } -bool SynEditASMHighlighter::isLastLineStringNotFinished(int /*state*/) const +bool ASMHighlighter::isLastLineStringNotFinished(int /*state*/) const { return true; } -SynRangeState SynEditASMHighlighter::getRangeState() const +HighlighterState ASMHighlighter::getState() const { - return SynRangeState(); + return HighlighterState(); } -void SynEditASMHighlighter::setState(const SynRangeState&) +void ASMHighlighter::setState(const HighlighterState&) { } -void SynEditASMHighlighter::resetState() +void ASMHighlighter::resetState() { } -QSet SynEditASMHighlighter::keywords() const +QSet ASMHighlighter::keywords() const { return Keywords; } diff --git a/libs/qsynedit/qsynedit/highlighter/asm.h b/libs/qsynedit/qsynedit/highlighter/asm.h index 3446469d..1a9b063b 100644 --- a/libs/qsynedit/qsynedit/highlighter/asm.h +++ b/libs/qsynedit/qsynedit/highlighter/asm.h @@ -21,9 +21,9 @@ namespace QSynedit { -class SynEditASMHighlighter : public SynHighlighter +class ASMHighlighter : public Highlighter { - enum TokenKind { + enum TokenId { Comment, Identifier, Key, @@ -35,8 +35,8 @@ class SynEditASMHighlighter : public SynHighlighter Unknown }; public: - explicit SynEditASMHighlighter(); - PSynHighlighterAttribute numberAttribute(); + explicit ASMHighlighter(); + PHighlighterAttribute numberAttribute(); static const QSet Keywords; private: @@ -47,8 +47,8 @@ private: int mStringLen; QChar mToIdent; int mTokenPos; - SynTokenKind mTokenID; - PSynHighlighterAttribute mNumberAttribute; + TokenKind mTokenID; + PHighlighterAttribute mNumberAttribute; private: void CommentProc(); @@ -72,18 +72,18 @@ public: bool eol() const override; QString languageName() override; - SynHighlighterLanguage language() override; + HighlighterLanguage language() override; QString getToken() const override; - PSynHighlighterAttribute getTokenAttribute() const override; - SynTokenKind getTokenKind() override; - SynHighlighterTokenType getTokenType() override; + PHighlighterAttribute getTokenAttribute() const override; + TokenKind getTokenKind() override; + TokenType getTokenType() override; int getTokenPos() override; void next() override; void setLine(const QString &newLine, int lineNumber) override; // SynHighlighter interface public: - SynHighlighterClass getClass() const override; + HighlighterClass getClass() const override; QString getName() const override; // SynHighlighter interface @@ -91,8 +91,8 @@ public: bool getTokenFinished() const override; bool isLastLineCommentNotFinished(int state) const override; bool isLastLineStringNotFinished(int state) const override; - SynRangeState getRangeState() const override; - void setState(const SynRangeState& rangeState) override; + HighlighterState getState() const override; + void setState(const HighlighterState& rangeState) override; void resetState() override; // SynHighlighter interface diff --git a/libs/qsynedit/qsynedit/highlighter/base.cpp b/libs/qsynedit/qsynedit/highlighter/base.cpp index f6362df7..40feaf35 100644 --- a/libs/qsynedit/qsynedit/highlighter/base.cpp +++ b/libs/qsynedit/qsynedit/highlighter/base.cpp @@ -18,85 +18,85 @@ #include "../Constants.h" namespace QSynedit { -SynHighlighter::SynHighlighter() : +Highlighter::Highlighter() : mEnabled(true), - mWordBreakChars{ SynWordBreakChars } + mWordBreakChars{ WordBreakChars } { } -const QMap& SynHighlighter::attributes() const +const QMap& Highlighter::attributes() const { return mAttributes; } -const QSet& SynHighlighter::wordBreakChars() const +const QSet& Highlighter::wordBreakChars() const { return mWordBreakChars; } -PSynHighlighterAttribute SynHighlighter::commentAttribute() const +PHighlighterAttribute Highlighter::commentAttribute() const { return mCommentAttribute; } -PSynHighlighterAttribute SynHighlighter::identifierAttribute() const +PHighlighterAttribute Highlighter::identifierAttribute() const { return mIdentifierAttribute; } -PSynHighlighterAttribute SynHighlighter::keywordAttribute() const +PHighlighterAttribute Highlighter::keywordAttribute() const { return mKeywordAttribute; } -PSynHighlighterAttribute SynHighlighter::stringAttribute() const +PHighlighterAttribute Highlighter::stringAttribute() const { return mStringAttribute; } -PSynHighlighterAttribute SynHighlighter::whitespaceAttribute() const +PHighlighterAttribute Highlighter::whitespaceAttribute() const { return mWhitespaceAttribute; } -PSynHighlighterAttribute SynHighlighter::symbolAttribute() const +PHighlighterAttribute Highlighter::symbolAttribute() const { return mSymbolAttribute; } -SynHighlighterTokenType SynHighlighter::getTokenType() +TokenType Highlighter::getTokenType() { - return SynHighlighterTokenType::Default; + return TokenType::Default; } -bool SynHighlighter::isKeyword(const QString &) +bool Highlighter::isKeyword(const QString &) { return false; } -void SynHighlighter::nextToEol() +void Highlighter::nextToEol() { while (!eol()) next(); } -QSet SynHighlighter::keywords() const +QSet Highlighter::keywords() const { return QSet(); } -QString SynHighlighter::foldString() +QString Highlighter::foldString() { return " ... }"; } -bool SynHighlighter::isSpaceChar(const QChar &ch) +bool Highlighter::isSpaceChar(const QChar &ch) { return ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n'; } -bool SynHighlighter::isWordBreakChar(const QChar &ch) +bool Highlighter::isWordBreakChar(const QChar &ch) { switch (ch.unicode()) { case '.': @@ -130,7 +130,7 @@ bool SynHighlighter::isWordBreakChar(const QChar &ch) } } -bool SynHighlighter::isIdentChar(const QChar &ch) const +bool Highlighter::isIdentChar(const QChar &ch) const { if (ch == '_') { return true; @@ -147,96 +147,96 @@ bool SynHighlighter::isIdentChar(const QChar &ch) const return false; } -void SynHighlighter::addAttribute(PSynHighlighterAttribute attribute) +void Highlighter::addAttribute(PHighlighterAttribute attribute) { mAttributes[attribute->name()]=attribute; } -void SynHighlighter::clearAttributes() +void Highlighter::clearAttributes() { mAttributes.clear(); } -int SynHighlighter::attributesCount() const +int Highlighter::attributesCount() const { return mAttributes.size(); } -PSynHighlighterAttribute SynHighlighter::getAttribute(const QString &name) const +PHighlighterAttribute Highlighter::getAttribute(const QString &name) const { auto search = mAttributes.find(name); if (search!=mAttributes.end()) { return search.value(); } - return PSynHighlighterAttribute(); + return PHighlighterAttribute(); } -bool SynHighlighter::enabled() const +bool Highlighter::enabled() const { return mEnabled; } -void SynHighlighter::setEnabled(bool value) +void Highlighter::setEnabled(bool value) { if (value != mEnabled) { mEnabled = value; } } -SynFontStyles SynHighlighterAttribute::styles() const +FontStyles HighlighterAttribute::styles() const { return mStyles; } -void SynHighlighterAttribute::setStyles(const SynFontStyles &styles) +void HighlighterAttribute::setStyles(const FontStyles &styles) { if (mStyles!=styles) { mStyles = styles; } } -QColor SynHighlighterAttribute::foreground() const +QColor HighlighterAttribute::foreground() const { return mForeground; } -void SynHighlighterAttribute::setForeground(const QColor &color) +void HighlighterAttribute::setForeground(const QColor &color) { mForeground = color; } -QColor SynHighlighterAttribute::background() const +QColor HighlighterAttribute::background() const { return mBackground; } -void SynHighlighterAttribute::setBackground(const QColor &background) +void HighlighterAttribute::setBackground(const QColor &background) { mBackground = background; } -QString SynHighlighterAttribute::name() const +QString HighlighterAttribute::name() const { return mName; } -void SynHighlighterAttribute::setName(const QString &name) +void HighlighterAttribute::setName(const QString &name) { if (mName!=name) { mName = name; } } -SynHighlighterAttribute::SynHighlighterAttribute(const QString &name): +HighlighterAttribute::HighlighterAttribute(const QString &name): mForeground(QColor()), mBackground(QColor()), mName(name), - mStyles(SynFontStyle::fsNone) + mStyles(FontStyle::fsNone) { } -bool SynRangeState::operator==(const SynRangeState &s2) +bool HighlighterState::operator==(const HighlighterState &s2) { // indents contains the information of brace/parenthesis/brackets embedded levels return (state == s2.state) @@ -244,14 +244,14 @@ bool SynRangeState::operator==(const SynRangeState &s2) ; } -int SynRangeState::getLastIndent() +int HighlighterState::getLastIndent() { if (indents.isEmpty()) return -1; return indents.back(); } -SynRangeState::SynRangeState(): +HighlighterState::HighlighterState(): state(0), braceLevel(0), bracketLevel(0), diff --git a/libs/qsynedit/qsynedit/highlighter/base.h b/libs/qsynedit/qsynedit/highlighter/base.h index 9521ca3e..6a338931 100644 --- a/libs/qsynedit/qsynedit/highlighter/base.h +++ b/libs/qsynedit/qsynedit/highlighter/base.h @@ -34,7 +34,7 @@ enum SynIndentType { sitStatement = 3, }; -struct SynRangeState { +struct HighlighterState { int state; // current syntax parsing state int braceLevel; // current braces embedding level (needed by rainbow color) int bracketLevel; // current brackets embedding level (needed by rainbow color) @@ -47,41 +47,41 @@ struct SynRangeState { QVector matchingIndents; /* the indent matched ( and removed ) but not started at this line (need by auto indent) */ - bool operator==(const SynRangeState& s2); + bool operator==(const HighlighterState& s2); int getLastIndent(); - SynRangeState(); + HighlighterState(); }; -typedef int SynTokenKind; +typedef int TokenKind; -enum class SynHighlighterTokenType { +enum class TokenType { Default, Space, Comment, PreprocessDirective, String, StringEscapeSequence, Identifier, Symbol, Character, Keyword, Number}; -enum class SynHighlighterClass { +enum class HighlighterClass { Composition, CppHighlighter, AsmHighlighter, GLSLHighlighter }; -enum class SynHighlighterLanguage { +enum class HighlighterLanguage { Asssembly, Cpp, GLSL }; -class SynHighlighterAttribute { +class HighlighterAttribute { public: - explicit SynHighlighterAttribute(const QString& name); + explicit HighlighterAttribute(const QString& name); QString name() const; void setName(const QString &name); - SynFontStyles styles() const; - void setStyles(const SynFontStyles &styles); + FontStyles styles() const; + void setStyles(const FontStyles &styles); QColor foreground() const; void setForeground(const QColor &color); @@ -93,58 +93,58 @@ private: QColor mForeground; QColor mBackground; QString mName; - SynFontStyles mStyles; + FontStyles mStyles; }; -typedef std::shared_ptr PSynHighlighterAttribute; -using SynHighlighterAttributeList = QVector; +typedef std::shared_ptr PHighlighterAttribute; +using HighlighterAttributeList = QVector; -class SynHighlighter { +class Highlighter { public: - explicit SynHighlighter(); + explicit Highlighter(); - const QMap& attributes() const; + const QMap& attributes() const; const QSet& wordBreakChars() const; - PSynHighlighterAttribute commentAttribute() const; + PHighlighterAttribute commentAttribute() const; - PSynHighlighterAttribute identifierAttribute() const; + PHighlighterAttribute identifierAttribute() const; - PSynHighlighterAttribute keywordAttribute() const; + PHighlighterAttribute keywordAttribute() const; - PSynHighlighterAttribute stringAttribute() const; + PHighlighterAttribute stringAttribute() const; - PSynHighlighterAttribute whitespaceAttribute() const; + PHighlighterAttribute whitespaceAttribute() const; - PSynHighlighterAttribute symbolAttribute() const; + PHighlighterAttribute symbolAttribute() const; virtual bool isIdentChar(const QChar& ch) const; - virtual SynHighlighterClass getClass() const = 0; + 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; virtual bool eol() const = 0; - virtual SynRangeState getRangeState() const = 0; + virtual HighlighterState getState() const = 0; virtual QString getToken() const=0; - virtual PSynHighlighterAttribute getTokenAttribute() const=0; - virtual SynHighlighterTokenType getTokenType(); - virtual SynTokenKind getTokenKind() = 0; + virtual PHighlighterAttribute getTokenAttribute() const=0; + virtual TokenType getTokenType(); + virtual TokenKind getTokenKind() = 0; virtual int getTokenPos() = 0; virtual bool isKeyword(const QString& word); virtual void next() = 0; virtual void nextToEol(); - virtual void setState(const SynRangeState& rangeState) = 0; + virtual void setState(const HighlighterState& rangeState) = 0; virtual void setLine(const QString& newLine, int lineNumber) = 0; virtual void resetState() = 0; virtual QSet keywords() const; virtual QString languageName() = 0; - virtual SynHighlighterLanguage language() = 0; + virtual HighlighterLanguage language() = 0; virtual QString foldString(); @@ -152,28 +152,28 @@ public: virtual bool isWordBreakChar(const QChar& ch); bool enabled() const; void setEnabled(bool value); - virtual PSynHighlighterAttribute getAttribute(const QString& name) const; + virtual PHighlighterAttribute getAttribute(const QString& name) const; protected: - PSynHighlighterAttribute mCommentAttribute; - PSynHighlighterAttribute mIdentifierAttribute; - PSynHighlighterAttribute mKeywordAttribute; - PSynHighlighterAttribute mStringAttribute; - PSynHighlighterAttribute mWhitespaceAttribute; - PSynHighlighterAttribute mSymbolAttribute; + PHighlighterAttribute mCommentAttribute; + PHighlighterAttribute mIdentifierAttribute; + PHighlighterAttribute mKeywordAttribute; + PHighlighterAttribute mStringAttribute; + PHighlighterAttribute mWhitespaceAttribute; + PHighlighterAttribute mSymbolAttribute; - void addAttribute(PSynHighlighterAttribute attribute); + void addAttribute(PHighlighterAttribute attribute); void clearAttributes(); virtual int attributesCount() const; private: - QMap mAttributes; + QMap mAttributes; bool mEnabled; QSet mWordBreakChars; }; -using PSynHighlighter = std::shared_ptr; -using SynHighlighterList = QVector; +using PHighlighter = std::shared_ptr; +using HighlighterList = QVector; } #endif // SYNHIGHLIGTERBASE_H diff --git a/libs/qsynedit/qsynedit/highlighter/composition.cpp b/libs/qsynedit/qsynedit/highlighter/composition.cpp index 6f5c712f..6436eef1 100644 --- a/libs/qsynedit/qsynedit/highlighter/composition.cpp +++ b/libs/qsynedit/qsynedit/highlighter/composition.cpp @@ -19,86 +19,86 @@ namespace QSynedit { -SynHighlightComposition::SynHighlightComposition() +CompositedHighlighter::CompositedHighlighter() { } -SynHighlighterClass SynHighlightComposition::getClass() const +HighlighterClass CompositedHighlighter::getClass() const { - return SynHighlighterClass::Composition; + return HighlighterClass::Composition; } -QString SynHighlightComposition::getName() const +QString CompositedHighlighter::getName() const { return "SynHighlightComposition"; } -SynScheme::SynScheme(QObject *parent): +HighlighterSchema::HighlighterSchema(QObject *parent): QObject(parent), mCaseSensitive(true) { - mMarkerAttribute = std::make_shared(SYNS_AttrMarker); + mMarkerAttribute = std::make_shared(SYNS_AttrMarker); mMarkerAttribute->setForeground(Qt::yellow); - mMarkerAttribute->setStyles(SynFontStyle::fsBold); + mMarkerAttribute->setStyles(FontStyle::fsBold); } -QString SynScheme::endExpr() const +QString HighlighterSchema::endExpr() const { return mEndExpr; } -void SynScheme::setEndExpr(const QString &endExpr) +void HighlighterSchema::setEndExpr(const QString &endExpr) { mEndExpr = endExpr; } -QString SynScheme::getStartExpr() const +QString HighlighterSchema::getStartExpr() const { return StartExpr; } -void SynScheme::setStartExpr(const QString &value) +void HighlighterSchema::setStartExpr(const QString &value) { StartExpr = value; } -PSynHighlighter SynScheme::getHighlighter() const +PHighlighter HighlighterSchema::getHighlighter() const { return mHighlighter; } -void SynScheme::setHighlighter(const PSynHighlighter &highlighter) +void HighlighterSchema::setHighlighter(const PHighlighter &highlighter) { mHighlighter = highlighter; } -PSynHighlighterAttribute SynScheme::getMarkerAttribute() const +PHighlighterAttribute HighlighterSchema::getMarkerAttribute() const { return mMarkerAttribute; } -QString SynScheme::getSchemeName() const +QString HighlighterSchema::getSchemeName() const { return mSchemeName; } -void SynScheme::setSchemeName(const QString &schemeName) +void HighlighterSchema::setSchemeName(const QString &schemeName) { mSchemeName = schemeName; } -int SynScheme::getCaseSensitive() const +int HighlighterSchema::getCaseSensitive() const { return mCaseSensitive; } -void SynScheme::setCaseSensitive(int caseSensitive) +void HighlighterSchema::setCaseSensitive(int caseSensitive) { mCaseSensitive = caseSensitive; } -QString SynScheme::ConvertExpression(const QString &Value) +QString HighlighterSchema::ConvertExpression(const QString &Value) { if (!mCaseSensitive) { return Value.toUpper(); @@ -107,7 +107,7 @@ QString SynScheme::ConvertExpression(const QString &Value) } } -void SynScheme::MarkerAttriChanged() { +void HighlighterSchema::MarkerAttriChanged() { } } diff --git a/libs/qsynedit/qsynedit/highlighter/composition.h b/libs/qsynedit/qsynedit/highlighter/composition.h index 494d7617..94e22969 100644 --- a/libs/qsynedit/qsynedit/highlighter/composition.h +++ b/libs/qsynedit/qsynedit/highlighter/composition.h @@ -21,26 +21,26 @@ #include namespace QSynedit { -class SynSchema; -using PSynSchema = std::shared_ptr; +class HighlighterSchema; +using PHighlighterSchema = std::shared_ptr; -using OnCheckMarker = std::function& MarkerText , int Line)>; +//using OnCheckMarker = std::function& MarkerText , int Line)>; -class SynScheme : public QObject { +class HighlighterSchema : public QObject { Q_OBJECT public: - explicit SynScheme(QObject* parent=nullptr); + explicit HighlighterSchema(QObject* parent=nullptr); QString endExpr() const; void setEndExpr(const QString &endExpr); QString getStartExpr() const; void setStartExpr(const QString &value); - PSynHighlighter getHighlighter() const; - void setHighlighter(const PSynHighlighter &highlighter); + PHighlighter getHighlighter() const; + void setHighlighter(const PHighlighter &highlighter); - PSynHighlighterAttribute getMarkerAttribute() const; + PHighlighterAttribute getMarkerAttribute() const; QString getSchemeName() const; void setSchemeName(const QString &schemeName); @@ -51,12 +51,12 @@ public: private: QString mEndExpr; QString StartExpr; - PSynHighlighter mHighlighter; - PSynHighlighterAttribute mMarkerAttribute; + PHighlighter mHighlighter; + PHighlighterAttribute mMarkerAttribute; QString mSchemeName; int mCaseSensitive; - OnCheckMarker mOnCheckStartMarker; - OnCheckMarker mOnCheckEndMarker; +// OnCheckMarker mOnCheckStartMarker; +// OnCheckMarker mOnCheckEndMarker; QString ConvertExpression(const QString& Value); private slots: void MarkerAttriChanged(); @@ -64,14 +64,14 @@ private slots: -class SynHighlightComposition : public SynHighlighter +class CompositedHighlighter : public Highlighter { public: - explicit SynHighlightComposition(); + explicit CompositedHighlighter(); // SynHighligterBase interface public: - SynHighlighterClass getClass() const override; + HighlighterClass getClass() const override; QString getName() const override; }; diff --git a/libs/qsynedit/qsynedit/highlighter/cpp.cpp b/libs/qsynedit/qsynedit/highlighter/cpp.cpp index d319c58e..e7f81575 100644 --- a/libs/qsynedit/qsynedit/highlighter/cpp.cpp +++ b/libs/qsynedit/qsynedit/highlighter/cpp.cpp @@ -33,7 +33,7 @@ static const QSet CppStatementKeyWords { -const QSet SynEditCppHighlighter::Keywords { +const QSet CppHighlighter::Keywords { "and", "and_eq", "bitand", @@ -140,159 +140,159 @@ const QSet SynEditCppHighlighter::Keywords { "nullptr", }; -SynEditCppHighlighter::SynEditCppHighlighter(): SynHighlighter() +CppHighlighter::CppHighlighter(): Highlighter() { - mAsmAttribute = std::make_shared(SYNS_AttrAssembler); + mAsmAttribute = std::make_shared(SYNS_AttrAssembler); addAttribute(mAsmAttribute); - mCharAttribute = std::make_shared(SYNS_AttrCharacter); + mCharAttribute = std::make_shared(SYNS_AttrCharacter); addAttribute(mCharAttribute); - mCommentAttribute = std::make_shared(SYNS_AttrComment); + mCommentAttribute = std::make_shared(SYNS_AttrComment); addAttribute(mCommentAttribute); - mClassAttribute = std::make_shared(SYNS_AttrClass); + mClassAttribute = std::make_shared(SYNS_AttrClass); addAttribute(mClassAttribute); - mFloatAttribute = std::make_shared(SYNS_AttrFloat); + mFloatAttribute = std::make_shared(SYNS_AttrFloat); addAttribute(mFloatAttribute); - mFunctionAttribute = std::make_shared(SYNS_AttrFunction); + mFunctionAttribute = std::make_shared(SYNS_AttrFunction); addAttribute(mFunctionAttribute); - mGlobalVarAttribute = std::make_shared(SYNS_AttrGlobalVariable); + mGlobalVarAttribute = std::make_shared(SYNS_AttrGlobalVariable); addAttribute(mGlobalVarAttribute); - mHexAttribute = std::make_shared(SYNS_AttrHexadecimal); + mHexAttribute = std::make_shared(SYNS_AttrHexadecimal); addAttribute(mHexAttribute); - mIdentifierAttribute = std::make_shared(SYNS_AttrIdentifier); + mIdentifierAttribute = std::make_shared(SYNS_AttrIdentifier); addAttribute(mIdentifierAttribute); - mInvalidAttribute = std::make_shared(SYNS_AttrIllegalChar); + mInvalidAttribute = std::make_shared(SYNS_AttrIllegalChar); addAttribute(mInvalidAttribute); - mLocalVarAttribute = std::make_shared(SYNS_AttrLocalVariable); + mLocalVarAttribute = std::make_shared(SYNS_AttrLocalVariable); addAttribute(mLocalVarAttribute); - mNumberAttribute = std::make_shared(SYNS_AttrNumber); + mNumberAttribute = std::make_shared(SYNS_AttrNumber); addAttribute(mNumberAttribute); - mOctAttribute = std::make_shared(SYNS_AttrOctal); + mOctAttribute = std::make_shared(SYNS_AttrOctal); addAttribute(mOctAttribute); - mPreprocessorAttribute = std::make_shared(SYNS_AttrPreprocessor); + mPreprocessorAttribute = std::make_shared(SYNS_AttrPreprocessor); addAttribute(mPreprocessorAttribute); - mKeywordAttribute = std::make_shared(SYNS_AttrReservedWord); + mKeywordAttribute = std::make_shared(SYNS_AttrReservedWord); addAttribute(mKeywordAttribute); - mWhitespaceAttribute = std::make_shared(SYNS_AttrSpace); + mWhitespaceAttribute = std::make_shared(SYNS_AttrSpace); addAttribute(mWhitespaceAttribute); - mStringAttribute = std::make_shared(SYNS_AttrString); + mStringAttribute = std::make_shared(SYNS_AttrString); addAttribute(mStringAttribute); - mStringEscapeSequenceAttribute = std::make_shared(SYNS_AttrStringEscapeSequences); + mStringEscapeSequenceAttribute = std::make_shared(SYNS_AttrStringEscapeSequences); addAttribute(mStringEscapeSequenceAttribute); - mSymbolAttribute = std::make_shared(SYNS_AttrSymbol); + mSymbolAttribute = std::make_shared(SYNS_AttrSymbol); addAttribute(mSymbolAttribute); - mVariableAttribute = std::make_shared(SYNS_AttrVariable); + mVariableAttribute = std::make_shared(SYNS_AttrVariable); addAttribute(mVariableAttribute); resetState(); } -PSynHighlighterAttribute SynEditCppHighlighter::asmAttribute() const +PHighlighterAttribute CppHighlighter::asmAttribute() const { return mAsmAttribute; } -PSynHighlighterAttribute SynEditCppHighlighter::preprocessorAttribute() const +PHighlighterAttribute CppHighlighter::preprocessorAttribute() const { return mPreprocessorAttribute; } -PSynHighlighterAttribute SynEditCppHighlighter::invalidAttribute() const +PHighlighterAttribute CppHighlighter::invalidAttribute() const { return mInvalidAttribute; } -PSynHighlighterAttribute SynEditCppHighlighter::numberAttribute() const +PHighlighterAttribute CppHighlighter::numberAttribute() const { return mNumberAttribute; } -PSynHighlighterAttribute SynEditCppHighlighter::floatAttribute() const +PHighlighterAttribute CppHighlighter::floatAttribute() const { return mFloatAttribute; } -PSynHighlighterAttribute SynEditCppHighlighter::hexAttribute() const +PHighlighterAttribute CppHighlighter::hexAttribute() const { return mHexAttribute; } -PSynHighlighterAttribute SynEditCppHighlighter::octAttribute() const +PHighlighterAttribute CppHighlighter::octAttribute() const { return mOctAttribute; } -PSynHighlighterAttribute SynEditCppHighlighter::stringEscapeSequenceAttribute() const +PHighlighterAttribute CppHighlighter::stringEscapeSequenceAttribute() const { return mStringEscapeSequenceAttribute; } -PSynHighlighterAttribute SynEditCppHighlighter::charAttribute() const +PHighlighterAttribute CppHighlighter::charAttribute() const { return mCharAttribute; } -PSynHighlighterAttribute SynEditCppHighlighter::variableAttribute() const +PHighlighterAttribute CppHighlighter::variableAttribute() const { return mVariableAttribute; } -PSynHighlighterAttribute SynEditCppHighlighter::functionAttribute() const +PHighlighterAttribute CppHighlighter::functionAttribute() const { return mFunctionAttribute; } -PSynHighlighterAttribute SynEditCppHighlighter::classAttribute() const +PHighlighterAttribute CppHighlighter::classAttribute() const { return mClassAttribute; } -PSynHighlighterAttribute SynEditCppHighlighter::globalVarAttribute() const +PHighlighterAttribute CppHighlighter::globalVarAttribute() const { return mGlobalVarAttribute; } -PSynHighlighterAttribute SynEditCppHighlighter::localVarAttribute() const +PHighlighterAttribute CppHighlighter::localVarAttribute() const { return mLocalVarAttribute; } -SynEditCppHighlighter::ExtTokenKind SynEditCppHighlighter::getExtTokenId() +CppHighlighter::ExtTokenId CppHighlighter::getExtTokenId() { return mExtTokenId; } -SynTokenKind SynEditCppHighlighter::getTokenId() +TokenKind CppHighlighter::getTokenId() { if ((mRange.state == RangeState::rsAsm || mRange.state == RangeState::rsAsmBlock) - && !mAsmStart && !(mTokenId == TokenKind::Comment || mTokenId == TokenKind::Space - || mTokenId == TokenKind::Null)) { - return TokenKind::Asm; + && !mAsmStart && !(mTokenId == TokenId::Comment || mTokenId == TokenId::Space + || mTokenId == TokenId::Null)) { + return TokenId::Asm; } else { return mTokenId; } } -void SynEditCppHighlighter::andSymbolProc() +void CppHighlighter::andSymbolProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; switch (mLine[mRun+1].unicode()) { case '=': mRun+=2; - mExtTokenId = ExtTokenKind::AndAssign; + mExtTokenId = ExtTokenId::AndAssign; break; case '&': mRun+=2; - mExtTokenId = ExtTokenKind::LogAnd; + mExtTokenId = ExtTokenId::LogAnd; break; default: mRun+=1; - mExtTokenId = ExtTokenKind::And; + mExtTokenId = ExtTokenId::And; } } -void SynEditCppHighlighter::ansiCppProc() +void CppHighlighter::ansiCppProc() { - mTokenId = TokenKind::Comment; + mTokenId = TokenId::Comment; if (mLine[mRun]==0) { nullProc(); if ( (mRun<1) || (mLine[mRun-1]!='\\')) { @@ -309,10 +309,10 @@ void SynEditCppHighlighter::ansiCppProc() } } -void SynEditCppHighlighter::ansiCProc() +void CppHighlighter::ansiCProc() { bool finishProcess = false; - mTokenId = TokenKind::Comment; + mTokenId = TokenId::Comment; if (mLine[mRun].unicode() == 0) { nullProc(); return; @@ -344,9 +344,9 @@ void SynEditCppHighlighter::ansiCProc() } } -void SynEditCppHighlighter::asciiCharProc() +void CppHighlighter::asciiCharProc() { - mTokenId = TokenKind::Char; + mTokenId = TokenId::Char; do { if (mLine[mRun] == '\\') { if (mLine[mRun+1] == '\'' || mLine[mRun+1] == '\\') { @@ -360,17 +360,17 @@ void SynEditCppHighlighter::asciiCharProc() mRange.state = RangeState::rsUnknown; } -void SynEditCppHighlighter::atSymbolProc() +void CppHighlighter::atSymbolProc() { - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; mRun+=1; } -void SynEditCppHighlighter::braceCloseProc() +void CppHighlighter::braceCloseProc() { mRun += 1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::BraceClose; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::BraceClose; if (mRange.state == RangeState::rsAsmBlock) { mRange.state = rsUnknown; } @@ -386,11 +386,11 @@ void SynEditCppHighlighter::braceCloseProc() popIndents(sitBrace); } -void SynEditCppHighlighter::braceOpenProc() +void CppHighlighter::braceOpenProc() { mRun += 1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::BraceOpen; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::BraceOpen; if (mRange.state == RangeState::rsAsm) { mRange.state = RangeState::rsAsmBlock; mAsmStart = true; @@ -413,34 +413,34 @@ void SynEditCppHighlighter::braceOpenProc() } } -void SynEditCppHighlighter::colonProc() +void CppHighlighter::colonProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; if (mLine[mRun+1]==':') { mRun+=2; - mExtTokenId = ExtTokenKind::ScopeResolution; + mExtTokenId = ExtTokenId::ScopeResolution; } else { mRun+=1; - mExtTokenId = ExtTokenKind::Colon; + mExtTokenId = ExtTokenId::Colon; } } -void SynEditCppHighlighter::commaProc() +void CppHighlighter::commaProc() { mRun+=1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::Comma; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::Comma; } -void SynEditCppHighlighter::directiveProc() +void CppHighlighter::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 - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; mRun+=1; return; } - mTokenId = TokenKind::Directive; + mTokenId = TokenId::Directive; mRun+=1; //skip spaces while (mLine[mRun]!=0 && isSpaceChar(mLine[mRun])) { @@ -461,17 +461,17 @@ void SynEditCppHighlighter::directiveProc() mRange.state = RangeState::rsUnknown; } -void SynEditCppHighlighter::defineIdentProc() +void CppHighlighter::defineIdentProc() { - mTokenId = TokenKind::Identifier; + mTokenId = TokenId::Identifier; while(mLine[mRun]!=0 && isIdentChar(mLine[mRun])) mRun++; mRange.state = RangeState::rsDefineRemaining; } -void SynEditCppHighlighter::defineRemainingProc() +void CppHighlighter::defineRemainingProc() { - mTokenId = TokenKind::Directive; + mTokenId = TokenId::Directive; do { switch(mLine[mRun].unicode()) { case '/': //comment? @@ -497,9 +497,9 @@ void SynEditCppHighlighter::defineRemainingProc() mRange.state=RangeState::rsUnknown; } -void SynEditCppHighlighter::directiveEndProc() +void CppHighlighter::directiveEndProc() { - mTokenId = TokenKind::Directive; + mTokenId = TokenId::Directive; if (mLine[mRun] == 0) { nullProc(); return; @@ -529,42 +529,42 @@ void SynEditCppHighlighter::directiveEndProc() } while (mLine[mRun]!=0); } -void SynEditCppHighlighter::equalProc() +void CppHighlighter::equalProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; if (mLine[mRun+1] == '=') { mRun += 2; - mExtTokenId = ExtTokenKind::LogEqual; + mExtTokenId = ExtTokenId::LogEqual; } else { mRun += 1; - mExtTokenId = ExtTokenKind::Assign; + mExtTokenId = ExtTokenId::Assign; } } -void SynEditCppHighlighter::greaterProc() +void CppHighlighter::greaterProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; switch (mLine[mRun + 1].unicode()) { case '=': mRun += 2; - mExtTokenId = ExtTokenKind::GreaterThanEqual; + mExtTokenId = ExtTokenId::GreaterThanEqual; break; case '>': if (mLine[mRun+2] == '=') { mRun+=3; - mExtTokenId = ExtTokenKind::ShiftRightAssign; + mExtTokenId = ExtTokenId::ShiftRightAssign; } else { mRun += 2; - mExtTokenId = ExtTokenKind::ShiftRight; + mExtTokenId = ExtTokenId::ShiftRight; } break; default: mRun+=1; - mExtTokenId = ExtTokenKind::GreaterThan; + mExtTokenId = ExtTokenId::GreaterThan; } } -void SynEditCppHighlighter::identProc() +void CppHighlighter::identProc() { int wordEnd = mRun; while (isIdentChar(mLine[wordEnd])) { @@ -573,94 +573,94 @@ void SynEditCppHighlighter::identProc() QString word = mLineString.mid(mRun,wordEnd-mRun); mRun=wordEnd; if (isKeyword(word)) { - mTokenId = TokenKind::Key; + mTokenId = TokenId::Key; if (CppStatementKeyWords.contains(word)) { pushIndents(sitStatement); } } else { - mTokenId = TokenKind::Identifier; + mTokenId = TokenId::Identifier; } } -void SynEditCppHighlighter::lowerProc() +void CppHighlighter::lowerProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; switch(mLine[mRun+1].unicode()) { case '=': mRun+=2; - mExtTokenId = ExtTokenKind::LessThanEqual; + mExtTokenId = ExtTokenId::LessThanEqual; break; case '<': if (mLine[mRun+2] == '=') { mRun+=3; - mExtTokenId = ExtTokenKind::ShiftLeftAssign; + mExtTokenId = ExtTokenId::ShiftLeftAssign; } else { mRun+=2; - mExtTokenId = ExtTokenKind::ShiftLeft; + mExtTokenId = ExtTokenId::ShiftLeft; } break; default: mRun+=1; - mExtTokenId = ExtTokenKind::LessThan; + mExtTokenId = ExtTokenId::LessThan; } } -void SynEditCppHighlighter::minusProc() +void CppHighlighter::minusProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; switch(mLine[mRun+1].unicode()) { case '=': mRun += 2; - mExtTokenId = ExtTokenKind::SubtractAssign; + mExtTokenId = ExtTokenId::SubtractAssign; break; case '-': mRun += 2; - mExtTokenId = ExtTokenKind::Decrement; + mExtTokenId = ExtTokenId::Decrement; break; case '>': if (mLine[mRun+2]=='*') { mRun += 3; - mExtTokenId = ExtTokenKind::PointerToMemberOfPointer; + mExtTokenId = ExtTokenId::PointerToMemberOfPointer; } else { mRun += 2; - mExtTokenId = ExtTokenKind::Arrow; + mExtTokenId = ExtTokenId::Arrow; } break; default: mRun += 1; - mExtTokenId = ExtTokenKind::Subtract; + mExtTokenId = ExtTokenId::Subtract; } } -void SynEditCppHighlighter::modSymbolProc() +void CppHighlighter::modSymbolProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; switch(mLine[mRun + 1].unicode()) { case '=': mRun += 2; - mExtTokenId = ExtTokenKind::ModAssign; + mExtTokenId = ExtTokenId::ModAssign; break; default: mRun += 1; - mExtTokenId = ExtTokenKind::Mod; + mExtTokenId = ExtTokenId::Mod; } } -void SynEditCppHighlighter::notSymbolProc() +void CppHighlighter::notSymbolProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; switch(mLine[mRun + 1].unicode()) { case '=': mRun+=2; - mExtTokenId = ExtTokenKind::NotEqual; + mExtTokenId = ExtTokenId::NotEqual; break; default: mRun+=1; - mExtTokenId = ExtTokenKind::LogComplement; + mExtTokenId = ExtTokenId::LogComplement; } } -void SynEditCppHighlighter::nullProc() +void CppHighlighter::nullProc() { if ((mRun-1>=0) && isSpaceChar(mLine[mRun-1]) && (mRange.state == RangeState::rsCppComment @@ -670,45 +670,45 @@ void SynEditCppHighlighter::nullProc() || mRange.state == RangeState::rsMultiLineDirective) ) { mRange.state = RangeState::rsUnknown; } else - mTokenId = TokenKind::Null; + mTokenId = TokenId::Null; } -void SynEditCppHighlighter::numberProc() +void CppHighlighter::numberProc() { int idx1; // token[1] idx1 = mRun; mRun+=1; - mTokenId = TokenKind::Number; + mTokenId = TokenId::Number; bool shouldExit = false; while (mLine[mRun]!=0) { switch(mLine[mRun].unicode()) { case '\'': - if (mTokenId != TokenKind::Number) { - mTokenId = TokenKind::Symbol; + if (mTokenId != TokenId::Number) { + mTokenId = TokenId::Symbol; return; } break; case '.': if (mLine[mRun+1] == '.') { mRun+=2; - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; return; - } else if (mTokenId != TokenKind::Hex) { - mTokenId = TokenKind::Float; + } else if (mTokenId != TokenId::Hex) { + mTokenId = TokenId::Float; } else { - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; return; } break; case '-': case '+': - if (mTokenId != TokenKind::Float) // number <> float. an arithmetic operator + if (mTokenId != TokenId::Float) // number <> float. an arithmetic operator return; if (mLine[mRun-1]!= 'e' && mLine[mRun-1]!='E') // number = float, but no exponent. an arithmetic operator return; if (mLine[mRun+1]<'0' || mLine[mRun+1]>'9') {// invalid mRun+=1; - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; return; } break; @@ -721,13 +721,13 @@ void SynEditCppHighlighter::numberProc() case '6': case '7': if ((mRun == idx1+1) && (mLine[idx1] == '0')) { // octal number - mTokenId = TokenKind::Octal; + mTokenId = TokenId::Octal; } break; case '8': case '9': - if ( (mLine[idx1]=='0') && (mTokenId != TokenKind::Hex) && (mTokenId != TokenKind::Float) ) // invalid octal char - mTokenId = TokenKind::Unknown; // we must continue parse, it may be an float number + if ( (mLine[idx1]=='0') && (mTokenId != TokenId::Hex) && (mTokenId != TokenId::Float) ) // invalid octal char + mTokenId = TokenId::Unknown; // we must continue parse, it may be an float number break; case 'a': case 'b': @@ -737,52 +737,52 @@ void SynEditCppHighlighter::numberProc() case 'B': case 'C': case 'D': - if (mTokenId!=TokenKind::Hex) { //invalid - mTokenId = TokenKind::Unknown; + if (mTokenId!=TokenId::Hex) { //invalid + mTokenId = TokenId::Unknown; return; } break; case 'e': case 'E': - if (mTokenId!=TokenKind::Hex) { + if (mTokenId!=TokenId::Hex) { if (mLine[mRun-1]>='0' || mLine[mRun-1]<='9' ) {//exponent for (int i=idx1;i='0' && mLine[mRun+1]<='9')) { return; } else { - mTokenId = TokenKind::Float; + mTokenId = TokenId::Float; } } else { mRun+=1; - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; return; } } break; case 'f': case 'F': - if (mTokenId!=TokenKind::Hex) { + if (mTokenId!=TokenId::Hex) { for (int i=idx1;i='0' && mLine[mRun+1]<='9') || (mLine[mRun+1]>='a' && mLine[mRun+1]<='f') || (mLine[mRun+1]>='A' && mLine[mRun+1]<='F')) ) { - mTokenId = TokenKind::Hex; + mTokenId = TokenId::Hex; } else { mRun+=1; - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; return; } break; @@ -839,76 +839,76 @@ void SynEditCppHighlighter::numberProc() mRun+=1; } if (mLine[mRun-1] == '\'') { - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; } } -void SynEditCppHighlighter::orSymbolProc() +void CppHighlighter::orSymbolProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; switch ( mLine[mRun+1].unicode()) { case '=': mRun+=2; - mExtTokenId = ExtTokenKind::IncOrAssign; + mExtTokenId = ExtTokenId::IncOrAssign; break; case '|': mRun+=2; - mExtTokenId = ExtTokenKind::LogOr; + mExtTokenId = ExtTokenId::LogOr; break; default: mRun+=1; - mExtTokenId = ExtTokenKind::IncOr; + mExtTokenId = ExtTokenId::IncOr; } } -void SynEditCppHighlighter::plusProc() +void CppHighlighter::plusProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; switch(mLine[mRun+1].unicode()){ case '=': mRun+=2; - mExtTokenId = ExtTokenKind::AddAssign; + mExtTokenId = ExtTokenId::AddAssign; break; case '+': mRun+=2; - mExtTokenId = ExtTokenKind::Increment; + mExtTokenId = ExtTokenId::Increment; break; default: mRun+=1; - mExtTokenId = ExtTokenKind::Add; + mExtTokenId = ExtTokenId::Add; } } -void SynEditCppHighlighter::pointProc() +void CppHighlighter::pointProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; if (mLine[mRun+1] == '*' ) { mRun+=2; - mExtTokenId = ExtTokenKind::PointerToMemberOfObject; + mExtTokenId = ExtTokenId::PointerToMemberOfObject; } else if (mLine[mRun+1] == '.' && mLine[mRun+2] == '.') { mRun+=3; - mExtTokenId = ExtTokenKind::Ellipse; + mExtTokenId = ExtTokenId::Ellipse; } else if (mLine[mRun+1]>='0' && mLine[mRun+1]<='9') { numberProc(); } else { mRun+=1; - mExtTokenId = ExtTokenKind::Point; + mExtTokenId = ExtTokenId::Point; } } -void SynEditCppHighlighter::questionProc() +void CppHighlighter::questionProc() { - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::Question; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::Question; mRun+=1; } -void SynEditCppHighlighter::rawStringProc() +void CppHighlighter::rawStringProc() { bool noEscaping = false; if (mRange.state == RangeState::rsRawStringNotEscaping) noEscaping = true; - mTokenId = TokenKind::RawString; + mTokenId = TokenId::RawString; mRange.state = RangeState::rsRawString; while (mLine[mRun]!=0) { @@ -929,31 +929,31 @@ void SynEditCppHighlighter::rawStringProc() mRange.state = RangeState::rsUnknown; } -void SynEditCppHighlighter::roundCloseProc() +void CppHighlighter::roundCloseProc() { mRun += 1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::RoundClose; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::RoundClose; mRange.parenthesisLevel--; if (mRange.parenthesisLevel<0) mRange.parenthesisLevel=0; popIndents(sitParenthesis); } -void SynEditCppHighlighter::roundOpenProc() +void CppHighlighter::roundOpenProc() { mRun += 1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::RoundOpen; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::RoundOpen; mRange.parenthesisLevel++; pushIndents(sitParenthesis); } -void SynEditCppHighlighter::semiColonProc() +void CppHighlighter::semiColonProc() { mRun += 1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::SemiColon; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::SemiColon; if (mRange.state == RangeState::rsAsm) mRange.state = RangeState::rsUnknown; while (mRange.getLastIndent() == sitStatement) { @@ -961,16 +961,16 @@ void SynEditCppHighlighter::semiColonProc() } } -void SynEditCppHighlighter::slashProc() +void CppHighlighter::slashProc() { switch(mLine[mRun+1].unicode()) { case '/': // Cpp style comment - mTokenId = TokenKind::Comment; + mTokenId = TokenId::Comment; mRun+=2; mRange.state = RangeState::rsCppComment; return; case '*': // C style comment - mTokenId = TokenKind::Comment; + mTokenId = TokenId::Comment; if (mRange.state == RangeState::rsAsm) { mRange.state = RangeState::rsAnsiCAsm; } else if (mRange.state == RangeState::rsAsmBlock) { @@ -986,71 +986,71 @@ void SynEditCppHighlighter::slashProc() break; case '=': mRun+=2; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::DivideAssign; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::DivideAssign; break; default: mRun += 1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::Divide; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::Divide; } } -void SynEditCppHighlighter::backSlashProc() +void CppHighlighter::backSlashProc() { if (mLine[mRun+1]==0) { - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::BackSlash; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::BackSlash; } else { - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; } mRun+=1; } -void SynEditCppHighlighter::spaceProc() +void CppHighlighter::spaceProc() { mRun += 1; - mTokenId = TokenKind::Space; + mTokenId = TokenId::Space; while (mLine[mRun]>=1 && mLine[mRun]<=32) mRun+=1; mRange.state = RangeState::rsUnknown; } -void SynEditCppHighlighter::squareCloseProc() +void CppHighlighter::squareCloseProc() { mRun+=1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::SquareClose; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::SquareClose; mRange.bracketLevel--; if (mRange.bracketLevel<0) mRange.bracketLevel=0; popIndents(sitBracket); } -void SynEditCppHighlighter::squareOpenProc() +void CppHighlighter::squareOpenProc() { mRun+=1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::SquareOpen; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::SquareOpen; mRange.bracketLevel++; pushIndents(sitBracket); } -void SynEditCppHighlighter::starProc() +void CppHighlighter::starProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; if (mLine[mRun+1] == '=') { mRun += 2; - mExtTokenId = ExtTokenKind::MultiplyAssign; + mExtTokenId = ExtTokenId::MultiplyAssign; } else { mRun += 1; - mExtTokenId = ExtTokenKind::Star; + mExtTokenId = ExtTokenId::Star; } } -void SynEditCppHighlighter::stringEndProc() +void CppHighlighter::stringEndProc() { - mTokenId = TokenKind::String; + mTokenId = TokenId::String; if (mLine[mRun]==0) { nullProc(); return; @@ -1100,9 +1100,9 @@ void SynEditCppHighlighter::stringEndProc() } } -void SynEditCppHighlighter::stringEscapeSeqProc() +void CppHighlighter::stringEscapeSeqProc() { - mTokenId = TokenKind::StringEscapeSeq; + mTokenId = TokenId::StringEscapeSeq; mRun+=1; switch(mLine[mRun].unicode()) { case '\'': @@ -1134,7 +1134,7 @@ void SynEditCppHighlighter::stringEscapeSeqProc() break; case '8': case '9': - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; mRun+=1; break; case 'x': @@ -1144,7 +1144,7 @@ void SynEditCppHighlighter::stringEscapeSeqProc() || (mLine[mRun]>='a' && mLine[mRun]<='f') || (mLine[mRun]>='A' && mLine[mRun]<='F') )) { - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; } else { while ( (mLine[mRun]>='0' && mLine[mRun]<='9') @@ -1159,7 +1159,7 @@ void SynEditCppHighlighter::stringEscapeSeqProc() mRun+=1; for (int i=0;i<4;i++) { if (mLine[mRun]<'0' || mLine[mRun]>'7') { - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; return; } mRun+=1; @@ -1169,7 +1169,7 @@ void SynEditCppHighlighter::stringEscapeSeqProc() mRun+=1; for (int i=0;i<8;i++) { if (mLine[mRun]<'0' || mLine[mRun]>'7') { - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; return; } mRun+=1; @@ -1182,13 +1182,13 @@ void SynEditCppHighlighter::stringEscapeSeqProc() mRange.state = RangeState::rsString; } -void SynEditCppHighlighter::stringProc() +void CppHighlighter::stringProc() { if (mLine[mRun] == 0) { mRange.state = RangeState::rsUnknown; return; } - mTokenId = TokenKind::String; + mTokenId = TokenId::String; mRange.state = RangeState::rsString; while (mLine[mRun]!=0) { if (mLine[mRun]=='"') { @@ -1234,9 +1234,9 @@ void SynEditCppHighlighter::stringProc() mRange.state = RangeState::rsUnknown; } -void SynEditCppHighlighter::stringStartProc() +void CppHighlighter::stringStartProc() { - mTokenId = TokenKind::String; + mTokenId = TokenId::String; mRun += 1; if (mLine[mRun]==0) { mRange.state = RangeState::rsUnknown; @@ -1245,32 +1245,32 @@ void SynEditCppHighlighter::stringStartProc() stringProc(); } -void SynEditCppHighlighter::tildeProc() +void CppHighlighter::tildeProc() { mRun+=1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::BitComplement; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::BitComplement; } -void SynEditCppHighlighter::unknownProc() +void CppHighlighter::unknownProc() { mRun+=1; - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; } -void SynEditCppHighlighter::xorSymbolProc() +void CppHighlighter::xorSymbolProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; if (mLine[mRun+1]=='=') { mRun+=2; - mExtTokenId = ExtTokenKind::XorAssign; + mExtTokenId = ExtTokenId::XorAssign; } else { mRun+=1; - mExtTokenId = ExtTokenKind::Xor; + mExtTokenId = ExtTokenId::Xor; } } -void SynEditCppHighlighter::processChar() +void CppHighlighter::processChar() { switch(mLine[mRun].unicode()) { case '&': @@ -1390,7 +1390,7 @@ void SynEditCppHighlighter::processChar() } } -void SynEditCppHighlighter::popIndents(int indentType) +void CppHighlighter::popIndents(int indentType) { while (!mRange.indents.isEmpty() && mRange.indents.back()!=indentType) { mRange.indents.pop_back(); @@ -1404,7 +1404,7 @@ void SynEditCppHighlighter::popIndents(int indentType) } } -void SynEditCppHighlighter::pushIndents(int indentType) +void CppHighlighter::pushIndents(int indentType) { int idx = mRange.indents.length(); if (idx SynEditCppHighlighter::keywords() const +QSet CppHighlighter::keywords() const { return Keywords; } -QString SynEditCppHighlighter::foldString() +QString CppHighlighter::foldString() { return "...}"; } diff --git a/libs/qsynedit/qsynedit/highlighter/cpp.h b/libs/qsynedit/qsynedit/highlighter/cpp.h index 03c51c20..09be1c6f 100644 --- a/libs/qsynedit/qsynedit/highlighter/cpp.h +++ b/libs/qsynedit/qsynedit/highlighter/cpp.h @@ -21,9 +21,9 @@ namespace QSynedit { -class SynEditCppHighlighter: public SynHighlighter +class CppHighlighter: public Highlighter { - enum TokenKind { + enum TokenId { Asm = 1, Comment, Directive, @@ -44,7 +44,7 @@ class SynEditCppHighlighter: public SynHighlighter RawString }; - enum class ExtTokenKind { + enum class ExtTokenId { Add, AddAssign, And, AndAssign, Arrow, Assign, BitComplement, BraceClose, BraceOpen, Colon, Comma, Decrement, Divide, DivideAssign, Ellipse, GreaterThan, @@ -68,40 +68,40 @@ class SynEditCppHighlighter: public SynHighlighter }; public: - explicit SynEditCppHighlighter(); + explicit CppHighlighter(); - PSynHighlighterAttribute asmAttribute() const; + PHighlighterAttribute asmAttribute() const; - PSynHighlighterAttribute preprocessorAttribute() const; + PHighlighterAttribute preprocessorAttribute() const; - PSynHighlighterAttribute invalidAttribute() const; + PHighlighterAttribute invalidAttribute() const; - PSynHighlighterAttribute numberAttribute() const; + PHighlighterAttribute numberAttribute() const; - PSynHighlighterAttribute floatAttribute() const; + PHighlighterAttribute floatAttribute() const; - PSynHighlighterAttribute hexAttribute() const; + PHighlighterAttribute hexAttribute() const; - PSynHighlighterAttribute octAttribute() const; + PHighlighterAttribute octAttribute() const; - PSynHighlighterAttribute stringEscapeSequenceAttribute() const; + PHighlighterAttribute stringEscapeSequenceAttribute() const; - PSynHighlighterAttribute charAttribute() const; + PHighlighterAttribute charAttribute() const; - PSynHighlighterAttribute variableAttribute() const; + PHighlighterAttribute variableAttribute() const; - PSynHighlighterAttribute functionAttribute() const; + PHighlighterAttribute functionAttribute() const; - PSynHighlighterAttribute classAttribute() const; + PHighlighterAttribute classAttribute() const; - PSynHighlighterAttribute globalVarAttribute() const; + PHighlighterAttribute globalVarAttribute() const; - PSynHighlighterAttribute localVarAttribute() const; + PHighlighterAttribute localVarAttribute() const; static const QSet Keywords; - ExtTokenKind getExtTokenId(); - SynTokenKind getTokenId(); + ExtTokenId getExtTokenId(); + TokenKind getTokenId(); private: void andSymbolProc(); void ansiCppProc(); @@ -152,7 +152,7 @@ private: private: bool mAsmStart; - SynRangeState mRange; + HighlighterState mRange; // SynRangeState mSpaceRange; QString mLineString; QChar* mLine; @@ -162,25 +162,25 @@ private: int mToIdent; int mTokenPos; int mTokenId; - ExtTokenKind mExtTokenId; + ExtTokenId mExtTokenId; int mLineNumber; int mLeftBraces; int mRightBraces; - PSynHighlighterAttribute mAsmAttribute; - PSynHighlighterAttribute mPreprocessorAttribute; - PSynHighlighterAttribute mInvalidAttribute; - PSynHighlighterAttribute mNumberAttribute; - PSynHighlighterAttribute mFloatAttribute; - PSynHighlighterAttribute mHexAttribute; - PSynHighlighterAttribute mOctAttribute; - PSynHighlighterAttribute mStringEscapeSequenceAttribute; - PSynHighlighterAttribute mCharAttribute; - PSynHighlighterAttribute mVariableAttribute; - PSynHighlighterAttribute mFunctionAttribute; - PSynHighlighterAttribute mClassAttribute; - PSynHighlighterAttribute mGlobalVarAttribute; - PSynHighlighterAttribute mLocalVarAttribute; + PHighlighterAttribute mAsmAttribute; + PHighlighterAttribute mPreprocessorAttribute; + PHighlighterAttribute mInvalidAttribute; + PHighlighterAttribute mNumberAttribute; + PHighlighterAttribute mFloatAttribute; + PHighlighterAttribute mHexAttribute; + PHighlighterAttribute mOctAttribute; + PHighlighterAttribute mStringEscapeSequenceAttribute; + PHighlighterAttribute mCharAttribute; + PHighlighterAttribute mVariableAttribute; + PHighlighterAttribute mFunctionAttribute; + PHighlighterAttribute mClassAttribute; + PHighlighterAttribute mGlobalVarAttribute; + PHighlighterAttribute mLocalVarAttribute; // SynHighligterBase interface public: @@ -189,24 +189,24 @@ public: bool isLastLineStringNotFinished(int state) const override; bool eol() const override; QString getToken() const override; - PSynHighlighterAttribute getTokenAttribute() const override; - SynTokenKind getTokenKind() override; + PHighlighterAttribute getTokenAttribute() const override; + TokenKind getTokenKind() override; int getTokenPos() override; void next() override; void setLine(const QString &newLine, int lineNumber) override; bool isKeyword(const QString &word) override; - SynHighlighterTokenType getTokenType() override; - void setState(const SynRangeState& rangeState) override; + TokenType getTokenType() override; + void setState(const HighlighterState& rangeState) override; void resetState() override; - SynHighlighterClass getClass() const override; + HighlighterClass getClass() const override; QString getName() const override; QString languageName() override; - SynHighlighterLanguage language() override; + HighlighterLanguage language() override; // SynHighlighter interface public: - SynRangeState getRangeState() const override; + HighlighterState getState() const override; // SynHighlighter interface public: diff --git a/libs/qsynedit/qsynedit/highlighter/glsl.cpp b/libs/qsynedit/qsynedit/highlighter/glsl.cpp index ec171443..6c8130bb 100644 --- a/libs/qsynedit/qsynedit/highlighter/glsl.cpp +++ b/libs/qsynedit/qsynedit/highlighter/glsl.cpp @@ -29,7 +29,7 @@ static const QSet GLSLStatementKeyWords { "while" }; -const QSet SynEditGLSLHighlighter::Keywords { +const QSet GLSLHighlighter::Keywords { "const", "uniform", "buffer", "shared", "attribute", "varying", "coherent", "volatile", "restrict", "readonly", "writeonly", "atomic_uint", @@ -81,159 +81,159 @@ const QSet SynEditGLSLHighlighter::Keywords { "struct" }; -SynEditGLSLHighlighter::SynEditGLSLHighlighter(): SynHighlighter() +GLSLHighlighter::GLSLHighlighter(): Highlighter() { - mAsmAttribute = std::make_shared(SYNS_AttrAssembler); + mAsmAttribute = std::make_shared(SYNS_AttrAssembler); addAttribute(mAsmAttribute); - mCharAttribute = std::make_shared(SYNS_AttrCharacter); + mCharAttribute = std::make_shared(SYNS_AttrCharacter); addAttribute(mCharAttribute); - mCommentAttribute = std::make_shared(SYNS_AttrComment); + mCommentAttribute = std::make_shared(SYNS_AttrComment); addAttribute(mCommentAttribute); - mClassAttribute = std::make_shared(SYNS_AttrClass); + mClassAttribute = std::make_shared(SYNS_AttrClass); addAttribute(mClassAttribute); - mFloatAttribute = std::make_shared(SYNS_AttrFloat); + mFloatAttribute = std::make_shared(SYNS_AttrFloat); addAttribute(mFloatAttribute); - mFunctionAttribute = std::make_shared(SYNS_AttrFunction); + mFunctionAttribute = std::make_shared(SYNS_AttrFunction); addAttribute(mFunctionAttribute); - mGlobalVarAttribute = std::make_shared(SYNS_AttrGlobalVariable); + mGlobalVarAttribute = std::make_shared(SYNS_AttrGlobalVariable); addAttribute(mGlobalVarAttribute); - mHexAttribute = std::make_shared(SYNS_AttrHexadecimal); + mHexAttribute = std::make_shared(SYNS_AttrHexadecimal); addAttribute(mHexAttribute); - mIdentifierAttribute = std::make_shared(SYNS_AttrIdentifier); + mIdentifierAttribute = std::make_shared(SYNS_AttrIdentifier); addAttribute(mIdentifierAttribute); - mInvalidAttribute = std::make_shared(SYNS_AttrIllegalChar); + mInvalidAttribute = std::make_shared(SYNS_AttrIllegalChar); addAttribute(mInvalidAttribute); - mLocalVarAttribute = std::make_shared(SYNS_AttrLocalVariable); + mLocalVarAttribute = std::make_shared(SYNS_AttrLocalVariable); addAttribute(mLocalVarAttribute); - mNumberAttribute = std::make_shared(SYNS_AttrNumber); + mNumberAttribute = std::make_shared(SYNS_AttrNumber); addAttribute(mNumberAttribute); - mOctAttribute = std::make_shared(SYNS_AttrOctal); + mOctAttribute = std::make_shared(SYNS_AttrOctal); addAttribute(mOctAttribute); - mPreprocessorAttribute = std::make_shared(SYNS_AttrPreprocessor); + mPreprocessorAttribute = std::make_shared(SYNS_AttrPreprocessor); addAttribute(mPreprocessorAttribute); - mKeywordAttribute = std::make_shared(SYNS_AttrReservedWord); + mKeywordAttribute = std::make_shared(SYNS_AttrReservedWord); addAttribute(mKeywordAttribute); - mWhitespaceAttribute = std::make_shared(SYNS_AttrSpace); + mWhitespaceAttribute = std::make_shared(SYNS_AttrSpace); addAttribute(mWhitespaceAttribute); - mStringAttribute = std::make_shared(SYNS_AttrString); + mStringAttribute = std::make_shared(SYNS_AttrString); addAttribute(mStringAttribute); - mStringEscapeSequenceAttribute = std::make_shared(SYNS_AttrStringEscapeSequences); + mStringEscapeSequenceAttribute = std::make_shared(SYNS_AttrStringEscapeSequences); addAttribute(mStringEscapeSequenceAttribute); - mSymbolAttribute = std::make_shared(SYNS_AttrSymbol); + mSymbolAttribute = std::make_shared(SYNS_AttrSymbol); addAttribute(mSymbolAttribute); - mVariableAttribute = std::make_shared(SYNS_AttrVariable); + mVariableAttribute = std::make_shared(SYNS_AttrVariable); addAttribute(mVariableAttribute); resetState(); } -PSynHighlighterAttribute SynEditGLSLHighlighter::asmAttribute() const +PHighlighterAttribute GLSLHighlighter::asmAttribute() const { return mAsmAttribute; } -PSynHighlighterAttribute SynEditGLSLHighlighter::preprocessorAttribute() const +PHighlighterAttribute GLSLHighlighter::preprocessorAttribute() const { return mPreprocessorAttribute; } -PSynHighlighterAttribute SynEditGLSLHighlighter::invalidAttribute() const +PHighlighterAttribute GLSLHighlighter::invalidAttribute() const { return mInvalidAttribute; } -PSynHighlighterAttribute SynEditGLSLHighlighter::numberAttribute() const +PHighlighterAttribute GLSLHighlighter::numberAttribute() const { return mNumberAttribute; } -PSynHighlighterAttribute SynEditGLSLHighlighter::floatAttribute() const +PHighlighterAttribute GLSLHighlighter::floatAttribute() const { return mFloatAttribute; } -PSynHighlighterAttribute SynEditGLSLHighlighter::hexAttribute() const +PHighlighterAttribute GLSLHighlighter::hexAttribute() const { return mHexAttribute; } -PSynHighlighterAttribute SynEditGLSLHighlighter::octAttribute() const +PHighlighterAttribute GLSLHighlighter::octAttribute() const { return mOctAttribute; } -PSynHighlighterAttribute SynEditGLSLHighlighter::stringEscapeSequenceAttribute() const +PHighlighterAttribute GLSLHighlighter::stringEscapeSequenceAttribute() const { return mStringEscapeSequenceAttribute; } -PSynHighlighterAttribute SynEditGLSLHighlighter::charAttribute() const +PHighlighterAttribute GLSLHighlighter::charAttribute() const { return mCharAttribute; } -PSynHighlighterAttribute SynEditGLSLHighlighter::variableAttribute() const +PHighlighterAttribute GLSLHighlighter::variableAttribute() const { return mVariableAttribute; } -PSynHighlighterAttribute SynEditGLSLHighlighter::functionAttribute() const +PHighlighterAttribute GLSLHighlighter::functionAttribute() const { return mFunctionAttribute; } -PSynHighlighterAttribute SynEditGLSLHighlighter::classAttribute() const +PHighlighterAttribute GLSLHighlighter::classAttribute() const { return mClassAttribute; } -PSynHighlighterAttribute SynEditGLSLHighlighter::globalVarAttribute() const +PHighlighterAttribute GLSLHighlighter::globalVarAttribute() const { return mGlobalVarAttribute; } -PSynHighlighterAttribute SynEditGLSLHighlighter::localVarAttribute() const +PHighlighterAttribute GLSLHighlighter::localVarAttribute() const { return mLocalVarAttribute; } -SynEditGLSLHighlighter::ExtTokenKind SynEditGLSLHighlighter::getExtTokenId() +GLSLHighlighter::ExtTokenId GLSLHighlighter::getExtTokenId() { return mExtTokenId; } -SynTokenKind SynEditGLSLHighlighter::getTokenId() +TokenKind GLSLHighlighter::getTokenId() { if ((mRange.state == RangeState::rsAsm || mRange.state == RangeState::rsAsmBlock) - && !mAsmStart && !(mTokenId == TokenKind::Comment || mTokenId == TokenKind::Space - || mTokenId == TokenKind::Null)) { - return TokenKind::Asm; + && !mAsmStart && !(mTokenId == TokenId::Comment || mTokenId == TokenId::Space + || mTokenId == TokenId::Null)) { + return TokenId::Asm; } else { return mTokenId; } } -void SynEditGLSLHighlighter::andSymbolProc() +void GLSLHighlighter::andSymbolProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; switch (mLine[mRun+1].unicode()) { case '=': mRun+=2; - mExtTokenId = ExtTokenKind::AndAssign; + mExtTokenId = ExtTokenId::AndAssign; break; case '&': mRun+=2; - mExtTokenId = ExtTokenKind::LogAnd; + mExtTokenId = ExtTokenId::LogAnd; break; default: mRun+=1; - mExtTokenId = ExtTokenKind::And; + mExtTokenId = ExtTokenId::And; } } -void SynEditGLSLHighlighter::ansiCppProc() +void GLSLHighlighter::ansiCppProc() { - mTokenId = TokenKind::Comment; + mTokenId = TokenId::Comment; if (mLine[mRun]==0) { nullProc(); if ( (mRun<1) || (mLine[mRun-1]!='\\')) { @@ -250,10 +250,10 @@ void SynEditGLSLHighlighter::ansiCppProc() } } -void SynEditGLSLHighlighter::ansiCProc() +void GLSLHighlighter::ansiCProc() { bool finishProcess = false; - mTokenId = TokenKind::Comment; + mTokenId = TokenId::Comment; if (mLine[mRun].unicode() == 0) { nullProc(); return; @@ -285,9 +285,9 @@ void SynEditGLSLHighlighter::ansiCProc() } } -void SynEditGLSLHighlighter::asciiCharProc() +void GLSLHighlighter::asciiCharProc() { - mTokenId = TokenKind::Char; + mTokenId = TokenId::Char; do { if (mLine[mRun] == '\\') { if (mLine[mRun+1] == '\'' || mLine[mRun+1] == '\\') { @@ -301,17 +301,17 @@ void SynEditGLSLHighlighter::asciiCharProc() mRange.state = RangeState::rsUnknown; } -void SynEditGLSLHighlighter::atSymbolProc() +void GLSLHighlighter::atSymbolProc() { - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; mRun+=1; } -void SynEditGLSLHighlighter::braceCloseProc() +void GLSLHighlighter::braceCloseProc() { mRun += 1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::BraceClose; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::BraceClose; if (mRange.state == RangeState::rsAsmBlock) { mRange.state = rsUnknown; } @@ -327,11 +327,11 @@ void SynEditGLSLHighlighter::braceCloseProc() popIndents(sitBrace); } -void SynEditGLSLHighlighter::braceOpenProc() +void GLSLHighlighter::braceOpenProc() { mRun += 1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::BraceOpen; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::BraceOpen; if (mRange.state == RangeState::rsAsm) { mRange.state = RangeState::rsAsmBlock; mAsmStart = true; @@ -354,34 +354,34 @@ void SynEditGLSLHighlighter::braceOpenProc() } } -void SynEditGLSLHighlighter::colonProc() +void GLSLHighlighter::colonProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; if (mLine[mRun+1]==':') { mRun+=2; - mExtTokenId = ExtTokenKind::ScopeResolution; + mExtTokenId = ExtTokenId::ScopeResolution; } else { mRun+=1; - mExtTokenId = ExtTokenKind::Colon; + mExtTokenId = ExtTokenId::Colon; } } -void SynEditGLSLHighlighter::commaProc() +void GLSLHighlighter::commaProc() { mRun+=1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::Comma; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::Comma; } -void SynEditGLSLHighlighter::directiveProc() +void GLSLHighlighter::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 - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; mRun+=1; return; } - mTokenId = TokenKind::Directive; + mTokenId = TokenId::Directive; mRun+=1; //skip spaces while (mLine[mRun]!=0 && isSpaceChar(mLine[mRun])) { @@ -416,9 +416,9 @@ void SynEditGLSLHighlighter::directiveProc() // } while (mLine[mRun]!=0); } -void SynEditGLSLHighlighter::directiveEndProc() +void GLSLHighlighter::directiveEndProc() { - mTokenId = TokenKind::Directive; + mTokenId = TokenId::Directive; if (mLine[mRun] == 0) { nullProc(); return; @@ -448,42 +448,42 @@ void SynEditGLSLHighlighter::directiveEndProc() } while (mLine[mRun]!=0); } -void SynEditGLSLHighlighter::equalProc() +void GLSLHighlighter::equalProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; if (mLine[mRun+1] == '=') { mRun += 2; - mExtTokenId = ExtTokenKind::LogEqual; + mExtTokenId = ExtTokenId::LogEqual; } else { mRun += 1; - mExtTokenId = ExtTokenKind::Assign; + mExtTokenId = ExtTokenId::Assign; } } -void SynEditGLSLHighlighter::greaterProc() +void GLSLHighlighter::greaterProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; switch (mLine[mRun + 1].unicode()) { case '=': mRun += 2; - mExtTokenId = ExtTokenKind::GreaterThanEqual; + mExtTokenId = ExtTokenId::GreaterThanEqual; break; case '>': if (mLine[mRun+2] == '=') { mRun+=3; - mExtTokenId = ExtTokenKind::ShiftRightAssign; + mExtTokenId = ExtTokenId::ShiftRightAssign; } else { mRun += 2; - mExtTokenId = ExtTokenKind::ShiftRight; + mExtTokenId = ExtTokenId::ShiftRight; } break; default: mRun+=1; - mExtTokenId = ExtTokenKind::GreaterThan; + mExtTokenId = ExtTokenId::GreaterThan; } } -void SynEditGLSLHighlighter::identProc() +void GLSLHighlighter::identProc() { int wordEnd = mRun; while (isIdentChar(mLine[wordEnd])) { @@ -492,94 +492,94 @@ void SynEditGLSLHighlighter::identProc() QString word = mLineString.mid(mRun,wordEnd-mRun); mRun=wordEnd; if (isKeyword(word)) { - mTokenId = TokenKind::Key; + mTokenId = TokenId::Key; if (GLSLStatementKeyWords.contains(word)) { pushIndents(sitStatement); } } else { - mTokenId = TokenKind::Identifier; + mTokenId = TokenId::Identifier; } } -void SynEditGLSLHighlighter::lowerProc() +void GLSLHighlighter::lowerProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; switch(mLine[mRun+1].unicode()) { case '=': mRun+=2; - mExtTokenId = ExtTokenKind::LessThanEqual; + mExtTokenId = ExtTokenId::LessThanEqual; break; case '<': if (mLine[mRun+2] == '=') { mRun+=3; - mExtTokenId = ExtTokenKind::ShiftLeftAssign; + mExtTokenId = ExtTokenId::ShiftLeftAssign; } else { mRun+=2; - mExtTokenId = ExtTokenKind::ShiftLeft; + mExtTokenId = ExtTokenId::ShiftLeft; } break; default: mRun+=1; - mExtTokenId = ExtTokenKind::LessThan; + mExtTokenId = ExtTokenId::LessThan; } } -void SynEditGLSLHighlighter::minusProc() +void GLSLHighlighter::minusProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; switch(mLine[mRun+1].unicode()) { case '=': mRun += 2; - mExtTokenId = ExtTokenKind::SubtractAssign; + mExtTokenId = ExtTokenId::SubtractAssign; break; case '-': mRun += 2; - mExtTokenId = ExtTokenKind::Decrement; + mExtTokenId = ExtTokenId::Decrement; break; case '>': if (mLine[mRun+2]=='*') { mRun += 3; - mExtTokenId = ExtTokenKind::PointerToMemberOfPointer; + mExtTokenId = ExtTokenId::PointerToMemberOfPointer; } else { mRun += 2; - mExtTokenId = ExtTokenKind::Arrow; + mExtTokenId = ExtTokenId::Arrow; } break; default: mRun += 1; - mExtTokenId = ExtTokenKind::Subtract; + mExtTokenId = ExtTokenId::Subtract; } } -void SynEditGLSLHighlighter::modSymbolProc() +void GLSLHighlighter::modSymbolProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; switch(mLine[mRun + 1].unicode()) { case '=': mRun += 2; - mExtTokenId = ExtTokenKind::ModAssign; + mExtTokenId = ExtTokenId::ModAssign; break; default: mRun += 1; - mExtTokenId = ExtTokenKind::Mod; + mExtTokenId = ExtTokenId::Mod; } } -void SynEditGLSLHighlighter::notSymbolProc() +void GLSLHighlighter::notSymbolProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; switch(mLine[mRun + 1].unicode()) { case '=': mRun+=2; - mExtTokenId = ExtTokenKind::NotEqual; + mExtTokenId = ExtTokenId::NotEqual; break; default: mRun+=1; - mExtTokenId = ExtTokenKind::LogComplement; + mExtTokenId = ExtTokenId::LogComplement; } } -void SynEditGLSLHighlighter::nullProc() +void GLSLHighlighter::nullProc() { if ((mRun-1>=0) && isSpaceChar(mLine[mRun-1]) && (mRange.state == RangeState::rsCppComment @@ -589,45 +589,45 @@ void SynEditGLSLHighlighter::nullProc() || mRange.state == RangeState::rsMultiLineDirective) ) { mRange.state = RangeState::rsUnknown; } else - mTokenId = TokenKind::Null; + mTokenId = TokenId::Null; } -void SynEditGLSLHighlighter::numberProc() +void GLSLHighlighter::numberProc() { int idx1; // token[1] idx1 = mRun; mRun+=1; - mTokenId = TokenKind::Number; + mTokenId = TokenId::Number; bool shouldExit = false; while (mLine[mRun]!=0) { switch(mLine[mRun].unicode()) { case '\'': - if (mTokenId != TokenKind::Number) { - mTokenId = TokenKind::Symbol; + if (mTokenId != TokenId::Number) { + mTokenId = TokenId::Symbol; return; } break; case '.': if (mLine[mRun+1] == '.') { mRun+=2; - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; return; - } else if (mTokenId != TokenKind::Hex) { - mTokenId = TokenKind::Float; + } else if (mTokenId != TokenId::Hex) { + mTokenId = TokenId::Float; } else { - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; return; } break; case '-': case '+': - if (mTokenId != TokenKind::Float) // number <> float. an arithmetic operator + if (mTokenId != TokenId::Float) // number <> float. an arithmetic operator return; if (mLine[mRun-1]!= 'e' && mLine[mRun-1]!='E') // number = float, but no exponent. an arithmetic operator return; if (mLine[mRun+1]<'0' || mLine[mRun+1]>'9') {// invalid mRun+=1; - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; return; } break; @@ -640,13 +640,13 @@ void SynEditGLSLHighlighter::numberProc() case '6': case '7': if ((mRun == idx1+1) && (mLine[idx1] == '0')) { // octal number - mTokenId = TokenKind::Octal; + mTokenId = TokenId::Octal; } break; case '8': case '9': - if ( (mLine[idx1]=='0') && (mTokenId != TokenKind::Hex) && (mTokenId != TokenKind::Float) ) // invalid octal char - mTokenId = TokenKind::Unknown; // we must continue parse, it may be an float number + if ( (mLine[idx1]=='0') && (mTokenId != TokenId::Hex) && (mTokenId != TokenId::Float) ) // invalid octal char + mTokenId = TokenId::Unknown; // we must continue parse, it may be an float number break; case 'a': case 'b': @@ -656,52 +656,52 @@ void SynEditGLSLHighlighter::numberProc() case 'B': case 'C': case 'D': - if (mTokenId!=TokenKind::Hex) { //invalid - mTokenId = TokenKind::Unknown; + if (mTokenId!=TokenId::Hex) { //invalid + mTokenId = TokenId::Unknown; return; } break; case 'e': case 'E': - if (mTokenId!=TokenKind::Hex) { + if (mTokenId!=TokenId::Hex) { if (mLine[mRun-1]>='0' || mLine[mRun-1]<='9' ) {//exponent for (int i=idx1;i='0' && mLine[mRun+1]<='9')) { return; } else { - mTokenId = TokenKind::Float; + mTokenId = TokenId::Float; } } else { mRun+=1; - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; return; } } break; case 'f': case 'F': - if (mTokenId!=TokenKind::Hex) { + if (mTokenId!=TokenId::Hex) { for (int i=idx1;i='0' && mLine[mRun+1]<='9') || (mLine[mRun+1]>='a' && mLine[mRun+1]<='f') || (mLine[mRun+1]>='A' && mLine[mRun+1]<='F')) ) { - mTokenId = TokenKind::Hex; + mTokenId = TokenId::Hex; } else { mRun+=1; - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; return; } break; @@ -758,76 +758,76 @@ void SynEditGLSLHighlighter::numberProc() mRun+=1; } if (mLine[mRun-1] == '\'') { - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; } } -void SynEditGLSLHighlighter::orSymbolProc() +void GLSLHighlighter::orSymbolProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; switch ( mLine[mRun+1].unicode()) { case '=': mRun+=2; - mExtTokenId = ExtTokenKind::IncOrAssign; + mExtTokenId = ExtTokenId::IncOrAssign; break; case '|': mRun+=2; - mExtTokenId = ExtTokenKind::LogOr; + mExtTokenId = ExtTokenId::LogOr; break; default: mRun+=1; - mExtTokenId = ExtTokenKind::IncOr; + mExtTokenId = ExtTokenId::IncOr; } } -void SynEditGLSLHighlighter::plusProc() +void GLSLHighlighter::plusProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; switch(mLine[mRun+1].unicode()){ case '=': mRun+=2; - mExtTokenId = ExtTokenKind::AddAssign; + mExtTokenId = ExtTokenId::AddAssign; break; case '+': mRun+=2; - mExtTokenId = ExtTokenKind::Increment; + mExtTokenId = ExtTokenId::Increment; break; default: mRun+=1; - mExtTokenId = ExtTokenKind::Add; + mExtTokenId = ExtTokenId::Add; } } -void SynEditGLSLHighlighter::pointProc() +void GLSLHighlighter::pointProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; if (mLine[mRun+1] == '*' ) { mRun+=2; - mExtTokenId = ExtTokenKind::PointerToMemberOfObject; + mExtTokenId = ExtTokenId::PointerToMemberOfObject; } else if (mLine[mRun+1] == '.' && mLine[mRun+2] == '.') { mRun+=3; - mExtTokenId = ExtTokenKind::Ellipse; + mExtTokenId = ExtTokenId::Ellipse; } else if (mLine[mRun+1]>='0' && mLine[mRun+1]<='9') { numberProc(); } else { mRun+=1; - mExtTokenId = ExtTokenKind::Point; + mExtTokenId = ExtTokenId::Point; } } -void SynEditGLSLHighlighter::questionProc() +void GLSLHighlighter::questionProc() { - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::Question; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::Question; mRun+=1; } -void SynEditGLSLHighlighter::rawStringProc() +void GLSLHighlighter::rawStringProc() { bool noEscaping = false; if (mRange.state == RangeState::rsRawStringNotEscaping) noEscaping = true; - mTokenId = TokenKind::RawString; + mTokenId = TokenId::RawString; mRange.state = RangeState::rsRawString; while (mLine[mRun]!=0) { @@ -848,31 +848,31 @@ void SynEditGLSLHighlighter::rawStringProc() mRange.state = RangeState::rsUnknown; } -void SynEditGLSLHighlighter::roundCloseProc() +void GLSLHighlighter::roundCloseProc() { mRun += 1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::RoundClose; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::RoundClose; mRange.parenthesisLevel--; if (mRange.parenthesisLevel<0) mRange.parenthesisLevel=0; popIndents(sitParenthesis); } -void SynEditGLSLHighlighter::roundOpenProc() +void GLSLHighlighter::roundOpenProc() { mRun += 1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::RoundOpen; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::RoundOpen; mRange.parenthesisLevel++; pushIndents(sitParenthesis); } -void SynEditGLSLHighlighter::semiColonProc() +void GLSLHighlighter::semiColonProc() { mRun += 1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::SemiColon; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::SemiColon; if (mRange.state == RangeState::rsAsm) mRange.state = RangeState::rsUnknown; while (mRange.getLastIndent() == sitStatement) { @@ -880,16 +880,16 @@ void SynEditGLSLHighlighter::semiColonProc() } } -void SynEditGLSLHighlighter::slashProc() +void GLSLHighlighter::slashProc() { switch(mLine[mRun+1].unicode()) { case '/': // Cpp style comment - mTokenId = TokenKind::Comment; + mTokenId = TokenId::Comment; mRun+=2; mRange.state = RangeState::rsCppComment; return; case '*': // C style comment - mTokenId = TokenKind::Comment; + mTokenId = TokenId::Comment; if (mRange.state == RangeState::rsAsm) { mRange.state = RangeState::rsAnsiCAsm; } else if (mRange.state == RangeState::rsAsmBlock) { @@ -905,60 +905,60 @@ void SynEditGLSLHighlighter::slashProc() break; case '=': mRun+=2; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::DivideAssign; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::DivideAssign; break; default: mRun += 1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::Divide; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::Divide; } } -void SynEditGLSLHighlighter::spaceProc() +void GLSLHighlighter::spaceProc() { mRun += 1; - mTokenId = TokenKind::Space; + mTokenId = TokenId::Space; while (mLine[mRun]>=1 && mLine[mRun]<=32) mRun+=1; mRange.state = RangeState::rsUnknown; } -void SynEditGLSLHighlighter::squareCloseProc() +void GLSLHighlighter::squareCloseProc() { mRun+=1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::SquareClose; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::SquareClose; mRange.bracketLevel--; if (mRange.bracketLevel<0) mRange.bracketLevel=0; popIndents(sitBracket); } -void SynEditGLSLHighlighter::squareOpenProc() +void GLSLHighlighter::squareOpenProc() { mRun+=1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::SquareOpen; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::SquareOpen; mRange.bracketLevel++; pushIndents(sitBracket); } -void SynEditGLSLHighlighter::starProc() +void GLSLHighlighter::starProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; if (mLine[mRun+1] == '=') { mRun += 2; - mExtTokenId = ExtTokenKind::MultiplyAssign; + mExtTokenId = ExtTokenId::MultiplyAssign; } else { mRun += 1; - mExtTokenId = ExtTokenKind::Star; + mExtTokenId = ExtTokenId::Star; } } -void SynEditGLSLHighlighter::stringEndProc() +void GLSLHighlighter::stringEndProc() { - mTokenId = TokenKind::String; + mTokenId = TokenId::String; if (mLine[mRun]==0) { nullProc(); return; @@ -1008,9 +1008,9 @@ void SynEditGLSLHighlighter::stringEndProc() } } -void SynEditGLSLHighlighter::stringEscapeSeqProc() +void GLSLHighlighter::stringEscapeSeqProc() { - mTokenId = TokenKind::StringEscapeSeq; + mTokenId = TokenId::StringEscapeSeq; mRun+=1; switch(mLine[mRun].unicode()) { case '\'': @@ -1042,7 +1042,7 @@ void SynEditGLSLHighlighter::stringEscapeSeqProc() break; case '8': case '9': - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; mRun+=1; break; case 'x': @@ -1052,7 +1052,7 @@ void SynEditGLSLHighlighter::stringEscapeSeqProc() || (mLine[mRun]>='a' && mLine[mRun]<='f') || (mLine[mRun]>='A' && mLine[mRun]<='F') )) { - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; } else { while ( (mLine[mRun]>='0' && mLine[mRun]<='9') @@ -1067,7 +1067,7 @@ void SynEditGLSLHighlighter::stringEscapeSeqProc() mRun+=1; for (int i=0;i<4;i++) { if (mLine[mRun]<'0' || mLine[mRun]>'7') { - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; return; } mRun+=1; @@ -1077,7 +1077,7 @@ void SynEditGLSLHighlighter::stringEscapeSeqProc() mRun+=1; for (int i=0;i<8;i++) { if (mLine[mRun]<'0' || mLine[mRun]>'7') { - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; return; } mRun+=1; @@ -1090,13 +1090,13 @@ void SynEditGLSLHighlighter::stringEscapeSeqProc() mRange.state = RangeState::rsString; } -void SynEditGLSLHighlighter::stringProc() +void GLSLHighlighter::stringProc() { if (mLine[mRun] == 0) { mRange.state = RangeState::rsUnknown; return; } - mTokenId = TokenKind::String; + mTokenId = TokenId::String; mRange.state = RangeState::rsString; while (mLine[mRun]!=0) { if (mLine[mRun]=='"') { @@ -1142,9 +1142,9 @@ void SynEditGLSLHighlighter::stringProc() mRange.state = RangeState::rsUnknown; } -void SynEditGLSLHighlighter::stringStartProc() +void GLSLHighlighter::stringStartProc() { - mTokenId = TokenKind::String; + mTokenId = TokenId::String; mRun += 1; if (mLine[mRun]==0) { mRange.state = RangeState::rsUnknown; @@ -1153,32 +1153,32 @@ void SynEditGLSLHighlighter::stringStartProc() stringProc(); } -void SynEditGLSLHighlighter::tildeProc() +void GLSLHighlighter::tildeProc() { mRun+=1; - mTokenId = TokenKind::Symbol; - mExtTokenId = ExtTokenKind::BitComplement; + mTokenId = TokenId::Symbol; + mExtTokenId = ExtTokenId::BitComplement; } -void SynEditGLSLHighlighter::unknownProc() +void GLSLHighlighter::unknownProc() { mRun+=1; - mTokenId = TokenKind::Unknown; + mTokenId = TokenId::Unknown; } -void SynEditGLSLHighlighter::xorSymbolProc() +void GLSLHighlighter::xorSymbolProc() { - mTokenId = TokenKind::Symbol; + mTokenId = TokenId::Symbol; if (mLine[mRun+1]=='=') { mRun+=2; - mExtTokenId = ExtTokenKind::XorAssign; + mExtTokenId = ExtTokenId::XorAssign; } else { mRun+=1; - mExtTokenId = ExtTokenKind::Xor; + mExtTokenId = ExtTokenId::Xor; } } -void SynEditGLSLHighlighter::processChar() +void GLSLHighlighter::processChar() { switch(mLine[mRun].unicode()) { case '&': @@ -1295,7 +1295,7 @@ void SynEditGLSLHighlighter::processChar() } } -void SynEditGLSLHighlighter::popIndents(int indentType) +void GLSLHighlighter::popIndents(int indentType) { while (!mRange.indents.isEmpty() && mRange.indents.back()!=indentType) { mRange.indents.pop_back(); @@ -1309,7 +1309,7 @@ void SynEditGLSLHighlighter::popIndents(int indentType) } } -void SynEditGLSLHighlighter::pushIndents(int indentType) +void GLSLHighlighter::pushIndents(int indentType) { int idx = mRange.indents.length(); if (idx='a' && ch<='z') || (ch>='A' && ch<='Z') || (ch>='0' && ch<='9'); } -QSet SynEditGLSLHighlighter::keywords() const +QSet GLSLHighlighter::keywords() const { return Keywords; } diff --git a/libs/qsynedit/qsynedit/highlighter/glsl.h b/libs/qsynedit/qsynedit/highlighter/glsl.h index 7394efee..fd03ddfa 100644 --- a/libs/qsynedit/qsynedit/highlighter/glsl.h +++ b/libs/qsynedit/qsynedit/highlighter/glsl.h @@ -21,9 +21,9 @@ namespace QSynedit { -class SynEditGLSLHighlighter: public SynHighlighter +class GLSLHighlighter: public Highlighter { - enum TokenKind { + enum TokenId { Asm = 1, Comment, Directive, @@ -44,7 +44,7 @@ class SynEditGLSLHighlighter: public SynHighlighter RawString }; - enum class ExtTokenKind { + enum class ExtTokenId { Add, AddAssign, And, AndAssign, Arrow, Assign, BitComplement, BraceClose, BraceOpen, Colon, Comma, Decrement, Divide, DivideAssign, Ellipse, GreaterThan, @@ -68,40 +68,40 @@ class SynEditGLSLHighlighter: public SynHighlighter }; public: - explicit SynEditGLSLHighlighter(); + explicit GLSLHighlighter(); - PSynHighlighterAttribute asmAttribute() const; + PHighlighterAttribute asmAttribute() const; - PSynHighlighterAttribute preprocessorAttribute() const; + PHighlighterAttribute preprocessorAttribute() const; - PSynHighlighterAttribute invalidAttribute() const; + PHighlighterAttribute invalidAttribute() const; - PSynHighlighterAttribute numberAttribute() const; + PHighlighterAttribute numberAttribute() const; - PSynHighlighterAttribute floatAttribute() const; + PHighlighterAttribute floatAttribute() const; - PSynHighlighterAttribute hexAttribute() const; + PHighlighterAttribute hexAttribute() const; - PSynHighlighterAttribute octAttribute() const; + PHighlighterAttribute octAttribute() const; - PSynHighlighterAttribute stringEscapeSequenceAttribute() const; + PHighlighterAttribute stringEscapeSequenceAttribute() const; - PSynHighlighterAttribute charAttribute() const; + PHighlighterAttribute charAttribute() const; - PSynHighlighterAttribute variableAttribute() const; + PHighlighterAttribute variableAttribute() const; - PSynHighlighterAttribute functionAttribute() const; + PHighlighterAttribute functionAttribute() const; - PSynHighlighterAttribute classAttribute() const; + PHighlighterAttribute classAttribute() const; - PSynHighlighterAttribute globalVarAttribute() const; + PHighlighterAttribute globalVarAttribute() const; - PSynHighlighterAttribute localVarAttribute() const; + PHighlighterAttribute localVarAttribute() const; static const QSet Keywords; - ExtTokenKind getExtTokenId(); - SynTokenKind getTokenId(); + ExtTokenId getExtTokenId(); + TokenKind getTokenId(); private: void andSymbolProc(); void ansiCppProc(); @@ -149,7 +149,7 @@ private: private: bool mAsmStart; - SynRangeState mRange; + HighlighterState mRange; // SynRangeState mSpaceRange; QString mLineString; QChar* mLine; @@ -159,25 +159,25 @@ private: int mToIdent; int mTokenPos; int mTokenId; - ExtTokenKind mExtTokenId; + ExtTokenId mExtTokenId; int mLineNumber; int mLeftBraces; int mRightBraces; - PSynHighlighterAttribute mAsmAttribute; - PSynHighlighterAttribute mPreprocessorAttribute; - PSynHighlighterAttribute mInvalidAttribute; - PSynHighlighterAttribute mNumberAttribute; - PSynHighlighterAttribute mFloatAttribute; - PSynHighlighterAttribute mHexAttribute; - PSynHighlighterAttribute mOctAttribute; - PSynHighlighterAttribute mStringEscapeSequenceAttribute; - PSynHighlighterAttribute mCharAttribute; - PSynHighlighterAttribute mVariableAttribute; - PSynHighlighterAttribute mFunctionAttribute; - PSynHighlighterAttribute mClassAttribute; - PSynHighlighterAttribute mGlobalVarAttribute; - PSynHighlighterAttribute mLocalVarAttribute; + PHighlighterAttribute mAsmAttribute; + PHighlighterAttribute mPreprocessorAttribute; + PHighlighterAttribute mInvalidAttribute; + PHighlighterAttribute mNumberAttribute; + PHighlighterAttribute mFloatAttribute; + PHighlighterAttribute mHexAttribute; + PHighlighterAttribute mOctAttribute; + PHighlighterAttribute mStringEscapeSequenceAttribute; + PHighlighterAttribute mCharAttribute; + PHighlighterAttribute mVariableAttribute; + PHighlighterAttribute mFunctionAttribute; + PHighlighterAttribute mClassAttribute; + PHighlighterAttribute mGlobalVarAttribute; + PHighlighterAttribute mLocalVarAttribute; // SynHighligterBase interface public: @@ -186,24 +186,24 @@ public: bool isLastLineStringNotFinished(int state) const override; bool eol() const override; QString getToken() const override; - PSynHighlighterAttribute getTokenAttribute() const override; - SynTokenKind getTokenKind() override; + PHighlighterAttribute getTokenAttribute() const override; + TokenKind getTokenKind() override; int getTokenPos() override; void next() override; void setLine(const QString &newLine, int lineNumber) override; bool isKeyword(const QString &word) override; - SynHighlighterTokenType getTokenType() override; - void setState(const SynRangeState& rangeState) override; + TokenType getTokenType() override; + void setState(const HighlighterState& rangeState) override; void resetState() override; - SynHighlighterClass getClass() const override; + HighlighterClass getClass() const override; QString getName() const override; QString languageName() override; - SynHighlighterLanguage language() override; + HighlighterLanguage language() override; // SynHighlighter interface public: - SynRangeState getRangeState() const override; + HighlighterState getState() const override; // SynHighlighter interface public: