aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/CellBuffer.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2021-04-05 16:34:10 +1000
committerNeil <nyamatongwe@gmail.com>2021-04-05 16:34:10 +1000
commit088d8034e79e7e2e44a114a2dc203bda5518dd49 (patch)
treed16ca55ee0799b7bb076807240935e17688bc2cf /src/CellBuffer.cxx
parent9f9b24ae9bc0ae771454732868cdb136fe995e42 (diff)
downloadscintilla-mirror-088d8034e79e7e2e44a114a2dc203bda5518dd49.tar.gz
Change actionType to an enum class.
Diffstat (limited to 'src/CellBuffer.cxx')
-rw-r--r--src/CellBuffer.cxx54
1 files changed, 27 insertions, 27 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx
index 21fbb7003..767a0c30d 100644
--- a/src/CellBuffer.cxx
+++ b/src/CellBuffer.cxx
@@ -303,7 +303,7 @@ public:
};
Action::Action() noexcept {
- at = startAction;
+ at = ActionType::start;
position = 0;
lenData = 0;
mayCoalesce = false;
@@ -312,7 +312,7 @@ Action::Action() noexcept {
Action::~Action() {
}
-void Action::Create(actionType at_, Sci::Position position_, const char *data_, Sci::Position lenData_, bool mayCoalesce_) {
+void Action::Create(ActionType at_, Sci::Position position_, const char *data_, Sci::Position lenData_, bool mayCoalesce_) {
data = nullptr;
position = position_;
at = at_;
@@ -356,7 +356,7 @@ UndoHistory::UndoHistory() {
savePoint = 0;
tentativePoint = -1;
- actions[currentAction].Create(startAction);
+ actions[currentAction].Create(ActionType::start);
}
UndoHistory::~UndoHistory() {
@@ -371,7 +371,7 @@ void UndoHistory::EnsureUndoRoom() {
}
}
-const char *UndoHistory::AppendAction(actionType at, Sci::Position position, const char *data, Sci::Position lengthData,
+const char *UndoHistory::AppendAction(ActionType at, Sci::Position position, const char *data, Sci::Position lengthData,
bool &startSequence, bool mayCoalesce) {
EnsureUndoRoom();
//Platform::DebugPrintf("%% %d action %d %d %d\n", at, position, lengthData, currentAction);
@@ -387,7 +387,7 @@ const char *UndoHistory::AppendAction(actionType at, Sci::Position position, con
int targetAct = -1;
const Action *actPrevious = &(actions[currentAction + targetAct]);
// Container actions may forward the coalesce state of Scintilla Actions.
- while ((actPrevious->at == containerAction) && actPrevious->mayCoalesce) {
+ while ((actPrevious->at == ActionType::container) && actPrevious->mayCoalesce) {
targetAct--;
actPrevious = &(actions[currentAction + targetAct]);
}
@@ -400,15 +400,15 @@ const char *UndoHistory::AppendAction(actionType at, Sci::Position position, con
currentAction++;
} else if (!mayCoalesce || !actPrevious->mayCoalesce) {
currentAction++;
- } else if (at == containerAction || actions[currentAction].at == containerAction) {
+ } else if (at == ActionType::container || actions[currentAction].at == ActionType::container) {
; // A coalescible containerAction
- } else if ((at != actPrevious->at) && (actPrevious->at != startAction)) {
+ } else if ((at != actPrevious->at) && (actPrevious->at != ActionType::start)) {
currentAction++;
- } else if ((at == insertAction) &&
+ } else if ((at == ActionType::insert) &&
(position != (actPrevious->position + actPrevious->lenData))) {
// Insertions must be immediately after to coalesce
currentAction++;
- } else if (at == removeAction) {
+ } else if (at == ActionType::remove) {
if ((lengthData == 1) || (lengthData == 2)) {
if ((position + lengthData) == actPrevious->position) {
; // Backspace -> OK
@@ -438,7 +438,7 @@ const char *UndoHistory::AppendAction(actionType at, Sci::Position position, con
const int actionWithData = currentAction;
actions[currentAction].Create(at, position, data, lengthData, mayCoalesce);
currentAction++;
- actions[currentAction].Create(startAction);
+ actions[currentAction].Create(ActionType::start);
maxAction = currentAction;
return actions[actionWithData].data.get();
}
@@ -446,9 +446,9 @@ const char *UndoHistory::AppendAction(actionType at, Sci::Position position, con
void UndoHistory::BeginUndoAction() {
EnsureUndoRoom();
if (undoSequenceDepth == 0) {
- if (actions[currentAction].at != startAction) {
+ if (actions[currentAction].at != ActionType::start) {
currentAction++;
- actions[currentAction].Create(startAction);
+ actions[currentAction].Create(ActionType::start);
maxAction = currentAction;
}
actions[currentAction].mayCoalesce = false;
@@ -461,9 +461,9 @@ void UndoHistory::EndUndoAction() {
EnsureUndoRoom();
undoSequenceDepth--;
if (0 == undoSequenceDepth) {
- if (actions[currentAction].at != startAction) {
+ if (actions[currentAction].at != ActionType::start) {
currentAction++;
- actions[currentAction].Create(startAction);
+ actions[currentAction].Create(ActionType::start);
maxAction = currentAction;
}
actions[currentAction].mayCoalesce = false;
@@ -479,7 +479,7 @@ void UndoHistory::DeleteUndoHistory() {
actions[i].Clear();
maxAction = 0;
currentAction = 0;
- actions[currentAction].Create(startAction);
+ actions[currentAction].Create(ActionType::start);
savePoint = 0;
tentativePoint = -1;
}
@@ -508,7 +508,7 @@ bool UndoHistory::TentativeActive() const noexcept {
int UndoHistory::TentativeSteps() noexcept {
// Drop any trailing startAction
- if (actions[currentAction].at == startAction && currentAction > 0)
+ if (actions[currentAction].at == ActionType::start && currentAction > 0)
currentAction--;
if (tentativePoint >= 0)
return currentAction - tentativePoint;
@@ -522,12 +522,12 @@ bool UndoHistory::CanUndo() const noexcept {
int UndoHistory::StartUndo() {
// Drop any trailing startAction
- if (actions[currentAction].at == startAction && currentAction > 0)
+ if (actions[currentAction].at == ActionType::start && currentAction > 0)
currentAction--;
// Count the steps in this action
int act = currentAction;
- while (actions[act].at != startAction && act > 0) {
+ while (actions[act].at != ActionType::start && act > 0) {
act--;
}
return currentAction - act;
@@ -547,12 +547,12 @@ bool UndoHistory::CanRedo() const noexcept {
int UndoHistory::StartRedo() {
// Drop any leading startAction
- if (currentAction < maxAction && actions[currentAction].at == startAction)
+ if (currentAction < maxAction && actions[currentAction].at == ActionType::start)
currentAction++;
// Count the steps in this action
int act = currentAction;
- while (act < maxAction && actions[act].at != startAction) {
+ while (act < maxAction && actions[act].at != ActionType::start) {
act++;
}
return act - currentAction;
@@ -647,7 +647,7 @@ const char *CellBuffer::InsertString(Sci::Position position, const char *s, Sci:
if (collectingUndo) {
// Save into the undo/redo stack, but only the characters - not the formatting
// This takes up about half load time
- data = uh.AppendAction(insertAction, position, s, insertLength, startSequence);
+ data = uh.AppendAction(ActionType::insert, position, s, insertLength, startSequence);
}
BasicInsertString(position, s, insertLength);
@@ -696,7 +696,7 @@ const char *CellBuffer::DeleteChars(Sci::Position position, Sci::Position delete
// Save into the undo/redo stack, but only the characters - not the formatting
// The gap would be moved to position anyway for the deletion so this doesn't cost extra
data = substance.RangePointer(position, deleteLength);
- data = uh.AppendAction(removeAction, position, data, deleteLength, startSequence);
+ data = uh.AppendAction(ActionType::remove, position, data, deleteLength, startSequence);
}
BasicDeleteChars(position, deleteLength);
@@ -1246,7 +1246,7 @@ void CellBuffer::EndUndoAction() {
void CellBuffer::AddUndoAction(Sci::Position token, bool mayCoalesce) {
bool startSequence;
- uh.AppendAction(containerAction, token, nullptr, 0, startSequence, mayCoalesce);
+ uh.AppendAction(ActionType::container, token, nullptr, 0, startSequence, mayCoalesce);
}
void CellBuffer::DeleteUndoHistory() {
@@ -1267,13 +1267,13 @@ const Action &CellBuffer::GetUndoStep() const {
void CellBuffer::PerformUndoStep() {
const Action &actionStep = uh.GetUndoStep();
- if (actionStep.at == insertAction) {
+ if (actionStep.at == ActionType::insert) {
if (substance.Length() < actionStep.lenData) {
throw std::runtime_error(
"CellBuffer::PerformUndoStep: deletion must be less than document length.");
}
BasicDeleteChars(actionStep.position, actionStep.lenData);
- } else if (actionStep.at == removeAction) {
+ } else if (actionStep.at == ActionType::remove) {
BasicInsertString(actionStep.position, actionStep.data.get(), actionStep.lenData);
}
uh.CompletedUndoStep();
@@ -1293,9 +1293,9 @@ const Action &CellBuffer::GetRedoStep() const {
void CellBuffer::PerformRedoStep() {
const Action &actionStep = uh.GetRedoStep();
- if (actionStep.at == insertAction) {
+ if (actionStep.at == ActionType::insert) {
BasicInsertString(actionStep.position, actionStep.data.get(), actionStep.lenData);
- } else if (actionStep.at == removeAction) {
+ } else if (actionStep.at == ActionType::remove) {
BasicDeleteChars(actionStep.position, actionStep.lenData);
}
uh.CompletedRedoStep();