From fd9b41ac6da04684e22f8a61780ff3cc42fbc136 Mon Sep 17 00:00:00 2001 From: royqh1979 Date: Mon, 21 Jun 2021 22:01:35 +0800 Subject: [PATCH] * work save for symbol completion options --- RedPandaIDE/RedPandaIDE_zh_CN.qm | Bin 19427 -> 19423 bytes RedPandaIDE/RedPandaIDE_zh_CN.ts | 2 +- RedPandaIDE/colorscheme.cpp | 2 ++ RedPandaIDE/editor.cpp | 2 +- RedPandaIDE/editor.h | 6 ++-- RedPandaIDE/main.cpp | 1 + RedPandaIDE/qsynedit/CodeFolding.cpp | 5 +-- RedPandaIDE/qsynedit/CodeFolding.h | 4 +-- RedPandaIDE/qsynedit/SynEdit.cpp | 9 +++-- RedPandaIDE/qsynedit/SynEdit.h | 2 +- RedPandaIDE/qsynedit/TextBuffer.cpp | 4 +-- RedPandaIDE/qsynedit/TextBuffer.h | 2 +- RedPandaIDE/qsynedit/highlighter/base.cpp | 6 ++-- .../editorsymbolcompletionwidget.cpp | 31 ++++++++++++++++++ 14 files changed, 58 insertions(+), 18 deletions(-) diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.qm b/RedPandaIDE/RedPandaIDE_zh_CN.qm index f0faa842a1dff93437fbf772d08c7ab7dfac0e62..6bd1c580352e6dbb9abc47582c3572eaf0311dc7 100644 GIT binary patch delta 1169 zcmXAodrTZ<6vfZ%?9A@afdzq%<+TxF2UrS)vMk7}h)BVrRn*E-yP*$p6Ocy%O-aE* zm9~;n_M-uWU=$-NgohhLsFZ4Kryu_k%ZL7TD)ZcnP0vyGxwf*?wN&F zZoZW}8!3Ga2u}fKXR{?$5&_#d5P!6}*20xG4_mmI=9Q?2<{`9Q1{9l%;Snyzl|q;p z03xojR8FxEB3;M;c2r{5s|mm(i`ey6F0gGDS>_HPpcq*vCxDc1kR93$#Oy)#!2>{I zGO{l(06X_!cRQVZhF#p+;9|r-F2<}O$9#h7Kglj~MlP4lb4r*9>jej?k3#-SJ4i_e ziY+P-T#eV_oB%@6(8dF?CT7$qV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OW zyETwB1W234e*~h>NISz0((5{@EaN}Q$E@^$M+IV*OG6ipKt_XfDU_zA{>9va%B^H| zf;k~Z*Hrs}&f;_z$;-8DOvui3$w#Vh z0tTHAqYua(Z>|8+y5ydFtM~Fdc7rQ3L$=+q%zbM4>AzKtp z`C|%SdW*6)rTA6M0!FhE6!4gw=v9Jl_!G}~CAeamctk2O2R)SQQ%dsw^;8!q&c36R z>t3bc@89Sz_*bb?iBZ@_<-?um95BVR%g+-SD diff --git a/RedPandaIDE/RedPandaIDE_zh_CN.ts b/RedPandaIDE/RedPandaIDE_zh_CN.ts index 319a6bb4..f91456ad 100644 --- a/RedPandaIDE/RedPandaIDE_zh_CN.ts +++ b/RedPandaIDE/RedPandaIDE_zh_CN.ts @@ -1003,7 +1003,7 @@ Are you really want to continue? Open - 打开打开 + 打开 diff --git a/RedPandaIDE/colorscheme.cpp b/RedPandaIDE/colorscheme.cpp index 4ea93439..421c5bcd 100644 --- a/RedPandaIDE/colorscheme.cpp +++ b/RedPandaIDE/colorscheme.cpp @@ -575,6 +575,7 @@ bool ColorManager::add(const QString &name, PColorScheme scheme) scheme->setCustomed(false); mSchemes[name] = scheme; saveScheme(name); + return true; } PColorScheme ColorManager::get(const QString &name) @@ -634,6 +635,7 @@ bool ColorManager::saveScheme(const QString &name) return false; QString newFilepath = generateFullPathname(name,scheme->bundled(),scheme->customed()); scheme->save(newFilepath); + return true; } QString ColorManager::generateFullPathname(const QString &name, bool isBundled, bool isCustomed) diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index b807285f..9ad4501e 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -252,7 +252,7 @@ void Editor::keyPressEvent(QKeyEvent *event) bool handled = false; QString t = event->text(); if (!t.isEmpty()) { - QChar ch = t; + QChar ch = t[0]; switch (ch.unicode()) { case '"': case '\'': diff --git a/RedPandaIDE/editor.h b/RedPandaIDE/editor.h index 3c385cc4..54225385 100644 --- a/RedPandaIDE/editor.h +++ b/RedPandaIDE/editor.h @@ -94,9 +94,9 @@ private: // QWidget interface protected: void wheelEvent(QWheelEvent *event) override; - void focusInEvent(QFocusEvent *event); - void focusOutEvent(QFocusEvent *event); - void keyPressEvent(QKeyEvent *event); + void focusInEvent(QFocusEvent *event) override; + void focusOutEvent(QFocusEvent *event) override; + void keyPressEvent(QKeyEvent *event) override; }; #endif // EDITOR_H diff --git a/RedPandaIDE/main.cpp b/RedPandaIDE/main.cpp index 20e6ea6c..251440cc 100644 --- a/RedPandaIDE/main.cpp +++ b/RedPandaIDE/main.cpp @@ -84,5 +84,6 @@ int main(int argc, char *argv[]) return retCode; } catch (BaseError e) { QMessageBox::critical(nullptr,QApplication::tr("Error"),e.reason()); + return -1; } } diff --git a/RedPandaIDE/qsynedit/CodeFolding.cpp b/RedPandaIDE/qsynedit/CodeFolding.cpp index ef3a1111..7eb65b99 100644 --- a/RedPandaIDE/qsynedit/CodeFolding.cpp +++ b/RedPandaIDE/qsynedit/CodeFolding.cpp @@ -6,7 +6,7 @@ int SynEditFoldRegions::count() return fRegions.size(); } -int SynEditFoldRegions::add(bool addEnding, const QChar &openSymbol, const QChar &closeSymbol, const QString &highlight) +PSynEditFoldRegion SynEditFoldRegions::add(bool addEnding, const QChar &openSymbol, const QChar &closeSymbol, const QString &highlight) { PSynEditFoldRegion region = std::make_shared(); region->addEnding = addEnding; @@ -14,6 +14,7 @@ int SynEditFoldRegions::add(bool addEnding, const QChar &openSymbol, const QChar region->closeSymbol = closeSymbol; region->highlight = highlight; fRegions.push_back(region); + return region; } PSynEditFoldRegion SynEditFoldRegions::get(int index) @@ -104,7 +105,7 @@ void SynEditFoldRanges::insert(int index, PSynEditFoldRange range) mRanges.insert(index,range); } -int SynEditFoldRanges::remove(int index) +void SynEditFoldRanges::remove(int index) { mRanges.remove(index); } diff --git a/RedPandaIDE/qsynedit/CodeFolding.h b/RedPandaIDE/qsynedit/CodeFolding.h index f2604b97..1dbf6689 100644 --- a/RedPandaIDE/qsynedit/CodeFolding.h +++ b/RedPandaIDE/qsynedit/CodeFolding.h @@ -13,7 +13,7 @@ private: std::vector fRegions; public: int count(); - int add(bool addEnding, const QChar& openSymbol, const QChar& closeSymbol, const QString& highlight); + PSynEditFoldRegion add(bool addEnding, const QChar& openSymbol, const QChar& closeSymbol, const QString& highlight); PSynEditFoldRegion get(int index); }; typedef std::shared_ptr PSynFoldRegions; @@ -54,7 +54,7 @@ public: int aFromLine, PSynEditFoldRegion aFoldRegion, int aToLine); void insert(int index, PSynEditFoldRange range); - int remove(int index); + void remove(int index); void add(PSynEditFoldRange foldRange); PSynEditFoldRange operator[](int index) const; }; diff --git a/RedPandaIDE/qsynedit/SynEdit.cpp b/RedPandaIDE/qsynedit/SynEdit.cpp index 63ab14eb..0e64211d 100644 --- a/RedPandaIDE/qsynedit/SynEdit.cpp +++ b/RedPandaIDE/qsynedit/SynEdit.cpp @@ -553,6 +553,7 @@ int SynEdit::charToColumn(int aLine, int aChar) const QString s = mLines->getString(aLine - 1); return charToColumn(s,aChar); } + return aChar; } int SynEdit::charToColumn(const QString &s, int aChar) const @@ -587,6 +588,7 @@ int SynEdit::columnToChar(int aLine, int aColumn) const } return i+1; } + return aColumn; } int SynEdit::stringColumns(const QString &line, int colsBefore) const @@ -2537,6 +2539,7 @@ QString SynEdit::expandAtWideGlyphs(const QString &S) j++; } Result.resize(j); + return Result; } void SynEdit::updateModifiedStatus() @@ -2577,7 +2580,7 @@ int SynEdit::scanFrom(int Index) return Result; } -int SynEdit::scanRanges() +void SynEdit::scanRanges() { if (mHighlighter && !mLines->empty()) { mHighlighter->resetState(); @@ -4227,6 +4230,7 @@ int SynEdit::InsertTextByColumnMode(const QString &Value, bool AddToUndoList) } while (P 0) { mIndexOfLongestLine = -1; @@ -739,7 +739,7 @@ SynChangeReason SynEditUndoList::LastChangeReason() if (mItems.count() == 0) return SynChangeReason::crNothing; else - mItems.last()->changeReason(); + return mItems.last()->changeReason(); } void SynEditUndoList::Lock() diff --git a/RedPandaIDE/qsynedit/TextBuffer.h b/RedPandaIDE/qsynedit/TextBuffer.h index 84d59847..89122a5e 100644 --- a/RedPandaIDE/qsynedit/TextBuffer.h +++ b/RedPandaIDE/qsynedit/TextBuffer.h @@ -75,7 +75,7 @@ public: void endUpdate(); int add(const QString& s); - int addStrings(const QStringList& Strings); + void addStrings(const QStringList& Strings); int getTextLength(); void clear(); diff --git a/RedPandaIDE/qsynedit/highlighter/base.cpp b/RedPandaIDE/qsynedit/highlighter/base.cpp index 4e55c3e0..c431cb73 100644 --- a/RedPandaIDE/qsynedit/highlighter/base.cpp +++ b/RedPandaIDE/qsynedit/highlighter/base.cpp @@ -89,13 +89,13 @@ bool SynHighlighter::isIdentChar(const QChar &ch) const if (ch == '_') { return true; } - if (ch>='0' && ch <= '9') { + if ((ch>='0') && (ch <= '9')) { return true; } - if (ch>='a' && ch <= 'z') { + if ((ch>='a') && (ch <= 'z')) { return true; } - if (ch>='A' && ch <= 'Z') { + if ((ch>='A') && (ch <= 'Z')) { return true; } diff --git a/RedPandaIDE/settingsdialog/editorsymbolcompletionwidget.cpp b/RedPandaIDE/settingsdialog/editorsymbolcompletionwidget.cpp index 5dceb274..05e3f50c 100644 --- a/RedPandaIDE/settingsdialog/editorsymbolcompletionwidget.cpp +++ b/RedPandaIDE/settingsdialog/editorsymbolcompletionwidget.cpp @@ -1,5 +1,6 @@ #include "editorsymbolcompletionwidget.h" #include "ui_editorsymbolcompletionwidget.h" +#include "../settings.h" EditorSymbolCompletionWidget::EditorSymbolCompletionWidget(const QString& name, const QString& group, QWidget *parent) : SettingsWidget(name,group,parent), @@ -12,3 +13,33 @@ EditorSymbolCompletionWidget::~EditorSymbolCompletionWidget() { delete ui; } + +void EditorSymbolCompletionWidget::doLoad() +{ + ui->grpCompleSymbols->setChecked(pSettings->editor().completeSymbols()); + ui->chkCompleteBrace->setChecked(pSettings->editor().completeBrace()); + ui->chkCompleteBracket->setChecked(pSettings->editor().completeBracket()); + ui->chkCompleteComments->setChecked(pSettings->editor().completeComment()); + ui->chkCompleteDoubleQuotation->setChecked(pSettings->editor().completeDoubleQuote()); + ui->chkCompleteGlobalInclude->setChecked(pSettings->editor().completeGlobalInclude()); + ui->chkCompleteParenthesis->setChecked(pSettings->editor().completeParenthese()); + ui->chkCompleteSingleQuotation->setChecked(pSettings->editor().completeSingleQuote()); + ui->chkRemoveMatchingSymbols->setChecked(pSettings->editor().removeMathcingSymbol()); + ui->chkSkipMathingSymbols->setChecked(pSettings->editor().overwriteSymbols()); +} + +void EditorSymbolCompletionWidget::doSave() +{ + pSettings->editor().setCompleteSymbols(ui->grpCompleSymbols->isChecked()); + pSettings->editor().setCompleteBrace(ui->chkCompleteBrace->isChecked()); + pSettings->editor().setCompleteBracket(ui->chkCompleteBracket->isChecked()); + pSettings->editor().setCompleteComment(ui->chkCompleteComments->isChecked()); + pSettings->editor().setCompleteDoubleQuote(ui->chkCompleteDoubleQuotation->isChecked()); + pSettings->editor().setCompleteGlobalInclude(ui->chkCompleteGlobalInclude->isChecked()); + pSettings->editor().setCompleteParenthese(ui->chkCompleteParenthesis->isChecked()); + pSettings->editor().setCompleteSingleQuote(ui->chkCompleteSingleQuotation->isChecked()); + pSettings->editor().setRemoveMathcingSymbol(ui->chkRemoveMatchingSymbols->isChecked()); + pSettings->editor().setOverwriteSymbols(ui->chkSkipMathingSymbols->isChecked()); + + pSettings->editor().save(); +}