diff --git a/NEWS.md b/NEWS.md index 2e3b6de7..eddccfbe 100644 --- a/NEWS.md +++ b/NEWS.md @@ -16,6 +16,7 @@ Version 0.7.8 - enhancement: can set editor's default background / foreground color. They must be setted to make the custom color schemes correctly. - enhancement: can set the color for the current line's number in the gutter - all predefined color schemes updated. + - enhancement: check syntax/parse symbols when modifed and cursor's line changed. Version 0.7.7 - enhancement: Problem Set diff --git a/RedPandaIDE/colorschemes/VS_Code.scheme b/RedPandaIDE/colorschemes/VS_Code.scheme index d7298b79..2cc3e83e 100644 --- a/RedPandaIDE/colorschemes/VS_Code.scheme +++ b/RedPandaIDE/colorschemes/VS_Code.scheme @@ -159,7 +159,7 @@ "Breakpoint" : { }, "Error" : { - "foreground" : "#ff2f32" + "foreground" : "#ff5053" }, "Active Breakpoint" : { "foreground" : "#FFFFCE", diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 20be2e7f..bf2104db 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -78,6 +78,7 @@ Editor::Editor(QWidget *parent, const QString& filename, mCurrentHighlightedWord(), mSaving(false) { + mCurrentLineModified = false; mUseCppSyntax = pSettings->editor().defaultFileCpp(); if (mFilename.isEmpty()) { mFilename = tr("untitled")+QString("%1").arg(getNewFileNumber()); @@ -1355,25 +1356,29 @@ Editor::PSyntaxIssue Editor::getSyntaxIssueAtPosition(const BufferCoord &pos) return PSyntaxIssue(); } -void Editor::onModificationChanged(bool) { - updateCaption(); -} - void Editor::onStatusChanged(SynStatusChanges changes) { - if (!changes.testFlag(SynStatusChange::scReadOnly) + if ((!changes.testFlag(SynStatusChange::scReadOnly) && !changes.testFlag(SynStatusChange::scInsertMode) && (lines()->count()!=mLineCount) - && (lines()->count()!=0) && ((mLineCount>0) || (lines()->count()>1))) { + && (lines()->count()!=0) && ((mLineCount>0) || (lines()->count()>1))) + || + (mCurrentLineModified + && !changes.testFlag(SynStatusChange::scReadOnly) + && changes.testFlag(SynStatusChange::scCaretY))) { + mCurrentLineModified = false; reparse(); if (pSettings->editor().syntaxCheckWhenLineChanged()) checkSyntaxInBack(); reparseTodo(); } mLineCount = lines()->count(); - if (changes.testFlag(scModified)) { + if (changes.testFlag(scModifyChanged)) { updateCaption(); } + if (changes.testFlag(scModified)) { + mCurrentLineModified = true; + } if (changes.testFlag(SynStatusChange::scCaretX) || changes.testFlag(SynStatusChange::scCaretY)) { diff --git a/RedPandaIDE/editor.h b/RedPandaIDE/editor.h index 14de640c..311a8543 100644 --- a/RedPandaIDE/editor.h +++ b/RedPandaIDE/editor.h @@ -173,7 +173,6 @@ public: void tab() override; private slots: - void onModificationChanged(bool status) ; void onStatusChanged(SynStatusChanges changes); void onGutterClicked(Qt::MouseButton button, int x, int y, int line); void onTipEvalValueReady(const QString& value); @@ -263,7 +262,7 @@ private: QString mCurrentHighlightedWord; bool mSaving; - + bool mCurrentLineModified; int mXOffsetSince; int mTabStopBegin; int mTabStopEnd; diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index 536e42e6..2e695288 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -5977,14 +5977,16 @@ bool SynEdit::modified() const void SynEdit::setModified(bool Value) { - if (Value) + if (Value) { mLastModifyTime = QDateTime::currentDateTime(); + emit statusChanged(SynStatusChange::scModified); + } if (Value != mModified) { mModified = Value; if (mOptions.testFlag(SynEditorOption::eoGroupUndo) && (!Value) && mUndoList->CanUndo()) mUndoList->AddGroupBreak(); mUndoList->setInitialState(!Value); - emit statusChanged(SynStatusChange::scModified); + emit statusChanged(SynStatusChange::scModifyChanged); } } diff --git a/RedPandaIDE/qsynedit/SynEdit.h b/RedPandaIDE/qsynedit/SynEdit.h index c7f42fef..783a3fc5 100644 --- a/RedPandaIDE/qsynedit/SynEdit.h +++ b/RedPandaIDE/qsynedit/SynEdit.h @@ -40,10 +40,11 @@ enum SynStatusChange { scLeftChar = 0x0008, scTopLine = 0x0010, scInsertMode = 0x0020, - scModified = 0x0040, + scModifyChanged = 0x0040, scSelection = 0x0080, scReadOnly = 0x0100, - scOpenFile = 0x0200 + scOpenFile = 0x0200, + scModified = 0x0400 }; Q_DECLARE_FLAGS(SynStatusChanges, SynStatusChange) diff --git a/RedPandaIDE/utils.cpp b/RedPandaIDE/utils.cpp index b472845c..265a38a3 100644 --- a/RedPandaIDE/utils.cpp +++ b/RedPandaIDE/utils.cpp @@ -857,5 +857,5 @@ QByteArray getHTTPBody(const QByteArray& content) { bool haveGoodContrast(const QColor& c1, const QColor &c2) { int lightness1 = qGray(c1.rgb()); int lightness2 = qGray(c2.rgb()); - return std::abs(lightness1 - lightness2)>=100; + return std::abs(lightness1 - lightness2)>=120; }