Skip to content

Commit

Permalink
Add multi-caret enhancement: column mode to multi-caret on HOME/END/A…
Browse files Browse the repository at this point in the history
…rrow keys

This feature transforms a rectangular selection to multiple selection mode, so it's manipulatable with HOME, END and Arrow keys without loosing the set carets.

Related issue: notepad-plus-plus#8203

Fix notepad-plus-plus#14266
  • Loading branch information
donho committed Nov 4, 2023
1 parent 37a968e commit 4506a5c
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions PowerEditor/src/ScintillaComponent/ScintillaEditView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,34 @@ LRESULT ScintillaEditView::scintillaNew_Proc(HWND hwnd, UINT Message, WPARAM wPa
break;
}

case WM_KEYDOWN :
{
if ((execute(SCI_GETSELECTIONMODE) == SC_SEL_RECTANGLE) || (execute(SCI_GETSELECTIONMODE) == SC_SEL_THIN))
{
switch (wParam)
{
case VK_LEFT:
case VK_RIGHT:
case VK_UP:
case VK_DOWN:
case VK_HOME:
case VK_END:
execute(SCI_SETSELECTIONMODE, SC_SEL_STREAM); // When it's rectangular selection and the arrow keys are pressed, we switch the mode for having multiple carets.

execute(SCI_SETSELECTIONMODE, SC_SEL_STREAM); // the 2nd call for removing the unwanted selection while moving carets.
// Solution suggested by Neil Hodgson. See:
// https://sourceforge.net/p/scintilla/bugs/2412/
break;

default:
break;

}

}
break;
}

case WM_VSCROLL :
{
break;
Expand Down

0 comments on commit 4506a5c

Please sign in to comment.