- fix: when size of undo items is greater than the limit, old items should be poped in group
- enhancement: max undo size in option dialog's editor->misc tab
This commit is contained in:
parent
420d32a13a
commit
4209241dea
2
NEWS.md
2
NEWS.md
|
@ -7,6 +7,8 @@ Red Panda C++ Version 1.0.1
|
|||
- fix: corresponding '>' not correctly removed when deleting '<' in #include line
|
||||
- enhancement: shortcut for goto definition/declaration
|
||||
- change: ctrl+click symbol will goto definition, instead of got declaration
|
||||
- fix: when size of undo items is greater than the limit, old items should be poped in group
|
||||
- enhancement: max undo size in option dialog's editor->misc tab
|
||||
|
||||
Red Panda C++ Version 1.0.0
|
||||
- fix: calculation for code snippets's tab stop positions is not correct
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -4397,6 +4397,8 @@ void Editor::applySettings()
|
|||
setRightEdge(0);
|
||||
}
|
||||
|
||||
this->setUndoLimit(pSettings->editor().undoLimit());
|
||||
|
||||
setMouseWheelScrollSpeed(pSettings->editor().mouseWheelScrollSpeed());
|
||||
setMouseSelectionScrollSpeed(pSettings->editor().mouseSelectionScrollSpeed());
|
||||
invalidate();
|
||||
|
|
|
@ -6320,6 +6320,13 @@ int SynEdit::charWidth() const
|
|||
return mCharWidth;
|
||||
}
|
||||
|
||||
void SynEdit::setUndoLimit(int size)
|
||||
{
|
||||
mUndoList->setMaxUndoActions(size);
|
||||
|
||||
mRedoList->setMaxUndoActions(size);
|
||||
}
|
||||
|
||||
int SynEdit::charsInWindow() const
|
||||
{
|
||||
return mCharsInWindow;
|
||||
|
|
|
@ -323,6 +323,8 @@ public:
|
|||
|
||||
int charWidth() const;
|
||||
|
||||
void setUndoLimit(int size);
|
||||
|
||||
int gutterWidth() const;
|
||||
void setGutterWidth(int value);
|
||||
|
||||
|
|
|
@ -930,7 +930,7 @@ void SynEditUndoList::PushItem(PSynEditUndoItem Item)
|
|||
if (!Item)
|
||||
return;
|
||||
mItems.append(Item);
|
||||
EnsureMaxEntries();
|
||||
ensureMaxEntries();
|
||||
if (Item->changeReason()!= SynChangeReason::crGroupBreak)
|
||||
emit addedUndo();
|
||||
}
|
||||
|
@ -958,7 +958,10 @@ int SynEditUndoList::maxUndoActions() const
|
|||
|
||||
void SynEditUndoList::setMaxUndoActions(int maxUndoActions)
|
||||
{
|
||||
mMaxUndoActions = maxUndoActions;
|
||||
if (maxUndoActions!=mMaxUndoActions) {
|
||||
mMaxUndoActions = maxUndoActions;
|
||||
ensureMaxEntries();
|
||||
}
|
||||
}
|
||||
|
||||
bool SynEditUndoList::initialState()
|
||||
|
@ -1032,12 +1035,16 @@ bool SynEditUndoList::fullUndoImposible() const
|
|||
return mFullUndoImposible;
|
||||
}
|
||||
|
||||
void SynEditUndoList::EnsureMaxEntries()
|
||||
void SynEditUndoList::ensureMaxEntries()
|
||||
{
|
||||
qDebug()<<mItems.count()<<mMaxUndoActions;
|
||||
if (mItems.count() > mMaxUndoActions){
|
||||
mFullUndoImposible = true;
|
||||
while (mItems.count() > mMaxUndoActions) {
|
||||
mItems.removeFirst();
|
||||
//remove all undo item in block
|
||||
int changeNumber = mItems.front()->changeNumber();
|
||||
while (mItems.count()>0 && mItems.front()->changeNumber() == changeNumber)
|
||||
mItems.removeFirst();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -234,7 +234,7 @@ public:
|
|||
signals:
|
||||
void addedUndo();
|
||||
protected:
|
||||
void EnsureMaxEntries();
|
||||
void ensureMaxEntries();
|
||||
protected:
|
||||
int mBlockChangeNumber;
|
||||
int mBlockCount;
|
||||
|
|
|
@ -624,6 +624,16 @@ void Settings::Editor::setAutoDetectFileEncoding(bool newAutoDetectFileEncoding)
|
|||
mAutoDetectFileEncoding = newAutoDetectFileEncoding;
|
||||
}
|
||||
|
||||
int Settings::Editor::undoLimit() const
|
||||
{
|
||||
return mUndoLimit;
|
||||
}
|
||||
|
||||
void Settings::Editor::setUndoLimit(int newUndoLimit)
|
||||
{
|
||||
mUndoLimit = newUndoLimit;
|
||||
}
|
||||
|
||||
bool Settings::Editor::highlightCurrentWord() const
|
||||
{
|
||||
return mHighlightCurrentWord;
|
||||
|
@ -1202,6 +1212,7 @@ 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);
|
||||
|
||||
//tooltips
|
||||
saveValue("enable_tooltips",mEnableTooltips);
|
||||
|
@ -1339,6 +1350,8 @@ void Settings::Editor::doLoad()
|
|||
else
|
||||
mDefaultEncoding = value("default_encoding", ENCODING_SYSTEM_DEFAULT).toByteArray();
|
||||
mAutoDetectFileEncoding = boolValue("auto_detect_file_encoding",true);
|
||||
mUndoLimit = intValue("undo_limit",1000);
|
||||
|
||||
|
||||
//tooltips
|
||||
mEnableTooltips = boolValue("enable_tooltips",true);
|
||||
|
|
|
@ -375,6 +375,9 @@ public:
|
|||
bool autoDetectFileEncoding() const;
|
||||
void setAutoDetectFileEncoding(bool newAutoDetectFileEncoding);
|
||||
|
||||
int undoLimit() const;
|
||||
void setUndoLimit(int newUndoLimit);
|
||||
|
||||
private:
|
||||
//General
|
||||
// indents
|
||||
|
@ -481,6 +484,8 @@ public:
|
|||
bool mReadOnlySytemHeader;
|
||||
bool mAutoLoadLastFiles;
|
||||
bool mDefaultFileCpp;
|
||||
int mUndoLimit;
|
||||
|
||||
|
||||
//hints tooltip
|
||||
bool mEnableTooltips;
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "ui_editormiscwidget.h"
|
||||
#include "../settings.h"
|
||||
#include "../platform.h"
|
||||
#include "../mainwindow.h"
|
||||
|
||||
EditorMiscWidget::EditorMiscWidget(const QString& name, const QString& group,
|
||||
QWidget *parent) :
|
||||
|
@ -62,6 +63,7 @@ void EditorMiscWidget::doLoad()
|
|||
}
|
||||
ui->cbEncodingDetail->setCurrentText(defaultEncoding);
|
||||
}
|
||||
ui->spinMaxUndo->setValue(pSettings->editor().undoLimit());
|
||||
}
|
||||
|
||||
void EditorMiscWidget::doSave()
|
||||
|
@ -76,7 +78,9 @@ void EditorMiscWidget::doSave()
|
|||
} else {
|
||||
pSettings->editor().setDefaultEncoding(ui->cbEncoding->currentData().toByteArray());
|
||||
}
|
||||
pSettings->editor().setUndoLimit(ui->spinMaxUndo->value());
|
||||
pSettings->editor().save();
|
||||
pMainWindow->updateEditorSettings();
|
||||
}
|
||||
|
||||
void EditorMiscWidget::init()
|
||||
|
|
|
@ -35,6 +35,57 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Max Undo Steps</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinMaxUndo">
|
||||
<property name="minimum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>1000000000</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>50</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
|
|
Loading…
Reference in New Issue