From 04c7f3b5d5bc3de8efd1b0fa8f65b02a6692fa49 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sun, 7 Apr 2024 21:33:08 +0800 Subject: [PATCH] - change: Remove "limit for copy" and "limit for undo" options. --- NEWS.md | 1 + RedPandaIDE/editor.cpp | 32 ------- RedPandaIDE/settings.cpp | 60 ------------ RedPandaIDE/settings.h | 20 ---- .../settingsdialog/editorclipboardwidget.cpp | 7 -- .../settingsdialog/editorclipboardwidget.ui | 87 ----------------- .../settingsdialog/editormiscwidget.cpp | 4 - .../settingsdialog/editormiscwidget.ui | 54 ----------- .../environmentperformancewidget.cpp | 2 - .../environmentperformancewidget.ui | 51 ---------- libs/qsynedit/qsynedit/document.cpp | 95 ------------------- libs/qsynedit/qsynedit/document.h | 10 -- libs/qsynedit/qsynedit/qsynedit.cpp | 11 --- libs/qsynedit/qsynedit/qsynedit.h | 3 - 14 files changed, 1 insertion(+), 436 deletions(-) diff --git a/NEWS.md b/NEWS.md index 35b76150..f70516a1 100644 --- a/NEWS.md +++ b/NEWS.md @@ -127,6 +127,7 @@ Red Panda C++ Version 2.27 - fix: Theme manager not correctly inited in options dialog / environment / appearance. - enhancement: Size of icons in the completion popup changes with the editor font size. - change: Completion popup size settings are based on editor's char width/line height. + - change: Remove "limit for copy" and "limit for undo" options. Red Panda C++ Version 2.26 - enhancement: Code suggestion for embedded std::vectors. diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 91632065..9153a084 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -1645,21 +1645,6 @@ void Editor::resizeEvent(QResizeEvent *event) void Editor::copyToClipboard() { - if (pSettings->editor().copySizeLimit()) { - int startLine = blockBegin().line; - int endLine = blockEnd().line; - if ((endLine-startLine+1) > pSettings->editor().copyLineLimits()) { - QMessageBox::critical(pMainWindow,tr("Error"), - tr("The text to be copied exceeds count limit!")); - return; - } - if ((selText().length()) > pSettings->editor().copyCharLimits() * 1000) { - QMessageBox::critical(pMainWindow,tr("Error"), - tr("The text to be copied exceeds character limit!")); - return; - } - } - switch(pSettings->editor().copyWithFormatAs()) { case 1: //HTML copyAsHTML(); @@ -1671,20 +1656,6 @@ void Editor::copyToClipboard() void Editor::cutToClipboard() { - if (pSettings->editor().copySizeLimit()) { - int startLine = blockBegin().line; - int endLine = blockEnd().line; - if ((endLine-startLine+1) > pSettings->editor().copyLineLimits()) { - QMessageBox::critical(pMainWindow,tr("Error"), - tr("The text to be cut exceeds count limit!")); - return; - } - if ((selText().length()) > pSettings->editor().copyCharLimits() * 1000) { - QMessageBox::critical(pMainWindow,tr("Error"), - tr("The text to be cut exceeds character limit!")); - return; - } - } QSynedit::QSynEdit::cutToClipboard(); } @@ -5434,9 +5405,6 @@ void Editor::applySettings() ((QSynedit::CppSyntaxer*)(syntaxer().get()))->setCustomTypeKeywords(set); } - this->setUndoLimit(pSettings->editor().undoLimit()); - this->setUndoMemoryUsage(pSettings->editor().undoMemoryUsage()); - initAutoBackup(); setMouseWheelScrollSpeed(pSettings->editor().mouseWheelScrollSpeed()); diff --git a/RedPandaIDE/settings.cpp b/RedPandaIDE/settings.cpp index 8bcf45c2..a4408b81 100644 --- a/RedPandaIDE/settings.cpp +++ b/RedPandaIDE/settings.cpp @@ -705,26 +705,6 @@ void Settings::Editor::setAutoDetectFileEncoding(bool newAutoDetectFileEncoding) mAutoDetectFileEncoding = newAutoDetectFileEncoding; } -int Settings::Editor::undoLimit() const -{ - return mUndoLimit; -} - -void Settings::Editor::setUndoLimit(int newUndoLimit) -{ - mUndoLimit = newUndoLimit; -} - -int Settings::Editor::undoMemoryUsage() const -{ - return mUndoMemoryUsage; -} - -void Settings::Editor::setUndoMemoryUsage(int newUndoMemoryUsage) -{ - mUndoMemoryUsage = newUndoMemoryUsage; -} - bool Settings::Editor::autoFormatWhenSaved() const { return mAutoFormatWhenSaved; @@ -1125,36 +1105,6 @@ void Settings::Editor::setCopyRTFUseBackground(bool copyRTFUseBackground) mCopyRTFUseBackground = copyRTFUseBackground; } -int Settings::Editor::copyLineLimits() const -{ - return mCopyLineLimits; -} - -void Settings::Editor::setCopyLineLimits(int copyLineLimits) -{ - mCopyLineLimits = copyLineLimits; -} - -int Settings::Editor::copyCharLimits() const -{ - return mCopyCharLimits; -} - -void Settings::Editor::setCopyCharLimits(int copyCharLimits) -{ - mCopyCharLimits = copyCharLimits; -} - -bool Settings::Editor::copySizeLimit() const -{ - return mCopySizeLimit; -} - -void Settings::Editor::setCopySizeLimit(bool copyLimit) -{ - mCopySizeLimit = copyLimit; -} - int Settings::Editor::gutterLeftOffset() const { return mGutterLeftOffset; @@ -1365,9 +1315,6 @@ void Settings::Editor::doSave() saveValue("gutter_font_only_monospaced",mGutterFontOnlyMonospaced); //copy - saveValue("copy_limit",mCopySizeLimit); - saveValue("copy_char_limits",mCopyCharLimits); - saveValue("copy_line_limits",mCopyLineLimits); saveValue("copy_with_format_as",mCopyWithFormatAs); saveValue("copy_rtf_use_background",mCopyRTFUseBackground); saveValue("copy_rtf_use_editor_color_scheme",mCopyRTFUseEditorColor); @@ -1413,8 +1360,6 @@ void Settings::Editor::doSave() saveValue("auto_load_last_files",mAutoLoadLastFiles); saveValue("default_file_cpp",mDefaultFileCpp); saveValue("auto_detect_file_encoding",mAutoDetectFileEncoding); - saveValue("undo_limit",mUndoLimit); - saveValue("undo_memory_usage", mUndoMemoryUsage); saveValue("auto_format_when_saved", mAutoFormatWhenSaved); saveValue("remove_trailing_spaces_when_saved",mRemoveTrailingSpacesWhenSaved); saveValue("parse_todos",mParseTodos); @@ -1518,9 +1463,6 @@ void Settings::Editor::doLoad() mGutterFontOnlyMonospaced = boolValue("gutter_font_only_monospaced",true); //copy - mCopySizeLimit = boolValue("copy_limit",false); - mCopyCharLimits = intValue("copy_char_limits",100); - mCopyLineLimits = intValue("copy_line_limits",100000); #ifdef Q_OS_WIN mCopyWithFormatAs = intValue("copy_with_format_as",1); //html #else @@ -1576,8 +1518,6 @@ void Settings::Editor::doLoad() else mDefaultEncoding = value("default_encoding", ENCODING_UTF8).toByteArray(); mAutoDetectFileEncoding = boolValue("auto_detect_file_encoding",true); - mUndoLimit = intValue("undo_limit",0); - mUndoMemoryUsage = intValue("undo_memory_usage", 0); mAutoFormatWhenSaved = boolValue("auto_format_when_saved", false); mRemoveTrailingSpacesWhenSaved = boolValue("remove_trailing_spaces_when_saved",false); mParseTodos = boolValue("parse_todos",true); diff --git a/RedPandaIDE/settings.h b/RedPandaIDE/settings.h index d880a5b4..5ca3c5a8 100644 --- a/RedPandaIDE/settings.h +++ b/RedPandaIDE/settings.h @@ -212,15 +212,6 @@ public: int gutterRightOffset() const; void setGutterRightOffset(int gutterRightOffset); - bool copySizeLimit() const; - void setCopySizeLimit(bool copyLimit); - - int copyCharLimits() const; - void setCopyCharLimits(int copyCharLimits); - - int copyLineLimits() const; - void setCopyLineLimits(int copyLineLimits); - bool copyRTFUseBackground() const; void setCopyRTFUseBackground(bool copyRTFUseBackground); @@ -362,12 +353,6 @@ public: bool autoDetectFileEncoding() const; void setAutoDetectFileEncoding(bool newAutoDetectFileEncoding); - int undoLimit() const; - void setUndoLimit(int newUndoLimit); - - int undoMemoryUsage() const; - void setUndoMemoryUsage(int newUndoMemoryUsage); - bool autoFormatWhenSaved() const; void setAutoFormatWhenSaved(bool newAutoFormatWhenSaved); @@ -471,9 +456,6 @@ public: bool mGutterFontOnlyMonospaced; //copy - bool mCopySizeLimit; - int mCopyCharLimits; - int mCopyLineLimits; int mCopyWithFormatAs; bool mCopyRTFUseBackground; bool mCopyRTFUseEditorColor; @@ -519,8 +501,6 @@ public: bool mReadOnlySytemHeader; bool mAutoLoadLastFiles; bool mDefaultFileCpp; - int mUndoLimit; - int mUndoMemoryUsage; bool mAutoFormatWhenSaved; bool mRemoveTrailingSpacesWhenSaved; bool mParseTodos; diff --git a/RedPandaIDE/settingsdialog/editorclipboardwidget.cpp b/RedPandaIDE/settingsdialog/editorclipboardwidget.cpp index 7e67dd70..d2c6db8d 100644 --- a/RedPandaIDE/settingsdialog/editorclipboardwidget.cpp +++ b/RedPandaIDE/settingsdialog/editorclipboardwidget.cpp @@ -60,10 +60,6 @@ void EditorClipboardWidget::doLoad() //pSettings->editor().load(); //copy QString mCopyHTMLColorScheme; - - ui->grpCopySizeLimit->setChecked(pSettings->editor().copySizeLimit()); - ui->spinCopyCharLimits->setValue(pSettings->editor().copyCharLimits()); - ui->spinCopyLineLimits->setValue(pSettings->editor().copyLineLimits()); ui->cbCopyWithFormatAs->setCurrentIndex(std::max(0,std::min(ui->cbCopyWithFormatAs->count(), pSettings->editor().copyWithFormatAs())) ); ui->chkCopyRTFUseBackground->setChecked(pSettings->editor().copyRTFUseBackground()); @@ -78,9 +74,6 @@ void EditorClipboardWidget::doLoad() void EditorClipboardWidget::doSave() { //copy - pSettings->editor().setCopySizeLimit(ui->grpCopySizeLimit->isChecked()); - pSettings->editor().setCopyCharLimits(ui->spinCopyCharLimits->value()); - pSettings->editor().setCopyLineLimits(ui->spinCopyLineLimits->value()); pSettings->editor().setCopyWithFormatAs(ui->cbCopyWithFormatAs->currentIndex()); pSettings->editor().setCopyRTFUseBackground(ui->chkCopyRTFUseBackground->isChecked()); diff --git a/RedPandaIDE/settingsdialog/editorclipboardwidget.ui b/RedPandaIDE/settingsdialog/editorclipboardwidget.ui index 18a181b5..e04d4822 100644 --- a/RedPandaIDE/settingsdialog/editorclipboardwidget.ui +++ b/RedPandaIDE/settingsdialog/editorclipboardwidget.ui @@ -14,90 +14,6 @@ Form - - - - Copy Size Limit - - - true - - - - - - Don't copy text larger than - - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Lines - - - - - - - Size(kilo characters): - - - - - - - 1 - - - 99999999 - - - - - - - 1 - - - 999999 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - @@ -277,9 +193,6 @@ - grpCopySizeLimit - spinCopyCharLimits - spinCopyLineLimits cbCopyWithFormatAs chkCopyHTMLUseBackground chkCopyHTMLUseEditorColor diff --git a/RedPandaIDE/settingsdialog/editormiscwidget.cpp b/RedPandaIDE/settingsdialog/editormiscwidget.cpp index db59d922..4d7bb962 100644 --- a/RedPandaIDE/settingsdialog/editormiscwidget.cpp +++ b/RedPandaIDE/settingsdialog/editormiscwidget.cpp @@ -64,8 +64,6 @@ void EditorMiscWidget::doLoad() } ui->cbEncodingDetail->setCurrentText(defaultEncoding); } - ui->spinMaxUndo->setValue(pSettings->editor().undoLimit()); - ui->spinMaxUndoMemory->setValue(pSettings->editor().undoMemoryUsage()); if (pSettings->editor().removeTrailingSpacesWhenSaved()) ui->rbRemoveTrailingSpaces->setChecked(true); else if (pSettings->editor().autoFormatWhenSaved()) @@ -88,8 +86,6 @@ void EditorMiscWidget::doSave() } else { pSettings->editor().setDefaultEncoding(ui->cbEncoding->currentData().toByteArray()); } - pSettings->editor().setUndoLimit(ui->spinMaxUndo->value()); - pSettings->editor().setUndoMemoryUsage(ui->spinMaxUndoMemory->value()); 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 77695623..4ec330d4 100644 --- a/RedPandaIDE/settingsdialog/editormiscwidget.ui +++ b/RedPandaIDE/settingsdialog/editormiscwidget.ui @@ -35,58 +35,6 @@ - - - - Limits for Undo - - - - - - Memory Usage - - - - - - - 0 - - - 1000000000 - - - 50 - - - 10000 - - - - - - - Steps - - - - - - - MB - - - 100 - - - 50 - - - - - - @@ -256,8 +204,6 @@ chkReadonlySystemHeaders chkLoadLastFiles chkParseTodos - spinMaxUndo - spinMaxUndoMemory rbNone rbAutoReformat rbRemoveTrailingSpaces diff --git a/RedPandaIDE/settingsdialog/environmentperformancewidget.cpp b/RedPandaIDE/settingsdialog/environmentperformancewidget.cpp index 93f705ef..123c8e2b 100644 --- a/RedPandaIDE/settingsdialog/environmentperformancewidget.cpp +++ b/RedPandaIDE/settingsdialog/environmentperformancewidget.cpp @@ -54,7 +54,6 @@ void EnvironmentPerformanceWidget::doLoad() // } //#endif ui->chkEditorsShareParser->setChecked(pSettings->codeCompletion().shareParser()); - ui->spinMaxUndoMemory->setValue(pSettings->editor().undoMemoryUsage()); } void EnvironmentPerformanceWidget::doSave() @@ -63,6 +62,5 @@ void EnvironmentPerformanceWidget::doSave() pSettings->codeCompletion().setShareParser(ui->chkEditorsShareParser->isChecked()); pSettings->codeCompletion().save(); - pSettings->editor().setUndoMemoryUsage(ui->spinMaxUndoMemory->value()); pSettings->editor().save(); } diff --git a/RedPandaIDE/settingsdialog/environmentperformancewidget.ui b/RedPandaIDE/settingsdialog/environmentperformancewidget.ui index 81e455e3..51493c82 100644 --- a/RedPandaIDE/settingsdialog/environmentperformancewidget.ui +++ b/RedPandaIDE/settingsdialog/environmentperformancewidget.ui @@ -34,57 +34,6 @@ - - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Max undo memory for each editor: - - - - - - - MB - - - 100 - - - 0 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - diff --git a/libs/qsynedit/qsynedit/document.cpp b/libs/qsynedit/qsynedit/document.cpp index 885464d8..7fc59c34 100644 --- a/libs/qsynedit/qsynedit/document.cpp +++ b/libs/qsynedit/qsynedit/document.cpp @@ -1373,16 +1373,12 @@ int DocumentLine::glyphStartChar(int i) const UndoList::UndoList():QObject() { - mMaxUndoActions = 1024; - mMaxMemoryUsage = 50 * 1024 * 1024; mNextChangeNumber = 1; mInsideRedo = false; mBlockChangeNumber=0; mBlockLock=0; mFullUndoImposible=false; - mBlockCount=0; - mMemoryUsage=0; mLastPoppedItemChangeNumber=0; mInitialChangeNumber = 0; mLastRestoredItemChangeNumber=0; @@ -1402,14 +1398,9 @@ void UndoList::addChange(ChangeReason reason, const BufferCoord &startPos, reason, selMode,startPos,endPos,changeText, changeNumber); -// qDebug()<<"add change"<changeNumber(); mItems.append(item); - addMemoryUsage(item); - ensureMaxEntries(); if (changeNumber>mNextChangeNumber) mNextChangeNumber=changeNumber; if (changeNumber!=mLastRestoredItemChangeNumber) { -// qDebug()<<"restore"< 0 && peekItem()->changeNumber() == iBlockID) { - mBlockCount++; -// qDebug()<<"end block"<memoryUsage(); -} - -void UndoList::reduceMemoryUsage(PUndoItem item) -{ - if (!item) - return; - mMemoryUsage -= item->memoryUsage(); -} - -int UndoList::maxMemoryUsage() const -{ - return mMaxMemoryUsage; -} - -void UndoList::setMaxMemoryUsage(int newMaxMemoryUsage) -{ - mMaxMemoryUsage = newMaxMemoryUsage; -} - ChangeReason UndoList::lastChangeReason() { if (mItems.count() == 0) @@ -1548,16 +1507,7 @@ PUndoItem UndoList::popItem() else { PUndoItem item = mItems.last(); // qDebug()<<"popped"<changeNumber()<changeText()<<(int)item->changeReason()<changeNumber() && item->changeReason()!=ChangeReason::GroupBreak) { - mBlockCount--; - Q_ASSERT(mBlockCount>=0); -// qDebug()<<"pop"<changeNumber(); - reduceMemoryUsage(item); mItems.removeLast(); return item; } @@ -1573,19 +1523,6 @@ int UndoList::itemCount() return mItems.count(); } -int UndoList::maxUndoActions() const -{ - return mMaxUndoActions; -} - -void UndoList::setMaxUndoActions(int maxUndoActions) -{ - if (maxUndoActions!=mMaxUndoActions) { - mMaxUndoActions = maxUndoActions; - ensureMaxEntries(); - } -} - bool UndoList::initialState() { if (itemCount() == 0) { @@ -1618,38 +1555,6 @@ bool UndoList::fullUndoImposible() const return mFullUndoImposible; } -void UndoList::ensureMaxEntries() -{ - if (mItems.isEmpty()) - return; -// qDebug()<0 && mBlockCount > mMaxUndoActions) - || (mMaxMemoryUsage>0 && mMemoryUsage>mMaxMemoryUsage)){ - PUndoItem lastItem = mItems.back(); - mFullUndoImposible = true; - while (((mMaxUndoActions >0 && mBlockCount > mMaxUndoActions) - || (mMaxMemoryUsage>0 && mMemoryUsage>mMaxMemoryUsage)) - && !mItems.isEmpty()) { - //remove all undo item in block - PUndoItem item = mItems.front(); - size_t changeNumber = item->changeNumber(); - //we shouldn't drop the newest changes; - if (changeNumber == lastItem->changeNumber()) - break; - while (mItems.count()>0) { - item = mItems.front(); - if (item->changeNumber()!=changeNumber) - break; - reduceMemoryUsage(item); - mItems.removeFirst(); - } - if (item->changeReason()!=ChangeReason::GroupBreak) - mBlockCount--; - } - } -// qDebug()< mItems; - int mMaxUndoActions; - int mMaxMemoryUsage; unsigned int mNextChangeNumber; unsigned int mInitialChangeNumber; bool mInsideRedo; diff --git a/libs/qsynedit/qsynedit/qsynedit.cpp b/libs/qsynedit/qsynedit/qsynedit.cpp index 3be655cf..f7768206 100644 --- a/libs/qsynedit/qsynedit/qsynedit.cpp +++ b/libs/qsynedit/qsynedit/qsynedit.cpp @@ -6493,17 +6493,6 @@ void QSynEdit::setGutterWidth(int Value) } } -void QSynEdit::setUndoLimit(int size) -{ - mUndoList->setMaxUndoActions(size); -} - -void QSynEdit::setUndoMemoryUsage(int size) -{ - mUndoList->setMaxMemoryUsage(size*1024*1024); -// mUndoList->setMaxMemoryUsage(size*1024); -} - void QSynEdit::onBookMarkOptionsChanged() { invalidateGutter(); diff --git a/libs/qsynedit/qsynedit/qsynedit.h b/libs/qsynedit/qsynedit/qsynedit.h index 91077935..313779ef 100644 --- a/libs/qsynedit/qsynedit/qsynedit.h +++ b/libs/qsynedit/qsynedit/qsynedit.h @@ -355,9 +355,6 @@ public: return clientWidth() - mGutterWidth - 2; } - void setUndoLimit(int size); - void setUndoMemoryUsage(int size); - int gutterWidth() const; void setGutterWidth(int value);