diff options
Diffstat (limited to 'win32/ScintillaWin.cxx')
-rw-r--r-- | win32/ScintillaWin.cxx | 49 |
1 files changed, 5 insertions, 44 deletions
diff --git a/win32/ScintillaWin.cxx b/win32/ScintillaWin.cxx index a0372f574..e084354f1 100644 --- a/win32/ScintillaWin.cxx +++ b/win32/ScintillaWin.cxx @@ -274,8 +274,6 @@ class ScintillaWin : virtual bool GetScrollInfo(int nBar, LPSCROLLINFO lpsi); void ChangeScrollPos(int barType, int pos); - void InsertPasteText(const char *text, int len, SelectionPosition selStart, bool isRectangular, bool isLine); - public: // Public for benefit of Scintilla_DirectFunction virtual sptr_t WndProc(unsigned int iMessage, uptr_t wParam, sptr_t lParam); @@ -1648,44 +1646,12 @@ public: } }; -void ScintillaWin::InsertPasteText(const char *text, int len, SelectionPosition selStart, bool isRectangular, bool isLine) { - if (isRectangular) { - PasteRectangular(selStart, text, len); - } else { - std::string convertedText; - if (convertPastes) { - // Convert line endings of the paste into our local line-endings mode - convertedText = Document::TransformLineEnds(text, len, pdoc->eolMode); - len = static_cast<int>(convertedText.length()); - text = convertedText.c_str(); - } - if (isLine) { - int insertPos = pdoc->LineStart(pdoc->LineFromPosition(sel.MainCaret())); - int lengthInserted = pdoc->InsertString(insertPos, text, len); - // add the newline if necessary - if ((len > 0) && (text[len-1] != '\n' && text[len-1] != '\r')) { - const char *endline = StringFromEOLMode(pdoc->eolMode); - int length = static_cast<int>(strlen(endline)); - lengthInserted += pdoc->InsertString(insertPos + lengthInserted, endline, length); - } - if (sel.MainCaret() == insertPos) { - SetEmptySelection(sel.MainCaret() + lengthInserted); - } - } else { - InsertPaste(selStart, text, len); - } - } -} - void ScintillaWin::Paste() { if (!::OpenClipboard(MainHWND())) return; UndoGroup ug(pdoc); - bool isLine = SelectionEmpty() && (::IsClipboardFormatAvailable(cfLineSelect) != 0); + const bool isLine = SelectionEmpty() && (::IsClipboardFormatAvailable(cfLineSelect) != 0); ClearSelection(multiPasteMode == SC_MULTIPASTE_EACH); - SelectionPosition selStart = sel.IsRectangular() ? - sel.Rectangular().Start() : - sel.Range(sel.Main()).Start(); bool isRectangular = (::IsClipboardFormatAvailable(cfColumnSelect) != 0); if (!isRectangular) { @@ -1696,6 +1662,7 @@ void ScintillaWin::Paste() { memBorlandSelection.Unlock(); } } + const PasteShape pasteShape = isRectangular ? pasteRectangular : (isLine ? pasteLine : pasteStream); // Always use CF_UNICODETEXT if available GlobalMemory memUSelection(::GetClipboardData(CF_UNICODETEXT)); @@ -1721,7 +1688,7 @@ void ScintillaWin::Paste() { &putf[0], len + 1, NULL, NULL); } - InsertPasteText(&putf[0], len, selStart, isRectangular, isLine); + InsertPasteShape(&putf[0], len, pasteShape); } memUSelection.Unlock(); } else { @@ -1749,9 +1716,9 @@ void ScintillaWin::Paste() { // CP_UTF8 not available on Windows 95, so use UTF8FromUTF16() UTF8FromUTF16(&uptr[0], ulen, &putf[0], mlen); - InsertPasteText(&putf[0], mlen, selStart, isRectangular, isLine); + InsertPasteShape(&putf[0], mlen, pasteShape); } else { - InsertPasteText(ptr, len, selStart, isRectangular, isLine); + InsertPasteShape(ptr, len, pasteShape); } } memSelection.Unlock(); @@ -2534,12 +2501,6 @@ STDMETHODIMP ScintillaWin::Drop(LPDATAOBJECT pIDataSource, DWORD grfKeyState, } } - if (!data.empty() && convertPastes) { - // Convert line endings of the drop into our local line-endings mode - std::string convertedText = Document::TransformLineEnds(&data[0], data.size() - 1, pdoc->eolMode); - data.assign(convertedText.c_str(), convertedText.c_str()+convertedText.length()+1); - } - if (!SUCCEEDED(hr) || data.empty()) { //Platform::DebugPrintf("Bad data format: 0x%x\n", hres); return hr; |