| 102 skipped lines |
|
| 104 | | 104 | | int Document::AddMark(int line, int markerNum) { |
|
| 105 | | 105 | | int prev = cb.AddMark(line, markerNum); |
|
| 106 | | DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0); | | 106 | | DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line); |
| | | 107 | | mh.line = line; |
| 107 | | 108 | | NotifyModified(mh); |
|
|
|
|
| | | 112 | | void Document::AddMarkSet(int line, int valueSet) { |
| | | 113 | | unsigned int m = valueSet; |
| | | 114 | | for (int i = 0; m; i++, m >>= 1) |
| | | 115 | | if (m & 1) |
| | | 116 | | cb.AddMark(line, i); |
| | | 117 | | DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line); |
| | | 118 | | mh.line = line; |
| | | 119 | | NotifyModified(mh); |
| | | 120 | | } |
| | | 121 | | |
| 111 | | 122 | | void Document::DeleteMark(int line, int markerNum) { |
|
| 112 | | 123 | | cb.DeleteMark(line, markerNum); |
|
| 113 | | DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0); | | 124 | | DocModification mh(SC_MOD_CHANGEMARKER, LineStart(line), 0, 0, 0, line); |
| | | 125 | | mh.line = line; |
| 114 | | 126 | | NotifyModified(mh); |
|
|
|
| 117 | | 129 | | void Document::DeleteMarkFromHandle(int markerHandle) { |
|
| 118 | | 130 | | cb.DeleteMarkFromHandle(markerHandle); |
|
| 119 | | 131 | | DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0); |
|
| | | 132 | | mh.line = -1; |
| 120 | | 133 | | NotifyModified(mh); |
|
|
|
| 123 | | 136 | | void Document::DeleteAllMarks(int markerNum) { |
|
| 124 | | 137 | | cb.DeleteAllMarks(markerNum); |
|
| 125 | | 138 | | DocModification mh(SC_MOD_CHANGEMARKER, 0, 0, 0, 0); |
|
| | | 139 | | mh.line = -1; |
| 126 | | 140 | | NotifyModified(mh); |
|
|
|
| 137 skipped lines |
|
|
|
| 269 | | #include <assert.h> | | 283 | | |
| 270 | | 284 | | // Normalise a position so that it is not halfway through a two byte character. |
|
| 271 | | 285 | | // This can occur in two situations - |
|
| 272 | | 286 | | // When lines are terminated with \r\n pairs which should be treated as one character. |
|
| 7 skipped lines |
| 280 | | 294 | | if (pos >= Length()) |
|
|
|
| 283 | | // assert pos > 0 && pos < Length() | | 297 | | // PLATFORM_ASSERT(pos > 0 && pos < Length()); |
| 284 | | 298 | | if (checkLineEnd && IsCrLf(pos - 1)) { |
|
|
|
| 49 skipped lines |
|
|
|
| | | 353 | | void Document::CheckReadOnly() { |
| | | 354 | | if (cb.IsReadOnly() && enteredReadOnlyCount == 0) { |
| | | 355 | | enteredReadOnlyCount++; |
| | | 356 | | NotifyModifyAttempt(); |
| | | 357 | | enteredReadOnlyCount--; |
| | | 358 | | } |
| | | 359 | | } |
| | | 360 | | |
| 339 | | 361 | | // Document only modified by gateways DeleteChars, InsertStyledString, Undo, Redo, and SetStyleAt. |
|
| 340 | | 362 | | // SetStyleAt does not change the persistent state of a document |
|
|
| 3 skipped lines |
|
| 346 | | 368 | | if ((pos + len) > Length()) |
|
|
| 348 | | if (cb.IsReadOnly() && enteredReadOnlyCount == 0) { | | 370 | | CheckReadOnly(); |
| 349 | | enteredReadOnlyCount++; | | |
| 350 | | NotifyModifyAttempt(); | | |
| 351 | | enteredReadOnlyCount--; | | |
| 352 | | } | | |
| 353 | | 371 | | if (enteredCount != 0) { |
|
|
|
| 28 skipped lines |
| 384 | | 402 | | * Insert a styled string (char/style pairs) with a length. |
|
|
| 386 | | 404 | | bool Document::InsertStyledString(int position, char *s, int insertLength) { |
|
| 387 | | if (cb.IsReadOnly() && enteredReadOnlyCount == 0) { | | 405 | | CheckReadOnly(); |
| 388 | | enteredReadOnlyCount++; | | |
| 389 | | NotifyModifyAttempt(); | | |
| 390 | | enteredReadOnlyCount--; | | |
| 391 | | } | | |
| 392 | | 406 | | if (enteredCount != 0) { |
|
|
|
| 22 skipped lines |
|
|
| 419 | | 433 | | int Document::Undo() { |
|
| 420 | | int newPos = 0; | | 434 | | int newPos = -1; |
| | | 435 | | CheckReadOnly(); |
| 421 | | 436 | | if (enteredCount == 0) { |
|
|
| | | 438 | | if (!cb.IsReadOnly()) { |
| 423 | | bool startSavePoint = cb.IsSavePoint(); | | 439 | | bool startSavePoint = cb.IsSavePoint(); |
| | | 440 | | bool multiLine = false; |
| 424 | | int steps = cb.StartUndo(); | | 441 | | int steps = cb.StartUndo(); |
| 425 | | //Platform::DebugPrintf("Steps=%d\n", steps); | | 442 | | //Platform::DebugPrintf("Steps=%d\n", steps); |
| 426 | | for (int step = 0; step < steps; step++) { | | 443 | | for (int step = 0; step < steps; step++) { |
| 427 | | int prevLinesTotal = LinesTotal(); | | 444 | | const int prevLinesTotal = LinesTotal(); |
| 428 | | const Action &action = cb.GetUndoStep(); | | 445 | | const Action &action = cb.GetUndoStep(); |
| 429 | | if (action.at == removeAction) { | | 446 | | if (action.at == removeAction) { |
| 430 | | NotifyModified(DocModification( | | 447 | | NotifyModified(DocModification( |
| 431 | | SC_MOD_BEFOREINSERT | SC_PERFORMED_UNDO, action)); | | 448 | | SC_MOD_BEFOREINSERT | SC_PERFORMED_UNDO, action)); |
| 432 | | } else { | | 449 | | } else { |
| 433 | | NotifyModified(DocModification( | | 450 | | NotifyModified(DocModification( |
| 434 | | SC_MOD_BEFOREDELETE | SC_PERFORMED_UNDO, action)); | | 451 | | SC_MOD_BEFOREDELETE | SC_PERFORMED_UNDO, action)); |
| 435 | | } | | 452 | | } |
| 436 | | cb.PerformUndoStep(); | | 453 | | cb.PerformUndoStep(); |
| 437 | | int cellPosition = action.position / 2; | | 454 | | int cellPosition = action.position; |
| 438 | | ModifiedAt(cellPosition); | | 455 | | ModifiedAt(cellPosition); |
| 439 | | newPos = cellPosition; | | 456 | | newPos = cellPosition; |
|
| 441 | | int modFlags = SC_PERFORMED_UNDO; | | 458 | | int modFlags = SC_PERFORMED_UNDO; |
| 442 | | // With undo, an insertion action becomes a deletion notification | | 459 | | // With undo, an insertion action becomes a deletion notification |
| 443 | | if (action.at == removeAction) { | | 460 | | if (action.at == removeAction) { |
| 444 | | newPos += action.lenData; | | 461 | | newPos += action.lenData; |
| 445 | | modFlags |= SC_MOD_INSERTTEXT; | | 462 | | modFlags |= SC_MOD_INSERTTEXT; |
| 446 | | } else { | | 463 | | } else { |
| 447 | | modFlags |= SC_MOD_DELETETEXT; | | 464 | | modFlags |= SC_MOD_DELETETEXT; |
| | | 465 | | } |
| | | 466 | | if (steps > 1) |
| | | 467 | | modFlags |= SC_MULTISTEPUNDOREDO; |
| | | 468 | | const int linesAdded = LinesTotal() - prevLinesTotal; |
| | | 469 | | if (linesAdded != 0) |
| | | 470 | | multiLine = true; |
| | | 471 | | if (step == steps - 1) { |
| | | 472 | | modFlags |= SC_LASTSTEPINUNDOREDO; |
| | | 473 | | if (multiLine) |
| | | 474 | | modFlags |= SC_MULTILINEUNDOREDO; |
| | | 475 | | } |
| | | 476 | | NotifyModified(DocModification(modFlags, cellPosition, action.lenData, |
| | | 477 | | linesAdded, action.data)); |
|
| 449 | | if (step == steps - 1) | | |
| 450 | | modFlags |= SC_LASTSTEPINUNDOREDO; | | |
| 451 | | NotifyModified(DocModification(modFlags, cellPosition, action.lenData, | | |
| 452 | | LinesTotal() - prevLinesTotal, action.data)); | | |
| 453 | | } | | |
|
| 455 | | bool endSavePoint = cb.IsSavePoint(); | | 480 | | bool endSavePoint = cb.IsSavePoint(); |
| 456 | | if (startSavePoint != endSavePoint) | | 481 | | if (startSavePoint != endSavePoint) |
| 457 | | NotifySavePoint(endSavePoint); | | 482 | | NotifySavePoint(endSavePoint); |
| | | 483 | | } |
|
|
|
|
|
| 463 | | 489 | | int Document::Redo() { |
|
| 464 | | int newPos = 0; | | 490 | | int newPos = -1; |
| | | 491 | | CheckReadOnly(); |
| 465 | | 492 | | if (enteredCount == 0) { |
|
|
| | | 494 | | if (!cb.IsReadOnly()) { |
| 467 | | bool startSavePoint = cb.IsSavePoint(); | | 495 | | bool startSavePoint = cb.IsSavePoint(); |
| | | 496 | | bool multiLine = false; |
| 468 | | int steps = cb.StartRedo(); | | 497 | | int steps = cb.StartRedo(); |
| 469 | | for (int step = 0; step < steps; step++) { | | 498 | | for (int step = 0; step < steps; step++) { |
| 470 | | int prevLinesTotal = LinesTotal(); | | 499 | | const int prevLinesTotal = LinesTotal(); |
| 471 | | const Action &action = cb.GetRedoStep(); | | 500 | | const Action &action = cb.GetRedoStep(); |
| 472 | | if (action.at == insertAction) { | | 501 | | if (action.at == insertAction) { |
| 473 | | NotifyModified(DocModification( | | 502 | | NotifyModified(DocModification( |
| 474 | | SC_MOD_BEFOREINSERT | SC_PERFORMED_REDO, action)); | | 503 | | SC_MOD_BEFOREINSERT | SC_PERFORMED_REDO, action)); |
| 475 | | } else { | | 504 | | } else { |
| 476 | | NotifyModified(DocModification( | | 505 | | NotifyModified(DocModification( |
| 477 | | SC_MOD_BEFOREDELETE | SC_PERFORMED_REDO, action)); | | 506 | | SC_MOD_BEFOREDELETE | SC_PERFORMED_REDO, action)); |
| 478 | | } | | 507 | | } |
| 479 | | cb.PerformRedoStep(); | | 508 | | cb.PerformRedoStep(); |
| 480 | | ModifiedAt(action.position / 2); | | 509 | | ModifiedAt(action.position); |
| 481 | | newPos = action.position / 2; | | 510 | | newPos = action.position; |
|
| 483 | | int modFlags = SC_PERFORMED_REDO; | | 512 | | int modFlags = SC_PERFORMED_REDO; |
| 484 | | if (action.at == insertAction) { | | 513 | | if (action.at == insertAction) { |
| 485 | | newPos += action.lenData; | | 514 | | newPos += action.lenData; |
| 486 | | modFlags |= SC_MOD_INSERTTEXT; | | 515 | | modFlags |= SC_MOD_INSERTTEXT; |
| 487 | | } else { | | 516 | | } else { |
| 488 | | modFlags |= SC_MOD_DELETETEXT; | | 517 | | modFlags |= SC_MOD_DELETETEXT; |
| | | 518 | | } |
| | | 519 | | if (steps > 1) |
| | | 520 | | modFlags |= SC_MULTISTEPUNDOREDO; |
| | | 521 | | const int linesAdded = LinesTotal() - prevLinesTotal; |
| | | 522 | | if (linesAdded != 0) |
| | | 523 | | multiLine = true; |
| | | 524 | | if ( |