aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Document.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/Document.cxx')
-rw-r--r--src/Document.cxx48
1 files changed, 39 insertions, 9 deletions
diff --git a/src/Document.cxx b/src/Document.cxx
index b50b9691a..bfb52d36e 100644
--- a/src/Document.cxx
+++ b/src/Document.cxx
@@ -94,22 +94,25 @@ int Document::LineStart(int line) {
return cb.LineStart(line);
}
-int Document::LineFromPosition(int pos) {
- return cb.LineFromPosition(pos);
-}
-
-int Document::LineEndPosition(int position) {
- int line = LineFromPosition(position);
+int Document::LineEnd(int line) {
if (line == LinesTotal() - 1) {
- position = LineStart(line + 1);
+ return LineStart(line + 1);
} else {
- position = LineStart(line + 1) - 1;
+ int position = LineStart(line + 1) - 1;
// When line terminator is CR+LF, may need to go back one more
if ((position > LineStart(line)) && (cb.CharAt(position - 1) == '\r')) {
position--;
}
+ return position;
}
- return position;
+}
+
+int Document::LineFromPosition(int pos) {
+ return cb.LineFromPosition(pos);
+}
+
+int Document::LineEndPosition(int position) {
+ return LineEnd(LineFromPosition(position));
}
int Document::VCHomePosition(int position) {
@@ -335,6 +338,7 @@ int Document::Undo() {
enteredCount++;
bool startSavePoint = cb.IsSavePoint();
int steps = cb.StartUndo();
+ Platform::DebugPrintf("Steps=%d\n", steps);
for (int step=0; step<steps; step++) {
int prevLinesTotal = LinesTotal();
const Action &action = cb.UndoStep();
@@ -345,9 +349,11 @@ int Document::Undo() {
int modFlags = SC_PERFORMED_UNDO;
// With undo, an insertion action becomes a deletion notification
if (action.at == removeAction) {
+ Platform::DebugPrintf("Insert of %d\n", action.lenData);
newPos += action.lenData;
modFlags |= SC_MOD_INSERTTEXT;
} else {
+ Platform::DebugPrintf("Remove of %d\n", action.lenData);
modFlags |= SC_MOD_DELETETEXT;
}
if (step == steps-1)
@@ -423,6 +429,11 @@ void Document::InsertString(int position, const char *s, int insertLength) {
}
}
+void Document::ChangeChar(int pos, char ch) {
+ DeleteChars(pos, 1);
+ InsertChar(pos, ch);
+}
+
void Document::DelChar(int pos) {
if (IsCrLf(pos)) {
DeleteChars(pos, 2);
@@ -633,6 +644,25 @@ int Document::LinesTotal() {
return cb.Lines();
}
+void Document::ChangeCase(Range r, bool makeUpperCase) {
+ for (int pos=r.start; pos<r.end; pos++) {
+ char ch = CharAt(pos);
+ if (dbcsCodePage && IsDBCS(pos)) {
+ pos++;
+ } else {
+ if (makeUpperCase) {
+ if (islower(ch)) {
+ ChangeChar(pos, toupper(ch));
+ }
+ } else {
+ if (isupper(ch)) {
+ ChangeChar(pos, tolower(ch));
+ }
+ }
+ }
+ }
+}
+
void Document::SetWordChars(unsigned char *chars) {
int ch;
for (ch = 0; ch < 256; ch++) {