| 253 skipped lines |
| 254 | | 254 | | linesData[i] = linesData[i + 1]; |
|
|
|
| 257 | | // Level information merges back onto previous line | | 257 | | // Move up following lines but merge header flag from this line |
| 258 | | int posAbove = pos - 1; | | 258 | | // to line before to avoid a temporary disappearence causing expansion. |
| 259 | | if (posAbove < 0) | | |
| 260 | | posAbove = 0; | | 259 | | int firstHeader = levels[pos] & SC_FOLDLEVELHEADERFLAG; |
| 261 | | for (int j = posAbove; j < lines; j++) { | | 260 | | for (int j = pos; j < lines; j++) { |
| 262 | | 261 | | levels[j] = levels[j + 1]; |
|
|
| | | 263 | | if (pos > 0) |
| | | 264 | | levels[pos-1] |= firstHeader; |
|
|
|
| 197 skipped lines |
| 464 | | 465 | | } else if (currentAction == savePoint) { |
|
|
| 466 | | 467 | | } else if ((at == insertAction) && |
|
| 467 | | (position != (actPrevious.position + actPrevious.lenData*2))) { | | 468 | | (position != (actPrevious.position + actPrevious.lenData))) { |
| 468 | | 469 | | // Insertions must be immediately after to coalesce |
|
|
| 470 | | 471 | | } else if (!actions[currentAction].mayCoalesce) { |
|
| 1 skipped line |
|
| 473 | | 474 | | } else if (at == removeAction) { |
|
| 474 | | 475 | | if ((lengthData == 1) || (lengthData == 2)){ |
|
| 475 | | if ((position + lengthData * 2) == actPrevious.position) { | | 476 | | if ((position + lengthData) == actPrevious.position) { |
| 476 | | 477 | | ; // Backspace -> OK |
|
| 477 | | 478 | | } else if (position == actPrevious.position) { |
|
| 478 | | 479 | | ; // Delete -> OK |
|
| 245 skipped lines |
| 724 | | 725 | | for (int i = 0; i < insertLength / 2; i++) { |
|
| 725 | | 726 | | data[i] = s[i * 2]; |
|
|
| 727 | | uh.AppendAction(insertAction, position, data, insertLength / 2); | | 728 | | uh.AppendAction(insertAction, position / 2, data, insertLength / 2); |
|
|
| 730 | | 731 | | BasicInsertString(position, s, insertLength); |
|
| 1 skipped line |
|
|
|
| 735 | | void CellBuffer::InsertCharStyle(int position, char ch, char style) { | | |
| 736 | | char s[2]; | | |
| 737 | | s[0] = ch; | | |
| 738 | | s[1] = style; | | |
| 739 | | InsertString(position*2, s, 2); | | |
| 740 | | } | | |
| 741 | | | | |
| 742 | | 736 | | bool CellBuffer::SetStyleAt(int position, char style, char mask) { |
|
|
| 744 | | 738 | | char curVal = ByteAt(position * 2 + 1); |
|
| 23 skipped lines |
|
| 769 | | 763 | | const char *CellBuffer::DeleteChars(int position, int deleteLength) { |
|
| 770 | | 764 | | // InsertString and DeleteChars are the bottleneck though which all changes occur |
|
| | | 765 | | PLATFORM_ASSERT(deleteLength > 0); |
|
|
| 773 | | 768 | | if (collectingUndo) { |
|
| 2 skipped lines |
| 776 | | 771 | | for (int i = 0; i < deleteLength / 2; i++) { |
|
| 777 | | 772 | | data[i] = ByteAt(position + i * 2); |
|
|
| 779 | | uh.AppendAction(removeAction, position, data, deleteLength / 2); | | 774 | | uh.AppendAction(removeAction, position / 2, data, deleteLength / 2); |
|
|
| 782 | | 777 | | BasicDeleteChars(position, deleteLength); |
|
| 91 skipped lines |
| 874 | | 869 | | //Platform::DebugPrintf("Inserting at %d for %d\n", position, insertLength); |
|
| 875 | | 870 | | if (insertLength == 0) |
|
|
| | | 872 | | PLATFORM_ASSERT(insertLength > 0); |
| 877 | | 873 | | RoomFor(insertLength); |
|
|
|
| 148 skipped lines |
|
|
| 1030 | | 1026 | | bool CellBuffer::CanUndo() { |
|
| 1031 | | return (!readOnly) && (uh.CanUndo()); | | 1027 | | return uh.CanUndo(); |
|
|
| 1034 | | 1030 | | int CellBuffer::StartUndo() { |
|
| 7 skipped lines |
| 1042 | | 1038 | | void CellBuffer::PerformUndoStep() { |
|
| 1043 | | 1039 | | const Action &actionStep = uh.GetUndoStep(); |
|
| 1044 | | 1040 | | if (actionStep.at == insertAction) { |
|
| 1045 | | BasicDeleteChars(actionStep.position, actionStep.lenData*2); | | 1041 | | BasicDeleteChars(actionStep.position*2, actionStep.lenData*2); |
| 1046 | | 1042 | | } else if (actionStep.at == removeAction) { |
|
| 1047 | | 1043 | | char *styledData = new char[actionStep.lenData * 2]; |
|
| 1048 | | 1044 | | for (int i = 0; i < actionStep.lenData; i++) { |
|
| 1049 | | 1045 | | styledData[i*2] = actionStep.data[i]; |
|
| 1050 | | 1046 | | styledData[i*2 + 1] = 0; |
|
|
| 1052 | | BasicInsertString(actionStep.position, styledData, actionStep.lenData*2); | | 1048 | | BasicInsertString(actionStep.position*2, styledData, actionStep.lenData*2); |
| 1053 | | 1049 | | delete []styledData; |
|
|
| 1055 | | 1051 | | uh.CompletedUndoStep(); |
|
|
|
| 1058 | | 1054 | | bool CellBuffer::CanRedo() { |
|
| 1059 | | return (!readOnly) && (uh.CanRedo()); | | 1055 | | return uh.CanRedo(); |
|
|
| 1062 | | 1058 | | int CellBuffer::StartRedo() { |
|
| 12 skipped lines |
| 1075 | | 1071 | | styledData[i*2] = actionStep.data[i]; |
|
| 1076 | | 1072 | | styledData[i*2 + 1] = 0; |
|
|
| 1078 | | BasicInsertString(actionStep.position, styledData, actionStep.lenData*2); | | 1074 | | BasicInsertString(actionStep.position*2, styledData, actionStep.lenData*2); |
| 1079 | | 1075 | | delete []styledData; |
|
| 1080 | | 1076 | | } else if (actionStep.at == removeAction) { |
|
| 1081 | | BasicDeleteChars(actionStep.position, actionStep.lenData*2); | | 1077 | | BasicDeleteChars(actionStep.position*2, actionStep.lenData*2); |
|
| 1083 | | 1079 | | uh.CompletedRedoStep(); |
|
|
| 41 skipped lines |