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

@ -503,6 +503,9 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
{
if ((execute(SCI_GETSELECTIONMODE) == SC_SEL_RECTANGLE) || (execute(SCI_GETSELECTIONMODE) == SC_SEL_THIN))
{
//
// Transform the column selection to multi-edit
//
switch (wParam)
{
case VK_LEFT:
@ -524,6 +527,49 @@ 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;
}