Applied patch from Armel Asselin (thanks). It adds SC_START_ACTION notification.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@877 ea778897-0a13-0410-b9d1-a72fbfd435f5
master
Enrico Tröger 2006-10-10 14:27:58 +00:00
parent c3972d6b2d
commit 5815ae99a9
4 changed files with 21 additions and 15 deletions

View File

@ -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,7 @@ 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 +454,8 @@ 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);

View File

@ -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);

View File

@ -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_START_ACTION: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_START_ACTION:0),
position / 2, insertLength / 2,
LinesTotal() - prevLinesTotal, text));
}

View File

@ -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_START_ACTION 0x2000
#define SC_MODEVENTMASKALL 0x2FFF
#define SCEN_CHANGE 768
#define SCEN_SETFOCUS 512
#define SCEN_KILLFOCUS 256