Add 3 line operation (delete, copy & cut) shortcuts

* Shift-Delete: without selected text, it will delete the whole line.
* Ctrl-C: without selected text, it will copy the whole line.
* Ctrl-X: without selected text, it will cut the whole line.

Fix #14296, close #14298
pull/14329/head
Don Ho 2023-11-01 08:07:01 +01:00
parent b5730eea31
commit e9c50ed967
1 changed files with 50 additions and 4 deletions

View File

@ -484,7 +484,7 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
break; break;
} }
case WM_KEYUP : case WM_KEYUP:
{ {
if (wParam == VK_PRIOR || wParam == VK_NEXT) if (wParam == VK_PRIOR || wParam == VK_NEXT)
{ {
@ -498,11 +498,14 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
} }
break; break;
} }
case WM_KEYDOWN : case WM_KEYDOWN:
{ {
if ((execute(SCI_GETSELECTIONMODE) == SC_SEL_RECTANGLE) || (execute(SCI_GETSELECTIONMODE) == SC_SEL_THIN)) if ((execute(SCI_GETSELECTIONMODE) == SC_SEL_RECTANGLE) || (execute(SCI_GETSELECTIONMODE) == SC_SEL_THIN))
{ {
//
// Transform the column selection to multi-edit
//
switch (wParam) switch (wParam)
{ {
case VK_LEFT: case VK_LEFT:
@ -524,8 +527,51 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
} }
} }
else
{
//
// Add 3 shortcuts:
// Shift + Delete: without selected text, it will delete the whole line.
// 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 VK_DELETE:
{
SHORT shift = GetKeyState(VK_SHIFT);
if (shift & 0x8000)
{
bool hasSelection = (execute(SCI_GETSELECTIONSTART) != execute(SCI_GETSELECTIONEND));
if (!hasSelection)
{
execute(SCI_LINEDELETE);
return TRUE;
}
}
}
break;
case 'C':
case 'X':
{
SHORT ctrl = GetKeyState(VK_CONTROL);
if (ctrl & 0x8000)
{
bool hasSelection = (execute(SCI_GETSELECTIONSTART) != execute(SCI_GETSELECTIONEND));
if (!hasSelection)
{
execute(wParam == 'C' ? SCI_LINECOPY : SCI_LINECUT);
//return TRUE;
// No return and let Scintilla procedure to continue
}
}
}
break;
}
}
break; break;
} }
case WM_VSCROLL : case WM_VSCROLL :
{ {