From ca0ad3249f9411a652ead60c48942e2912fb0ca2 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 13 Apr 2022 16:42:23 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E5=8A=9F=E8=83=BD=E5=A2=9E=E5=BC=BA?= =?UTF-8?q?=EF=BC=9A=E8=BE=93=E5=85=A5'('=E6=97=B6=EF=BC=8C=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E4=B8=8B=E4=B8=80=E4=B8=AA=E9=9D=9E=E7=A9=BA=E7=99=BD?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E6=98=AF'('=E6=88=96=E8=80=85=E6=A0=87?= =?UTF-8?q?=E8=AF=86=E7=AC=A6/=E6=95=B0=E5=AD=97=EF=BC=8C=E5=88=99?= =?UTF-8?q?=E4=B8=8D=E8=87=AA=E5=8A=A8=E8=A1=A5=E5=85=A8=20=20-=20?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=A2=9E=E5=BC=BA=EF=BC=9A=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=96=87=E4=BB=B6=E5=92=8C=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=9A=84=E7=BC=96=E7=A0=81=E7=9B=B8=E5=90=8C=EF=BC=8C=E5=88=99?= =?UTF-8?q?=E4=B8=8D=E4=BF=9D=E5=AD=98=E5=AE=83=E7=9A=84=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=20=20-=20=E4=BF=AE=E6=AD=A3=EF=BC=9A?= =?UTF-8?q?=E5=9C=A8=E4=BF=9D=E5=AD=98=E6=96=87=E4=BB=B6=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E4=BC=9A=E9=94=99=E8=AF=AF=E7=9A=84=E4=BD=BF=E7=94=A8=E7=BC=BA?= =?UTF-8?q?=E7=9C=81=E7=BC=96=E7=A0=81=E8=80=8C=E4=B8=8D=E6=98=AF=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=8E=9F=E6=9C=89=E7=9A=84=E7=BC=96=E7=A0=81=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NEWS.md | 3 +++ RedPandaIDE/editor.cpp | 14 +++++++++----- RedPandaIDE/project.cpp | 5 +++-- RedPandaIDE/qsynedit/SynEdit.cpp | 17 +++++++++++++++++ RedPandaIDE/qsynedit/SynEdit.h | 1 + 5 files changed, 33 insertions(+), 7 deletions(-) diff --git a/NEWS.md b/NEWS.md index b7583a1d..a5d257e7 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,9 @@ Red Panda C++ Version 1.0.4 - enhancement: add help link for regular expression in search dialog - enhancement: remember current problem set's filename - enhancement: F1 shorcut opens offcial website + - enhancement: don't auto complete '(', if the next non-space char is neither '(' nor ident char + - enhancement: if a project's unit encoding is the same with project's encoding, don't save its encoding + - fix: files will be saved to default encoding inspite of its original encoding Red Panda C++ Version 1.0.3 - fix: when oj problem grabbed by competitive companion received, diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 8f0e775d..411fb73b 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -228,7 +228,10 @@ void Editor::loadFile(QString filename) { void Editor::saveFile(QString filename) { QFile file(filename); - this->lines()->saveToFile(file,mEncodingOption, + QByteArray encoding = mFileEncoding; + if (mFileEncoding==ENCODING_ASCII) + encoding = mEncodingOption; + this->lines()->saveToFile(file,encoding, pSettings->editor().defaultEncoding(), mFileEncoding); emit fileSaved(filename, mInProject); @@ -797,13 +800,14 @@ void Editor::keyPressEvent(QKeyEvent *event) case '*': handled = handleSymbolCompletion(ch); return; - case '(': - if (caretX()-1>=lineText().length() - || caretX()<=0 - || isSpaceOrRightParenthesis(lineText().at(caretX()-1))) { + case '(': { + QChar nextCh = nextNotspaceChar(caretY()-1,caretX()-1); + qDebug()<': if ((caretX() <= 1) || lineText().isEmpty() || lineText()[caretX() - 2] != '-') { diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index 33ad6d03..76177e50 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -608,7 +608,8 @@ bool Project::saveUnits() ini.SetLongValue(groupName,"OverrideBuildCmd", unit->overrideBuildCmd()); ini.SetValue(groupName,"BuildCmd", toByteArray(unit->buildCmd())); ini.SetLongValue(groupName,"DetectEncoding", unit->encoding()==ENCODING_AUTO_DETECT); - ini.SetValue(groupName,"FileEncoding", toByteArray(unit->encoding())); + if (unit->encoding() != options().encoding) + ini.SetValue(groupName,"FileEncoding", toByteArray(unit->encoding())); } ini.SetLongValue("Project","UnitCount",count); ini.SaveFile(mFilename.toLocal8Bit()); @@ -927,7 +928,7 @@ PProjectUnit Project::addUnit(const QString &inFileName, PProjectModelNode paren newUnit->setEncoding(e->fileEncoding()); e->setInProject(true); } else { - newUnit->setEncoding(pSettings->editor().defaultEncoding()); + newUnit->setEncoding(options().encoding.toUtf8()); } newUnit->setFolder(getFolderPath(parentNode)); newUnit->setNode(makeNewFileNode(extractFileName(newUnit->fileName()), false, parentNode)); diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index a370dc6b..dca25886 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -1100,6 +1100,23 @@ QChar SynEdit::charAt(const BufferCoord &pos) return QChar(0); } +QChar SynEdit::nextNotspaceChar(int line, int ch) +{ + if (ch<0) + return QChar(); + QString s = mLines->getString(line); + if (s.isEmpty()) + return QChar(); + int x=ch; + while (x