diff options
author | nyamatongwe <unknown> | 2010-03-11 10:21:29 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2010-03-11 10:21:29 +0000 |
commit | 8e37e4efe5f90c7b6157ffd513ac418db7089c2d (patch) | |
tree | cac1e613a55d874579c775c8cb681b275d26fa52 /src | |
parent | 046d1d2dcefe90b80b58330c043be32d7ef49d49 (diff) | |
download | scintilla-mirror-8e37e4efe5f90c7b6157ffd513ac418db7089c2d.tar.gz |
Implemented multipaste as an option.
Diffstat (limited to 'src')
-rw-r--r-- | src/Editor.cxx | 40 | ||||
-rw-r--r-- | src/Editor.h | 2 |
2 files changed, 42 insertions, 0 deletions
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; r<sel.Count(); r++) { + if (!RangeContainsProtected(sel.Range(r).Start().Position(), + sel.Range(r).End().Position())) { + int positionInsert = sel.Range(r).Start().Position(); + if (!sel.Range(r).Empty()) { + if (sel.Range(r).Length()) { + pdoc->DeleteChars(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(); |