From 69ba84fc86503dafb9e6fadf6860fb390a2eb4ad Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Mon, 22 Nov 2021 18:42:58 +0800 Subject: [PATCH 1/4] - fix: the count in the title of issues view isn't correct --- NEWS.md | 3 +++ RedPandaIDE/compiler/compilermanager.cpp | 5 +++-- RedPandaIDE/mainwindow.ui | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index a918d8aa..9604af37 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +Version 0.9.3 For Dev-C++ 7 Beta + - fix: the count in the title of issues view isn't correct + Version 0.9.2 For Dev-C++ 7 Beta - fix: gutter of the disassembly code control in the cpu info dialog is grayed - fix: problem set & problem views not correctly hidden when disabled in the executor / problem set options diff --git a/RedPandaIDE/compiler/compilermanager.cpp b/RedPandaIDE/compiler/compilermanager.cpp index 9c680f9e..9caf66f2 100644 --- a/RedPandaIDE/compiler/compilermanager.cpp +++ b/RedPandaIDE/compiler/compilermanager.cpp @@ -330,8 +330,9 @@ void CompilerManager::onSyntaxCheckIssue(PCompileIssue issue) { if (issue->type == CompileIssueType::Error) mSyntaxCheckErrorCount++; - mSyntaxCheckIssueCount++; - + if (issue->type == CompileIssueType::Error || + issue->type == CompileIssueType::Warning) + mSyntaxCheckIssueCount++; } int CompilerManager::syntaxCheckIssueCount() const diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 52bd5973..47e7a255 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -506,7 +506,7 @@ QTabWidget::South - 6 + 0 @@ -702,7 +702,7 @@ QTabWidget::North - 2 + 0 @@ -1381,7 +1381,7 @@ 0 0 1114 - 25 + 30 From dda0f82b4d0a39b3192b5c44a0efb53fd272ad4c Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Mon, 22 Nov 2021 19:10:56 +0800 Subject: [PATCH 2/4] - fix: columns calculation not correct when paint lines containing chinese characters --- NEWS.md | 1 + RedPandaIDE/editor.cpp | 1 - RedPandaIDE/mainwindow.cpp | 11 ----------- RedPandaIDE/mainwindow.h | 2 -- RedPandaIDE/qsynedit/SynEdit.cpp | 6 +++++- RedPandaIDE/qsynedit/TextPainter.cpp | 2 +- 6 files changed, 7 insertions(+), 16 deletions(-) diff --git a/NEWS.md b/NEWS.md index 9604af37..6bbcf14e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ Version 0.9.3 For Dev-C++ 7 Beta - fix: the count in the title of issues view isn't correct + - fix: columns calculation not correct when paint lines containing chinese characters Version 0.9.2 For Dev-C++ 7 Beta - fix: gutter of the disassembly code control in the cpu info dialog is grayed diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 7873cbb1..94d48b1a 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -876,7 +876,6 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to if (token.isEmpty()) return; -// qDebug()<name()<<" - "<identifierAttribute())) { BufferCoord p{aChar,line}; BufferCoord pBeginPos,pEndPos; diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 300df729..87fb4e50 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -5695,16 +5695,6 @@ void MainWindow::on_actionProblem_triggered() showHideMessagesTab(ui->tabProblem,state); } - -void MainWindow::on_actionInsert_Line_triggered() -{ - Editor *e=mEditorList->getEditor(); - if (e) { - e->insertLine(); - } -} - - void MainWindow::on_actionDelete_Line_triggered() { Editor *e=mEditorList->getEditor(); @@ -5713,7 +5703,6 @@ void MainWindow::on_actionDelete_Line_triggered() } } - void MainWindow::on_actionDuplicate_Line_triggered() { Editor *e=mEditorList->getEditor(); diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index 693299e8..4e0383b4 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -518,8 +518,6 @@ private slots: void on_actionProblem_triggered(); - void on_actionInsert_Line_triggered(); - void on_actionDelete_Line_triggered(); void on_actionDuplicate_Line_triggered(); diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index 5194d8f3..3c1793f3 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -250,6 +250,10 @@ void SynEdit::setCaretXYEx(bool CallEnsureCursorPos, BufferCoord value) invalidateLine(mCaretY); invalidateLine(oldCaretY); } + if (mGutter.activeLineTextColor().isValid()) { + invalidateGutterLine(mCaretY); + invalidateGutterLine(oldCaretY); + } mStatusChanges.setFlag(SynStatusChange::scCaretY); } // Call UpdateLastCaretX before DecPaintLock because the event handler it @@ -829,7 +833,7 @@ int SynEdit::columnToChar(int aLine, int aColumn) const int SynEdit::stringColumns(const QString &line, int colsBefore) const { - int columns = colsBefore; + int columns = std::max(0,colsBefore); int charCols; for (int i=0;imHighlighter->next(); } // Don't assume HL.GetTokenPos is valid after HL.GetEOL == True. - nTokenColumnsBefore += edit->stringColumns(sToken,nTokenColumnsBefore-1); + nTokenColumnsBefore += edit->stringColumns(sToken,nTokenColumnsBefore); if (edit->mHighlighter->eol() && (nTokenColumnsBefore < vLastChar)) { int lineColumns = edit->mLines->lineColumns(vLine-1); // Draw text that couldn't be parsed by the highlighter, if any. From cd1e20c2d7f76f03d4cc0624ee00bcc2d85fb11c Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 23 Nov 2021 10:32:33 +0800 Subject: [PATCH 3/4] - fix: restore caret position after reformat code - enhancement: ask user to rebuild project, when run/debug the project and it has been modified - fix: correct set the enabled state of "delete line"/"insert line"/"delete word"/"delete to BOL"/"delete to EOL" menu items --- NEWS.md | 3 ++ RedPandaIDE/compiler/compilermanager.cpp | 2 +- RedPandaIDE/compiler/projectcompiler.cpp | 9 ++-- RedPandaIDE/editor.cpp | 4 ++ RedPandaIDE/mainwindow.cpp | 54 ++++++++++++++++-------- RedPandaIDE/mainwindow.ui | 9 ++++ 6 files changed, 58 insertions(+), 23 deletions(-) diff --git a/NEWS.md b/NEWS.md index 6bbcf14e..f78aa83d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,9 @@ Version 0.9.3 For Dev-C++ 7 Beta - fix: the count in the title of issues view isn't correct - fix: columns calculation not correct when paint lines containing chinese characters + - fix: restore caret position after reformat code + - enhancement: ask user to rebuild project, when run/debug the project and it has been modified + - fix: correct set the enabled state of "delete line"/"insert line"/"delete word"/"delete to BOL"/"delete to EOL" menu items Version 0.9.2 For Dev-C++ 7 Beta - fix: gutter of the disassembly code control in the cpu info dialog is grayed diff --git a/RedPandaIDE/compiler/compilermanager.cpp b/RedPandaIDE/compiler/compilermanager.cpp index 9caf66f2..c9ddc372 100644 --- a/RedPandaIDE/compiler/compilermanager.cpp +++ b/RedPandaIDE/compiler/compilermanager.cpp @@ -133,8 +133,8 @@ void CompilerManager::cleanProject(std::shared_ptr project) mCompileIssueCount = 0; ProjectCompiler* compiler = new ProjectCompiler(project,false,false); compiler->setOnlyClean(true); - mCompiler->setRebuild(false); mCompiler = compiler; + mCompiler->setRebuild(false); connect(mCompiler, &Compiler::finished, mCompiler, &QObject::deleteLater); connect(mCompiler, &Compiler::compileFinished, this, &CompilerManager::onCompileFinished); diff --git a/RedPandaIDE/compiler/projectcompiler.cpp b/RedPandaIDE/compiler/projectcompiler.cpp index d6b65313..379053f7 100644 --- a/RedPandaIDE/compiler/projectcompiler.cpp +++ b/RedPandaIDE/compiler/projectcompiler.cpp @@ -9,7 +9,8 @@ #include ProjectCompiler::ProjectCompiler(std::shared_ptr project, bool silent, bool onlyCheckSyntax): - Compiler("",silent,onlyCheckSyntax) + Compiler("",silent,onlyCheckSyntax), + mOnlyClean(false) { setProject(project); } @@ -264,9 +265,9 @@ void ProjectCompiler::writeMakeClean(QFile &file) { writeln(file, "clean: clean-custom"); if (mProject->options().type == ProjectType::DynamicLib) - writeln(file, "\t${RM} $(CLEANOBJ) $(BIN) $(DEF) $(STATIC)"); + writeln(file, "\t${RM} $(CLEANOBJ) $(BIN) $(DEF) $(STATIC) > NUL 2>&1"); else - writeln(file, "\t${RM} $(CLEANOBJ) $(BIN)"); + writeln(file, "\t${RM} $(CLEANOBJ) $(BIN) > NUL 2>&1"); writeln(file); } @@ -465,7 +466,7 @@ bool ProjectCompiler::prepareForCompile() mArguments = QString("-f \"%1\" clean").arg(extractRelativePath( mProject->directory(), mProject->makeFileName())); - } if (mRebuild) { + } else if (mRebuild) { mArguments = QString("-f \"%1\" clean all").arg(extractRelativePath( mProject->directory(), mProject->makeFileName())); diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 94d48b1a..5755af9e 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -3568,6 +3568,8 @@ void Editor::reformat() pSettings->dirs().app(), args, content); + int oldTopLine = topLine(); + BufferCoord mOldCaret = caretXY(); selectAll(); SynEditorOptions oldOptions = getOptions(); @@ -3575,6 +3577,8 @@ void Editor::reformat() newOptions.setFlag(SynEditorOption::eoAutoIndent,false); setOptions(newOptions); setSelText(QString::fromUtf8(newContent)); + setCaretXY(mOldCaret); + setTopLine(oldTopLine); setOptions(oldOptions); reparse(); checkSyntaxInBack(); diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 87fb4e50..dd964017 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -339,6 +339,12 @@ void MainWindow::updateEditorActions() ui->actionUnIndent->setEnabled(false); ui->actionUndo->setEnabled(false); ui->actionUnfoldAll->setEnabled(false); + ui->actionDelete_Line->setEnabled(false); + ui->actionDelete_Word->setEnabled(false); + ui->actionDuplicate_Line->setEnabled(false); + ui->actionDelete_to_BOL->setEnabled(false); + ui->actionDelete_to_EOL->setEnabled(false); + ui->actionFind->setEnabled(false); ui->actionReplace->setEnabled(false); ui->actionFind_Next->setEnabled(false); @@ -379,6 +385,11 @@ void MainWindow::updateEditorActions() ui->actionToggleComment->setEnabled(!e->readOnly() && e->lines()->count()>0); ui->actionUnIndent->setEnabled(!e->readOnly() && e->lines()->count()>0); ui->actionUnfoldAll->setEnabled(e->lines()->count()>0); + ui->actionDelete_Line->setEnabled(!e->readOnly() && e->lines()->count()>0); + ui->actionDelete_Word->setEnabled(!e->readOnly() && e->lines()->count()>0); + ui->actionDuplicate_Line->setEnabled(!e->readOnly() && e->lines()->count()>0); + ui->actionDelete_to_BOL->setEnabled(!e->readOnly() && e->lines()->count()>0); + ui->actionDelete_to_EOL->setEnabled(!e->readOnly() && e->lines()->count()>0); ui->actionFind->setEnabled(true); ui->actionReplace->setEnabled(true); @@ -1079,30 +1090,14 @@ void MainWindow::checkSyntaxInBack(Editor *e) mCompilerManager->checkSyntax(e->filename(),e->text(), e->fileEncoding() == ENCODING_ASCII, nullptr); } -// if not PrepareForCompile(cttStdin,True) then begin -// fCheckSyntaxInBack:=False; -// Exit; -// end; -// if e.InProject then begin -// if not assigned(MainForm.fProject) then -// Exit; -// fSyntaxChecker.Project := MainForm.fProject; -// end; - // fSyntaxChecker.CheckSyntax(True); } bool MainWindow::compile(bool rebuild) { CompileTarget target =getCompileTarget(); if (target == CompileTarget::Project) { - if (!mProject->saveUnits()) - return false; - // Check if saves have been succesful - for (int i=0; ipageCount();i++) { - Editor * e= (*(mEditorList))[i]; - if (e->inProject() && e->modified()) - return false; - } + if (mProject->modified()) + mProject->saveAll(); clearIssues(); // Increment build number automagically @@ -1209,6 +1204,18 @@ void MainWindow::runExecutable(RunType runType) { CompileTarget target =getCompileTarget(); if (target == CompileTarget::Project) { + if (mProject->modified() && + QMessageBox::question( + this, + tr("Rebuild Project"), + tr("Project has been modified, do you want to rebuild it?") + ) == QMessageBox::Yes) { + mProject->saveAll(); + mCompileSuccessionTask=std::make_shared(); + mCompileSuccessionTask->type = CompileSuccessionTaskType::RunNormal; + compile(); + return; + } runExecutable(mProject->executable(),mProject->filename(),runType); } else { Editor * editor = mEditorList->getEditor(); @@ -1277,6 +1284,17 @@ void MainWindow::debug() } return; } + if (mProject->modified() && + QMessageBox::question( + this, + tr("Compile Project"), + tr("Project has been modified, do you want to rebuild it?") + ) == QMessageBox::Yes) { + mCompileSuccessionTask=std::make_shared(); + mCompileSuccessionTask->type = CompileSuccessionTaskType::Debug; + compile(); + return; + } // Did we choose a host application for our DLL? if (mProject->options().type == ProjectType::DynamicLib) { if (mProject->options().hostApplication.isEmpty()) { diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 47e7a255..7bac4e6a 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -2613,16 +2613,25 @@ Delete Line + + Ctrl+D + Duplicate Line + + Ctrl+E + Delete Word + + Ctrl+Shift+D + From 39e32e2fc54a5cc1a71573c988b32b671d9b7e29 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Tue, 23 Nov 2021 10:34:38 +0800 Subject: [PATCH 4/4] short cut for actions --- RedPandaIDE/mainwindow.ui | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 7bac4e6a..d45c3e17 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -2637,11 +2637,17 @@ Delete to EOL + + Ctrl+Del + Delete to BOL + + Ctrl+Backspace +