From 8e37e4efe5f90c7b6157ffd513ac418db7089c2d Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Thu, 11 Mar 2010 10:21:29 +0000 Subject: Implemented multipaste as an option. --- src/Editor.cxx | 40 ++++++++++++++++++++++++++++++++++++++++ src/Editor.h | 2 ++ 2 files changed, 42 insertions(+) (limited to 'src') diff --git a/src/Editor.cxx b/src/Editor.cxx index 4cc275e71..54fb6185b 100644 --- a/src/Editor.cxx +++ b/src/Editor.cxx @@ -150,6 +150,7 @@ Editor::Editor() { caretSticky = false; multipleSelection = false; additionalSelectionTyping = false; + multiPasteMode = SC_MULTIPASTE_ONCE; additionalCaretsBlink = true; additionalCaretsVisible = true; virtualSpaceOptions = SCVS_NONE; @@ -3797,6 +3798,38 @@ void Editor::AddCharUTF(char *s, unsigned int len, bool treatAsDBCS) { } } +void Editor::InsertPaste(SelectionPosition selStart, const char *text, int len) { + if (multiPasteMode == SC_MULTIPASTE_ONCE) { + selStart = SelectionPosition(InsertSpace(selStart.Position(), selStart.VirtualSpace())); + if (pdoc->InsertString(selStart.Position(), text, len)) { + SetEmptySelection(selStart.Position() + len); + } + } else { + // SC_MULTIPASTE_EACH + for (size_t r=0; rDeleteChars(positionInsert, sel.Range(r).Length()); + sel.Range(r).ClearVirtualSpace(); + } else { + // Range is all virtual so collapse to start of virtual space + sel.Range(r).MinimizeVirtualSpace(); + } + } + positionInsert = InsertSpace(positionInsert, sel.Range(r).caret.VirtualSpace()); + if (pdoc->InsertString(positionInsert, text, len)) { + sel.Range(r).caret.SetPosition(positionInsert + len); + sel.Range(r).anchor.SetPosition(positionInsert + len); + } + sel.Range(r).ClearVirtualSpace(); + } + } + } +} + void Editor::ClearSelection() { if (!sel.IsRectangular()) FilterSelections(); @@ -8282,6 +8315,13 @@ sptr_t Editor::WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam) { case SCI_GETADDITIONALSELECTIONTYPING: return additionalSelectionTyping; + case SCI_SETMULTIPASTE: + multiPasteMode = wParam; + break; + + case SCI_GETMULTIPASTE: + return multiPasteMode; + case SCI_SETADDITIONALCARETSBLINK: additionalCaretsBlink = wParam != 0; InvalidateCaret(); diff --git a/src/Editor.h b/src/Editor.h index 94454b2d9..6e6c25f0f 100644 --- a/src/Editor.h +++ b/src/Editor.h @@ -142,6 +142,7 @@ protected: // ScintillaBase subclass needs access to much of Editor bool caretSticky; bool multipleSelection; bool additionalSelectionTyping; + int multiPasteMode; bool additionalCaretsBlink; bool additionalCaretsVisible; @@ -358,6 +359,7 @@ protected: // ScintillaBase subclass needs access to much of Editor int InsertSpace(int position, unsigned int spaces); void AddChar(char ch); virtual void AddCharUTF(char *s, unsigned int len, bool treatAsDBCS=false); + void InsertPaste(SelectionPosition selStart, const char *text, int len); void ClearSelection(); void ClearAll(); void ClearDocumentStyle(); -- cgit v1.2.3