diff options
-rw-r--r-- | src/CellBuffer.cxx | 23 | ||||
-rw-r--r-- | src/CellBuffer.h | 1 | ||||
-rw-r--r-- | src/Document.cxx | 8 | ||||
-rw-r--r-- | src/Document.h | 2 |
4 files changed, 13 insertions, 21 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index 2e8349481..1109a17fb 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -465,7 +465,7 @@ void UndoHistory::AppendAction(actionType at, int position, char *data, int leng } else if (currentAction == savePoint) { currentAction++; } else if ((at == insertAction) && - (position != (actPrevious.position + actPrevious.lenData*2))) { + (position != (actPrevious.position + actPrevious.lenData))) { // Insertions must be immediately after to coalesce currentAction++; } else if (!actions[currentAction].mayCoalesce) { @@ -473,7 +473,7 @@ void UndoHistory::AppendAction(actionType at, int position, char *data, int leng currentAction++; } else if (at == removeAction) { if ((lengthData == 1) || (lengthData == 2)){ - if ((position + lengthData * 2) == actPrevious.position) { + if ((position + lengthData) == actPrevious.position) { ; // Backspace -> OK } else if (position == actPrevious.position) { ; // Delete -> OK @@ -725,7 +725,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, data, insertLength / 2); + uh.AppendAction(insertAction, position / 2, data, insertLength / 2); } BasicInsertString(position, s, insertLength); @@ -733,13 +733,6 @@ const char *CellBuffer::InsertString(int position, char *s, int insertLength) { return data; } -void CellBuffer::InsertCharStyle(int position, char ch, char style) { - char s[2]; - s[0] = ch; - s[1] = style; - InsertString(position*2, s, 2); -} - bool CellBuffer::SetStyleAt(int position, char style, char mask) { style &= mask; char curVal = ByteAt(position * 2 + 1); @@ -778,7 +771,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, data, deleteLength / 2); + uh.AppendAction(removeAction, position / 2, data, deleteLength / 2); } BasicDeleteChars(position, deleteLength); @@ -1045,14 +1038,14 @@ const Action &CellBuffer::GetUndoStep() const { void CellBuffer::PerformUndoStep() { const Action &actionStep = uh.GetUndoStep(); if (actionStep.at == insertAction) { - BasicDeleteChars(actionStep.position, actionStep.lenData*2); + BasicDeleteChars(actionStep.position*2, actionStep.lenData*2); } else if (actionStep.at == removeAction) { char *styledData = new char[actionStep.lenData * 2]; for (int i = 0; i < actionStep.lenData; i++) { styledData[i*2] = actionStep.data[i]; styledData[i*2 + 1] = 0; } - BasicInsertString(actionStep.position, styledData, actionStep.lenData*2); + BasicInsertString(actionStep.position*2, styledData, actionStep.lenData*2); delete []styledData; } uh.CompletedUndoStep(); @@ -1078,10 +1071,10 @@ void CellBuffer::PerformRedoStep() { styledData[i*2] = actionStep.data[i]; styledData[i*2 + 1] = 0; } - BasicInsertString(actionStep.position, styledData, actionStep.lenData*2); + BasicInsertString(actionStep.position*2, styledData, actionStep.lenData*2); delete []styledData; } else if (actionStep.at == removeAction) { - BasicDeleteChars(actionStep.position, actionStep.lenData*2); + BasicDeleteChars(actionStep.position*2, actionStep.lenData*2); } uh.CompletedRedoStep(); } diff --git a/src/CellBuffer.h b/src/CellBuffer.h index b16eef5e5..bb81fd572 100644 --- a/src/CellBuffer.h +++ b/src/CellBuffer.h @@ -191,7 +191,6 @@ public: int LineStart(int line); int LineFromPosition(int pos) { return lv.LineFromPosition(pos); } const char *InsertString(int position, char *s, int insertLength); - void InsertCharStyle(int position, char ch, char style); /// 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. diff --git a/src/Document.cxx b/src/Document.cxx index 7b189541a..a88468cb1 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -451,7 +451,7 @@ int Document::Undo() { SC_MOD_BEFOREDELETE | SC_PERFORMED_UNDO, action)); } cb.PerformUndoStep(); - int cellPosition = action.position / 2; + int cellPosition = action.position; ModifiedAt(cellPosition); newPos = cellPosition; @@ -506,8 +506,8 @@ int Document::Redo() { SC_MOD_BEFOREDELETE | SC_PERFORMED_REDO, action)); } cb.PerformRedoStep(); - ModifiedAt(action.position / 2); - newPos = action.position / 2; + ModifiedAt(action.position); + newPos = action.position; int modFlags = SC_PERFORMED_REDO; if (action.at == insertAction) { @@ -527,7 +527,7 @@ int Document::Redo() { modFlags |= SC_MULTILINEUNDOREDO; } NotifyModified( - DocModification(modFlags, action.position / 2, action.lenData, + DocModification(modFlags, action.position, action.lenData, linesAdded, action.data)); } diff --git a/src/Document.h b/src/Document.h index 3c0273d0f..6ff858b92 100644 --- a/src/Document.h +++ b/src/Document.h @@ -278,7 +278,7 @@ public: DocModification(int modificationType_, const Action &act, int linesAdded_=0) : modificationType(modificationType_), - position(act.position / 2), + position(act.position), length(act.lenData), linesAdded(linesAdded_), text(act.data), |