aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Editor.cxx
diff options
context:
space:
mode:
authornyamatongwe <unknown>2002-04-03 12:51:37 +0000
committernyamatongwe <unknown>2002-04-03 12:51:37 +0000
commit8947805be9f56db782923bc07fb948524df95030 (patch)
treea9a11313782ccf31cd3a41a64a558d20a4077f3f /src/Editor.cxx
parent570bedab6964a0fa3d2a1c74053fa7c54fa02c08 (diff)
downloadscintilla-mirror-8947805be9f56db782923bc07fb948524df95030.tar.gz
Enhancements to read-only mode to stop caret moving when typing or deleting.
Diffstat (limited to 'src/Editor.cxx')
-rw-r--r--src/Editor.cxx25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/Editor.cxx b/src/Editor.cxx
index fd8a2d719..d66b49238 100644
--- a/src/Editor.cxx
+++ b/src/Editor.cxx
@@ -2220,8 +2220,9 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) {
}
}
}
- pdoc->InsertString(currentPos, s, len);
- SetEmptySelection(currentPos + len);
+ if (pdoc->InsertString(currentPos, s, len)) {
+ SetEmptySelection(currentPos + len);
+ }
EnsureCaretVisible();
// Avoid blinking during rapid typing:
ShowCaretAtCurrentPosition();
@@ -3456,9 +3457,10 @@ void Editor::DropAt(int position, const char *value, bool moving, bool rectangul
SetSelection(position, position);
} else {
position = MovePositionOutsideChar(position, currentPos - position);
- pdoc->InsertString(position, value);
+ if (pdoc->InsertString(position, value)) {
+ SetSelection(position + strlen(value), position);
+ }
pdoc->EndUndoAction();
- SetSelection(position + strlen(value), position);
}
} else if (inDragDrop) {
SetSelection(position, position);
@@ -3743,17 +3745,20 @@ void Editor::ButtonUp(Point pt, unsigned int curTime, bool ctrl) {
if (selStart < selEnd) {
if (drag.len) {
if (ctrl) {
- pdoc->InsertString(newPos, drag.s, drag.len);
- SetSelection(newPos, newPos + drag.len);
+ if (pdoc->InsertString(newPos, drag.s, drag.len)) {
+ SetSelection(newPos, newPos + drag.len);
+ }
} else if (newPos < selStart) {
pdoc->DeleteChars(selStart, drag.len);
- pdoc->InsertString(newPos, drag.s, drag.len);
- SetSelection(newPos, newPos + drag.len);
+ if (pdoc->InsertString(newPos, drag.s, drag.len)) {
+ SetSelection(newPos, newPos + drag.len);
+ }
} else if (newPos > selEnd) {
pdoc->DeleteChars(selStart, drag.len);
newPos -= drag.len;
- pdoc->InsertString(newPos, drag.s, drag.len);
- SetSelection(newPos, newPos + drag.len);
+ if (pdoc->InsertString(newPos, drag.s, drag.len)) {
+ SetSelection(newPos, newPos + drag.len);
+ }
} else {
SetEmptySelection(newPos);
}