diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CellBuffer.cxx | 8 | ||||
-rw-r--r-- | src/CellBuffer.h | 3 | ||||
-rw-r--r-- | src/Document.cxx | 24 | ||||
-rw-r--r-- | src/Document.h | 8 | ||||
-rw-r--r-- | src/Editor.cxx | 5 |
5 files changed, 39 insertions, 9 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index 0e9ae6950..ccb357a41 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -424,6 +424,9 @@ void UndoHistory::AppendAction(actionType at, int position, char *data, int leng } else if (!actions[currentAction].mayCoalesce) { // Not allowed to coalesce if this set currentAction++; + } else if (at == containerAction) { + // Not allowed to coalesce container actions + currentAction++; } else if (at == removeAction) { if ((lengthData == 1) || (lengthData == 2)){ if ((position + lengthData) == actPrevious.position) { @@ -862,6 +865,11 @@ void CellBuffer::EndUndoAction() { uh.EndUndoAction(); } +void CellBuffer::AddUndoAction(int token) { + bool startSequence; + uh.AppendAction(containerAction, token, 0, 0, startSequence); +} + void CellBuffer::DeleteUndoHistory() { uh.DeleteUndoHistory(); } diff --git a/src/CellBuffer.h b/src/CellBuffer.h index 4b83f48e0..6cf8ad056 100644 --- a/src/CellBuffer.h +++ b/src/CellBuffer.h @@ -83,7 +83,7 @@ public: int LineFromHandle(int markerHandle); }; -enum actionType { insertAction, removeAction, startAction }; +enum actionType { insertAction, removeAction, startAction, containerAction }; /** * Actions are used to store all the information required to perform one undo/redo step. @@ -213,6 +213,7 @@ public: bool IsCollectingUndo(); void BeginUndoAction(); void EndUndoAction(); + void AddUndoAction(int token); void DeleteUndoHistory(); /// To perform an undo, StartUndo is called to retrieve the number of steps, then UndoStep is diff --git a/src/Document.cxx b/src/Document.cxx index 611da25a0..e5913ad98 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -503,21 +503,27 @@ int Document::Undo() { if (action.at == removeAction) { NotifyModified(DocModification( SC_MOD_BEFOREINSERT | SC_PERFORMED_UNDO, action)); + } else if (action.at == containerAction) { + DocModification dm(SC_MOD_CONTAINER | SC_PERFORMED_UNDO); + dm.token = action.position; + NotifyModified(dm); } else { NotifyModified(DocModification( SC_MOD_BEFOREDELETE | SC_PERFORMED_UNDO, action)); } cb.PerformUndoStep(); int cellPosition = action.position; - ModifiedAt(cellPosition); - newPos = cellPosition; + if (action.at != containerAction) { + ModifiedAt(cellPosition); + newPos = cellPosition; + } int modFlags = SC_PERFORMED_UNDO; // With undo, an insertion action becomes a deletion notification if (action.at == removeAction) { newPos += action.lenData; modFlags |= SC_MOD_INSERTTEXT; - } else { + } else if (action.at == insertAction) { modFlags |= SC_MOD_DELETETEXT; } if (steps > 1) @@ -558,19 +564,25 @@ int Document::Redo() { if (action.at == insertAction) { NotifyModified(DocModification( SC_MOD_BEFOREINSERT | SC_PERFORMED_REDO, action)); + } else if (action.at == containerAction) { + DocModification dm(SC_MOD_CONTAINER | SC_PERFORMED_REDO); + dm.token = action.position; + NotifyModified(dm); } else { NotifyModified(DocModification( SC_MOD_BEFOREDELETE | SC_PERFORMED_REDO, action)); } cb.PerformRedoStep(); - ModifiedAt(action.position); - newPos = action.position; + if (action.at != containerAction) { + ModifiedAt(action.position); + newPos = action.position; + } int modFlags = SC_PERFORMED_REDO; if (action.at == insertAction) { newPos += action.lenData; modFlags |= SC_MOD_INSERTTEXT; - } else { + } else if (action.at == removeAction) { modFlags |= SC_MOD_DELETETEXT; } if (steps > 1) diff --git a/src/Document.h b/src/Document.h index 0457b475b..2e8c43eeb 100644 --- a/src/Document.h +++ b/src/Document.h @@ -173,6 +173,7 @@ public: bool IsCollectingUndo() { return cb.IsCollectingUndo(); } void BeginUndoAction() { cb.BeginUndoAction(); } void EndUndoAction() { cb.EndUndoAction(); } + void AddUndoAction(int token) { cb.AddUndoAction(token); } void SetSavePoint(); bool IsSavePoint() { return cb.IsSavePoint(); } const char *BufferPointer() { return cb.BufferPointer(); } @@ -288,6 +289,7 @@ public: int line; int foldLevelNow; int foldLevelPrev; + int token; DocModification(int modificationType_, int position_=0, int length_=0, int linesAdded_=0, const char *text_=0, int line_=0) : @@ -298,7 +300,8 @@ public: text(text_), line(line_), foldLevelNow(0), - foldLevelPrev(0) {} + foldLevelPrev(0), + token(0) {} DocModification(int modificationType_, const Action &act, int linesAdded_=0) : modificationType(modificationType_), @@ -308,7 +311,8 @@ public: text(act.data), line(0), foldLevelNow(0), - foldLevelPrev(0) {} + foldLevelPrev(0), + token(0) {} }; /** diff --git a/src/Editor.cxx b/src/Editor.cxx index 7ba26bb53..5d709fe06 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -3961,6 +3961,7 @@ void Editor::NotifyModified(Document*, DocModification mh, void *) { scn.line = mh.line; scn.foldLevelNow = mh.foldLevelNow; scn.foldLevelPrev = mh.foldLevelPrev; + scn.token = mh.token; NotifyParent(scn); } } @@ -7635,6 +7636,10 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETEXTRADESCENT: return vs.extraDescent; + case SCI_ADDUNDOACTION: + pdoc->AddUndoAction(wParam); + break; + default: return DefWndProc(iMessage, wParam, lParam); } |