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