From 8947805be9f56db782923bc07fb948524df95030 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Wed, 3 Apr 2002 12:51:37 +0000 Subject: Enhancements to read-only mode to stop caret moving when typing or deleting. --- src/Editor.cxx | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/Editor.cxx') 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); } -- cgit v1.2.3