mirror of https://github.com/buggins/dlangui.git
edit marks
This commit is contained in:
parent
f902ceb0b2
commit
1003270833
|
@ -295,10 +295,16 @@ class EditOperation {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void saved() {
|
//void saved() {
|
||||||
|
// for (int i = 0; i < _oldEditMarks.length; i++) {
|
||||||
|
// if (_oldEditMarks[i] == EditStateMark.changed)
|
||||||
|
// _oldEditMarks[i] = EditStateMark.saved;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
void modified(bool all = true) {
|
||||||
for (int i = 0; i < _oldEditMarks.length; i++) {
|
for (int i = 0; i < _oldEditMarks.length; i++) {
|
||||||
if (_oldEditMarks[i] == EditStateMark.changed)
|
if (all || _oldEditMarks[i] == EditStateMark.saved)
|
||||||
_oldEditMarks[i] = EditStateMark.saved;
|
_oldEditMarks[i] = EditStateMark.changed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,6 +329,7 @@ class UndoBuffer {
|
||||||
_redoList.clear();
|
_redoList.clear();
|
||||||
if (!_undoList.empty) {
|
if (!_undoList.empty) {
|
||||||
if (_undoList.back.merge(op)) {
|
if (_undoList.back.merge(op)) {
|
||||||
|
//_undoList.back.modified();
|
||||||
return; // merged - no need to add new operation
|
return; // merged - no need to add new operation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -360,24 +367,13 @@ class UndoBuffer {
|
||||||
void saved() {
|
void saved() {
|
||||||
_savedState = _undoList.peekBack;
|
_savedState = _undoList.peekBack;
|
||||||
for (int i = 0; i < _undoList.length; i++) {
|
for (int i = 0; i < _undoList.length; i++) {
|
||||||
_undoList[i].saved();
|
_undoList[i].modified();
|
||||||
}
|
}
|
||||||
for (int i = 0; i < _redoList.length; i++) {
|
for (int i = 0; i < _redoList.length; i++) {
|
||||||
_redoList[i].saved();
|
_redoList[i].modified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// returns true if saved state is in undo buffer
|
|
||||||
bool savedInUndo() {
|
|
||||||
if (!_savedState)
|
|
||||||
return false;
|
|
||||||
for (int i = 0; i < _undoList.length; i++) {
|
|
||||||
if (_savedState is _undoList[i])
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// returns true if saved state is in redo buffer
|
/// returns true if saved state is in redo buffer
|
||||||
bool savedInRedo() {
|
bool savedInRedo() {
|
||||||
if (!_savedState)
|
if (!_savedState)
|
||||||
|
@ -971,7 +967,7 @@ class EditableContent {
|
||||||
TextRange rangeBefore = op.newRange;
|
TextRange rangeBefore = op.newRange;
|
||||||
dstring[] oldcontent = op.content;
|
dstring[] oldcontent = op.content;
|
||||||
dstring[] newcontent = op.oldContent;
|
dstring[] newcontent = op.oldContent;
|
||||||
EditStateMark[] newmarks = _undoBuffer.savedInUndo() ? op.oldEditMarks : null;
|
EditStateMark[] newmarks = op.oldEditMarks; //_undoBuffer.savedInUndo() ? : null;
|
||||||
TextRange rangeAfter = op.range;
|
TextRange rangeAfter = op.range;
|
||||||
//Log.d("Undoing op rangeBefore=", rangeBefore, " contentBefore=`", oldcontent, "` rangeAfter=", rangeAfter, " contentAfter=`", newcontent, "`");
|
//Log.d("Undoing op rangeBefore=", rangeBefore, " contentBefore=`", oldcontent, "` rangeAfter=", rangeAfter, " contentAfter=`", newcontent, "`");
|
||||||
replaceRange(rangeBefore, rangeAfter, newcontent, newmarks);
|
replaceRange(rangeBefore, rangeAfter, newcontent, newmarks);
|
||||||
|
|
Loading…
Reference in New Issue