1 // Scintilla source code edit control
\r
2 /** @file CellBuffer.cxx
\r
3 ** Manages a buffer of cells.
\r
5 // Copyright 1998-2001 by Neil Hodgson <neilh@scintilla.org>
\r
6 // The License.txt file describes the conditions under which this software may be distributed.
\r
13 #include "Platform.h"
\r
15 #include "Scintilla.h"
\r
16 #include "SplitVector.h"
\r
17 #include "Partitioning.h"
\r
18 #include "CellBuffer.h"
\r
20 #ifdef SCI_NAMESPACE
\r
21 using namespace Scintilla;
\r
24 MarkerHandleSet::MarkerHandleSet() {
\r
28 MarkerHandleSet::~MarkerHandleSet() {
\r
29 MarkerHandleNumber *mhn = root;
\r
31 MarkerHandleNumber *mhnToFree = mhn;
\r
38 int MarkerHandleSet::Length() const {
\r
40 MarkerHandleNumber *mhn = root;
\r
48 int MarkerHandleSet::NumberFromHandle(int handle) const {
\r
49 MarkerHandleNumber *mhn = root;
\r
51 if (mhn->handle == handle) {
\r
59 int MarkerHandleSet::MarkValue() const {
\r
61 MarkerHandleNumber *mhn = root;
\r
63 m |= (1 << mhn->number);
\r
69 bool MarkerHandleSet::Contains(int handle) const {
\r
70 MarkerHandleNumber *mhn = root;
\r
72 if (mhn->handle == handle) {
\r
80 bool MarkerHandleSet::InsertHandle(int handle, int markerNum) {
\r
81 MarkerHandleNumber *mhn = new MarkerHandleNumber;
\r
84 mhn->handle = handle;
\r
85 mhn->number = markerNum;
\r
91 void MarkerHandleSet::RemoveHandle(int handle) {
\r
92 MarkerHandleNumber **pmhn = &root;
\r
94 MarkerHandleNumber *mhn = *pmhn;
\r
95 if (mhn->handle == handle) {
\r
100 pmhn = &((*pmhn)->next);
\r
104 bool MarkerHandleSet::RemoveNumber(int markerNum) {
\r
105 bool performedDeletion = false;
\r
106 MarkerHandleNumber **pmhn = &root;
\r
108 MarkerHandleNumber *mhn = *pmhn;
\r
109 if (mhn->number == markerNum) {
\r
112 performedDeletion = true;
\r
114 pmhn = &((*pmhn)->next);
\r
117 return performedDeletion;
\r
120 void MarkerHandleSet::CombineWith(MarkerHandleSet *other) {
\r
121 MarkerHandleNumber **pmhn = &root;
\r
123 pmhn = &((*pmhn)->next);
\r
125 *pmhn = other->root;
\r
129 LineVector::LineVector() : starts(256) {
\r
135 LineVector::~LineVector() {
\r
136 starts.DeleteAll();
\r
137 for (int line = 0; line < markers.Length(); line++) {
\r
138 delete markers[line];
\r
141 markers.DeleteAll();
\r
142 levels.DeleteAll();
\r
145 void LineVector::Init() {
\r
146 starts.DeleteAll();
\r
147 for (int line = 0; line < markers.Length(); line++) {
\r
148 delete markers[line];
\r
151 markers.DeleteAll();
\r
152 levels.DeleteAll();
\r
155 void LineVector::ExpandLevels(int sizeNew) {
\r
156 levels.InsertValue(levels.Length(), sizeNew - levels.Length(), SC_FOLDLEVELBASE);
\r
159 void LineVector::ClearLevels() {
\r
160 levels.DeleteAll();
\r
163 int LineVector::SetLevel(int line, int level) {
\r
165 if ((line >= 0) && (line < Lines())) {
\r
166 if (!levels.Length()) {
\r
167 ExpandLevels(Lines() + 1);
\r
169 prev = levels[line];
\r
170 if (prev != level) {
\r
171 levels[line] = level;
\r
177 int LineVector::GetLevel(int line) {
\r
178 if (levels.Length() && (line >= 0) && (line < Lines())) {
\r
179 return levels[line];
\r
181 return SC_FOLDLEVELBASE;
\r
185 void LineVector::InsertText(int line, int delta) {
\r
186 starts.InsertText(line, delta);
\r
189 void LineVector::InsertLine(int line, int position) {
\r
190 starts.InsertPartition(line, position);
\r
191 if (markers.Length()) {
\r
192 markers.Insert(line, 0);
\r
194 if (levels.Length()) {
\r
195 int level = SC_FOLDLEVELBASE;
\r
196 if ((line > 0) && (line < Lines())) {
\r
197 level = levels[line-1] & ~SC_FOLDLEVELWHITEFLAG;
\r
199 levels.InsertValue(line, 1, level);
\r
203 void LineVector::SetLineStart(int line, int position) {
\r
204 starts.SetPartitionStartPosition(line, position);
\r
207 void LineVector::RemoveLine(int line) {
\r
208 starts.RemovePartition(line);
\r
209 // Retain the markers from the deleted line by oring them into the previous line
\r
210 if (markers.Length()) {
\r
212 MergeMarkers(line - 1);
\r
214 markers.Delete(line);
\r
216 if (levels.Length()) {
\r
217 // Move up following lines but merge header flag from this line
\r
218 // to line before to avoid a temporary disappearence causing expansion.
\r
219 int firstHeader = levels[line] & SC_FOLDLEVELHEADERFLAG;
\r
220 levels.Delete(line);
\r
222 levels[line-1] |= firstHeader;
\r
226 int LineVector::LineFromPosition(int pos) {
\r
227 return starts.PartitionFromPosition(pos);
\r
230 int LineVector::MarkValue(int line) {
\r
231 if (markers.Length() && markers[line])
\r
232 return markers[line]->MarkValue();
\r
237 int LineVector::AddMark(int line, int markerNum) {
\r
239 if (!markers.Length()) {
\r
240 // No existing markers so allocate one element per line
\r
241 markers.InsertValue(0, Lines(), 0);
\r
243 if (!markers[line]) {
\r
244 // Need new structure to hold marker handle
\r
245 markers[line] = new MarkerHandleSet();
\r
246 if (!markers[line])
\r
249 markers[line]->InsertHandle(handleCurrent, markerNum);
\r
251 return handleCurrent;
\r
254 void LineVector::MergeMarkers(int pos) {
\r
255 if (markers[pos + 1] != NULL) {
\r
256 if (markers[pos] == NULL)
\r
257 markers[pos] = new MarkerHandleSet;
\r
258 markers[pos]->CombineWith(markers[pos + 1]);
\r
259 delete markers[pos + 1];
\r
260 markers[pos + 1] = NULL;
\r
264 void LineVector::DeleteMark(int line, int markerNum, bool all) {
\r
265 if (markers.Length() && markers[line]) {
\r
266 if (markerNum == -1) {
\r
267 delete markers[line];
\r
268 markers[line] = NULL;
\r
270 bool performedDeletion = markers[line]->RemoveNumber(markerNum);
\r
271 while (all && performedDeletion) {
\r
272 performedDeletion = markers[line]->RemoveNumber(markerNum);
\r
274 if (markers[line]->Length() == 0) {
\r
275 delete markers[line];
\r
276 markers[line] = NULL;
\r
282 void LineVector::DeleteMarkFromHandle(int markerHandle) {
\r
283 int line = LineFromHandle(markerHandle);
\r
285 markers[line]->RemoveHandle(markerHandle);
\r
286 if (markers[line]->Length() == 0) {
\r
287 delete markers[line];
\r
288 markers[line] = NULL;
\r
293 int LineVector::LineFromHandle(int markerHandle) {
\r
294 if (markers.Length()) {
\r
295 for (int line = 0; line < Lines(); line++) {
\r
296 if (markers[line]) {
\r
297 if (markers[line]->Contains(markerHandle)) {
\r
313 Action::~Action() {
\r
317 void Action::Create(actionType at_, int position_, char *data_, int lenData_, bool mayCoalesce_) {
\r
319 position = position_;
\r
322 lenData = lenData_;
\r
323 mayCoalesce = mayCoalesce_;
\r
326 void Action::Destroy() {
\r
331 void Action::Grab(Action *source) {
\r
334 position = source->position;
\r
336 data = source->data;
\r
337 lenData = source->lenData;
\r
338 mayCoalesce = source->mayCoalesce;
\r
340 // Ownership of source data transferred to this
\r
341 source->position = 0;
\r
342 source->at = startAction;
\r
344 source->lenData = 0;
\r
345 source->mayCoalesce = true;
\r
348 // The undo history stores a sequence of user operations that represent the user's view of the
\r
349 // commands executed on the text.
\r
350 // Each user operation contains a sequence of text insertion and text deletion actions.
\r
351 // All the user operations are stored in a list of individual actions with 'start' actions used
\r
352 // as delimiters between user operations.
\r
353 // Initially there is one start action in the history.
\r
354 // As each action is performed, it is recorded in the history. The action may either become
\r
355 // part of the current user operation or may start a new user operation. If it is to be part of the
\r
356 // current operation, then it overwrites the current last action. If it is to be part of a new
\r
357 // operation, it is appended after the current last action.
\r
358 // After writing the new action, a new start action is appended at the end of the history.
\r
359 // The decision of whether to start a new user operation is based upon two factors. If a
\r
360 // compound operation has been explicitly started by calling BeginUndoAction and no matching
\r
361 // EndUndoAction (these calls nest) has been called, then the action is coalesced into the current
\r
362 // operation. If there is no outstanding BeginUndoAction call then a new operation is started
\r
363 // unless it looks as if the new action is caused by the user typing or deleting a stream of text.
\r
364 // Sequences that look like typing or deletion are coalesced into a single user operation.
\r
366 UndoHistory::UndoHistory() {
\r
369 actions = new Action[lenActions];
\r
372 undoSequenceDepth = 0;
\r
375 actions[currentAction].Create(startAction);
\r
378 UndoHistory::~UndoHistory() {
\r
383 void UndoHistory::EnsureUndoRoom() {
\r
384 // Have to test that there is room for 2 more actions in the array
\r
385 // as two actions may be created by the calling function
\r
386 if (currentAction >= (lenActions - 2)) {
\r
387 // Run out of undo nodes so extend the array
\r
388 int lenActionsNew = lenActions * 2;
\r
389 Action *actionsNew = new Action[lenActionsNew];
\r
392 for (int act = 0; act <= currentAction; act++)
\r
393 actionsNew[act].Grab(&actions[act]);
\r
395 lenActions = lenActionsNew;
\r
396 actions = actionsNew;
\r
400 void UndoHistory::AppendAction(actionType at, int position, char *data, int lengthData,
\r
401 bool &startSequence) {
\r
403 //Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction);
\r
404 //Platform::DebugPrintf("^ %d action %d %d\n", actions[currentAction - 1].at,
\r
405 // actions[currentAction - 1].position, actions[currentAction - 1].lenData);
\r
406 if (currentAction < savePoint) {
\r
409 int oldCurrentAction = currentAction;
\r
410 if (currentAction >= 1) {
\r
411 if (0 == undoSequenceDepth) {
\r
412 // Top level actions may not always be coalesced
\r
413 Action &actPrevious = actions[currentAction - 1];
\r
414 // See if current action can be coalesced into previous action
\r
415 // Will work if both are inserts or deletes and position is same
\r
416 if (at != actPrevious.at) {
\r
418 } else if (currentAction == savePoint) {
\r
420 } else if ((at == insertAction) &&
\r
421 (position != (actPrevious.position + actPrevious.lenData))) {
\r
422 // Insertions must be immediately after to coalesce
\r
424 } else if (!actions[currentAction].mayCoalesce) {
\r
425 // Not allowed to coalesce if this set
\r
427 } else if (at == removeAction) {
\r
428 if ((lengthData == 1) || (lengthData == 2)){
\r
429 if ((position + lengthData) == actPrevious.position) {
\r
430 ; // Backspace -> OK
\r
431 } else if (position == actPrevious.position) {
\r
434 // Removals must be at same position to coalesce
\r
438 // Removals must be of one character to coalesce
\r
442 // Action coalesced.
\r
446 // Actions not at top level are always coalesced unless this is after return to top level
\r
447 if (!actions[currentAction].mayCoalesce)
\r
453 startSequence = oldCurrentAction != currentAction;
\r
454 actions[currentAction].Create(at, position, data, lengthData);
\r
456 actions[currentAction].Create(startAction);
\r
457 maxAction = currentAction;
\r
460 void UndoHistory::BeginUndoAction() {
\r
462 if (undoSequenceDepth == 0) {
\r
463 if (actions[currentAction].at != startAction) {
\r
465 actions[currentAction].Create(startAction);
\r
466 maxAction = currentAction;
\r
468 actions[currentAction].mayCoalesce = false;
\r
470 undoSequenceDepth++;
\r
473 void UndoHistory::EndUndoAction() {
\r
474 PLATFORM_ASSERT(undoSequenceDepth > 0);
\r
476 undoSequenceDepth--;
\r
477 if (0 == undoSequenceDepth) {
\r
478 if (actions[currentAction].at != startAction) {
\r
480 actions[currentAction].Create(startAction);
\r
481 maxAction = currentAction;
\r
483 actions[currentAction].mayCoalesce = false;
\r
487 void UndoHistory::DropUndoSequence() {
\r
488 undoSequenceDepth = 0;
\r
491 void UndoHistory::DeleteUndoHistory() {
\r
492 for (int i = 1; i < maxAction; i++)
\r
493 actions[i].Destroy();
\r
496 actions[currentAction].Create(startAction);
\r
500 void UndoHistory::SetSavePoint() {
\r
501 savePoint = currentAction;
\r
504 bool UndoHistory::IsSavePoint() const {
\r
505 return savePoint == currentAction;
\r
508 bool UndoHistory::CanUndo() const {
\r
509 return (currentAction > 0) && (maxAction > 0);
\r
512 int UndoHistory::StartUndo() {
\r
513 // Drop any trailing startAction
\r
514 if (actions[currentAction].at == startAction && currentAction > 0)
\r
517 // Count the steps in this action
\r
518 int act = currentAction;
\r
519 while (actions[act].at != startAction && act > 0) {
\r
522 return currentAction - act;
\r
525 const Action &UndoHistory::GetUndoStep() const {
\r
526 return actions[currentAction];
\r
529 void UndoHistory::CompletedUndoStep() {
\r
533 bool UndoHistory::CanRedo() const {
\r
534 return maxAction > currentAction;
\r
537 int UndoHistory::StartRedo() {
\r
538 // Drop any leading startAction
\r
539 if (actions[currentAction].at == startAction && currentAction < maxAction)
\r
542 // Count the steps in this action
\r
543 int act = currentAction;
\r
544 while (actions[act].at != startAction && act < maxAction) {
\r
547 return act - currentAction;
\r
550 const Action &UndoHistory::GetRedoStep() const {
\r
551 return actions[currentAction];
\r
554 void UndoHistory::CompletedRedoStep() {
\r
558 CellBuffer::CellBuffer() {
\r
560 collectingUndo = true;
\r
563 CellBuffer::~CellBuffer() {
\r
566 char CellBuffer::CharAt(int position) const {
\r
567 return substance.ValueAt(position);
\r
570 void CellBuffer::GetCharRange(char *buffer, int position, int lengthRetrieve) {
\r
571 if (lengthRetrieve < 0)
\r
575 if ((position + lengthRetrieve) > substance.Length()) {
\r
576 Platform::DebugPrintf("Bad GetCharRange %d for %d of %d\n", position,
\r
577 lengthRetrieve, substance.Length());
\r
581 for (int i=0; i<lengthRetrieve; i++) {
\r
582 *buffer++ = substance.ValueAt(position + i);
\r
586 char CellBuffer::StyleAt(int position) {
\r
587 return style.ValueAt(position);
\r
590 const char *CellBuffer::BufferPointer() {
\r
591 return substance.BufferPointer();
\r
594 // The char* returned is to an allocation owned by the undo history
\r
595 const char *CellBuffer::InsertString(int position, const char *s, int insertLength, bool &startSequence) {
\r
597 // InsertString and DeleteChars are the bottleneck though which all changes occur
\r
599 if (collectingUndo) {
\r
600 // Save into the undo/redo stack, but only the characters - not the formatting
\r
601 // This takes up about half load time
\r
602 data = new char[insertLength];
\r
603 for (int i = 0; i < insertLength; i++) {
\r
606 uh.AppendAction(insertAction, position, data, insertLength, startSequence);
\r
609 BasicInsertString(position, s, insertLength);
\r
614 bool CellBuffer::SetStyleAt(int position, char styleValue, char mask) {
\r
615 styleValue &= mask;
\r
616 char curVal = style.ValueAt(position);
\r
617 if ((curVal & mask) != styleValue) {
\r
618 style.SetValueAt(position, static_cast<char>((curVal & ~mask) | styleValue));
\r
625 bool CellBuffer::SetStyleFor(int position, int lengthStyle, char styleValue, char mask) {
\r
626 bool changed = false;
\r
627 PLATFORM_ASSERT(lengthStyle == 0 ||
\r
628 (lengthStyle > 0 && lengthStyle + position <= style.Length()));
\r
629 while (lengthStyle--) {
\r
630 char curVal = style.ValueAt(position);
\r
631 if ((curVal & mask) != styleValue) {
\r
632 style.SetValueAt(position, static_cast<char>((curVal & ~mask) | styleValue));
\r
640 // The char* returned is to an allocation owned by the undo history
\r
641 const char *CellBuffer::DeleteChars(int position, int deleteLength, bool &startSequence) {
\r
642 // InsertString and DeleteChars are the bottleneck though which all changes occur
\r
643 PLATFORM_ASSERT(deleteLength > 0);
\r
646 if (collectingUndo) {
\r
647 // Save into the undo/redo stack, but only the characters - not the formatting
\r
648 data = new char[deleteLength];
\r
649 for (int i = 0; i < deleteLength; i++) {
\r
650 data[i] = substance.ValueAt(position + i);
\r
652 uh.AppendAction(removeAction, position, data, deleteLength, startSequence);
\r
655 BasicDeleteChars(position, deleteLength);
\r
660 int CellBuffer::Length() const {
\r
661 return substance.Length();
\r
664 void CellBuffer::Allocate(int newSize) {
\r
665 substance.ReAllocate(newSize);
\r
666 style.ReAllocate(newSize);
\r
669 int CellBuffer::Lines() const {
\r
673 int CellBuffer::LineStart(int line) const {
\r
676 else if (line >= Lines())
\r
679 return lv.LineStart(line);
\r
682 bool CellBuffer::IsReadOnly() {
\r
686 void CellBuffer::SetReadOnly(bool set) {
\r
690 void CellBuffer::SetSavePoint() {
\r
694 bool CellBuffer::IsSavePoint() {
\r
695 return uh.IsSavePoint();
\r
698 int CellBuffer::AddMark(int line, int markerNum) {
\r
699 if ((line >= 0) && (line < Lines())) {
\r
700 return lv.AddMark(line, markerNum);
\r
705 void CellBuffer::DeleteMark(int line, int markerNum) {
\r
706 if ((line >= 0) && (line < Lines())) {
\r
707 lv.DeleteMark(line, markerNum, false);
\r
711 void CellBuffer::DeleteMarkFromHandle(int markerHandle) {
\r
712 lv.DeleteMarkFromHandle(markerHandle);
\r
715 int CellBuffer::GetMark(int line) {
\r
716 if ((line >= 0) && (line < Lines()))
\r
717 return lv.MarkValue(line);
\r
721 void CellBuffer::DeleteAllMarks(int markerNum) {
\r
722 for (int line = 0; line < Lines(); line++) {
\r
723 lv.DeleteMark(line, markerNum, true);
\r
727 int CellBuffer::LineFromHandle(int markerHandle) {
\r
728 return lv.LineFromHandle(markerHandle);
\r
733 void CellBuffer::InsertLine(int line, int position) {
\r
734 lv.InsertLine(line, position);
\r
735 if (lineStates.Length()) {
\r
736 lineStates.EnsureLength(line);
\r
737 lineStates.Insert(line, 0);
\r
741 void CellBuffer::RemoveLine(int line) {
\r
742 lv.RemoveLine(line);
\r
743 if (lineStates.Length() > line) {
\r
744 lineStates.Delete(line);
\r
748 void CellBuffer::BasicInsertString(int position, const char *s, int insertLength) {
\r
749 if (insertLength == 0)
\r
751 PLATFORM_ASSERT(insertLength > 0);
\r
753 substance.InsertFromArray(position, s, 0, insertLength);
\r
754 style.InsertValue(position, insertLength, 0);
\r
756 int lineInsert = lv.LineFromPosition(position) + 1;
\r
757 // Point all the lines after the insertion point further along in the buffer
\r
758 lv.InsertText(lineInsert-1, insertLength);
\r
759 char chPrev = substance.ValueAt(position - 1);
\r
760 char chAfter = substance.ValueAt(position + insertLength);
\r
761 if (chPrev == '\r' && chAfter == '\n') {
\r
762 // Splitting up a crlf pair at position
\r
763 InsertLine(lineInsert, position);
\r
767 for (int i = 0; i < insertLength; i++) {
\r
770 InsertLine(lineInsert, (position + i) + 1);
\r
772 } else if (ch == '\n') {
\r
773 if (chPrev == '\r') {
\r
774 // Patch up what was end of line
\r
775 lv.SetLineStart(lineInsert - 1, (position + i) + 1);
\r
777 InsertLine(lineInsert, (position + i) + 1);
\r
783 // Joining two lines where last insertion is cr and following substance starts with lf
\r
784 if (chAfter == '\n') {
\r
786 // End of line already in buffer so drop the newly created one
\r
787 RemoveLine(lineInsert - 1);
\r
792 void CellBuffer::BasicDeleteChars(int position, int deleteLength) {
\r
793 if (deleteLength == 0)
\r
796 if ((position == 0) && (deleteLength == substance.Length())) {
\r
797 // If whole buffer is being deleted, faster to reinitialise lines data
\r
798 // than to delete each line.
\r
801 // Have to fix up line positions before doing deletion as looking at text in buffer
\r
802 // to work out which lines have been removed
\r
804 int lineRemove = lv.LineFromPosition(position) + 1;
\r
805 lv.InsertText(lineRemove-1, - (deleteLength));
\r
806 char chPrev = substance.ValueAt(position - 1);
\r
807 char chBefore = chPrev;
\r
808 char chNext = substance.ValueAt(position);
\r
809 bool ignoreNL = false;
\r
810 if (chPrev == '\r' && chNext == '\n') {
\r
812 lv.SetLineStart(lineRemove, position);
\r
814 ignoreNL = true; // First \n is not real deletion
\r
818 for (int i = 0; i < deleteLength; i++) {
\r
819 chNext = substance.ValueAt(position + i + 1);
\r
821 if (chNext != '\n') {
\r
822 RemoveLine(lineRemove);
\r
824 } else if (ch == '\n') {
\r
826 ignoreNL = false; // Further \n are real deletions
\r
828 RemoveLine(lineRemove);
\r
834 // May have to fix up end if last deletion causes cr to be next to lf
\r
835 // or removes one of a crlf pair
\r
836 char chAfter = substance.ValueAt(position + deleteLength);
\r
837 if (chBefore == '\r' && chAfter == '\n') {
\r
838 // Using lineRemove-1 as cr ended line before start of deletion
\r
839 RemoveLine(lineRemove - 1);
\r
840 lv.SetLineStart(lineRemove - 1, position + 1);
\r
843 substance.DeleteRange(position, deleteLength);
\r
844 style.DeleteRange(position, deleteLength);
\r
847 bool CellBuffer::SetUndoCollection(bool collectUndo) {
\r
848 collectingUndo = collectUndo;
\r
849 uh.DropUndoSequence();
\r
850 return collectingUndo;
\r
853 bool CellBuffer::IsCollectingUndo() {
\r
854 return collectingUndo;
\r
857 void CellBuffer::BeginUndoAction() {
\r
858 uh.BeginUndoAction();
\r
861 void CellBuffer::EndUndoAction() {
\r
862 uh.EndUndoAction();
\r
865 void CellBuffer::DeleteUndoHistory() {
\r
866 uh.DeleteUndoHistory();
\r
869 bool CellBuffer::CanUndo() {
\r
870 return uh.CanUndo();
\r
873 int CellBuffer::StartUndo() {
\r
874 return uh.StartUndo();
\r
877 const Action &CellBuffer::GetUndoStep() const {
\r
878 return uh.GetUndoStep();
\r
881 void CellBuffer::PerformUndoStep() {
\r
882 const Action &actionStep = uh.GetUndoStep();
\r
883 if (actionStep.at == insertAction) {
\r
884 BasicDeleteChars(actionStep.position, actionStep.lenData);
\r
885 } else if (actionStep.at == removeAction) {
\r
886 BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData);
\r
888 uh.CompletedUndoStep();
\r
891 bool CellBuffer::CanRedo() {
\r
892 return uh.CanRedo();
\r
895 int CellBuffer::StartRedo() {
\r
896 return uh.StartRedo();
\r
899 const Action &CellBuffer::GetRedoStep() const {
\r
900 return uh.GetRedoStep();
\r
903 void CellBuffer::PerformRedoStep() {
\r
904 const Action &actionStep = uh.GetRedoStep();
\r
905 if (actionStep.at == insertAction) {
\r
906 BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData);
\r
907 } else if (actionStep.at == removeAction) {
\r
908 BasicDeleteChars(actionStep.position, actionStep.lenData);
\r
910 uh.CompletedRedoStep();
\r
913 int CellBuffer::SetLineState(int line, int state) {
\r
914 lineStates.EnsureLength(line + 1);
\r
915 int stateOld = lineStates[line];
\r
916 lineStates[line] = state;
\r
920 int CellBuffer::GetLineState(int line) {
\r
921 lineStates.EnsureLength(line + 1);
\r
922 return lineStates[line];
\r
925 int CellBuffer::GetMaxLineState() {
\r
926 return lineStates.Length();
\r
929 int CellBuffer::SetLevel(int line, int level) {
\r
930 return lv.SetLevel(line, level);
\r
933 int CellBuffer::GetLevel(int line) {
\r
934 return lv.GetLevel(line);
\r
937 void CellBuffer::ClearLevels() {
\r