diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 3d52939e5fca..825d49188d29 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -356,20 +356,37 @@ void Notepad_plus::command(int id) } case IDM_EDIT_CUT: - if (!_pEditView->hasSelection()) // Ctrl + X: without selected text, it will cut the whole line. - _pEditView->execute(SCI_LINECUT); - else - _pEditView->execute(WM_CUT); - + { + HWND focusedHwnd = ::GetFocus(); + if (focusedHwnd == _pEditView->getHSelf()) + { + if (!_pEditView->hasSelection()) // Ctrl + X: without selected text, it will cut the whole line. + _pEditView->execute(SCI_LINECUT); + else + _pEditView->execute(WM_CUT); + } break; + } case IDM_EDIT_COPY: - if (!_pEditView->hasSelection()) // Ctrl + C: without selected text, it will copy the whole line. - _pEditView->execute(SCI_LINECOPY); - else - _pEditView->execute(WM_COPY); + { + HWND focusedHwnd = ::GetFocus(); + if (focusedHwnd == _pEditView->getHSelf()) + { + if (!_pEditView->hasSelection()) // Ctrl + C: without selected text, it will copy the whole line. + _pEditView->execute(SCI_LINECOPY); + else + _pEditView->execute(WM_COPY); + } + else // Search result + { + Finder* finder = _findReplaceDlg.getFinderFrom(focusedHwnd); + if (finder) + finder->scintillaExecute(WM_COPY); + } break; + } case IDM_EDIT_COPY_LINK: { @@ -448,18 +465,21 @@ void Notepad_plus::command(int id) case IDM_EDIT_PASTE: { std::lock_guard lock(command_mutex); - - size_t nbSelections = _pEditView->execute(SCI_GETSELECTIONS); - Buffer* buf = getCurrentBuffer(); - bool isRO = buf->isReadOnly(); - if (nbSelections > 1 && !isRO) + HWND focusedHwnd = ::GetFocus(); + if (focusedHwnd == _pEditView->getHSelf()) { - bool isPasteDone = _pEditView->pasteToMultiSelection(); - if (isPasteDone) - return; - } + size_t nbSelections = _pEditView->execute(SCI_GETSELECTIONS); + Buffer* buf = getCurrentBuffer(); + bool isRO = buf->isReadOnly(); + if (nbSelections > 1 && !isRO) + { + bool isPasteDone = _pEditView->pasteToMultiSelection(); + if (isPasteDone) + return; + } - _pEditView->execute(SCI_PASTE); + _pEditView->execute(SCI_PASTE); + } } break; diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index fac5202da287..d9f407e34426 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -97,9 +97,9 @@ static const WinMenuKeyDefinition winKeyDefs[] = // { VK_NULL, IDM_EDIT_UNDO, false, false, false, nullptr }, // { VK_NULL, IDM_EDIT_REDO, false, false, false, nullptr }, -// { VK_NULL, IDM_EDIT_CUT, false, false, false, nullptr }, -// { VK_NULL, IDM_EDIT_COPY, false, false, false, nullptr }, -// { VK_NULL, IDM_EDIT_PASTE, false, false, false, nullptr }, + { VK_X, IDM_EDIT_CUT, true, false, false, nullptr }, + { VK_C, IDM_EDIT_COPY, true, false, false, nullptr }, + { VK_V, IDM_EDIT_PASTE, true, false, false, nullptr }, // { VK_NULL, IDM_EDIT_DELETE, false, false, false, nullptr }, // { VK_NULL, IDM_EDIT_SELECTALL, false, false, false, nullptr }, { VK_B, IDM_EDIT_BEGINENDSELECT, true, false, true, nullptr }, @@ -471,12 +471,12 @@ static const ScintillaKeyDefinition scintKeyDefs[] = //Scintilla command name, SCINTILLA_CMD_ID, Ctrl, Alt, Shift, V_KEY, NOTEPAD++_CMD_ID // ------------------------------------------------------------------------------------------------------------------- // - {TEXT("SCI_CUT"), SCI_CUT, true, false, false, VK_X, IDM_EDIT_CUT}, - {TEXT(""), SCI_CUT, false, false, true, VK_DELETE, 0}, - {TEXT("SCI_COPY"), SCI_COPY, true, false, false, VK_C, IDM_EDIT_COPY}, - {TEXT(""), SCI_COPY, true, false, false, VK_INSERT, 0}, - {TEXT("SCI_PASTE"), SCI_PASTE, true, false, false, VK_V, IDM_EDIT_PASTE}, - {TEXT(""), SCI_PASTE, false, false, true, VK_INSERT, 0}, +// {TEXT("SCI_CUT"), SCI_CUT, true, false, false, VK_X, IDM_EDIT_CUT}, +// {TEXT(""), SCI_CUT, false, false, true, VK_DELETE, 0}, +// {TEXT("SCI_COPY"), SCI_COPY, true, false, false, VK_C, IDM_EDIT_COPY}, +// {TEXT(""), SCI_COPY, true, false, false, VK_INSERT, 0}, +// {TEXT("SCI_PASTE"), SCI_PASTE, true, false, false, VK_V, IDM_EDIT_PASTE}, +// {TEXT(""), SCI_PASTE, false, false, true, VK_INSERT, 0}, {TEXT("SCI_SELECTALL"), SCI_SELECTALL, true, false, false, VK_A, IDM_EDIT_SELECTALL}, {TEXT("SCI_CLEAR"), SCI_CLEAR, false, false, false, VK_DELETE, IDM_EDIT_DELETE}, {TEXT("SCI_CLEARALL"), SCI_CLEARALL, false, false, false, 0, 0}, diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index aa25ea3dd134..c6424f3d0649 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -3412,6 +3412,26 @@ bool FindReplaceDlg::removeFinder(Finder *finder2remove) return false; } +Finder* FindReplaceDlg::getFinderFrom(HWND hwnd) +{ + if (_pFinder && _pFinder->isCreated()) + { + if (_pFinder->_scintView.getHSelf() == hwnd) + return _pFinder; + + if (!_findersOfFinder.empty()) + { + for (const auto& finder : _findersOfFinder) + { + if (finder->_scintView.getHSelf() == hwnd) + return finder; + } + } + } + + return nullptr; +} + void FindReplaceDlg::setSearchText(TCHAR * txt2find) { HWND hCombo = ::GetDlgItem(_hSelf, IDFINDWHAT); diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h index 53799bf52190..61fe824c4aad 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h @@ -145,6 +145,9 @@ friend class FindReplaceDlg; void setVolatiled(bool val) { _canBeVolatiled = val; }; generic_string getHitsString(int count) const; + LRESULT scintillaExecute(UINT msg, WPARAM wParam = 0, LPARAM lParam = 0) const { + return _scintView.execute(msg, wParam, lParam); + } protected : intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override; bool notify(SCNotification *notification); @@ -282,7 +285,9 @@ public : void findAllIn(InWhat op); void setSearchText(TCHAR * txt2find); - void gotoNextFoundResult(int direction = 0) {if (_pFinder) _pFinder->gotoNextFoundResult(direction);}; + void gotoNextFoundResult(int direction = 0) const { + if (_pFinder) _pFinder->gotoNextFoundResult(direction); + }; void putFindResult(int result) { _findAllResult = result; @@ -392,6 +397,7 @@ public : Finder * createFinder(); bool removeFinder(Finder *finder2remove); DIALOG_TYPE getCurrentStatus() {return _currentStatus;}; + Finder* getFinderFrom(HWND hwnd); protected : void resizeDialogElements(LONG newWidth); diff --git a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp index d56c0c9e7178..541e94cf00cf 100644 --- a/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp @@ -509,16 +509,6 @@ 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; - ::SendMessage(_hParent, NPPM_INTERNAL_CHECKUNDOREDOSTATE, 0, 0); - } - } break; } @@ -648,48 +638,6 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa } } - else - { - switch (wParam) - { - // - // 2 shortcuts: - // Ctrl + C: without selected text, it will copy the whole line. - // Ctrl + X: without selected text, it will cut the whole line. - // - case 'C': - case 'X': - { - if (((ctrl & 0x8000) && !(alt & 0x8000) && !(shift & 0x8000)) && !hasSelection()) - { - execute(wParam == 'C' ? SCI_LINECOPY : SCI_LINECUT); - //return TRUE; - // No return and let Scintilla procedure to continue - } - } - break; - - case 'V': - { - if ((ctrl & 0x8000) && !(alt & 0x8000) && !(shift & 0x8000)) - { - Buffer* buf = getCurrentBuffer(); - bool isRO = buf->isReadOnly(); - size_t nbSelections = execute(SCI_GETSELECTIONS); - if (nbSelections > 1 && !isRO) - { - if (pasteToMultiSelection()) - { - // Hack for preventing the char "SYN" (0x16) from being adding into edit zone - buf->setUserReadOnly(true); - - _isMultiPasteActive = true; // It will be set false with WM_KEYUP message - } - } - } - } - } - } break; }