work save
This commit is contained in:
parent
fc6b582402
commit
10631f54d7
|
@ -3425,7 +3425,12 @@ QString SynEdit::expandAtWideGlyphs(const QString &S)
|
||||||
|
|
||||||
void SynEdit::updateModifiedStatus()
|
void SynEdit::updateModifiedStatus()
|
||||||
{
|
{
|
||||||
setModified(!mUndoList->isEmpty());
|
bool oldModified = mModified;
|
||||||
|
mModified = !mUndoList->initialState();
|
||||||
|
setModified(mModified);
|
||||||
|
qDebug()<<mModified<<oldModified;
|
||||||
|
if (oldModified!=mModified)
|
||||||
|
emit statusChanged(SynStatusChange::scModifyChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SynEdit::scanFrom(int Index, int canStopIndex)
|
int SynEdit::scanFrom(int Index, int canStopIndex)
|
||||||
|
@ -4301,8 +4306,8 @@ void SynEdit::doUndo()
|
||||||
|
|
||||||
PSynEditUndoItem item = mUndoList->peekItem();
|
PSynEditUndoItem item = mUndoList->peekItem();
|
||||||
if (item) {
|
if (item) {
|
||||||
int oldChangeNumber = item->changeNumber();
|
size_t oldChangeNumber = item->changeNumber();
|
||||||
int saveChangeNumber = mRedoList->blockChangeNumber();
|
size_t saveChangeNumber = mRedoList->blockChangeNumber();
|
||||||
mRedoList->setBlockChangeNumber(item->changeNumber());
|
mRedoList->setBlockChangeNumber(item->changeNumber());
|
||||||
{
|
{
|
||||||
auto action = finally([&,this] {
|
auto action = finally([&,this] {
|
||||||
|
@ -4473,8 +4478,8 @@ void SynEdit::doRedo()
|
||||||
PSynEditUndoItem item = mRedoList->peekItem();
|
PSynEditUndoItem item = mRedoList->peekItem();
|
||||||
if (!item)
|
if (!item)
|
||||||
return;
|
return;
|
||||||
int oldChangeNumber = item->changeNumber();
|
size_t oldChangeNumber = item->changeNumber();
|
||||||
int saveChangeNumber = mUndoList->blockChangeNumber();
|
size_t saveChangeNumber = mUndoList->blockChangeNumber();
|
||||||
mUndoList->setBlockChangeNumber(item->changeNumber());
|
mUndoList->setBlockChangeNumber(item->changeNumber());
|
||||||
{
|
{
|
||||||
auto action = finally([&,this]{
|
auto action = finally([&,this]{
|
||||||
|
@ -6549,10 +6554,16 @@ void SynEdit::setModified(bool Value)
|
||||||
}
|
}
|
||||||
if (Value != mModified) {
|
if (Value != mModified) {
|
||||||
mModified = Value;
|
mModified = Value;
|
||||||
if (mOptions.testFlag(SynEditorOption::eoGroupUndo) && (!Value) ) {
|
|
||||||
mUndoList->addGroupBreak();
|
if (Value) {
|
||||||
|
mUndoList->clear();
|
||||||
|
mRedoList->clear();
|
||||||
|
} else {
|
||||||
|
if (mOptions.testFlag(SynEditorOption::eoGroupUndo)) {
|
||||||
|
mUndoList->addGroupBreak();
|
||||||
|
}
|
||||||
|
mUndoList->setInitialState();
|
||||||
}
|
}
|
||||||
mUndoList->setInitialState(!Value);
|
|
||||||
emit statusChanged(SynStatusChange::scModifyChanged);
|
emit statusChanged(SynStatusChange::scModifyChanged);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6689,6 +6700,8 @@ void SynEdit::onUndoAdded()
|
||||||
if (! mUndoList->insideRedo() &&
|
if (! mUndoList->insideRedo() &&
|
||||||
mUndoList->peekItem() && (mUndoList->peekItem()->changeReason()!=SynChangeReason::GroupBreak))
|
mUndoList->peekItem() && (mUndoList->peekItem()->changeReason()!=SynChangeReason::GroupBreak))
|
||||||
mRedoList->clear();
|
mRedoList->clear();
|
||||||
|
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
SynSelectionMode SynEdit::activeSelectionMode() const
|
SynSelectionMode SynEdit::activeSelectionMode() const
|
||||||
|
@ -6899,6 +6912,7 @@ void SynEdit::setTopLine(int Value)
|
||||||
void SynEdit::onRedoAdded()
|
void SynEdit::onRedoAdded()
|
||||||
{
|
{
|
||||||
updateModifiedStatus();
|
updateModifiedStatus();
|
||||||
|
onChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEdit::onGutterChanged()
|
void SynEdit::onGutterChanged()
|
||||||
|
|
|
@ -842,6 +842,8 @@ SynEditUndoList::SynEditUndoList():QObject()
|
||||||
mBlockChangeNumber=0;
|
mBlockChangeNumber=0;
|
||||||
mBlockLockCount=0;
|
mBlockLockCount=0;
|
||||||
mFullUndoImposible=false;
|
mFullUndoImposible=false;
|
||||||
|
mBlockCount=0;
|
||||||
|
mLastPoppedItemChangeNumber=0;
|
||||||
mInitialChangeNumber = 0;
|
mInitialChangeNumber = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -855,11 +857,13 @@ void SynEditUndoList::addChange(SynChangeReason AReason, const BufferCoord &ASta
|
||||||
} else {
|
} else {
|
||||||
changeNumber = getNextChangeNumber();
|
changeNumber = getNextChangeNumber();
|
||||||
}
|
}
|
||||||
PSynEditUndoItem NewItem = std::make_shared<SynEditUndoItem>(AReason,
|
PSynEditUndoItem newItem = std::make_shared<SynEditUndoItem>(AReason,
|
||||||
SelMode,AStart,AEnd,ChangeText,
|
SelMode,AStart,AEnd,ChangeText,
|
||||||
changeNumber);
|
changeNumber);
|
||||||
pushItem(NewItem);
|
mItems.append(newItem);
|
||||||
if (mBlockLockCount == 0) {
|
ensureMaxEntries();
|
||||||
|
if (AReason!=SynChangeReason::GroupBreak && !inBlock()) {
|
||||||
|
mBlockCount++;
|
||||||
emit addedUndo();
|
emit addedUndo();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -884,14 +888,10 @@ void SynEditUndoList::clear()
|
||||||
{
|
{
|
||||||
mItems.clear();
|
mItems.clear();
|
||||||
mFullUndoImposible = false;
|
mFullUndoImposible = false;
|
||||||
}
|
mInitialChangeNumber=0;
|
||||||
|
mLastPoppedItemChangeNumber=0;
|
||||||
void SynEditUndoList::deleteItem(int index)
|
mBlockCount=0;
|
||||||
{
|
mBlockLockCount=0;
|
||||||
if (index <0 || index>=mItems.count()) {
|
|
||||||
ListIndexOutOfBounds(index);
|
|
||||||
}
|
|
||||||
mItems.removeAt(index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEditUndoList::endBlock()
|
void SynEditUndoList::endBlock()
|
||||||
|
@ -899,10 +899,12 @@ void SynEditUndoList::endBlock()
|
||||||
if (mBlockLockCount > 0) {
|
if (mBlockLockCount > 0) {
|
||||||
mBlockLockCount--;
|
mBlockLockCount--;
|
||||||
if (mBlockLockCount == 0) {
|
if (mBlockLockCount == 0) {
|
||||||
int iBlockID = mBlockChangeNumber;
|
size_t iBlockID = mBlockChangeNumber;
|
||||||
mBlockChangeNumber = 0;
|
mBlockChangeNumber = 0;
|
||||||
if (mItems.count() > 0 && peekItem()->changeNumber() == iBlockID)
|
if (mItems.count() > 0 && peekItem()->changeNumber() == iBlockID) {
|
||||||
|
mBlockCount++;
|
||||||
emit addedUndo();
|
emit addedUndo();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -944,19 +946,19 @@ PSynEditUndoItem SynEditUndoList::popItem()
|
||||||
return PSynEditUndoItem();
|
return PSynEditUndoItem();
|
||||||
else {
|
else {
|
||||||
PSynEditUndoItem item = mItems.last();
|
PSynEditUndoItem item = mItems.last();
|
||||||
|
if (mLastPoppedItemChangeNumber!=item->changeNumber()) {
|
||||||
|
mBlockCount--;
|
||||||
|
if (mBlockCount<0) {
|
||||||
|
qDebug()<<"block count calculation error";
|
||||||
|
mBlockCount=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mLastPoppedItemChangeNumber = item->changeNumber();
|
||||||
mItems.removeLast();
|
mItems.removeLast();
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEditUndoList::pushItem(PSynEditUndoItem Item)
|
|
||||||
{
|
|
||||||
if (!Item)
|
|
||||||
return;
|
|
||||||
mItems.append(Item);
|
|
||||||
ensureMaxEntries();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SynEditUndoList::canUndo()
|
bool SynEditUndoList::canUndo()
|
||||||
{
|
{
|
||||||
return mItems.count()>0;
|
return mItems.count()>0;
|
||||||
|
@ -980,20 +982,21 @@ void SynEditUndoList::setMaxUndoActions(int maxUndoActions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PSynEditUndoItem SynEditUndoList::item(int index)
|
bool SynEditUndoList::initialState()
|
||||||
{
|
{
|
||||||
if (index <0 || index>=mItems.count()) {
|
if (itemCount() == 0) {
|
||||||
ListIndexOutOfBounds(index);
|
return mInitialChangeNumber==0;
|
||||||
|
} else {
|
||||||
|
return peekItem()->changeNumber() == mInitialChangeNumber;
|
||||||
}
|
}
|
||||||
return mItems[index];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SynEditUndoList::setItem(int index, PSynEditUndoItem Value)
|
void SynEditUndoList::setInitialState()
|
||||||
{
|
{
|
||||||
if (index <0 || index>=mItems.count()) {
|
if (itemCount() == 0)
|
||||||
ListIndexOutOfBounds(index);
|
mInitialChangeNumber = 0;
|
||||||
}
|
else
|
||||||
mItems[index]=Value;
|
mInitialChangeNumber = peekItem()->changeNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
int SynEditUndoList::blockChangeNumber() const
|
int SynEditUndoList::blockChangeNumber() const
|
||||||
|
@ -1023,13 +1026,14 @@ bool SynEditUndoList::fullUndoImposible() const
|
||||||
|
|
||||||
void SynEditUndoList::ensureMaxEntries()
|
void SynEditUndoList::ensureMaxEntries()
|
||||||
{
|
{
|
||||||
if (mMaxUndoActions>0 && mItems.count() > mMaxUndoActions){
|
if (mMaxUndoActions>0 && mBlockCount > mMaxUndoActions){
|
||||||
mFullUndoImposible = true;
|
mFullUndoImposible = true;
|
||||||
while (mItems.count() > mMaxUndoActions) {
|
while (mBlockCount > mMaxUndoActions && !mItems.isEmpty()) {
|
||||||
//remove all undo item in block
|
//remove all undo item in block
|
||||||
int changeNumber = mItems.front()->changeNumber();
|
size_t changeNumber = mItems.front()->changeNumber();
|
||||||
while (mItems.count()>0 && mItems.front()->changeNumber() == changeNumber)
|
while (mItems.count()>0 && mItems.front()->changeNumber() == changeNumber)
|
||||||
mItems.removeFirst();
|
mItems.removeFirst();
|
||||||
|
mBlockCount--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1054,7 +1058,7 @@ QStringList SynEditUndoItem::changeText() const
|
||||||
return mChangeText;
|
return mChangeText;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SynEditUndoItem::changeNumber() const
|
size_t SynEditUndoItem::changeNumber() const
|
||||||
{
|
{
|
||||||
return mChangeNumber;
|
return mChangeNumber;
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,7 +194,7 @@ public:
|
||||||
BufferCoord changeStartPos() const;
|
BufferCoord changeStartPos() const;
|
||||||
BufferCoord changeEndPos() const;
|
BufferCoord changeEndPos() const;
|
||||||
QStringList changeText() const;
|
QStringList changeText() const;
|
||||||
int changeNumber() const;
|
size_t changeNumber() const;
|
||||||
};
|
};
|
||||||
using PSynEditUndoItem = std::shared_ptr<SynEditUndoItem>;
|
using PSynEditUndoItem = std::shared_ptr<SynEditUndoItem>;
|
||||||
|
|
||||||
|
@ -211,22 +211,18 @@ public:
|
||||||
void endBlock();
|
void endBlock();
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
void deleteItem(int index);
|
|
||||||
SynChangeReason lastChangeReason();
|
SynChangeReason lastChangeReason();
|
||||||
bool isEmpty();
|
bool isEmpty();
|
||||||
PSynEditUndoItem peekItem();
|
PSynEditUndoItem peekItem();
|
||||||
PSynEditUndoItem popItem();
|
PSynEditUndoItem popItem();
|
||||||
void pushItem(PSynEditUndoItem Item);
|
|
||||||
|
|
||||||
|
|
||||||
bool canUndo();
|
bool canUndo();
|
||||||
int itemCount();
|
int itemCount();
|
||||||
|
|
||||||
int maxUndoActions() const;
|
int maxUndoActions() const;
|
||||||
void setMaxUndoActions(int maxUndoActions);
|
void setMaxUndoActions(int maxUndoActions);
|
||||||
|
bool initialState();
|
||||||
PSynEditUndoItem item(int index);
|
void setInitialState();
|
||||||
void setItem(int index, PSynEditUndoItem Value);
|
|
||||||
|
|
||||||
int blockChangeNumber() const;
|
int blockChangeNumber() const;
|
||||||
void setBlockChangeNumber(int blockChangeNumber);
|
void setBlockChangeNumber(int blockChangeNumber);
|
||||||
|
@ -245,10 +241,13 @@ protected:
|
||||||
protected:
|
protected:
|
||||||
size_t mBlockChangeNumber;
|
size_t mBlockChangeNumber;
|
||||||
int mBlockLockCount;
|
int mBlockLockCount;
|
||||||
|
int mBlockCount; // count of action blocks;
|
||||||
|
size_t mLastPoppedItemChangeNumber;
|
||||||
bool mFullUndoImposible;
|
bool mFullUndoImposible;
|
||||||
QVector<PSynEditUndoItem> mItems;
|
QVector<PSynEditUndoItem> mItems;
|
||||||
int mMaxUndoActions;
|
int mMaxUndoActions;
|
||||||
size_t mNextChangeNumber;
|
size_t mNextChangeNumber;
|
||||||
|
size_t mInitialChangeNumber;
|
||||||
bool mInsideRedo;
|
bool mInsideRedo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -110,13 +110,13 @@ enum Direction {
|
||||||
};
|
};
|
||||||
|
|
||||||
// from windows style
|
// from windows style
|
||||||
static const int windowsItemFrame = 2; // menu item frame width
|
//static const int windowsItemFrame = 2; // menu item frame width
|
||||||
static const int windowsItemHMargin = 3; // menu item hor text margin
|
//static const int windowsItemHMargin = 3; // menu item hor text margin
|
||||||
static const int windowsItemVMargin = 8; // menu item ver text margin
|
//static const int windowsItemVMargin = 8; // menu item ver text margin
|
||||||
static const int windowsRightBorder = 15; // right border on windows
|
//static const int windowsRightBorder = 15; // right border on windows
|
||||||
|
|
||||||
static const int groupBoxBottomMargin = 0; // space below the groupbox
|
//static const int groupBoxBottomMargin = 0; // space below the groupbox
|
||||||
static const int groupBoxTopMargin = 3;
|
//static const int groupBoxTopMargin = 3;
|
||||||
|
|
||||||
DarkFusionStyle::DarkFusionStyle():QProxyStyle("fusion")
|
DarkFusionStyle::DarkFusionStyle():QProxyStyle("fusion")
|
||||||
{
|
{
|
||||||
|
@ -849,7 +849,7 @@ void DarkFusionStyle::drawControl(ControlElement element, const QStyleOption *op
|
||||||
{
|
{
|
||||||
QRect rect = option->rect;
|
QRect rect = option->rect;
|
||||||
QColor outline = calcOutline(option->palette);
|
QColor outline = calcOutline(option->palette);
|
||||||
QColor highlightedOutline = calcHighlightedOutline(option->palette);
|
//QColor highlightedOutline = calcHighlightedOutline(option->palette);
|
||||||
QColor shadow = calcDarkShade();
|
QColor shadow = calcDarkShade();
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue