Skip to content

Commit

Permalink
Enable Copy & Cut commands on menu all the time
Browse files Browse the repository at this point in the history
Before the implementation of notepad-plus-plus@e9c50ed,
Copy & Cut command were disabled when there were no selection, which makes sense because there was nothing to be copied & cut.
Now users can copy/cut current line without selection.

Fix notepad-plus-plus#14401
  • Loading branch information
donho committed Nov 27, 2023
1 parent 2768cf5 commit 0c85626
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 28 deletions.
3 changes: 0 additions & 3 deletions PowerEditor/src/Notepad_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2561,11 +2561,8 @@ void Notepad_plus::checkClipboard()
{
bool hasSelection = _pEditView->hasSelection();
bool canPaste = (_pEditView->execute(SCI_CANPASTE) != 0);
enableCommand(IDM_EDIT_CUT, hasSelection, MENU | TOOLBAR);
enableCommand(IDM_EDIT_COPY, hasSelection, MENU | TOOLBAR);

enableCommand(IDM_EDIT_PASTE, canPaste, MENU | TOOLBAR);
enableCommand(IDM_EDIT_DELETE, hasSelection, MENU | TOOLBAR);
enableCommand(IDM_EDIT_UPPERCASE, hasSelection, MENU);
enableCommand(IDM_EDIT_LOWERCASE, hasSelection, MENU);
enableCommand(IDM_EDIT_PROPERCASE_FORCE, hasSelection, MENU);
Expand Down
16 changes: 11 additions & 5 deletions PowerEditor/src/NppCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,21 @@ void Notepad_plus::command(int id)
checkUndoState();
break;
}

case IDM_EDIT_CUT:
_pEditView->execute(WM_CUT);
checkClipboard();
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:
_pEditView->execute(WM_COPY);
checkClipboard();
if (!_pEditView->hasSelection()) // Ctrl + C: without selected text, it will copy the whole line.
_pEditView->execute(SCI_LINECOPY);
else
_pEditView->execute(WM_COPY);

break;

case IDM_EDIT_COPY_LINK:
Expand Down
20 changes: 0 additions & 20 deletions PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -650,28 +650,8 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
}
else
{
//
// 2 shortcuts:
// Ctrl + C: without selected text, it will copy the whole line.
// Ctrl + X: without selected text, it will cut the whole line.
//
switch (wParam)
{
case 'C':
case 'X':
{
if ((ctrl & 0x8000) && !(alt & 0x8000) && !(shift & 0x8000))
{
if (!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))
Expand Down

0 comments on commit 0c85626

Please sign in to comment.