diff options
author | nyamatongwe <unknown> | 2006-10-17 00:32:34 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2006-10-17 00:32:34 +0000 |
commit | 672b30f73d556b09af3dc4d3afdc5ad24b841a44 (patch) | |
tree | 8df7c305d4f7536b2fe3bb1756449ceb11a4efe4 | |
parent | 924270507fe35db90f99a88eb13242e1c5799bbc (diff) | |
download | scintilla-mirror-672b30f73d556b09af3dc4d3afdc5ad24b841a44.tar.gz |
Armel Asselin contributed a feature that adds the flag SC_STARTACTION to
modification notifications where the modification is the first step of an
undo transaction. This is used to synchronize with the container's undo
stack.
-rw-r--r-- | doc/ScintillaDoc.html | 27 | ||||
-rw-r--r-- | include/Scintilla.h | 3 | ||||
-rw-r--r-- | include/Scintilla.iface | 3 | ||||
-rw-r--r-- | src/CellBuffer.cxx | 17 | ||||
-rw-r--r-- | src/CellBuffer.h | 6 | ||||
-rw-r--r-- | src/Document.cxx | 10 |
6 files changed, 44 insertions, 22 deletions
diff --git a/doc/ScintillaDoc.html b/doc/ScintillaDoc.html index 3767b3b24..3758bd05a 100644 --- a/doc/ScintillaDoc.html +++ b/doc/ScintillaDoc.html @@ -862,10 +862,10 @@ struct TextToFind { <p>Scintilla has multiple level undo and redo. It will continue to collect undoable actions until memory runs out. Scintilla saves actions that change the document. Scintilla does not save caret and selection movements, view scrolling and the like. Sequences of typing or - deleting are compressed into single actions to make it easier to undo and redo at a sensible - level of detail. Sequences of actions can be combined into actions that are undone as a unit. + deleting are compressed into single transactions to make it easier to undo and redo at a sensible + level of detail. Sequences of actions can be combined into transactions that are undone as a unit. These sequences occur between <code>SCI_BEGINUNDOACTION</code> and - <code>SCI_ENDUNDOACTION</code> messages. These sequences can be nested and only the top-level + <code>SCI_ENDUNDOACTION</code> messages. These transactions can be nested and only the top-level sequences are undone as units.</p> <code><a class="message" href="#SCI_UNDO">SCI_UNDO</a><br /> <a class="message" href="#SCI_CANUNDO">SCI_CANUNDO</a><br /> @@ -2419,7 +2419,7 @@ struct TextToFind { normal Unicode encoding before being drawn by the OS and thus can display Hebrew, Arabic, Cyrillic, and Han characters. Languages which can use two characters stacked vertically in one horizontal space, such as Thai, will mostly work but there are some issues where the characters - are drawn separately leading to visual glitches. Bi-directional text is not supported. Characters outside the + are drawn separately leading to visual glitches. Bi-directional text is not supported. Characters outside the Basic Multilingual Plane are unlikely to work.</p> <p>On Windows, code page can be set to 932 (Japanese Shift-JIS), 936 (Simplified Chinese GBK), @@ -4841,7 +4841,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber); <td align="center">0x80</td> - <td>This is part of a multi-step Undo or Redo.</td> + <td>This is part of a multi-step Undo or Redo transaction.</td> <td>None</td> </tr> @@ -4851,7 +4851,7 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber); <td align="center">0x100</td> - <td>This is the final step in an Undo or Redo.</td> + <td>This is the final step in an Undo or Redo transaction.</td> <td>None</td> </tr> @@ -4897,6 +4897,21 @@ href="#SCI_POSITIONFROMLINE">SCI_POSITIONFROMLINE</a>(lineNumber); </tr> <tr> + <td align="left"><code>SC_STARTACTION</code></td> + + <td align="center">0x2000</td> + + <td>This is set on a SC_PERFORMED_USER action when it is the + first or only step in an undo transaction. This can be used to integrate the Scintilla + undo stack with an undo stack in the container application by adding a Scintilla + action to the container's stack for the currently opened container transaction or + to open a new container transaction if there is no open container transaction. + </td> + + <td>None</td> + </tr> + + <tr> <td align="left"><code>SC_MODEVENTMASKALL</code></td> <td align="center">0x1fff</td> diff --git a/include/Scintilla.h b/include/Scintilla.h index 07469b47a..21bcbf490 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -647,7 +647,8 @@ typedef sptr_t (*SciFnDirect)(sptr_t ptr, unsigned int iMessage, uptr_t wParam, #define SC_MOD_BEFOREINSERT 0x400 #define SC_MOD_BEFOREDELETE 0x800 #define SC_MULTILINEUNDOREDO 0x1000 -#define SC_MODEVENTMASKALL 0x1FFF +#define SC_STARTACTION 0x2000 +#define SC_MODEVENTMASKALL 0x2FFF #define SCEN_CHANGE 768 #define SCEN_SETFOCUS 512 #define SCEN_KILLFOCUS 256 diff --git a/include/Scintilla.iface b/include/Scintilla.iface index 78e62b8ce..b9ff854e0 100644 --- a/include/Scintilla.iface +++ b/include/Scintilla.iface @@ -1728,7 +1728,8 @@ val SC_MOD_CHANGEMARKER=0x200 val SC_MOD_BEFOREINSERT=0x400 val SC_MOD_BEFOREDELETE=0x800 val SC_MULTILINEUNDOREDO=0x1000 -val SC_MODEVENTMASKALL=0x1FFF +val SC_STARTACTION=0x2000 +val SC_MODEVENTMASKALL=0x2FFF # For compatibility, these go through the COMMAND notification rather than NOTIFY # and should have had exactly the same values as the EN_* constants. diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index 1109a17fb..a6c0cf577 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -316,10 +316,10 @@ void LineVector::DeleteMark(int line, int markerNum, bool all) { delete linesData[line].handleSet; linesData[line].handleSet = 0; } else { - bool performedDeletion = + bool performedDeletion = linesData[line].handleSet->RemoveNumber(markerNum); while (all && performedDeletion) { - performedDeletion = + performedDeletion = linesData[line].handleSet->RemoveNumber(markerNum); } if (linesData[line].handleSet->Length() == 0) { @@ -446,7 +446,8 @@ void UndoHistory::EnsureUndoRoom() { } } -void UndoHistory::AppendAction(actionType at, int position, char *data, int lengthData) { +void UndoHistory::AppendAction(actionType at, int position, char *data, int lengthData, + bool &startSequence) { EnsureUndoRoom(); //Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction); //Platform::DebugPrintf("^ %d action %d %d\n", actions[currentAction - 1].at, @@ -454,6 +455,7 @@ void UndoHistory::AppendAction(actionType at, int position, char *data, int leng if (currentAction < savePoint) { savePoint = -1; } + int oldCurrentAction = currentAction; if (currentAction >= 1) { if (0 == undoSequenceDepth) { // Top level actions may not always be coalesced @@ -497,6 +499,7 @@ void UndoHistory::AppendAction(actionType at, int position, char *data, int leng } else { currentAction++; } + startSequence = oldCurrentAction != currentAction; actions[currentAction].Create(at, position, data, lengthData); currentAction++; actions[currentAction].Create(startAction); @@ -714,7 +717,7 @@ char CellBuffer::StyleAt(int position) { return ByteAt(position*2 + 1); } -const char *CellBuffer::InsertString(int position, char *s, int insertLength) { +const char *CellBuffer::InsertString(int position, char *s, int insertLength, bool &startSequence) { char *data = 0; // InsertString and DeleteChars are the bottleneck though which all changes occur if (!readOnly) { @@ -725,7 +728,7 @@ const char *CellBuffer::InsertString(int position, char *s, int insertLength) { for (int i = 0; i < insertLength / 2; i++) { data[i] = s[i * 2]; } - uh.AppendAction(insertAction, position / 2, data, insertLength / 2); + uh.AppendAction(insertAction, position / 2, data, insertLength / 2, startSequence); } BasicInsertString(position, s, insertLength); @@ -760,7 +763,7 @@ bool CellBuffer::SetStyleFor(int position, int lengthStyle, char style, char mas return changed; } -const char *CellBuffer::DeleteChars(int position, int deleteLength) { +const char *CellBuffer::DeleteChars(int position, int deleteLength, bool &startSequence) { // InsertString and DeleteChars are the bottleneck though which all changes occur PLATFORM_ASSERT(deleteLength > 0); char *data = 0; @@ -771,7 +774,7 @@ const char *CellBuffer::DeleteChars(int position, int deleteLength) { for (int i = 0; i < deleteLength / 2; i++) { data[i] = ByteAt(position + i * 2); } - uh.AppendAction(removeAction, position / 2, data, deleteLength / 2); + uh.AppendAction(removeAction, position / 2, data, deleteLength / 2, startSequence); } BasicDeleteChars(position, deleteLength); diff --git a/src/CellBuffer.h b/src/CellBuffer.h index bb81fd572..92bbfa0da 100644 --- a/src/CellBuffer.h +++ b/src/CellBuffer.h @@ -119,7 +119,7 @@ public: UndoHistory(); ~UndoHistory(); - void AppendAction(actionType at, int position, char *data, int length); + void AppendAction(actionType at, int position, char *data, int length, bool &startSequence); void BeginUndoAction(); void EndUndoAction(); @@ -190,14 +190,14 @@ public: int Lines(); int LineStart(int line); int LineFromPosition(int pos) { return lv.LineFromPosition(pos); } - const char *InsertString(int position, char *s, int insertLength); + const char *InsertString(int position, char *s, int insertLength, bool &startSequence); /// Setting styles for positions outside the range of the buffer is safe and has no effect. /// @return true if the style of a character is changed. bool SetStyleAt(int position, char style, char mask='\377'); bool SetStyleFor(int position, int length, char style, char mask); - const char *DeleteChars(int position, int deleteLength); + const char *DeleteChars(int position, int deleteLength, bool &startSequence); bool IsReadOnly(); void SetReadOnly(bool set); diff --git a/src/Document.cxx b/src/Document.cxx index 92be92691..fee76840d 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -380,7 +380,8 @@ bool Document::DeleteChars(int pos, int len) { 0, 0)); int prevLinesTotal = LinesTotal(); bool startSavePoint = cb.IsSavePoint(); - const char *text = cb.DeleteChars(pos * 2, len * 2); + bool startSequence = false; + const char *text = cb.DeleteChars(pos * 2, len * 2, startSequence); if (startSavePoint && cb.IsCollectingUndo()) NotifySavePoint(!startSavePoint); if ((pos < Length()) || (pos == 0)) @@ -389,7 +390,7 @@ bool Document::DeleteChars(int pos, int len) { ModifiedAt(pos-1); NotifyModified( DocModification( - SC_MOD_DELETETEXT | SC_PERFORMED_USER, + SC_MOD_DELETETEXT | SC_PERFORMED_USER | (startSequence?SC_STARTACTION:0), pos, len, LinesTotal() - prevLinesTotal, text)); } @@ -415,13 +416,14 @@ bool Document::InsertStyledString(int position, char *s, int insertLength) { 0, s)); int prevLinesTotal = LinesTotal(); bool startSavePoint = cb.IsSavePoint(); - const char *text = cb.InsertString(position, s, insertLength); + bool startSequence = false; + const char *text = cb.InsertString(position, s, insertLength, startSequence); if (startSavePoint && cb.IsCollectingUndo()) NotifySavePoint(!startSavePoint); ModifiedAt(position / 2); NotifyModified( DocModification( - SC_MOD_INSERTTEXT | SC_PERFORMED_USER, + SC_MOD_INSERTTEXT | SC_PERFORMED_USER | (startSequence?SC_STARTACTION:0), position / 2, insertLength / 2, LinesTotal() - prevLinesTotal, text)); } |