From 16db14e761ec6bc6b42c3ea49cb3a9104e26b82e Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Fri, 16 Dec 2022 01:03:57 +0800 Subject: [PATCH] - enhancement: "Remove trailing spaces" in options / editor / misc - enhancement: show special chars --- NEWS.md | 1 + RedPandaIDE/RedPandaIDE.pro | 2 +- RedPandaIDE/editor.cpp | 127 +-- RedPandaIDE/mainwindow.cpp | 1 - RedPandaIDE/settings.cpp | 12 + RedPandaIDE/settings.h | 4 + .../settingsdialog/editormiscwidget.cpp | 11 +- .../settingsdialog/editormiscwidget.ui | 152 +-- RedPandaIDE/translations/RedPandaIDE_pt_BR.ts | 38 +- RedPandaIDE/translations/RedPandaIDE_zh_CN.ts | 939 +++++++++--------- RedPandaIDE/translations/RedPandaIDE_zh_TW.ts | 40 +- Red_Panda_CPP.pro | 2 +- libs/qsynedit/qsynedit/Constants.cpp | 2 +- libs/qsynedit/qsynedit/KeyStrokes.cpp | 146 ++- libs/qsynedit/qsynedit/KeyStrokes.h | 217 ++-- libs/qsynedit/qsynedit/SynEdit.cpp | 323 +++--- libs/qsynedit/qsynedit/SynEdit.h | 87 +- libs/qsynedit/qsynedit/TextPainter.cpp | 23 +- libs/qsynedit/qsynedit/syntaxer/asm.cpp | 10 +- libs/qsynedit/qsynedit/syntaxer/asm.h | 1 + libs/qsynedit/qsynedit/syntaxer/cpp.cpp | 214 ++-- libs/qsynedit/qsynedit/syntaxer/cpp.h | 8 +- libs/qsynedit/qsynedit/syntaxer/glsl.cpp | 40 +- libs/qsynedit/qsynedit/syntaxer/glsl.h | 4 +- libs/qsynedit/qsynedit/syntaxer/makefile.cpp | 5 + libs/qsynedit/qsynedit/syntaxer/makefile.h | 1 + libs/qsynedit/qsynedit/syntaxer/syntaxer.cpp | 3 +- libs/qsynedit/qsynedit/syntaxer/syntaxer.h | 1 + 28 files changed, 1272 insertions(+), 1142 deletions(-) diff --git a/NEWS.md b/NEWS.md index c80e4724..5e764f80 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,7 @@ Red Panda C++ Version 2.7 - enhancement: Remove multiple problems in the problem set view - enhancement: Clear the proble view after a new problem set created + - enhancement: "Remove trailing spaces" in options / editor / misc Red Panda C++ Version 2.6 diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 8c438c7f..479eae73 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -10,7 +10,7 @@ isEmpty(APP_NAME) { } isEmpty(APP_VERSION) { - APP_VERSION = 2.6 + APP_VERSION = 2.7 } macos: { diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 3b239b36..d40bf93a 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -265,6 +265,8 @@ bool Editor::save(bool force, bool doReparse) { try { if (pSettings->editor().autoFormatWhenSaved()) { reformat(false); + } else if (pSettings->editor().removeTrailingSpacesWhenSaved()) { + trimTrailingSpaces(); } saveFile(mFilename); pMainWindow->fileSystemWatcher()->addPath(mFilename); @@ -356,6 +358,8 @@ bool Editor::saveAs(const QString &name, bool fromProject){ if (pSettings->editor().autoFormatWhenSaved()) { reformat(false); + } else if (pSettings->editor().removeTrailingSpacesWhenSaved()) { + trimTrailingSpaces(); } try { mFilename = newName; @@ -521,7 +525,7 @@ void Editor::undoSymbolCompletion(int pos) (pSettings->editor().completeBrace() && (DeletedChar == '{') && (NextChar == '}')) || (pSettings->editor().completeSingleQuote() && (DeletedChar == '\'') && (NextChar == '\'')) || (pSettings->editor().completeDoubleQuote() && (DeletedChar == '\"') && (NextChar == '\"'))) { - commandProcessor(QSynedit::EditCommand::ecDeleteChar); + processCommand(QSynedit::EditCommand::DeleteChar); } } @@ -723,7 +727,7 @@ void Editor::keyPressEvent(QKeyEvent *event) if (mParser && mParser->isIncludeLine(lineText()) && mLastIdCharPressed==pSettings->codeCompletion().minCharRequired()) { // is a #include line - commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr); + processCommand(QSynedit::EditCommand::Char,ch,nullptr); showHeaderCompletion(false); handled=true; return; @@ -731,12 +735,12 @@ void Editor::keyPressEvent(QKeyEvent *event) QString lastWord = getPreviousWordAtPositionForSuggestion(caretXY()); if (mParser && !lastWord.isEmpty()) { if (lastWord == "using") { - commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr); + processCommand(QSynedit::EditCommand::Char,ch,nullptr); showCompletion(lastWord,false, CodeCompletionType::ComplexKeyword); handled=true; return; } else if (lastWord == "namespace") { - commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr); + processCommand(QSynedit::EditCommand::Char,ch,nullptr); showCompletion(lastWord,false, CodeCompletionType::Namespaces); handled=true; return; @@ -747,7 +751,7 @@ void Editor::keyPressEvent(QKeyEvent *event) } if (!currentScope || currentScope->kind == StatementKind::skNamespace) { //may define a function - commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr); + processCommand(QSynedit::EditCommand::Char,ch,nullptr); showCompletion(lastWord,false,CodeCompletionType::FunctionWithoutDefinition); handled=true; return; @@ -757,7 +761,7 @@ void Editor::keyPressEvent(QKeyEvent *event) lastWord == "signed" || lastWord == "unsigned" ) { - commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr); + processCommand(QSynedit::EditCommand::Char,ch,nullptr); showCompletion(lastWord,false, CodeCompletionType::ComplexKeyword); handled=true; return; @@ -783,7 +787,7 @@ void Editor::keyPressEvent(QKeyEvent *event) } if (!currentScope || currentScope->kind == StatementKind::skNamespace) { //may define a function - commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr); + processCommand(QSynedit::EditCommand::Char,ch,nullptr); showCompletion("",false,CodeCompletionType::FunctionWithoutDefinition); handled=true; return; @@ -801,13 +805,13 @@ void Editor::keyPressEvent(QKeyEvent *event) } if (!currentScope || currentScope->kind == StatementKind::skNamespace) { //may define a function - commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr); + processCommand(QSynedit::EditCommand::Char,ch,nullptr); showCompletion("",false,CodeCompletionType::FunctionWithoutDefinition); handled=true; return; } } - commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr); + processCommand(QSynedit::EditCommand::Char,ch,nullptr); showCompletion("",false,CodeCompletionType::Normal); handled=true; return; @@ -819,7 +823,7 @@ void Editor::keyPressEvent(QKeyEvent *event) if (pSettings->codeCompletion().enabled() && pSettings->codeCompletion().showCompletionWhileInput() ) { mLastIdCharPressed++; - commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr); + processCommand(QSynedit::EditCommand::Char,ch,nullptr); showCompletion("",false,CodeCompletionType::Normal); handled=true; return; @@ -831,7 +835,7 @@ void Editor::keyPressEvent(QKeyEvent *event) if (pSettings->codeCompletion().enabled() && pSettings->codeCompletion().showCompletionWhileInput() ) { mLastIdCharPressed++; - commandProcessor(QSynedit::EditCommand::ecChar,ch,nullptr); + processCommand(QSynedit::EditCommand::Char,ch,nullptr); showCompletion("",false,CodeCompletionType::Normal); handled=true; return; @@ -1877,52 +1881,52 @@ bool Editor::notParsed() void Editor::insertLine() { - commandProcessor(QSynedit::EditCommand::ecInsertLine,QChar(),nullptr); + processCommand(QSynedit::EditCommand::InsertLine,QChar(),nullptr); } void Editor::deleteWord() { - commandProcessor(QSynedit::EditCommand::ecDeleteWord,QChar(),nullptr); + processCommand(QSynedit::EditCommand::DeleteWord,QChar(),nullptr); } void Editor::deleteToWordStart() { - commandProcessor(QSynedit::EditCommand::ecDeleteWordStart,QChar(),nullptr); + processCommand(QSynedit::EditCommand::DeleteWordStart,QChar(),nullptr); } void Editor::deleteToWordEnd() { - commandProcessor(QSynedit::EditCommand::ecDeleteWordEnd,QChar(),nullptr); + processCommand(QSynedit::EditCommand::DeleteWordEnd,QChar(),nullptr); } void Editor::deleteLine() { - commandProcessor(QSynedit::EditCommand::ecDeleteLine,QChar(),nullptr); + processCommand(QSynedit::EditCommand::DeleteLine,QChar(),nullptr); } void Editor::duplicateLine() { - commandProcessor(QSynedit::EditCommand::ecDuplicateLine,QChar(),nullptr); + processCommand(QSynedit::EditCommand::DuplicateLine,QChar(),nullptr); } void Editor::deleteToEOL() { - commandProcessor(QSynedit::EditCommand::ecDeleteEOL,QChar(),nullptr); + processCommand(QSynedit::EditCommand::DeleteEOL,QChar(),nullptr); } void Editor::deleteToBOL() { - commandProcessor(QSynedit::EditCommand::ecDeleteBOL,QChar(),nullptr); + processCommand(QSynedit::EditCommand::DeleteBOL,QChar(),nullptr); } void Editor::gotoBlockStart() { - commandProcessor(QSynedit::EditCommand::ecBlockStart,QChar(),nullptr); + processCommand(QSynedit::EditCommand::BlockStart,QChar(),nullptr); } void Editor::gotoBlockEnd() { - commandProcessor(QSynedit::EditCommand::ecBlockEnd,QChar(),nullptr); + processCommand(QSynedit::EditCommand::BlockEnd,QChar(),nullptr); } QStringList Editor::getOwnerExpressionAndMemberAtPositionForCompletion( @@ -2302,17 +2306,17 @@ bool Editor::handleParentheseCompletion() QString text=selText(); beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::EditCommand::ecChar,'('); + processCommand(QSynedit::EditCommand::Char,'('); setSelText(text); - commandProcessor(QSynedit::EditCommand::ecChar,')'); + processCommand(QSynedit::EditCommand::Char,')'); endUndoBlock(); endUpdate(); } else { beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::EditCommand::ecChar,'('); + processCommand(QSynedit::EditCommand::Char,'('); QSynedit::BufferCoord oldCaret = caretXY(); - commandProcessor(QSynedit::EditCommand::ecChar,')'); + processCommand(QSynedit::EditCommand::Char,')'); setCaretXY(oldCaret); endUndoBlock(); endUpdate(); @@ -2363,17 +2367,17 @@ bool Editor::handleBracketCompletion() QString text=selText(); beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::EditCommand::ecChar,'['); + processCommand(QSynedit::EditCommand::Char,'['); setSelText(text); - commandProcessor(QSynedit::EditCommand::ecChar,']'); + processCommand(QSynedit::EditCommand::Char,']'); endUndoBlock(); endUpdate(); } else { beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::EditCommand::ecChar,'['); + processCommand(QSynedit::EditCommand::Char,'['); QSynedit::BufferCoord oldCaret = caretXY(); - commandProcessor(QSynedit::EditCommand::ecChar,']'); + processCommand(QSynedit::EditCommand::Char,']'); setCaretXY(oldCaret); endUndoBlock(); endUpdate(); @@ -2411,14 +2415,14 @@ bool Editor::handleMultilineCommentCompletion() QString text=selText(); beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::EditCommand::ecChar,'*'); + processCommand(QSynedit::EditCommand::Char,'*'); QSynedit::BufferCoord oldCaret; if (text.isEmpty()) oldCaret = caretXY(); else setSelText(text); - commandProcessor(QSynedit::EditCommand::ecChar,'*'); - commandProcessor(QSynedit::EditCommand::ecChar,'/'); + processCommand(QSynedit::EditCommand::Char,'*'); + processCommand(QSynedit::EditCommand::Char,'/'); if (text.isEmpty()) setCaretXY(oldCaret); endUndoBlock(); @@ -2439,16 +2443,16 @@ bool Editor::handleBraceCompletion() QString text=selText(); beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::EditCommand::ecChar,'{'); + processCommand(QSynedit::EditCommand::Char,'{'); QSynedit::BufferCoord oldCaret; if (text.isEmpty()) { oldCaret = caretXY(); } else { - commandProcessor(QSynedit::EditCommand::ecInsertLine); + processCommand(QSynedit::EditCommand::InsertLine); setSelText(text); - commandProcessor(QSynedit::EditCommand::ecInsertLine); + processCommand(QSynedit::EditCommand::InsertLine); } - commandProcessor(QSynedit::EditCommand::ecChar,'}'); + processCommand(QSynedit::EditCommand::Char,'}'); if ( ( (s.startsWith("struct") || s.startsWith("class") @@ -2459,7 +2463,7 @@ bool Editor::handleBraceCompletion() || s.startsWith("enum") ) && !s.contains(';') ) || s.endsWith('=')) { - commandProcessor(QSynedit::EditCommand::ecChar,';'); + processCommand(QSynedit::EditCommand::Char,';'); } if (text.isEmpty()) setCaretXY(oldCaret); @@ -2481,7 +2485,7 @@ bool Editor::handleBraceSkip() if (lastLineState.braceLevel==0) { bool oldInsertMode = insertMode(); setInsertMode(false); //set mode to overwrite - commandProcessor(QSynedit::EditCommand::ecChar,'}'); + processCommand(QSynedit::EditCommand::Char,'}'); setInsertMode(oldInsertMode); return true; } @@ -2490,7 +2494,7 @@ bool Editor::handleBraceSkip() if (pos.line != 0) { bool oldInsertMode = insertMode(); setInsertMode(false); //set mode to overwrite - commandProcessor(QSynedit::EditCommand::ecChar,'}'); + processCommand(QSynedit::EditCommand::Char,'}'); setInsertMode(oldInsertMode); return true; } @@ -2513,9 +2517,9 @@ bool Editor::handleSingleQuoteCompletion() QString text=selText(); beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::EditCommand::ecChar,'\''); + processCommand(QSynedit::EditCommand::Char,'\''); setSelText(text); - commandProcessor(QSynedit::EditCommand::ecChar,'\''); + processCommand(QSynedit::EditCommand::Char,'\''); endUndoBlock(); endUpdate(); return true; @@ -2524,9 +2528,9 @@ bool Editor::handleSingleQuoteCompletion() // insert '' beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::EditCommand::ecChar,'\''); + processCommand(QSynedit::EditCommand::Char,'\''); QSynedit::BufferCoord oldCaret = caretXY(); - commandProcessor(QSynedit::EditCommand::ecChar,'\''); + processCommand(QSynedit::EditCommand::Char,'\''); setCaretXY(oldCaret); endUndoBlock(); endUpdate(); @@ -2553,9 +2557,9 @@ bool Editor::handleDoubleQuoteCompletion() QString text=selText(); beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::EditCommand::ecChar,'"'); + processCommand(QSynedit::EditCommand::Char,'"'); setSelText(text); - commandProcessor(QSynedit::EditCommand::ecChar,'"'); + processCommand(QSynedit::EditCommand::Char,'"'); endUndoBlock(); endUpdate(); return true; @@ -2564,9 +2568,9 @@ bool Editor::handleDoubleQuoteCompletion() // insert "" beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::EditCommand::ecChar,'"'); + processCommand(QSynedit::EditCommand::Char,'"'); QSynedit::BufferCoord oldCaret = caretXY(); - commandProcessor(QSynedit::EditCommand::ecChar,'"'); + processCommand(QSynedit::EditCommand::Char,'"'); setCaretXY(oldCaret); endUndoBlock(); endUpdate(); @@ -2586,9 +2590,9 @@ bool Editor::handleGlobalIncludeCompletion() return false; beginUpdate(); beginUndoBlock(); - commandProcessor(QSynedit::EditCommand::ecChar,'<'); + processCommand(QSynedit::EditCommand::Char,'<'); QSynedit::BufferCoord oldCaret = caretXY(); - commandProcessor(QSynedit::EditCommand::ecChar,'>'); + processCommand(QSynedit::EditCommand::Char,'>'); setCaretXY(oldCaret); endUpdate(); endUndoBlock(); @@ -2617,17 +2621,17 @@ bool Editor::handleCodeCompletion(QChar key) if (mParser) { switch(key.unicode()) { case '.': - commandProcessor(QSynedit::EditCommand::ecChar, key); + processCommand(QSynedit::EditCommand::Char, key); showCompletion("",false,CodeCompletionType::Normal); return true; case '>': - commandProcessor(QSynedit::EditCommand::ecChar, key); + processCommand(QSynedit::EditCommand::Char, key); if ((caretX() > 2) && (lineText().length() >= 2) && (lineText()[caretX() - 3] == '-')) showCompletion("",false,CodeCompletionType::Normal); return true; case ':': - commandProcessor(QSynedit::EditCommand::ecChar,':',nullptr); + processCommand(QSynedit::EditCommand::Char,':',nullptr); //setSelText(key); if ((caretX() > 2) && (lineText().length() >= 2) && (lineText()[caretX() - 3] == ':')) @@ -2635,7 +2639,7 @@ bool Editor::handleCodeCompletion(QChar key) return true; case '/': case '\\': - commandProcessor(QSynedit::EditCommand::ecChar, key); + processCommand(QSynedit::EditCommand::Char, key); if (mParser->isIncludeLine(lineText())) { showHeaderCompletion(false); } @@ -3395,8 +3399,8 @@ bool Editor::onCompletionKeyPressed(QKeyEvent *event) //ignore it return true; case Qt::Key_Backspace: - commandProcessor( - QSynedit::EditCommand::ecDeleteLastChar, + processCommand( + QSynedit::EditCommand::DeleteLastChar, QChar(), nullptr); // Simulate backspace in editor if (purpose == WordPurpose::wpCompletion) { phrase = getWordForCompletionSearch(caretXY(), mCompletionPopup->memberOperator()=="::"); @@ -3429,7 +3433,7 @@ bool Editor::onCompletionKeyPressed(QKeyEvent *event) } QChar ch = event->text().front(); if (isIdentChar(ch)) { - commandProcessor(QSynedit::EditCommand::ecChar, ch); + processCommand(QSynedit::EditCommand::Char, ch); if (purpose == WordPurpose::wpCompletion) { phrase = getWordForCompletionSearch(caretXY(),mCompletionPopup->memberOperator()=="::"); } else @@ -3457,8 +3461,8 @@ bool Editor::onHeaderCompletionKeyPressed(QKeyEvent *event) QSynedit::BufferCoord pBeginPos,pEndPos; switch (event->key()) { case Qt::Key_Backspace: - commandProcessor( - QSynedit::EditCommand::ecDeleteLastChar, + processCommand( + QSynedit::EditCommand::DeleteLastChar, QChar(), nullptr); // Simulate backspace in editor phrase = getWordAtPosition(this,caretXY(), pBeginPos,pEndPos, @@ -3489,7 +3493,7 @@ bool Editor::onHeaderCompletionKeyPressed(QKeyEvent *event) if (isIdentChar(ch) || ch == '.' || ch =='_' || ch=='+') { - commandProcessor(QSynedit::EditCommand::ecChar, ch); + processCommand(QSynedit::EditCommand::Char, ch); phrase = getWordAtPosition(this,caretXY(), pBeginPos,pEndPos, WordPurpose::wpHeaderCompletion); @@ -4698,7 +4702,10 @@ void Editor::applySettings() { QSynedit::EditorOptions options = QSynedit::eoAltSetsColumnMode | QSynedit::eoDragDropEditing | QSynedit::eoDropFiles | QSynedit::eoKeepCaretX | QSynedit::eoTabsToSpaces | - QSynedit::eoRightMouseMovesCursor | QSynedit::eoScrollByOneLess | QSynedit::eoTabIndent | QSynedit::eoHideShowScrollbars | QSynedit::eoGroupUndo; + QSynedit::eoRightMouseMovesCursor | QSynedit::eoScrollByOneLess | QSynedit::eoTabIndent | QSynedit::eoHideShowScrollbars | QSynedit::eoGroupUndo + | QSynedit::eoSelectWordByDblClick; + + options.setFlag(QSynedit::eoShowSpecialChars); //options options.setFlag(QSynedit::eoAutoIndent,pSettings->editor().autoIndent()); diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 5df33cd2..4f14d329 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -7818,7 +7818,6 @@ void MainWindow::on_btnRemoveProblem_clicked() std::sort(idxList.begin(),idxList.end(),[](int i1, int i2){ return i1>i2; }); - qDebug()<spinMaxUndo->setValue(pSettings->editor().undoLimit()); ui->spinMaxUndoMemory->setValue(pSettings->editor().undoMemoryUsage()); - ui->chkAutoReformat->setChecked(pSettings->editor().autoFormatWhenSaved()); + if (pSettings->editor().removeTrailingSpacesWhenSaved()) + ui->rbRemoveTrailingSpaces->setChecked(true); + else if (pSettings->editor().autoFormatWhenSaved()) + ui->rbAutoReformat->setChecked(true); + else + ui->rbNone->setChecked(true); + ui->chkParseTodos->setChecked(pSettings->editor().parseTodos()); } @@ -84,7 +90,8 @@ void EditorMiscWidget::doSave() } pSettings->editor().setUndoLimit(ui->spinMaxUndo->value()); pSettings->editor().setUndoMemoryUsage(ui->spinMaxUndoMemory->value()); - pSettings->editor().setAutoFormatWhenSaved(ui->chkAutoReformat->isChecked()); + pSettings->editor().setAutoFormatWhenSaved(ui->rbAutoReformat->isChecked()); + pSettings->editor().setRemoveTrailingSpacesWhenSaved(ui->rbRemoveTrailingSpaces->isChecked()); pSettings->editor().setParseTodos(ui->chkParseTodos->isChecked()); diff --git a/RedPandaIDE/settingsdialog/editormiscwidget.ui b/RedPandaIDE/settingsdialog/editormiscwidget.ui index 7315cda6..afe46cf4 100644 --- a/RedPandaIDE/settingsdialog/editormiscwidget.ui +++ b/RedPandaIDE/settingsdialog/editormiscwidget.ui @@ -7,7 +7,7 @@ 0 0 515 - 408 + 510 @@ -36,10 +36,55 @@ - - - Auto reformat code before saving files + + + Limits for Undo + + + + + Memory Usage + + + + + + + 0 + + + 1000000000 + + + 50 + + + 10000 + + + + + + + Steps + + + + + + + MB + + + 100 + + + 50 + + + + @@ -57,42 +102,6 @@ 0 - - - - Max Undo Steps - - - - - - - 0 - - - 1000000000 - - - 50 - - - 10000 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - @@ -111,28 +120,38 @@ 0 - - + + + + + + + Action before saving files + + + + - Max Undo Memory Usage + Reformat Code - - - - MB - - - 100 - - - 50 + + + + Remove Trailing Spaces - - + + + + None + + + + + Qt::Horizontal @@ -187,7 +206,14 @@ Default file type - + + + + + C files + + + @@ -196,11 +222,17 @@ - - - C files + + + Qt::Horizontal - + + + 40 + 20 + + + diff --git a/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts b/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts index 2e3673c7..7bff5434 100644 --- a/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts +++ b/RedPandaIDE/translations/RedPandaIDE_pt_BR.ts @@ -1433,7 +1433,7 @@ Max Undo Steps - Quantidade máxima de passos a serem desfeitos + Quantidade máxima de passos a serem desfeitos Default file encoding @@ -1463,20 +1463,40 @@ UTF-8 BOM UTF-8 BOM - - Max Undo Memory Usage - - MB MB - Auto reformat code before saving files + Parse TODOs - Parse TODOs + Memory Usage + + + + Steps + + + + Action before saving files + + + + Reformat Code + Reformatar código + + + Remove Trailing Spaces + + + + None + + + + Limits for Undo @@ -6947,6 +6967,10 @@ Command: %1 %2 Comando: %1 %2 + + Compiling... + + SymbolUsageManager diff --git a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts index 10db32e9..e396c328 100644 --- a/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/translations/RedPandaIDE_zh_CN.ts @@ -967,12 +967,12 @@ p, li { white-space: pre-wrap; } 选择性能分析器 - + Confirm 确认 - + Red Panda C++ will clear current compiler list and search for compilers in the following locations:<br /> '%1'<br /> '%2'<br />Are you really want to continue? Red Panda C++ will clear current compiler list and search for compilers in the following locations: '%1' @@ -981,96 +981,96 @@ Are you really want to continue? 小熊猫C++ 将会清除现有的编译器配置列表,然后在下列文件夹中搜索编译器:<br/> '%1'<br/> '%2'<br />你确定要继续吗? - + ANSI ANSI - + UTF-8 UTF-8 - + Red Panda C++ will clear current compiler list and search for compilers in the the PATH. <br />Are you really want to continue? 小熊猫C++ 将会清除现有的编译器配置列表,然后在PATH路径中搜索gcc编译器.<br />你确定要继续吗? - - + + Failed 失败 - - + + Can't find any compiler. 找不到编译器 - - + + Compiler Set Name 编译器配置名称 - + Name 名称 - + Compiler Set Folder 编译器所在文件夹 - + New name 新名称 - + Locate C Compiler 定位C编译器 - - - - - - - + + + + + + + Executable files (*.exe) 可执行文件 (*.exe) - + Locate C++ Compiler 定位C++编译器 - + Locate Make 定位make程序 - + Locate GDB 定位gdb程序 - + Locate GDB Server 定位gdb server程序 - + Locate windres 定位windres程序 - + Locate gprof 定位gprof程序 @@ -1368,13 +1368,13 @@ Are you really want to continue? 失败 - - - - - - - + + + + + + + Error 错误 @@ -1383,44 +1383,44 @@ Are you really want to continue? 无法写入文件"%1" - + Save As 另存为 - + File %1 already openned! 文件%1已经被打开! - + The text to be copied exceeds count limit! 要复制的内容超过了行数限制! - + The text to be copied exceeds character limit! 要复制的内容超过了字符数限制! - + The text to be cut exceeds count limit! 要剪切的内容超过了行数限制! - + The text to be cut exceeds character limit! 要剪切的内容超过了字符数限制! - + Print Document 打印文档 - - - + + + Ctrl+click for more info Ctrl+单击以获取更多信息 @@ -1429,27 +1429,27 @@ Are you really want to continue? 未找到符号'%1'! - + astyle not found 找不到astyle程序 - + Can't find astyle in "%1". 找不到astyle程序"%1". - + Break point condition 断点条件 - + Enter the condition of the breakpoint: 输入当前断点的生效条件: - + Readonly 只读 @@ -1969,15 +1969,49 @@ Are you really want to continue? 自动打开上次退出时打开的文件 - + + Limits for Undo + + + + + Memory Usage + + + + + Steps + + + + + Action before saving files + + + + + Reformat Code + 对代码重新排版 + + + + Remove Trailing Spaces + + + + + None + + + + Auto detect encoding when openning files Use UTF-8 as the default encoding for new file 在打开文件时自动探测文件编码 - Auto reformat code before saving files - 在保存文件时自动重新排版 + 在保存文件时自动重新排版 @@ -1985,52 +2019,50 @@ Are you really want to continue? 查找代码中的TODO注释(含todo或者fixme的注释) - Max Undo Steps - 最大可撤销编辑操作数量 + 最大可撤销编辑操作数量 - Max Undo Memory Usage - 最大可撤销编辑操作占用内存 + 最大可撤销编辑操作占用内存 - + MB MB - + Default file encoding 缺省文件编码 - + Default file type 缺省文件类型 - + C++ files C++语言文件 - + C files C语言文件 - + ANSI ANSI - + UTF-8 UTF-8 - + UTF-8 BOM UTF-8 BOM @@ -3988,13 +4020,13 @@ Are you really want to continue? 小熊猫C++ - - - - - - - + + + + + + + Issues 编译器 @@ -4013,8 +4045,8 @@ Are you really want to continue? 工具 - + Run 运行 @@ -4026,25 +4058,25 @@ Are you really want to continue? - + Project 项目 - + Watch 监视 - + Structure 结构 - + Files 文件 @@ -4054,68 +4086,68 @@ Are you really want to continue? - - + - + + Debug 调试 - + Evaluate: 求值 - + Debug Console 调试主控台 - + Call Stack 调用栈 - + Breakpoints 断点 - + Locals 局部变量 - - + + Search 查找 - + History: 历史: - + Search Again 重新查找 - + Replace with: 替换为: - + Replace 替换 - + Close 关闭 @@ -4149,78 +4181,78 @@ Are you really want to continue? 新建 - + Ctrl+N Ctrl+N - + Open... 打开... - + Ctrl+O Ctrl+O - + Save 保存 - + Ctrl+S Ctrl+S - + Save As... 另存为... - + Save As 另存为 - + Save All 全部保存 - + Ctrl+Shift+S Ctrl+Shift+S - + Options 选项 - + Compile 编译 - - + + Tools Output 工具输出 - + Choose Input File 选择输入文件 - + ... ... @@ -4240,47 +4272,47 @@ Are you really want to continue? 选择 - + F9 F9 - + F10 F10 - + Undo 恢复 - + Ctrl+Z Ctrl+Z - + Redo 重做 - + Ctrl+Y Ctrl+Y - + Cut 剪切 - + Ctrl+X Ctrl+X - + @@ -4288,151 +4320,151 @@ Are you really want to continue? 复制 - + Ctrl+C Ctrl+C - + Paste 粘贴 - + Ctrl+V Ctrl+V - + Select All 选择全部 - + Ctrl+A Ctrl+A - + Indent 缩进 - + UnIndent 取消缩进 - + Toggle Comment 切换注释 - + Ctrl+/ Ctrl+/ - + Collapse All 全部收起 - + Uncollapse All 全部展开 - + Encode in ANSI 使用ANSI编码 - + Encode in UTF-8 使用UTF-8编码 - + Auto Detect 自动检测 - + Convert to ANSI 转换为ANSI编码 - + Convert to UTF-8 转换为UTF-8编码 - + Compile & Run 编译运行 - + F11 F11 - + Rebuild All 全部重编译 - + F12 F12 - + Stop Execution 停止执行 - + F6 F6 - + F5 F5 - + Step Over 单步跳过 - + F7 F7 - + Step Into 单步进入 - + Problem Set 试题集 - + New Problem Set 新建试题集 @@ -4451,101 +4483,101 @@ Are you really want to continue? - + Save Problem Set 保存试题集 - + Load Problem Set 载入试题集 - + Memory 内存 - + Address Expression: Address: 地址表达式: - + Cancel 取消 - - + + TODO TODO - - + + Bookmark 书签 - - - + + + Problem 试题 - + Add Probem Case 添加试题案例 - + Remove Problem Case Remove Problem Set 删除试题集 - + Open Anwser Source File 打开答案源代码文件 - + Run All Cases Run Current Case 运行所有案例 - + Problem Cases Validation Options 测试案例验证选项 - + %v/%m %v/%m - + Output 输出 - + Input 输入 - + Expected 期望输出 @@ -4585,430 +4617,430 @@ Are you really want to continue? - + Import FPS Problem Set 导入FPS试题集 - + Messages 消息 - + Ignore Spaces 忽略空格 - + New Source File 新建源代码文件 - + Tab Tab - + Shift+Tab Shift+Tab - + F8 F8 - + Step Out 单步跳出 - + Ctrl+F8 Ctrl+F8 - + Run To Cursor 执行到光标处 - + Ctrl+F5 Ctrl+F5 - + Continue 继续执行 - + F4 F4 - + Add Watch... 添加监视 - + View CPU Window... 打开CPU信息窗口... - + Exit 退出 - + Find... 查找... - + Ctrl+F Ctrl+F - + Find in Files... 在文件中查找... - + Ctrl+Shift+F Ctrl+Shift+F - + Replace... 替换 - + Ctrl+R Ctrl+R - + Find Next 查找下一个 - + F3 F3 - + Find Previous 查找前一个 - + Shift+F3 Shift+F3 - + Remove Watch 删除监视值 - + Remove All Watches Remove All 删除全部监视值 - + Modify Watch... 修改监视值 - + Reformat Code 对代码重新排版 - + Ctrl+Shift+A Ctrl+Shift+A - + Go back 前一次编辑位置 - + Ctrl+Alt+Left Ctrl+Alt+Left - + Forward 后一次编辑位置 - + Ctrl+Alt+Right Ctrl+Alt+Right - + Ctrl+W Ctrl+W - + Close All 全部关闭 - + Ctrl+Shift+W Ctrl+Shift+W - + Maximize Editor 最大化编辑器 - + Ctrl+F11 Ctrl+F11 - + Next 下一窗口 - + Ctrl+Tab Ctrl+Tab - + Previous 前一窗口 - + Ctrl+Shift+Tab Ctrl+Shift+Tab - + Toggle breakpoint 切换断点 - + Ctrl+F4 Ctrl+F4 - - + + Clear all breakpoints 删除所有断点 - + Breakpoint property... 设置断点条件... - + Goto Declaration 跳转到声明处 - + Ctrl+Shift+G Ctrl+Shift+G - + Goto Definition 跳转到定义处 - + Ctrl+G Ctrl+G - + Find references 查找符号的引用 - + Open containing folder 打开所在的文件夹 - + Ctrl+B Ctrl+B - + Open a terminal here 打开命令行窗口 - + File Properties... 文件属性... - + Close Project 关闭项目 - + Project options 项目属性 - + New Project... 新建项目... - + New Project File 新建项目文件 - + F1 F1 - + Move Selection Up 向上移动选中的行 - + Ctrl+Shift+Up Ctrl+Shift+Up - + Move Selection Down 向下移动选中的行 - + Ctrl+Shift+Down Ctrl+Shift+Down - + Convert to UTF-8 BOM 转换为UTF-8 BOM编码 - + Encode in UTF-8 BOM 使用UTF-8 BOM编码 - + Compiler Options... 编译器选项... - + Toggle Explorer Panel 切换管理器面板 - + Ctrl+F9 Ctrl+F9 - + Toggle Messages Panel 切换消息面板 - + Ctrl+F10 Ctrl+F10 - + Raylib Manual Raylib教程 - + Select Word 选中当前单词 - + Go to Line... 跳转到行... - + New Template... 新建模板... - + New Template from Project 从项目创建模板 - + Goto block start 跳转到代码段开始 - + Ctrl+Alt+Up Ctrl+Alt+Up - + Goto block end 跳转到代码段结束 - + Ctrl+Alt+Down Ctrl+Alt+Down - + Switch header/source 切换头文件/源文件 - + Switch Header/Source 切换头文件/源文件 - + Generate Assembly 生成汇编 @@ -5017,200 +5049,200 @@ Are you really want to continue? 保存为模板... - + New File 新建文件 - + Add to project... 添加到项目... - + Remove from project 从项目删除 - + View Makefile 查看Makefile - + Clean 清理构建文件 - + Open Folder in Explorer 在浏览器中打开 - + Open In Terminal 在终端中打开 - + About 关于 - - + + Rename Symbol 重命名符号 - + Shift+F6 Shift+F6 - + Print... 打印... - + Ctrl+P Ctrl+P - - + + Export As RTF 导出为RTF - - + + Export As HTML 导出为HTML - + Move To Other View 移动到其他视图 - + Ctrl+M Ctrl+M - + C++ Reference C++参考手册 - + C Reference C参考手册 - + Show Tool Panels 显示全部工具面板 - + Create Git Repository Create Repository 创建Git仓库 - + Commit 提交(Commit) - + Revert 撤销(Revert) - + Reset 回滚(Reset) - + Add Files 添加文件 - + Restore 还原(Restore) - + Website 官方网站 - + Branch/Switch 分支切换(Switch) - + Merge 合并(Merge) - + Show Log Log 显示日志(Log) - + Remotes... 远程仓库... - + Fetch 取回(Fetch) - + Pull 拉取(Pull) - + Push 推送(Push) - + Hide Non Support Files 隐藏不支持的文件 - + Toggle Block Comment 切换块注释 - + Alt+Shift+A Alt+Shift+A - + Match Bracket 匹配当前括号 - + Ctrl+] Ctrl+] @@ -5219,50 +5251,50 @@ Are you really want to continue? 工具窗口栏 - + Status Bar 状态栏 - + Ctrl+Backspace Ctrl+Backspace - + Interrupt 中断 - + Delete To Word Begin 删除到单词开头 - + Ctrl+Shift+B Ctrl+Shift+B - + Delete to Word End 删除到单词结尾 - + Ctrl+Shift+E Ctrl+Shift+E - + New Class... Add Class... 新建类... - + New Header... New Header 新建头文件... @@ -5272,47 +5304,47 @@ Are you really want to continue? 插入行 - + Delete Line 删除当前行 - + Ctrl+D Ctrl+D - + Duplicate Line 复制当前行 - + Ctrl+E Ctrl+E - + Delete Word 删除当前单词 - + Ctrl+Shift+D Ctrl+Shift+D - + Delete to EOL 删除到行尾 - + Ctrl+Del Ctrl+Del - + Delete to BOL 删除到行首 @@ -5321,27 +5353,27 @@ Are you really want to continue? C/C++参考 - + EGE Manual EGE图形库手册 - + Add Bookmark 添加书签 - + Remove Bookmark 删除书签 - + Modify Bookmark Description 修改书签说明 - + Locate in Files View 在文件视图中定位 @@ -5350,7 +5382,7 @@ Are you really want to continue? 打开文件夹 - + Running Parameters... 运行参数... @@ -5460,22 +5492,22 @@ Are you really want to continue? - - + + Wrong Compiler Settings 错误的编译器设置 - - + + Compiler is set not to generate executable. 编译器被设置为不生成可执行文件。 - + We need the executabe to run problem case. 我们需要可执行文件来运行试题案例。 @@ -5543,7 +5575,7 @@ Are you really want to continue? - + Please correct this before start debugging 请在调试前改正设置。 @@ -5601,29 +5633,29 @@ Are you really want to continue? 全部复制 - + Go to Line 跳转到行 - + Line - + Template Exists 模板已存在 - + Template %1 already exists. Do you want to overwrite? 模板%1已存在。是否覆盖? - - + + @@ -5642,7 +5674,7 @@ Are you really want to continue? - + Problem Set %1 试题集%1 @@ -5716,15 +5748,15 @@ Are you really want to continue? - - + + Bookmark Description 书签描述 - - + + Description: 描述: @@ -5880,7 +5912,7 @@ Are you really want to continue? - + Delete 删除 @@ -5935,7 +5967,7 @@ Are you really want to continue? 选择答案源代码文件 - + FPS Problem Set Files (*.fps;*.xml) FPS试题集文件(*.fps;*.xml) @@ -5983,7 +6015,7 @@ Are you really want to continue? - + Do you want to save it? 需要保存吗? @@ -6007,23 +6039,23 @@ Are you really want to continue? - + Save Error 保存失败 - + Change Project Compiler Set 改变项目编译器配置集 - + Change the project's compiler set will lose all custom compiler set options. 改变项目的编译器配置集会导致所有的自定义编译器选项被重置。 - + Do you really want to do that? 你真的想要那么做吗? @@ -6046,104 +6078,104 @@ Are you really want to continue? 无标题%1 - + Modify Watch 修改监视表达式 - + Watch Expression 监视表达式 - + Do you really want to clear all breakpoints in this file? 您真的要清除该文件的所有断点吗? - + New project 新建项目 - + Close %1 and start new project? 关闭'%1'以打开新项目? - + Folder not exist 文件夹不存在 - + Folder '%1' doesn't exist. Create it now? 文件夹'%1'不存在。是否创建? - + Can't create folder 无法创建文件夹 - + Failed to create folder '%1'. 创建文件夹'%1'失败。 - + Save new project as - + Folder %1 is not empty. 文件夹%1不是空的。 - + Do you really want to delete it? 你真的要删除它吗? - + Change working folder 改变工作文件夹 - + File '%1' is not in the current working folder. File '%1' is not in the current working folder 文件'%1'不在当前工作文件夹中。 - + Do you want to change working folder to '%1'? 是否将工作文件夹改设为'%1'? - + Can't Commit 无法提交 - + Git needs user info to commit. Git需要用信息进行提交。 - + Choose Input Data File 选择输入数据文件 - - + + All files (*.*) 所有文件 (*.*) - + Choose Expected Output Data File Choose Expected Input Data File 选择期望输出文件 @@ -6153,61 +6185,61 @@ Are you really want to continue? 第%1行 - - + + Choose Working Folder 选择工作文件夹 - - + + Header Exists 头文件已存在 - - + + Header file "%1" already exists! 头文件"%1"已存在! - + Source Exists 源文件已存在! - + Source file "%1" already exists! 源文件"%1"已存在! - + Can't commit! 无法提交! - + The following files are in conflicting: 下列文件处于冲突状态,请解决后重新添加和提交: - + Commit Message 提交信息 - + Commit Message: 提交信息: - + Commit Failed 提交失败 - + Commit message shouldn't be empty! 提交信息不能为空! @@ -6216,22 +6248,22 @@ Are you really want to continue? 小熊猫Dev-C++项目文件 (*.dev) - + New project fail 新建项目失败 - + Can't assign project template 无法使用模板创建项目 - + Remove file 删除文件 - + Remove the file from disk? 同时从硬盘上删除文件? @@ -6240,27 +6272,27 @@ Are you really want to continue? 无标题 - + New Project File Name 新的项目文件名 - + File Name: 文件名: - + File Already Exists! 文件已存在! - + File '%1' already exists! 文件'%1'已经存在! - + Add to project 添加到项目 @@ -6275,76 +6307,76 @@ Are you really want to continue? 本操作会删除此试题的所有案例。 - + Red Panda C++ project file (*.dev) 小熊猫C++项目文件(*.dev) - + Rename Error 重命名出错 - + Symbol '%1' is defined in system header. 符号'%1'在系统头文件中定义,无法修改。 - + New Name 新名称 - - + + Replace Error 替换出错 - + Can't open file '%1' for replace! 无法打开文件'%1'进行替换! - + Contents has changed since last search! 内容和上次查找时不一致。 - + Rich Text Format Files (*.rtf) RTF格式文件 (*.rtf) - + HTML Files (*.html) HTML文件 (*.html) - + The current problem set is not empty. 当前的试题集不是空的。 - + Problem %1 试题%1 - - + + Problem Set Files (*.pbs) 试题集文件 (*.pbs) - - + + Load Error 载入失败 - + Problem Case %1 试题案例%1 @@ -6362,9 +6394,9 @@ Are you really want to continue? - - - + + + Error 错误 @@ -6416,54 +6448,54 @@ Are you really want to continue? 打开 - + Compile Failed 编译失败 - + Run Failed 运行失败 - - - + + + Confirm Convertion 确认转换 - - - + + + The editing file will be saved using %1 encoding. <br />This operation can't be reverted. <br />Are you sure to continue? 当前编辑器中的文件将会使用%1编码保存。<br />这项操作无法被撤回。<br />你确定要继续吗? - + New Watch Expression 新监视表达式 - + Enter Watch Expression (it is recommended to use 'this->' for class members): 输入监视表达式 - + Parsing file %1 of %2: "%3" (%1/%2)正在解析文件"%3" - - + + Done parsing %1 files in %2 seconds 完成%1个文件的解析,用时%2秒 - + (%1 files per second) (每秒%1个文件) @@ -7778,32 +7810,32 @@ Are you really want to continue? 无法载入自动链接设置 - - - - + + + + The following %1 directories don't exist: 下列%1文件夹不存在: - - + + binary 二进制 - + No %1 directories have been specified. 未指定%1文件夹 - + C include C包含 - - + + C++ include C++包含 @@ -7889,7 +7921,7 @@ Are you really want to continue? 生成调试信息(-g3) - + Would you like Red Panda C++ to search for compilers in PATH? 您同意小熊猫C++在PATH路径中寻找gcc编译器吗? @@ -8002,23 +8034,23 @@ Are you really want to continue? 只生成汇编代码(-S) - - + + Confirm 确认 - + The following problems were found during validation of compiler set "%1": 在验证编译器设置"%1"时遇到了下列问题: - + Leaving those directories will lead to problems during compilation. 在配置中保留这些文件夹可能会导致编译出错。 - + Would you like Red Panda C++ to remove them for you and add the default paths to the valid paths? 是否让小熊猫C++删除这些配置,并尝试重新建立配置? @@ -8027,13 +8059,13 @@ Are you really want to continue? 如果仍然保留这些设置,可能会导致编译错误。<br /><br />请选择“是”,除非您清楚的知道选择“否”的后果, - - + + Compiler set not configuared. 未配置编译器设置。 - + Would you like Red Panda C++ to search for compilers in the following locations: <BR />'%1'<BR />'%2'? 您需要小熊猫C++在下列位置搜索编译器吗:<br />%1<br />%2 @@ -9096,14 +9128,14 @@ Are you really want to continue? 性能 - + Compiler Set 编译器配置集 - + Compiler @@ -9115,7 +9147,7 @@ Are you really want to continue? 自动链接 - + @@ -9192,15 +9224,15 @@ Are you really want to continue? 杂项 - - + + Program Runner 程序运行 - + Problem Set 试题集 @@ -9376,42 +9408,47 @@ Are you really want to continue? StdinCompiler - + Checking file syntax... 正在检查语法... - + + Compiling... + + + + - Filename: %1 - 文件名: %1 - + - Compiler Set Name: %1 - 编译器配置: %1 - + Can't find the compiler for file %1 找不到适合文件%1的编译器 - + The Compiler '%1' doesn't exists! 编译器程序'%1'不存在! - + Processing %1 source file: 正在处理%1源程序文件: - + %1 Compiler: %2 %1编译器: %2 - + Command: %1 %2 命令: %1 %2 diff --git a/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts b/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts index b9529bf2..93687695 100644 --- a/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts +++ b/RedPandaIDE/translations/RedPandaIDE_zh_TW.ts @@ -1324,10 +1324,6 @@ Auto detect encoding when openning files - - Max Undo Steps - - Default file encoding @@ -1356,20 +1352,40 @@ UTF-8 BOM - - Max Undo Memory Usage - - MB - Auto reformat code before saving files + Parse TODOs - Parse TODOs + Memory Usage + + + + Steps + + + + Action before saving files + + + + Reformat Code + + + + Remove Trailing Spaces + + + + None + + + + Limits for Undo @@ -6560,6 +6576,10 @@ Command: %1 %2 + + Compiling... + + SymbolUsageManager diff --git a/Red_Panda_CPP.pro b/Red_Panda_CPP.pro index 08c8465d..9808384d 100644 --- a/Red_Panda_CPP.pro +++ b/Red_Panda_CPP.pro @@ -33,7 +33,7 @@ RedPandaIDE.depends += redpanda-git-askpass APP_NAME = RedPandaCPP -APP_VERSION = 2.6 +APP_VERSION = 2.7 linux: { isEmpty(PREFIX) { diff --git a/libs/qsynedit/qsynedit/Constants.cpp b/libs/qsynedit/qsynedit/Constants.cpp index 7f84ebc3..380e8cc6 100644 --- a/libs/qsynedit/qsynedit/Constants.cpp +++ b/libs/qsynedit/qsynedit/Constants.cpp @@ -21,7 +21,7 @@ const QSet WordBreakChars{'.', ',', ';', ':', '"', '\'', '!', '?', '[', ']', '(', ')', '{', '}', '^', '-', '=', '+', '-', '*', '/', '\\', '|'}; const QChar TabGlyph(0x2192); -const QChar SpaceGlyph('.'); +const QChar SpaceGlyph(0x2027); const QChar LineBreakGlyph(0x2193); const QChar SoftBreakGlyph(0x2193); } diff --git a/libs/qsynedit/qsynedit/KeyStrokes.cpp b/libs/qsynedit/qsynedit/KeyStrokes.cpp index eb867dda..199e05d5 100644 --- a/libs/qsynedit/qsynedit/KeyStrokes.cpp +++ b/libs/qsynedit/qsynedit/KeyStrokes.cpp @@ -24,7 +24,7 @@ EditKeyStroke::EditKeyStroke() mKeyModifiers = Qt::NoModifier; mKey2 = 0; mKeyModifiers2 = Qt::NoModifier; - mCommand = EditCommand::ecNone; + mCommand = EditCommand::None; } QKeySequence EditKeyStroke::keySequence() const @@ -181,105 +181,71 @@ void EditKeyStrokes::clear() void EditKeyStrokes::resetDefaults() { clear(); - 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(EditCommand::Up, Qt::Key_Up, Qt::NoModifier); + add(EditCommand::SelUp, Qt::Key_Up, Qt::ShiftModifier); + add(EditCommand::SelUp, Qt::Key_Up, Qt::ShiftModifier | Qt::AltModifier); + add(EditCommand::ScrollUp, Qt::Key_Up, Qt::ControlModifier); + add(EditCommand::Down, Qt::Key_Down, Qt::NoModifier); + add(EditCommand::SelDown, Qt::Key_Down, Qt::ShiftModifier); + add(EditCommand::SelDown, Qt::Key_Down, Qt::ShiftModifier | Qt::AltModifier); + add(EditCommand::ScrollDown, Qt::Key_Down, Qt::ControlModifier); + add(EditCommand::Left, Qt::Key_Left, Qt::NoModifier); + add(EditCommand::SelLeft, Qt::Key_Left, Qt::ShiftModifier); + add(EditCommand::WordLeft, Qt::Key_Left, Qt::ControlModifier); + add(EditCommand::SelWordLeft, Qt::Key_Left, Qt::ShiftModifier|Qt::ControlModifier); + add(EditCommand::Right, Qt::Key_Right, Qt::NoModifier); + add(EditCommand::SelRight, Qt::Key_Right, Qt::ShiftModifier); + add(EditCommand::WordRight, Qt::Key_Right, Qt::ControlModifier); + add(EditCommand::SelWordRight, Qt::Key_Right, Qt::ShiftModifier|Qt::ControlModifier); - add(EditCommand::ecBlockStart, Qt::Key_Up, Qt::MetaModifier|Qt::ControlModifier); - add(EditCommand::ecSelBlockStart, Qt::Key_Up, Qt::ShiftModifier|Qt::ControlModifier|Qt::MetaModifier); - add(EditCommand::ecBlockEnd, Qt::Key_Down, Qt::MetaModifier|Qt::ControlModifier); - add(EditCommand::ecSelBlockEnd, Qt::Key_Down, Qt::ShiftModifier|Qt::ControlModifier|Qt::MetaModifier); + add(EditCommand::BlockStart, Qt::Key_Up, Qt::MetaModifier|Qt::ControlModifier); + add(EditCommand::SelBlockStart, Qt::Key_Up, Qt::ShiftModifier|Qt::ControlModifier|Qt::MetaModifier); + add(EditCommand::BlockEnd, Qt::Key_Down, Qt::MetaModifier|Qt::ControlModifier); + add(EditCommand::SelBlockEnd, Qt::Key_Down, Qt::ShiftModifier|Qt::ControlModifier|Qt::MetaModifier); -// add(SynEditorCommand::ecExpandSelection, Qt::Key_Right, Qt::ShiftModifier|Qt::AltModifier); -// add(SynEditorCommand::ecShrinkSelection, Qt::Key_Left, Qt::ShiftModifier | Qt::AltModifier); + add(EditCommand::PageDown, Qt::Key_PageDown, Qt::NoModifier); + add(EditCommand::SelPageDown, Qt::Key_PageDown, Qt::ShiftModifier); + add(EditCommand::PageBottom, Qt::Key_PageDown, Qt::ControlModifier); + add(EditCommand::SelPageBottom, Qt::Key_PageDown, Qt::ShiftModifier|Qt::ControlModifier); + add(EditCommand::PageUp, Qt::Key_PageUp, Qt::NoModifier); + add(EditCommand::SelPageUp, Qt::Key_PageUp, Qt::ShiftModifier); + add(EditCommand::PageTop, Qt::Key_PageUp, Qt::ControlModifier); + add(EditCommand::SelPageTop, Qt::Key_PageUp, Qt::ShiftModifier|Qt::ControlModifier); + add(EditCommand::LineStart, Qt::Key_Home, Qt::NoModifier); + add(EditCommand::SelLineStart, Qt::Key_Home, Qt::ShiftModifier); + add(EditCommand::EditorStart, Qt::Key_Home, Qt::ControlModifier); + add(EditCommand::SelEditorStart, Qt::Key_Home, Qt::ShiftModifier|Qt::ControlModifier); + add(EditCommand::LineEnd, Qt::Key_End, Qt::NoModifier); + add(EditCommand::SelLineEnd, Qt::Key_End, Qt::ShiftModifier); + add(EditCommand::EditorEnd, Qt::Key_End, Qt::ControlModifier); + add(EditCommand::SelEditorEnd, Qt::Key_End, Qt::ShiftModifier|Qt::ControlModifier); + add(EditCommand::ToggleMode, Qt::Key_Insert, Qt::NoModifier); + add(EditCommand::DeleteChar, Qt::Key_Delete, Qt::NoModifier); + add(EditCommand::DeleteLastChar, Qt::Key_Backspace, Qt::NoModifier); + add(EditCommand::LineBreak, Qt::Key_Return, Qt::NoModifier); + add(EditCommand::LineBreak, Qt::Key_Return, Qt::ShiftModifier); + add(EditCommand::LineBreakAtEnd, Qt::Key_Return, Qt::ControlModifier); + add(EditCommand::LineBreak, Qt::Key_Enter, Qt::NoModifier); + add(EditCommand::LineBreak, Qt::Key_Enter, Qt::ShiftModifier); + add(EditCommand::LineBreakAtEnd, Qt::Key_Enter, Qt::ControlModifier); - 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(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(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(EditCommand::ecContextHelp, Qt::Key_F1, Qt::NoModifier); - -// 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(SynEditorCommand::ecBlockIndent, Qt::Key_I, Qt::ControlModifier|Qt::ShiftModifier); -// add(SynEditorCommand::ecBlockUnindent, Qt::Key_U, Qt::ControlModifier|Qt::ShiftModifier); -// add(SynEditorCommand::ecLineBreak, Qt::Key_M, Qt::ControlModifier); -// add(SynEditorCommand::ecInsertLine, Qt::Key_N, Qt::ControlModifier); -// add(SynEditorCommand::ecDeleteWord, Qt::Key_T, Qt::ControlModifier); -// add(SynEditorCommand::ecDeleteLine, Qt::Key_Y, Qt::ControlModifier); -// add(SynEditorCommand::ecDeleteEOL, Qt::Key_Y, Qt::ControlModifier|Qt::ShiftModifier); -// add(SynEditorCommand::ecDuplicateLine, Qt::Key_D, Qt::ControlModifier); - -// add(SynEditorCommand::ecUndo, Qt::Key_Z, Qt::ControlModifier); -// add(SynEditorCommand::ecRedo, Qt::Key_Z, Qt::ControlModifier|Qt::ShiftModifier); -// add(SynEditorCommand::ecNormalSelect, Qt::Key_N, Qt::ControlModifier | Qt::ShiftModifier); -// add(SynEditorCommand::ecColumnSelect, Qt::Key_C, Qt::ControlModifier | Qt::ShiftModifier); -// add(SynEditorCommand::ecLineSelect, Qt::Key_L, Qt::ControlModifier | Qt::ShiftModifier); - // add(SynEditorCommand::ecMatchBracket, Qt::Key_B, Qt::ControlModifier | Qt::ShiftModifier); } void EditKeyStrokes::setExtraKeyStrokes() { - add(EditCommand::ecDeleteWordStart, Qt::Key_Backspace, Qt::ControlModifier); - add(EditCommand::ecDeleteWordEnd, Qt::Key_Delete, Qt::ControlModifier); + add(EditCommand::DeleteWordStart, Qt::Key_Backspace, Qt::ControlModifier); + add(EditCommand::DeleteWordEnd, Qt::Key_Delete, Qt::ControlModifier); - add(EditCommand::ecDuplicateLine, Qt::Key_D, Qt::ControlModifier); - add(EditCommand::ecDeleteLine, Qt::Key_E, Qt::ControlModifier); + add(EditCommand::DuplicateLine, Qt::Key_D, Qt::ControlModifier); + add(EditCommand::DeleteLine, Qt::Key_E, 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(EditCommand::SelectAll, Qt::Key_A, Qt::ControlModifier); + add(EditCommand::Copy, Qt::Key_C, Qt::ControlModifier); + add(EditCommand::Paste, Qt::Key_V, Qt::ControlModifier); + add(EditCommand::Cut, Qt::Key_X, Qt::ControlModifier); - add(EditCommand::ecUndo, Qt::Key_Z, Qt::ControlModifier); - add(EditCommand::ecRedo, Qt::Key_Y, Qt::ControlModifier); + add(EditCommand::Undo, Qt::Key_Z, Qt::ControlModifier); + add(EditCommand::Redo, Qt::Key_Y, Qt::ControlModifier); } } diff --git a/libs/qsynedit/qsynedit/KeyStrokes.h b/libs/qsynedit/qsynedit/KeyStrokes.h index e92cc001..dcc51fa7 100644 --- a/libs/qsynedit/qsynedit/KeyStrokes.h +++ b/libs/qsynedit/qsynedit/KeyStrokes.h @@ -39,144 +39,139 @@ namespace QSynedit { // read-only mode enum class EditCommand { - ecNone = 0, // Nothing. Useful for user event to handle command - ecViewCommandFirst = 0, - ecViewCommandLast = 500, - ecEditCommandFirst = 501, - ecEditCommandLast = 1000, + None = 0, // Nothing. Useful for user event to handle command - ecLeft = 1, // Move cursor left one char - ecRight = 2, // Move cursor right one char - ecUp = 3, // Move cursor up one line - ecDown = 4, // Move cursor down one line - ecWordLeft = 5, // Move cursor left one word - ecWordRight = 6, // Move cursor right one word - ecLineStart = 7, // Move cursor to beginning of line - ecLineEnd = 8, // Move cursor to end of line - ecPageUp = 9, // Move cursor up one page - ecPageDown = 10, // Move cursor down one page - ecPageLeft = 11, // Move cursor right one page - ecPageRight = 12, // Move cursor left one page - ecPageTop = 13, // Move cursor to top of page - ecPageBottom = 14, // Move cursor to bottom of page - ecEditorStart = 15, // Move cursor to absolute beginning - ecEditorEnd = 16, // Move cursor to absolute end - ecGotoXY = 17, // Move cursor to specific coordinates, Data = PPoint - ecBlockStart = 18, // Move cursor to begin of block - ecBlockEnd = 19, // Move cursor to end of block + Left = 1, // Move cursor left one char + Right = 2, // Move cursor right one char + Up = 3, // Move cursor up one line + Down = 4, // Move cursor down one line + WordLeft = 5, // Move cursor left one word + WordRight = 6, // Move cursor right one word + LineStart = 7, // Move cursor to beginning of line + LineEnd = 8, // Move cursor to end of line + PageUp = 9, // Move cursor up one page + PageDown = 10, // Move cursor down one page + PageLeft = 11, // Move cursor right one page + PageRight = 12, // Move cursor left one page + PageTop = 13, // Move cursor to top of page + PageBottom = 14, // Move cursor to bottom of page + EditorStart = 15, // Move cursor to absolute beginning + EditorEnd = 16, // Move cursor to absolute end + GotoXY = 17, // Move cursor to specific coordinates, Data = PPoint + BlockStart = 18, // Move cursor to begin of block + BlockEnd = 19, // Move cursor to end of block //****************************************************************************** // Maybe the command processor should just take a boolean that signifies if // selection is affected or not? //****************************************************************************** - ecSelection = 100, // Add this to ecXXX command to get equivalent + Selection = 100, // Add this to ecXXX command to get equivalent // command, but with selection enabled. This is not // a command itself. // Same as commands above, except they affect selection, too - ecSelLeft = ecLeft + ecSelection, - ecSelRight = ecRight + ecSelection, - ecSelUp = ecUp + ecSelection, - ecSelDown = ecDown + ecSelection, - ecSelWordLeft = ecWordLeft + ecSelection, - ecSelWordRight = ecWordRight + ecSelection, - ecSelLineStart = ecLineStart + ecSelection, - ecSelLineEnd = ecLineEnd + ecSelection, - ecSelPageUp = ecPageUp + ecSelection, - ecSelPageDown = ecPageDown + ecSelection, - ecSelPageLeft = ecPageLeft + ecSelection, - ecSelPageRight = ecPageRight + ecSelection, - ecSelPageTop = ecPageTop + ecSelection, - ecSelPageBottom = ecPageBottom + ecSelection, - ecSelEditorStart = ecEditorStart + ecSelection, - ecSelEditorEnd = ecEditorEnd + ecSelection, - ecSelGotoXY = ecGotoXY + ecSelection, // Data = PPoint - ecSelBlockStart = ecBlockStart + ecSelection, // Move cursor to begin of scope - ecSelBlockEnd = ecBlockEnd + ecSelection, // Move cursor to end of scope + SelLeft = Left + Selection, + SelRight = Right + Selection, + SelUp = Up + Selection, + SelDown = Down + Selection, + SelWordLeft = WordLeft + Selection, + SelWordRight = WordRight + Selection, + SelLineStart = LineStart + Selection, + SelLineEnd = LineEnd + Selection, + SelPageUp = PageUp + Selection, + SelPageDown = PageDown + Selection, + SelPageLeft = PageLeft + Selection, + SelPageRight = PageRight + Selection, + SelPageTop = PageTop + Selection, + SelPageBottom = PageBottom + Selection, + SelEditorStart = EditorStart + Selection, + SelEditorEnd = EditorEnd + Selection, + SelGotoXY = GotoXY + Selection, // Data = PPoint + SelBlockStart = BlockStart + Selection, // Move cursor to begin of scope + SelBlockEnd = BlockEnd + Selection, // Move cursor to end of scope - ecCopy = 201, // Copy selection to clipboard - ecSelWord = 202, - ecSelectAll = 203, // Select entire contents of editor, cursor to end - ecExpandSelection = 204, // expand selection - ecShrinkSelection = 205, // shrink selection + Copy = 201, // Copy selection to clipboard + SelWord = 202, + SelectAll = 203, // Select entire contents of editor, cursor to end + ExpandSelection = 204, // expand selection + ShrinkSelection = 205, // shrink selection - ecScrollUp = 211, // Scroll up one line leaving cursor position unchanged. - ecScrollDown = 212, // Scroll down one line leaving cursor position unchanged. - ecScrollLeft = 213, // Scroll left one char leaving cursor position unchanged. - ecScrollRight = 214, // Scroll right one char leaving cursor position unchanged. + ScrollUp = 211, // Scroll up one line leaving cursor position unchanged. + ScrollDown = 212, // Scroll down one line leaving cursor position unchanged. + ScrollLeft = 213, // Scroll left one char leaving cursor position unchanged. + ScrollRight = 214, // Scroll right one char leaving cursor position unchanged. - ecInsertMode = 221, // Set insert mode - ecOverwriteMode = 222, // Set overwrite mode - ecToggleMode = 223, // Toggle ins/ovr mode + InsertMode = 221, // Set insert mode + OverwriteMode = 222, // Set overwrite mode + ToggleMode = 223, // Toggle ins/ovr mode - ecNormalSelect = 231, // Normal selection mode - ecColumnSelect = 232, // Column selection mode - ecLineSelect = 233, // Line selection mode + NormalSelect = 231, // Normal selection mode + ColumnSelect = 232, // Column selection mode + LineSelect = 233, // Line selection mode - ecMatchBracket = 250, // Go to matching bracket + MatchBracket = 250, // Go to matching bracket - ecContextHelp = 490, // Help on Word, Data = Word + ContextHelp = 490, // Help on Word, Data = Word - ecDeleteLastChar = 501, // Delete last char (i.e. backspace key) - ecDeleteChar = 502, // Delete char at cursor (i.e. delete key) - ecDeleteWordEnd = 503, // Delete from cursor to end of word - ecDeleteWordStart = 504, // Delete from cursor to start of word - ecDeleteBOL = 505, // Delete from cursor to beginning of line - ecDeleteEOL = 506, // Delete from cursor to end of line - ecDeleteLine = 507, // Delete current line - ecClearAll = 508, // Delete everything - ecLineBreak = 509, // Break line at current position, move caret to new line - ecInsertLine = 510, // Break line at current position, leave caret - ecChar = 511, // Insert a character at current position - ecDuplicateLine = 512, // Duplicate current line - ecMoveSelUp = 513, // Move selection up - ecMoveSelDown = 514, // Move selection down - ecImeStr = 550, // Insert character(s) from IME - ecDeleteWord = 551, // Delete current Word + DeleteLastChar = 501, // Delete last char (i.e. backspace key) + DeleteChar = 502, // Delete char at cursor (i.e. delete key) + DeleteWordEnd = 503, // Delete from cursor to end of word + DeleteWordStart = 504, // Delete from cursor to start of word + DeleteBOL = 505, // Delete from cursor to beginning of line + DeleteEOL = 506, // Delete from cursor to end of line + DeleteLine = 507, // Delete current line + ClearAll = 508, // Delete everything + LineBreak = 509, // Break line at current position, move caret to new line + InsertLine = 510, // Break line at current position, leave caret + Char = 511, // Insert a character at current position + DuplicateLine = 512, // Duplicate current line + MoveSelUp = 513, // Move selection up + MoveSelDown = 514, // Move selection down + ImeStr = 550, // Insert character(s) from IME + DeleteWord = 551, // Delete current Word - ecUndo = 601, // Perform undo if available - ecRedo = 602, // Perform redo if available - ecCut = 603, // Cut selection to clipboard - ecPaste = 604, // Paste clipboard to current position + Undo = 601, // Perform undo if available + Redo = 602, // Perform redo if available + Cut = 603, // Cut selection to clipboard + Paste = 604, // Paste clipboard to current position - ecBlockIndent = 610, // Indent selection - ecBlockUnindent = 611, // Unindent selection - ecTab = 612, // Tab key - ecShiftTab = 613, // Shift+Tab key - ecComment = 614, - ecUncomment = 615, - ecToggleComment = 616, - ecToggleBlockComment = 617, + BlockIndent = 610, // Indent selection + BlockUnindent = 611, // Unindent selection + Tab = 612, // Tab key + ShiftTab = 613, // Shift+Tab key + Comment = 614, + Uncomment = 615, + ToggleComment = 616, + ToggleBlockComment = 617, - ecUpperCase = 620, // apply to the current or previous word - ecLowerCase = 621, - ecToggleCase = 622, - ecTitleCase = 623, - ecUpperCaseBlock = 625, // apply to current selection, or current char if no selection - ecLowerCaseBlock = 626, - ecToggleCaseBlock = 627, + UpperCase = 620, // apply to the current or previous word + LowerCase = 621, + ToggleCase = 622, + TitleCase = 623, + UpperCaseBlock = 625, // apply to current selection, or current char if no selection + LowerCaseBlock = 626, + ToggleCaseBlock = 627, - ecString = 630, //Insert a whole string - ecZoomOut = 631, //Increase Font Size - ecZoomIn = 632, //Decrease Font Size + String = 630, //Insert a whole string + ZoomOut = 631, //Increase Font Size + ZoomIn = 632, //Decrease Font Size - ecLineBreakAtBegin = 651, //add a line break at the begin of the line - ecLineBreakAtEnd = 652, + LineBreakAtBegin = 651, //add a line break at the begin of the line + LineBreakAtEnd = 652, + + TrimTrailingSpaces = 653, //### Code Folding ### - ecCollapse = 700, - ecUncollapse = 701, - ecCollapseLevel = 702, - ecUncollapseLevel = 703, - ecCollapseAll = 704, - ecUncollapseAll = 705, + Collapse = 700, + Uncollapse = 701, + CollapseLevel = 702, + UncollapseLevel = 703, + CollapseAll = 704, + UncollapseAll = 705, //### End Code Folding ### - ecUserFirst = 1001, // Start of user-defined commands - - - + UserFirst = 1001, // Start of user-defined commands }; class KeyError: public BaseError { diff --git a/libs/qsynedit/qsynedit/SynEdit.cpp b/libs/qsynedit/qsynedit/SynEdit.cpp index 9ff7b091..cc492c60 100644 --- a/libs/qsynedit/qsynedit/SynEdit.cpp +++ b/libs/qsynedit/qsynedit/SynEdit.cpp @@ -462,6 +462,65 @@ void SynEdit::addSelectionToUndo() mBlockEnd,QStringList(),mActiveSelectionMode); } +void SynEdit::doTrimTrailingSpaces() +{ + if (mDocument->count()<=0) + return; + + if (mSyntaxer) { + for (int i=0;icount();i++) { + if (mDocument->ranges(i).hasTrailingSpaces) { + int line = i+1; + QString oldLine = mDocument->getString(i); + QString newLine = trimRight(oldLine); + if (newLine.isEmpty()) + continue; + properSetLine(i,newLine); + mUndoList->addChange( + ChangeReason::Delete, + BufferCoord{1,line}, + BufferCoord{oldLine.length()+1, line}, + QStringList(oldLine), + SelectionMode::Normal + ); + mUndoList->addChange( + ChangeReason::Insert, + BufferCoord{1, line}, + BufferCoord{newLine.length()+1, line}, + QStringList(), + SelectionMode::Normal + ); + } + } + + } else { + for (int i=0;icount();i++) { + int line = i+1; + QString oldLine = mDocument->getString(i); + QString newLine = trimRight(oldLine); + if (newLine.isEmpty()) + continue; + properSetLine(i,newLine); + mUndoList->addChange( + ChangeReason::Delete, + BufferCoord{1,line}, + BufferCoord{oldLine.length()+1, line}, + QStringList(oldLine), + SelectionMode::Normal + ); + mUndoList->addChange( + ChangeReason::Insert, + BufferCoord{1, line}, + BufferCoord{newLine.length()+1, line}, + QStringList(), + SelectionMode::Normal + ); + } + + } + mUndoList->endBlock(); +} + void SynEdit::beginUpdate() { incPaintLock(); @@ -2025,8 +2084,6 @@ void SynEdit::doDeleteLastChar() internalSetCaretX(mDocument->getString(mCaretY - 1).length() + 1); mDocument->deleteAt(mCaretY); doLinesDeleted(mCaretY+1, 1); - if (mOptions.testFlag(eoTrimTrailingSpaces)) - Temp = trimRight(Temp); setLineText(lineText() + Temp); helper.append(""); helper.append(""); @@ -3021,18 +3078,8 @@ void SynEdit::doCopyToClipboard() bool selected=selAvail(); if (!selected) doSelecteLine(); - bool ChangeTrim = (mActiveSelectionMode == SelectionMode::Column) && - mOptions.testFlag(eoTrimTrailingSpaces); QString sText; - { - auto action = finally([&,this] { - if (ChangeTrim) - mOptions.setFlag(eoTrimTrailingSpaces); - }); - if (ChangeTrim) - mOptions.setFlag(eoTrimTrailingSpaces,false); - sText = selText(); - } + sText = selText(); internalDoCopyToClipboard(sText); if (!selected) { setBlockBegin(caretXY()); @@ -3867,7 +3914,7 @@ EditCommand SynEdit::TranslateKeyCode(int key, Qt::KeyboardModifiers modifiers) { PEditKeyStroke keyStroke = mKeyStrokes.findKeycode2(mLastKey,mLastKeyModifiers, key, modifiers); - EditCommand cmd=EditCommand::ecNone; + EditCommand cmd=EditCommand::None; if (keyStroke) cmd = keyStroke->command(); else { @@ -3875,7 +3922,7 @@ EditCommand SynEdit::TranslateKeyCode(int key, Qt::KeyboardModifiers modifiers) if (keyStroke) cmd = keyStroke->command(); } - if (cmd == EditCommand::ecNone) { + if (cmd == EditCommand::None) { mLastKey = key; mLastKeyModifiers = modifiers; } else { @@ -4147,9 +4194,9 @@ void SynEdit::setOptions(const EditorOptions &Value) //if (!mOptions.testFlag(eoScrollPastEof)) setTopLine(mTopLine); - bool bUpdateAll = Value.testFlag(eoShowSpecialChars) != mOptions.testFlag(eoShowSpecialChars); - if (!bUpdateAll) - bUpdateAll = Value.testFlag(eoShowRainbowColor) != mOptions.testFlag(eoShowRainbowColor); + bool bUpdateAll = + (Value.testFlag(eoShowSpecialChars) != mOptions.testFlag(eoShowSpecialChars)) + || (Value.testFlag(eoShowRainbowColor) != mOptions.testFlag(eoShowRainbowColor)); //bool bUpdateScroll = (Options * ScrollOptions)<>(Value * ScrollOptions); bool bUpdateScroll = true; mOptions = Value; @@ -4525,7 +4572,7 @@ void SynEdit::doRedoItem() item->changeEndPos(),item->changeText(), item->changeSelMode(),item->changeNumber()); setCaretAndSelection(CaretPt, CaretPt, CaretPt); - commandProcessor(EditCommand::ecLineBreak); + processCommand(EditCommand::LineBreak); break; } default: @@ -4791,11 +4838,11 @@ bool SynEdit::empty() return mDocument->empty(); } -void SynEdit::commandProcessor(EditCommand Command, QChar AChar, void *pData) +void SynEdit::processCommand(EditCommand Command, QChar AChar, void *pData) { // first the program event handler gets a chance to process the command onProcessCommand(Command, AChar, pData); - if (Command != EditCommand::ecNone) + if (Command != EditCommand::None) executeCommand(Command, AChar, pData); onCommandProcessed(Command, AChar, pData); } @@ -5306,11 +5353,7 @@ void SynEdit::doLinesInserted(int firstLine, int count) void SynEdit::properSetLine(int ALine, const QString &ALineText, bool notify) { - if (mOptions.testFlag(eoTrimTrailingSpaces)) { - mDocument->putString(ALine,trimRight(ALineText),notify); - } else { - mDocument->putString(ALine,ALineText,notify); - } + mDocument->putString(ALine,ALineText,notify); } void SynEdit::doDeleteText(BufferCoord startPos, BufferCoord endPos, SelectionMode mode) @@ -5520,10 +5563,7 @@ int SynEdit::doInsertTextByNormalMode(const BufferCoord& pos, const QStringList& if (bChangeScroll) mOptions.setFlag(eoScrollPastEol,false); }); - if (mOptions.testFlag(eoTrimTrailingSpaces) && (sRightSide == "")) { - newPos=BufferCoord{mDocument->getString(caretY-1).length()+1,caretY}; - } else - newPos=BufferCoord{str.length() - sRightSide.length()+1,caretY}; + newPos=BufferCoord{str.length() - sRightSide.length()+1,caretY}; onLinesPutted(startLine-1,result+1); if (!mUndoing) { mUndoList->addChange( @@ -5699,43 +5739,43 @@ void SynEdit::executeCommand(EditCommand command, QChar ch, void *pData) }); switch(command) { //horizontal caret movement or selection - case EditCommand::ecLeft: - case EditCommand::ecSelLeft: - moveCaretHorz(-1, command == EditCommand::ecSelLeft); + case EditCommand::Left: + case EditCommand::SelLeft: + moveCaretHorz(-1, command == EditCommand::SelLeft); break; - case EditCommand::ecRight: - case EditCommand::ecSelRight: - moveCaretHorz(1, command == EditCommand::ecSelRight); + case EditCommand::Right: + case EditCommand::SelRight: + moveCaretHorz(1, command == EditCommand::SelRight); break; - case EditCommand::ecPageLeft: - case EditCommand::ecSelPageLeft: - moveCaretHorz(-mCharsInWindow, command == EditCommand::ecSelPageLeft); + case EditCommand::PageLeft: + case EditCommand::SelPageLeft: + moveCaretHorz(-mCharsInWindow, command == EditCommand::SelPageLeft); break; - case EditCommand::ecPageRight: - case EditCommand::ecSelPageRight: - moveCaretHorz(mCharsInWindow, command == EditCommand::ecSelPageRight); + case EditCommand::PageRight: + case EditCommand::SelPageRight: + moveCaretHorz(mCharsInWindow, command == EditCommand::SelPageRight); break; - case EditCommand::ecLineStart: - case EditCommand::ecSelLineStart: - moveCaretToLineStart(command == EditCommand::ecSelLineStart); + case EditCommand::LineStart: + case EditCommand::SelLineStart: + moveCaretToLineStart(command == EditCommand::SelLineStart); break; - case EditCommand::ecLineEnd: - case EditCommand::ecSelLineEnd: - moveCaretToLineEnd(command == EditCommand::ecSelLineEnd); + case EditCommand::LineEnd: + case EditCommand::SelLineEnd: + moveCaretToLineEnd(command == EditCommand::SelLineEnd); break; // vertical caret movement or selection - case EditCommand::ecUp: - case EditCommand::ecSelUp: - moveCaretVert(-1, command == EditCommand::ecSelUp); + case EditCommand::Up: + case EditCommand::SelUp: + moveCaretVert(-1, command == EditCommand::SelUp); break; - case EditCommand::ecDown: - case EditCommand::ecSelDown: - moveCaretVert(1, command == EditCommand::ecSelDown); + case EditCommand::Down: + case EditCommand::SelDown: + moveCaretVert(1, command == EditCommand::SelDown); break; - case EditCommand::ecPageUp: - case EditCommand::ecSelPageUp: - case EditCommand::ecPageDown: - case EditCommand::ecSelPageDown: + case EditCommand::PageUp: + case EditCommand::SelPageUp: + case EditCommand::PageDown: + case EditCommand::SelPageDown: { int counter = mLinesInWindow; if (mOptions.testFlag(eoHalfPageScroll)) @@ -5745,112 +5785,112 @@ void SynEdit::executeCommand(EditCommand command, QChar ch, void *pData) } if (counter<0) break; - if (command == EditCommand::ecPageUp || command == EditCommand::ecSelPageUp) { + if (command == EditCommand::PageUp || command == EditCommand::SelPageUp) { counter = -counter; } - moveCaretVert(counter, command == EditCommand::ecSelPageUp || command == EditCommand::ecSelPageDown); + moveCaretVert(counter, command == EditCommand::SelPageUp || command == EditCommand::SelPageDown); break; } - case EditCommand::ecPageTop: - case EditCommand::ecSelPageTop: - moveCaretVert(mTopLine-mCaretY, command == EditCommand::ecSelPageTop); + case EditCommand::PageTop: + case EditCommand::SelPageTop: + moveCaretVert(mTopLine-mCaretY, command == EditCommand::SelPageTop); break; - case EditCommand::ecPageBottom: - case EditCommand::ecSelPageBottom: - moveCaretVert(mTopLine+mLinesInWindow-1-mCaretY, command == EditCommand::ecSelPageBottom); + case EditCommand::PageBottom: + case EditCommand::SelPageBottom: + moveCaretVert(mTopLine+mLinesInWindow-1-mCaretY, command == EditCommand::SelPageBottom); break; - case EditCommand::ecEditorStart: - case EditCommand::ecSelEditorStart: - doGotoEditorStart(command == EditCommand::ecSelEditorStart); + case EditCommand::EditorStart: + case EditCommand::SelEditorStart: + doGotoEditorStart(command == EditCommand::SelEditorStart); break; - case EditCommand::ecEditorEnd: - case EditCommand::ecSelEditorEnd: - doGotoEditorEnd(command == EditCommand::ecSelEditorEnd); + case EditCommand::EditorEnd: + case EditCommand::SelEditorEnd: + doGotoEditorEnd(command == EditCommand::SelEditorEnd); break; - case EditCommand::ecBlockStart: - case EditCommand::ecSelBlockStart: - doGotoBlockStart(command == EditCommand::ecSelBlockStart); + case EditCommand::BlockStart: + case EditCommand::SelBlockStart: + doGotoBlockStart(command == EditCommand::SelBlockStart); break; - case EditCommand::ecBlockEnd: - case EditCommand::ecSelBlockEnd: - doGotoBlockEnd(command == EditCommand::ecSelBlockEnd); + case EditCommand::BlockEnd: + case EditCommand::SelBlockEnd: + doGotoBlockEnd(command == EditCommand::SelBlockEnd); break; // goto special line / column position - case EditCommand::ecGotoXY: - case EditCommand::ecSelGotoXY: + case EditCommand::GotoXY: + case EditCommand::SelGotoXY: if (pData) - moveCaretAndSelection(caretXY(), *((BufferCoord *)(pData)), command == EditCommand::ecSelGotoXY); + moveCaretAndSelection(caretXY(), *((BufferCoord *)(pData)), command == EditCommand::SelGotoXY); break; // word selection - case EditCommand::ecWordLeft: - case EditCommand::ecSelWordLeft: + case EditCommand::WordLeft: + case EditCommand::SelWordLeft: { BufferCoord CaretNew = prevWordPos(); - moveCaretAndSelection(caretXY(), CaretNew, command == EditCommand::ecSelWordLeft); + moveCaretAndSelection(caretXY(), CaretNew, command == EditCommand::SelWordLeft); break; } - case EditCommand::ecWordRight: - case EditCommand::ecSelWordRight: + case EditCommand::WordRight: + case EditCommand::SelWordRight: { BufferCoord CaretNew = nextWordPos(); - moveCaretAndSelection(caretXY(), CaretNew, command == EditCommand::ecSelWordRight); + moveCaretAndSelection(caretXY(), CaretNew, command == EditCommand::SelWordRight); break; } - case EditCommand::ecSelWord: + case EditCommand::SelWord: setSelWord(); break; - case EditCommand::ecSelectAll: + case EditCommand::SelectAll: doSelectAll(); break; - case EditCommand::ecExpandSelection: + case EditCommand::ExpandSelection: doExpandSelection(caretXY()); break; - case EditCommand::ecShrinkSelection: + case EditCommand::ShrinkSelection: doShrinkSelection(caretXY()); break; - case EditCommand::ecDeleteLastChar: + case EditCommand::DeleteLastChar: doDeleteLastChar(); break; - case EditCommand::ecDeleteChar: + case EditCommand::DeleteChar: doDeleteCurrentChar(); break; - case EditCommand::ecDeleteWord: + case EditCommand::DeleteWord: doDeleteWord(); break; - case EditCommand::ecDeleteEOL: + case EditCommand::DeleteEOL: doDeleteToEOL(); break; - case EditCommand::ecDeleteWordStart: + case EditCommand::DeleteWordStart: doDeleteToWordStart(); break; - case EditCommand::ecDeleteWordEnd: + case EditCommand::DeleteWordEnd: doDeleteToWordEnd(); break; - case EditCommand::ecDeleteBOL: + case EditCommand::DeleteBOL: doDeleteFromBOL(); break; - case EditCommand::ecDeleteLine: + case EditCommand::DeleteLine: doDeleteLine(); break; - case EditCommand::ecDuplicateLine: + case EditCommand::DuplicateLine: doDuplicateLine(); break; - case EditCommand::ecMoveSelUp: + case EditCommand::MoveSelUp: doMoveSelUp(); break; - case EditCommand::ecMoveSelDown: + case EditCommand::MoveSelDown: doMoveSelDown(); break; - case EditCommand::ecClearAll: + case EditCommand::ClearAll: clearAll(); break; - case EditCommand::ecInsertLine: + case EditCommand::InsertLine: insertLine(false); break; - case EditCommand::ecLineBreak: + case EditCommand::LineBreak: insertLine(true); break; - case EditCommand::ecLineBreakAtEnd: + case EditCommand::LineBreakAtEnd: mUndoList->beginBlock(); addCaretToUndo(); addSelectionToUndo(); @@ -5858,98 +5898,102 @@ void SynEdit::executeCommand(EditCommand command, QChar ch, void *pData) insertLine(true); mUndoList->endBlock(); break; - case EditCommand::ecTab: + case EditCommand::Tab: doTabKey(); break; - case EditCommand::ecShiftTab: + case EditCommand::ShiftTab: doShiftTabKey(); break; - case EditCommand::ecChar: + case EditCommand::Char: doAddChar(ch); break; - case EditCommand::ecInsertMode: + case EditCommand::InsertMode: if (!mReadOnly) setInsertMode(true); break; - case EditCommand::ecOverwriteMode: + case EditCommand::OverwriteMode: if (!mReadOnly) setInsertMode(false); break; - case EditCommand::ecToggleMode: + case EditCommand::ToggleMode: if (!mReadOnly) { setInsertMode(!mInserting); } break; - case EditCommand::ecCut: + case EditCommand::Cut: if (!mReadOnly) doCutToClipboard(); break; - case EditCommand::ecCopy: + case EditCommand::Copy: doCopyToClipboard(); break; - case EditCommand::ecPaste: + case EditCommand::Paste: if (!mReadOnly) doPasteFromClipboard(); break; - case EditCommand::ecImeStr: - case EditCommand::ecString: + case EditCommand::ImeStr: + case EditCommand::String: if (!mReadOnly) doAddStr(*((QString*)pData)); break; - case EditCommand::ecUndo: + case EditCommand::Undo: if (!mReadOnly) doUndo(); break; - case EditCommand::ecRedo: + case EditCommand::Redo: if (!mReadOnly) doRedo(); break; - case EditCommand::ecZoomIn: + case EditCommand::ZoomIn: doZoomIn(); break; - case EditCommand::ecZoomOut: + case EditCommand::ZoomOut: doZoomOut(); break; - case EditCommand::ecComment: + case EditCommand::Comment: doComment(); break; - case EditCommand::ecUncomment: + case EditCommand::Uncomment: doUncomment(); break; - case EditCommand::ecToggleComment: + case EditCommand::ToggleComment: doToggleComment(); break; - case EditCommand::ecToggleBlockComment: + case EditCommand::ToggleBlockComment: doToggleBlockComment(); break; - case EditCommand::ecNormalSelect: + case EditCommand::NormalSelect: setSelectionMode(SelectionMode::Normal); break; - case EditCommand::ecLineSelect: + case EditCommand::LineSelect: setSelectionMode(SelectionMode::Line); break; - case EditCommand::ecColumnSelect: + case EditCommand::ColumnSelect: setSelectionMode(SelectionMode::Column); break; - case EditCommand::ecScrollLeft: + case EditCommand::ScrollLeft: horizontalScrollBar()->setValue(horizontalScrollBar()->value()-mMouseWheelScrollSpeed); break; - case EditCommand::ecScrollRight: + case EditCommand::ScrollRight: horizontalScrollBar()->setValue(horizontalScrollBar()->value()+mMouseWheelScrollSpeed); break; - case EditCommand::ecScrollUp: + case EditCommand::ScrollUp: verticalScrollBar()->setValue(verticalScrollBar()->value()-mMouseWheelScrollSpeed); break; - case EditCommand::ecScrollDown: + case EditCommand::ScrollDown: verticalScrollBar()->setValue(verticalScrollBar()->value()+mMouseWheelScrollSpeed); break; - case EditCommand::ecMatchBracket: + case EditCommand::MatchBracket: { BufferCoord coord = getMatchingBracket(); if (coord.ch!=0 && coord.line!=0) internalSetCaretXY(coord); } break; + case EditCommand::TrimTrailingSpaces: + if (!mReadOnly) + doTrimTrailingSpaces(); + break; default: break; } @@ -6169,13 +6213,13 @@ void SynEdit::keyPressEvent(QKeyEvent *event) event->accept(); } else { EditCommand cmd=TranslateKeyCode(event->key(),event->modifiers()); - if (cmd!=EditCommand::ecNone) { - commandProcessor(cmd,QChar(),nullptr); + if (cmd!=EditCommand::None) { + processCommand(cmd,QChar(),nullptr); event->accept(); } else if (!event->text().isEmpty()) { QChar c = event->text().at(0); if (c=='\t' || c.isPrint()) { - commandProcessor(EditCommand::ecChar,c,nullptr); + processCommand(EditCommand::Char,c,nullptr); event->accept(); } } @@ -6306,8 +6350,9 @@ void SynEdit::mouseDoubleClickEvent(QMouseEvent *event) QAbstractScrollArea::mouseDoubleClickEvent(event); QPoint ptMouse = event->pos(); if (ptMouse.x() >= mGutterWidth + 2) { - setSelWord(); - mStateFlags.setFlag(StateFlag::sfDblClicked); + if (mOptions.testFlag(EditorOption::eoSelectWordByDblClick)) + setSelWord(); + mStateFlags.setFlag(StateFlag::sfDblClicked); } } @@ -6328,7 +6373,7 @@ void SynEdit::inputMethodEvent(QInputMethodEvent *event) } QString s = event->commitString(); if (!s.isEmpty()) { - commandProcessor(EditCommand::ecImeStr,QChar(),&s); + processCommand(EditCommand::ImeStr,QChar(),&s); // for (QChar ch:s) { // CommandProcessor(SynEditorCommand::ecChar,ch); // } diff --git a/libs/qsynedit/qsynedit/SynEdit.h b/libs/qsynedit/qsynedit/SynEdit.h index bffe6576..92a21059 100644 --- a/libs/qsynedit/qsynedit/SynEdit.h +++ b/libs/qsynedit/qsynedit/SynEdit.h @@ -74,36 +74,27 @@ Q_DECLARE_FLAGS(StateFlags,StateFlag) Q_DECLARE_OPERATORS_FOR_FLAGS(StateFlags) 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 - eoDragDropEditing = 0x00000008, //Allows you to select a block of text and drag it within the document to another location - eoDropFiles = 0x00000010, //Allows the editor accept OLE file drops - eoEnhanceHomeKey = 0x00000020, //enhances home key positioning, similar to visual studio - eoEnhanceEndKey = 0x00000040, //enhances End key positioning, similar to JDeveloper - eoGroupUndo = 0x00000080, //When undoing/redoing actions, handle all continous changes of the same kind in one call instead undoing/redoing each command separately - eoHalfPageScroll = 0x00000100, //When scrolling with page-up and page-down commands, only scroll a half page at a time - eoHideShowScrollbars =0x00000200, //if enabled, then the scrollbars will only show when necessary. If you have ScrollPastEOL, then it the horizontal bar will always be there (it uses MaxLength instead) - eoKeepCaretX = 0x00000400 , //When moving through lines w/o Cursor Past EOL, keeps the X position of the cursor - eoRightMouseMovesCursor= 0x00000800, //When clicking with the right mouse for a popup menu, move the cursor to that location - eoScrollByOneLess = 0x00001000, //Forces scrolling to be one less - eoScrollPastEof = 0x00002000, //Allows the cursor to go past the end of file marker - eoScrollPastEol = 0x00004000, //Allows the cursor to go past the last character into the white space at the end of a line - eoShowSpecialChars = 0x00008000, //Shows the special Characters + 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 + eoDragDropEditing = 0x00000008, //Allows you to select a block of text and drag it within the document to another location + eoDropFiles = 0x00000010, //Allows the editor accept OLE file drops + eoEnhanceHomeKey = 0x00000020, //enhances home key positioning, similar to visual studio + eoEnhanceEndKey = 0x00000040, //enhances End key positioning, similar to JDeveloper + eoGroupUndo = 0x00000080, //When undoing/redoing actions, handle all continous changes of the same kind in one call instead undoing/redoing each command separately + eoHalfPageScroll = 0x00000100, //When scrolling with page-up and page-down commands, only scroll a half page at a time + eoHideShowScrollbars = 0x00000200, //if enabled, then the scrollbars will only show when necessary. If you have ScrollPastEOL, then it the horizontal bar will always be there (it uses MaxLength instead) + eoKeepCaretX = 0x00000400 , //When moving through lines w/o Cursor Past EOL, keeps the X position of the cursor + eoRightMouseMovesCursor= 0x00000800, //When clicking with the right mouse for a popup menu, move the cursor to that location + eoScrollByOneLess = 0x00001000, //Forces scrolling to be one less + eoScrollPastEof = 0x00002000, //Allows the cursor to go past the end of file marker + eoScrollPastEol = 0x00004000, //Allows the cursor to go past the last character into the white space at the end of a line + eoShowSpecialChars = 0x00008000, //Shows the special Characters // eoSpecialLineDefaultFg = 0x00010000, //disables the foreground text color override when using the OnSpecialLineColor event - eoTabIndent = 0x00020000, //When active and act as block indent, unindent when text is selected - eoTabsToSpaces = 0x00040000, //Converts a tab character to a specified number of space characters - eoShowRainbowColor = 0x00080000, - eoTrimTrailingSpaces =0x00100000, //Spaces at the end of lines will be trimmed and not saved - eoSelectWordByDblClick=0x00200000, -// eoNoSelection = 0x00400000, //Disables selecting text - //eoAutoSizeMaxScrollWidth = 0x00000008, //Automatically resizes the MaxScrollWidth property when inserting text - //eoDisableScrollArrows = 0x00000010 , //Disables the scroll bar arrow buttons when you can't scroll in that direction any more - // eoScrollHintFollows = 0x00020000, //The scroll hint follows the mouse when scrolling vertically - // eoShowScrollHint = 0x00100000, //Shows a hint of the visible line numbers when scrolling vertically - // eoSmartTabDelete = 0x00400000, //similar to Smart Tabs, but when you delete characters - // eoSmartTabs = 0x00800000, //When tabbing, the cursor will go to the next non-white space character of the previous line - // eoNoCaret = 0x00000800, //Makes it so the caret is never visible + eoTabIndent = 0x00020000, //When active and act as block indent, unindent when text is selected + eoTabsToSpaces = 0x00040000, //Converts a tab character to a specified number of space characters + eoShowRainbowColor = 0x00080000, + eoSelectWordByDblClick= 0x00100000, }; Q_DECLARE_FLAGS(EditorOptions, EditorOption) @@ -215,7 +206,7 @@ public: BufferCoord prevWordPos(); BufferCoord prevWordPosEx(const BufferCoord& XY); - void commandProcessor(EditCommand Command, QChar AChar = QChar(), void * pData = nullptr); + void processCommand(EditCommand Command, QChar AChar = QChar(), void * pData = nullptr); //Caret void showCaret(); void hideCaret(); @@ -261,28 +252,31 @@ public: selectAll(); setSelText(text); } + void trimTrailingSpaces() { + processCommand(EditCommand::TrimTrailingSpaces); + } //Commands - 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 cutToClipboard() { processCommand(EditCommand::Cut);} + virtual void copyToClipboard() { processCommand(EditCommand::Copy);} + virtual void pasteFromClipboard() { processCommand(EditCommand::Paste);} + virtual void undo() { processCommand(EditCommand::Undo);} + virtual void redo() { processCommand(EditCommand::Redo);} + virtual void zoomIn() { processCommand(EditCommand::ZoomIn);} + virtual void zoomOut() { processCommand(EditCommand::ZoomOut);} virtual void selectAll() { - commandProcessor(EditCommand::ecSelectAll); + processCommand(EditCommand::SelectAll); } virtual void selectWord() { - commandProcessor(EditCommand::ecSelWord); + processCommand(EditCommand::SelWord); } - 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 tab() { processCommand(EditCommand::Tab);} + virtual void shifttab() { processCommand(EditCommand::ShiftTab);} + virtual void toggleComment() { processCommand(EditCommand::ToggleComment);} + virtual void toggleBlockComment() { processCommand(EditCommand::ToggleBlockComment);} + virtual void matchBracket() { processCommand(EditCommand::MatchBracket);} + virtual void moveSelUp(){ processCommand(EditCommand::MoveSelUp);} + virtual void moveSelDown(){ processCommand(EditCommand::MoveSelDown);} virtual void beginUpdate(); virtual void endUpdate(); @@ -555,6 +549,7 @@ private: int doInsertTextByColumnMode(const BufferCoord& pos, const QStringList& text, BufferCoord &newPos, int startLine, int endLine); int doInsertTextByLineMode(const BufferCoord& pos, const QStringList& text, BufferCoord &newPos); + void doTrimTrailingSpaces(); void deleteFromTo(const BufferCoord& start, const BufferCoord& end); void setSelWord(); void setWordBlock(BufferCoord value); diff --git a/libs/qsynedit/qsynedit/TextPainter.cpp b/libs/qsynedit/qsynedit/TextPainter.cpp index d72246ee..64b28bc1 100644 --- a/libs/qsynedit/qsynedit/TextPainter.cpp +++ b/libs/qsynedit/qsynedit/TextPainter.cpp @@ -389,9 +389,26 @@ void SynEditTextPainter::paintToken(const QString &token, int tokenCols, int col drawed = true; } if (!drawed) { - if (token[i].unicode()<=0xFF) - painter->drawText(nX,rcToken.bottom()-painter->fontMetrics().descent() , token[i]); - else { + if (token[i].unicode()<=0xFF) { + QChar ch; + int padding=0; + if (edit->mOptions.testFlag(eoShowSpecialChars)) { + switch(token[i].unicode()) { + case '\t': + ch=TabGlyph; + padding=(charCols-1)/2*edit->mCharWidth; + break; + case ' ': + ch=SpaceGlyph; + break; + default: + ch=token[i]; + } + } else { + ch=token[i]; + } + painter->drawText(nX+padding,rcToken.bottom()-painter->fontMetrics().descent() , ch); + } else { painter->setFont(fontForNonAscii); painter->drawText(nX,rcToken.bottom()-painter->fontMetrics().descent() , token[i]); painter->setFont(font); diff --git a/libs/qsynedit/qsynedit/syntaxer/asm.cpp b/libs/qsynedit/qsynedit/syntaxer/asm.cpp index 901cbeb1..6590446d 100644 --- a/libs/qsynedit/qsynedit/syntaxer/asm.cpp +++ b/libs/qsynedit/qsynedit/syntaxer/asm.cpp @@ -242,6 +242,8 @@ void ASMSyntaxer::SpaceProc() if (mLine[mRun] > 32) break; } + if (mRun>=mStringLen) + mHasTrailingSpaces = true; } void ASMSyntaxer::StringProc() @@ -441,17 +443,19 @@ bool ASMSyntaxer::isLastLineStringNotFinished(int /*state*/) const SyntaxerState ASMSyntaxer::getState() const { - return SyntaxerState(); + SyntaxerState state; + state.hasTrailingSpaces = mHasTrailingSpaces; + return state; } void ASMSyntaxer::setState(const SyntaxerState&) { - + mHasTrailingSpaces = false; } void ASMSyntaxer::resetState() { - + mHasTrailingSpaces = false; } QSet ASMSyntaxer::keywords() const diff --git a/libs/qsynedit/qsynedit/syntaxer/asm.h b/libs/qsynedit/qsynedit/syntaxer/asm.h index 1d23d7ab..1b02d870 100644 --- a/libs/qsynedit/qsynedit/syntaxer/asm.h +++ b/libs/qsynedit/qsynedit/syntaxer/asm.h @@ -61,6 +61,7 @@ private: QChar mToIdent; int mTokenPos; TokenId mTokenID; + bool mHasTrailingSpaces; PTokenAttribute mNumberAttribute; PTokenAttribute mDirectiveAttribute; PTokenAttribute mRegisterAttribute; diff --git a/libs/qsynedit/qsynedit/syntaxer/cpp.cpp b/libs/qsynedit/qsynedit/syntaxer/cpp.cpp index 20b3d3d6..0eb3c7d8 100644 --- a/libs/qsynedit/qsynedit/syntaxer/cpp.cpp +++ b/libs/qsynedit/qsynedit/syntaxer/cpp.cpp @@ -290,20 +290,17 @@ void CppSyntaxer::andSymbolProc() void CppSyntaxer::ansiCppProc() { mTokenId = TokenId::Comment; - if (mRun>=mLineSize) { - nullProc(); - if ( (mRun-1<0) || (mLine[mRun-1]!='\\')) { - mRange.state = RangeState::rsUnknown; - } - return; - } while (mRun=0 && mLine[mRun-1] == '\\' ) { // continues on next line + mRange.state = RangeState::rsCppComment; + } else + mRange.state = RangeState::rsUnknown; } void CppSyntaxer::ansiCProc() @@ -316,6 +313,9 @@ void CppSyntaxer::ansiCProc() } while (mRun=0) - && (mRun-1=1 && mLine[mRun]<=32) mRun+=1; - mRange.state = RangeState::rsUnknown; + if (mRun>=mLineSize) + mRange.hasTrailingSpaces = true; } void CppSyntaxer::squareCloseProc() @@ -1015,60 +1008,62 @@ void CppSyntaxer::starProc() } } -void CppSyntaxer::stringEndProc() -{ - mTokenId = TokenId::String; - if (mRun>=mLineSize) { - nullProc(); - return; - } - mRange.state = RangeState::rsUnknown; +//void CppSyntaxer::stringEndProc() +//{ +// mTokenId = TokenId::String; +// if (mRun>=mLineSize) { +// nullProc(); +// return; +// } +// mRange.state = RangeState::rsUnknown; - while (mRun=1 && mLine[mRun]<=32) mRun+=1; mRange.state = RangeState::rsUnknown; + if (mRun>=mLineSize) + mRange.hasTrailingSpaces=true; } void GLSLSyntaxer::squareCloseProc() @@ -1284,8 +1262,6 @@ bool GLSLSyntaxer::getTokenFinished() const bool GLSLSyntaxer::isLastLineCommentNotFinished(int state) const { return (state == RangeState::rsAnsiC || - state == RangeState::rsAnsiCAsm || - state == RangeState::rsAnsiCAsmBlock || state == RangeState::rsDirectiveComment|| state == RangeState::rsCppComment); } @@ -1353,13 +1329,10 @@ int GLSLSyntaxer::getTokenPos() void GLSLSyntaxer::next() { - mAsmStart = false; mTokenPos = mRun; do { switch (mRange.state) { case RangeState::rsAnsiC: - case RangeState::rsAnsiCAsm: - case RangeState::rsAnsiCAsmBlock: case RangeState::rsDirectiveComment: ansiCProc(); break; @@ -1439,6 +1412,7 @@ void GLSLSyntaxer::setState(const SyntaxerState& rangeState) mRange.blockEndedLastLine = 0; mRange.firstIndentThisLine = mRange.indents.length(); mRange.matchingIndents.clear(); + mRange.hasTrailingSpaces = false; } void GLSLSyntaxer::resetState() @@ -1454,7 +1428,7 @@ void GLSLSyntaxer::resetState() mRange.indents.clear(); mRange.firstIndentThisLine = 0; mRange.matchingIndents.clear(); - mAsmStart = false; + mRange.hasTrailingSpaces = false; } QString GLSLSyntaxer::languageName() diff --git a/libs/qsynedit/qsynedit/syntaxer/glsl.h b/libs/qsynedit/qsynedit/syntaxer/glsl.h index 13e4a317..e8863b02 100644 --- a/libs/qsynedit/qsynedit/syntaxer/glsl.h +++ b/libs/qsynedit/qsynedit/syntaxer/glsl.h @@ -45,8 +45,7 @@ class GLSLSyntaxer: public Syntaxer }; enum RangeState { - rsUnknown, rsAnsiC, rsAnsiCAsm, rsAnsiCAsmBlock, rsAsm, - rsAsmBlock, rsDirective, rsDirectiveComment, rsString, + rsUnknown, rsAnsiC, rsDirective, rsDirectiveComment, rsString, rsMultiLineString, rsMultiLineDirective, rsCppComment, rsStringEscapeSeq, rsMultiLineStringEscapeSeq, rsRawString, rsSpace,rsRawStringEscaping,rsRawStringNotEscaping,rsChar, @@ -133,7 +132,6 @@ private: void pushIndents(int indentType); private: - bool mAsmStart; SyntaxerState mRange; // SynRangeState mSpaceRange; QString mLineString; diff --git a/libs/qsynedit/qsynedit/syntaxer/makefile.cpp b/libs/qsynedit/qsynedit/syntaxer/makefile.cpp index c88abd03..1b06792c 100644 --- a/libs/qsynedit/qsynedit/syntaxer/makefile.cpp +++ b/libs/qsynedit/qsynedit/syntaxer/makefile.cpp @@ -201,6 +201,8 @@ void MakefileSyntaxer::procSpace() mTokenID = TokenId::Space; while (mLine[mRun]!=0 && mLine[mRun]<=32) mRun++; + if (mRun>=mStringLen) + mHasTrailingSpaces = true; } void MakefileSyntaxer::procNumber() @@ -666,6 +668,7 @@ SyntaxerState MakefileSyntaxer::getState() const { SyntaxerState state; state.state = (int)mState; + state.hasTrailingSpaces = mHasTrailingSpaces; return state; } @@ -673,12 +676,14 @@ void MakefileSyntaxer::setState(const SyntaxerState & rangeState) { mState = (RangeState)rangeState.state; mStates.clear(); + mHasTrailingSpaces = false; } void MakefileSyntaxer::resetState() { mState = RangeState::Unknown; mStates.clear(); + mHasTrailingSpaces = false; } QSet MakefileSyntaxer::keywords() const diff --git a/libs/qsynedit/qsynedit/syntaxer/makefile.h b/libs/qsynedit/qsynedit/syntaxer/makefile.h index 2749fd7e..105bd912 100644 --- a/libs/qsynedit/qsynedit/syntaxer/makefile.h +++ b/libs/qsynedit/qsynedit/syntaxer/makefile.h @@ -79,6 +79,7 @@ private: QVector mStates; RangeState mState; TokenId mTokenID; + bool mHasTrailingSpaces; PTokenAttribute mTargetAttribute; PTokenAttribute mCommandAttribute; diff --git a/libs/qsynedit/qsynedit/syntaxer/syntaxer.cpp b/libs/qsynedit/qsynedit/syntaxer/syntaxer.cpp index 479b862e..9ac5bd63 100644 --- a/libs/qsynedit/qsynedit/syntaxer/syntaxer.cpp +++ b/libs/qsynedit/qsynedit/syntaxer/syntaxer.cpp @@ -274,7 +274,8 @@ SyntaxerState::SyntaxerState(): parenthesisLevel(0), // leftBraces(0), // rightBraces(0), - firstIndentThisLine(0) + firstIndentThisLine(0), + hasTrailingSpaces(false) { } } diff --git a/libs/qsynedit/qsynedit/syntaxer/syntaxer.h b/libs/qsynedit/qsynedit/syntaxer/syntaxer.h index fed3197a..85eee161 100644 --- a/libs/qsynedit/qsynedit/syntaxer/syntaxer.h +++ b/libs/qsynedit/qsynedit/syntaxer/syntaxer.h @@ -51,6 +51,7 @@ struct SyntaxerState { QVector matchingIndents; /* the indent matched ( and removed ) but not started at this line (need by auto indent) */ + bool hasTrailingSpaces; bool operator==(const SyntaxerState& s2); int getLastIndent(); SyntaxerState();