diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 28b7d80158d0..8fa9575b66ec 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -429,8 +429,8 @@ void Notepad_plus::command(int id) GlobalUnlock(hglbLenCopy); // Place the handle on the clipboard. - UINT f = RegisterClipboardFormat(CF_NPPTEXTLEN); - SetClipboardData(f, hglbLenCopy); + UINT cf_nppTextLen = RegisterClipboardFormat(CF_NPPTEXTLEN); + SetClipboardData(cf_nppTextLen, hglbLenCopy); CloseClipboard(); diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index 08b99aa606f2..533602a73595 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -496,6 +496,16 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa ::SendMessage(_hParent, WM_NOTIFY, LINKTRIGGERED, reinterpret_cast(¬ification)); } + else if (wParam == 'V') + { + if (_isMultiPasteActive) + { + Buffer* buf = getCurrentBuffer(); + buf->setUserReadOnly(false); + + _isMultiPasteActive = false; + } + } break; } @@ -570,6 +580,58 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa } } break; + + case 'V': + { + SHORT ctrl = GetKeyState(VK_CONTROL); + SHORT alt = GetKeyState(VK_MENU); + SHORT shift = GetKeyState(VK_SHIFT); + if ((ctrl & 0x8000) && !(alt & 0x8000) && !(shift & 0x8000)) + { + // "MSDEVColumnSelect" is column format from Scintilla + CLIPFORMAT cfColumnSelect = static_cast(::RegisterClipboardFormat(TEXT("MSDEVColumnSelect"))); + if (IsClipboardFormatAvailable(cfColumnSelect) && OpenClipboard(NULL)) + { + HANDLE clipboardData = ::GetClipboardData(CF_UNICODETEXT); + ::GlobalSize(clipboardData); + LPVOID clipboardDataPtr = ::GlobalLock(clipboardData); + if (clipboardDataPtr) + { + wstring clipboardStr = (const TCHAR*)clipboardDataPtr; + ::GlobalUnlock(clipboardData); + ::CloseClipboard(); + + vector stringArray; + stringSplit(clipboardStr, getEOLString(), stringArray); + stringArray.erase(stringArray.cend() - 1); // remove the last empty string + + size_t numSelections = execute(SCI_GETSELECTIONS); + if (numSelections > 1 && numSelections == stringArray.size()) + { + execute(SCI_BEGINUNDOACTION); + for (int i = 0; i < numSelections; ++i) + { + LRESULT posStart = execute(SCI_GETSELECTIONNSTART, i); + LRESULT posEnd = execute(SCI_GETSELECTIONNEND, i); + replaceTarget(stringArray[i].c_str(), posStart, posEnd); + posStart += stringArray[i].length(); + execute(SCI_SETSELECTIONNSTART, i, posStart); + execute(SCI_SETSELECTIONNEND, i, posStart); + } + execute(SCI_ENDUNDOACTION); + + // Hack for prevent + //Buffer* buf = getCurrentBuffer(); + //buf->setUserReadOnly(true); + + _isMultiPasteActive = true; + return TRUE; + } + } + } + } + } + break; } } break; diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h index 9e9671ceb0ba..b378fc49d00a 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.h +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.h @@ -811,8 +811,8 @@ friend class Finder; BufferStyleMap _hotspotStyles; intptr_t _beginSelectPosition = -1; - static std::string _defaultCharList; + bool _isMultiPasteActive = false; //Lexers and Styling void restyleBuffer();