+ add: multiple selection on end-of-lines from rectangular selection

This commit is contained in:
RaiKoHoff 2020-02-12 18:49:05 +01:00
parent e88dc03fde
commit 352bca00db
8 changed files with 70 additions and 43 deletions

View File

@ -1 +1 @@
2
3

View File

@ -3,7 +3,7 @@
<assemblyIdentity
name="Notepad3"
processorArchitecture="*"
version="5.20.212.2"
version="5.20.212.3"
type="win32"
/>
<description>Notepad3 RC1</description>

View File

@ -2415,28 +2415,40 @@ void EditMoveDown(HWND hwnd)
//
// EditSetCaretToSelectionStart()
//
DocPos EditSetCaretToSelectionStart()
bool EditSetCaretToSelectionStart()
{
if (!Sci_IsMultiSelection()) {
if (SciCall_GetCurrentPos() != SciCall_GetSelectionStart()) {
size_t const m = SciCall_GetMainSelection();
DocPos const c = SciCall_GetSelectionNCaret(m) + SciCall_GetSelectionNCaretVirtualSpace(m);
DocPos const s = SciCall_GetSelectionNStart(m) + SciCall_GetSelectionNStartVirtualSpace(m);
bool const bSwap = (c != s);
if (bSwap) {
size_t const n = SciCall_GetSelections();
for (size_t i = 0; i < n; ++i) {
SciCall_SwapMainAnchorCaret();
SciCall_RotateSelection();
}
}
return SciCall_GetSelectionStart();
return bSwap;
}
//=============================================================================
//
// EditSetCaretToSelectionEnd()
//
DocPos EditSetCaretToSelectionEnd()
bool EditSetCaretToSelectionEnd()
{
if (!Sci_IsMultiSelection()) {
if (SciCall_GetCurrentPos() != SciCall_GetSelectionEnd()) {
size_t const m = SciCall_GetMainSelection();
DocPos const c = SciCall_GetSelectionNCaret(m) + SciCall_GetSelectionNCaretVirtualSpace(m);
DocPos const e = SciCall_GetSelectionNEnd(m) + SciCall_GetSelectionNEndVirtualSpace(m);
bool const bSwap = (c != e);
if (bSwap) {
size_t const n = SciCall_GetSelections();
for (size_t i = 0; i < n; ++i) {
SciCall_SwapMainAnchorCaret();
SciCall_RotateSelection();
}
}
return SciCall_GetSelectionEnd();
return bSwap;
}
@ -6344,7 +6356,8 @@ bool EditFindNext(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bExtendSelection, bo
SetFocus(hwnd);
}
DocPos const iDocEndPos = Sci_GetDocEndPosition();
DocPos start = EditSetCaretToSelectionEnd();
EditSetCaretToSelectionEnd();
DocPos start = SciCall_GetSelectionEnd();
DocPos end = iDocEndPos;
if (start >= end) {
@ -6426,7 +6439,8 @@ bool EditFindPrev(HWND hwnd, LPCEDITFINDREPLACE lpefr, bool bExtendSelection, bo
int const sFlags = (int)(lpefr->fuFlags);
DocPos const iDocEndPos = Sci_GetDocEndPosition();
DocPos start = EditSetCaretToSelectionStart();
EditSetCaretToSelectionStart();
DocPos start = SciCall_GetSelectionStart();
DocPos end = 0;
if (start <= end) {

View File

@ -59,8 +59,8 @@ void EditSpacesToTabs(HWND hwnd,int nTabWidth,bool);
void EditMoveUp(HWND hwnd);
void EditMoveDown(HWND hwnd);
DocPos EditSetCaretToSelectionStart();
DocPos EditSetCaretToSelectionEnd();
bool EditSetCaretToSelectionStart();
bool EditSetCaretToSelectionEnd();
void EditModifyLines(HWND hwnd,LPCWSTR pwszPrefix,LPCWSTR pwszAppend);
void EditIndentBlock(HWND hwnd,int cmd, bool bFormatIndentation, bool bForceAll);
void EditAlignText(HWND hwnd,int nMode);

View File

@ -400,9 +400,6 @@ static void _SplitUndoTransaction(const int iModType);
static void _DelayClearZoomCallTip(int delay);
static void _DelaySplitUndoTransaction(int delay, int iModType);
//#define NP3_VIRTUAL_SPACE_ACCESS_OPTIONS (SCVS_RECTANGULARSELECTION | SCVS_NOWRAPLINESTART | SCVS_USERACCESSIBLE)
#define NP3_VIRTUAL_SPACE_ACCESS_OPTIONS (SCVS_RECTANGULARSELECTION)
//=============================================================================
//
// IgnoreNotifyChangeEvent(), ObserveNotifyChangeEvent(), CheckNotifyChangeEvent()
@ -1364,16 +1361,16 @@ HWND InitInstance(HINSTANCE hInstance,LPCWSTR pszCmdLine,int nCmdShow)
// Check for /c [if no file is specified] -- even if a file is specified
/*else */if (s_flagNewFromClipboard) {
if (SendMessage(Globals.hwndEdit, SCI_CANPASTE, 0, 0)) {
if (SciCall_CanPaste()) {
bool bAutoIndent2 = Settings.AutoIndent;
Settings.AutoIndent = 0;
EditJumpTo(Globals.hwndEdit, -1, 0);
_BEGIN_UNDO_ACTION_
if (SendMessage(Globals.hwndEdit, SCI_GETLENGTH, 0, 0) > 0) {
SendMessage(Globals.hwndEdit, SCI_NEWLINE, 0, 0);
if (!Sci_IsDocEmpty()) {
SciCall_NewLine();
}
SendMessage(Globals.hwndEdit, SCI_PASTE, 0, 0);
SendMessage(Globals.hwndEdit, SCI_NEWLINE, 0, 0);
SciCall_Paste();
SciCall_NewLine();
_END_UNDO_ACTION_
Settings.AutoIndent = bAutoIndent2;
if (s_flagJumpTo)
@ -1799,8 +1796,7 @@ static void _InitializeSciEditCtrl(HWND hwndEditCtrl)
SendMessage(hwndEditCtrl, SCI_AUTOCSETMULTI, SC_MULTIAUTOC_EACH, 0); // paste into rectangular selection
SendMessage(hwndEditCtrl, SCI_SETMOUSESELECTIONRECTANGULARSWITCH, true, 0);
int const vspaceOpt = Settings2.DenyVirtualSpaceAccess ? SCVS_NONE : NP3_VIRTUAL_SPACE_ACCESS_OPTIONS;
SendMessage(hwndEditCtrl, SCI_SETVIRTUALSPACEOPTIONS, vspaceOpt, 0);
SendMessage(hwndEditCtrl, SCI_SETVIRTUALSPACEOPTIONS, NP3_VIRTUAL_SPACE_ACCESS_OPTIONS, 0);
SendMessage(hwndEditCtrl, SCI_SETADDITIONALCARETSBLINK, true, 0);
SendMessage(hwndEditCtrl, SCI_SETADDITIONALCARETSVISIBLE, true, 0);
@ -1902,7 +1898,6 @@ static void _InitializeSciEditCtrl(HWND hwndEditCtrl)
else {
SendMessage(hwndEditCtrl, SCI_SETYCARETPOLICY, (WPARAM)(_CARET_SYMETRY), 0);
}
SendMessage(hwndEditCtrl, SCI_SETVIRTUALSPACEOPTIONS, (WPARAM)(Settings2.DenyVirtualSpaceAccess ? SCVS_NONE : NP3_VIRTUAL_SPACE_ACCESS_OPTIONS), 0);
SendMessage(hwndEditCtrl, SCI_SETENDATLASTLINE, (WPARAM)((Settings.ScrollPastEOF) ? 0 : 1), 0);
// Tabs
@ -2524,7 +2519,7 @@ LRESULT MsgDPIChanged(HWND hwnd, WPARAM wParam, LPARAM lParam)
#if 0
char buf[128];
sprintf(buf, "WM_DPICHANGED: dpi=%u,%u ppi=%u,%u\n", Globals.CurrentDPI.x, Globals.CurrentDPI.y, Globals.CurrentPPI.x, Globals.CurrentPPI.y);
SendMessage(Globals.hwndEdit, SCI_INSERTTEXT, 0, (LPARAM)buf);
SciCall_InsertText(0, buf);
#endif
Style_ResetCurrentLexer(Globals.hwndEdit);
@ -4140,7 +4135,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
case IDM_EDIT_SELECTALL:
SendMessage(Globals.hwndEdit,SCI_SELECTALL,0,0);
SciCall_SelectAll();
UpdateToolbar();
UpdateStatusbar(false);
break;
@ -4284,7 +4279,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
// break;
case CMD_VK_INSERT:
SendMessage(Globals.hwndEdit, SCI_EDITTOGGLEOVERTYPE, 0, 0);
SciCall_EditToggleOverType();
UpdateStatusbar(false);
break;
@ -6019,10 +6014,12 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
WideCharToMultiByteEx(Encoding_SciCP, 0, wchFind, -1, efrTS.szFind,COUNTOF(efrTS.szFind),NULL,NULL);
WideCharToMultiByteEx(Encoding_SciCP, 0, wchReplace, -1, efrTS.szReplace, COUNTOF(efrTS.szReplace), NULL, NULL);
if (!SendMessage(Globals.hwndEdit, SCI_GETSELECTIONEMPTY, 0, 0))
if (!SciCall_IsSelectionEmpty()) {
EditReplaceAllInSelection(Globals.hwndEdit, &efrTS, true);
else
EditReplaceAll(Globals.hwndEdit,&efrTS,true);
}
else {
EditReplaceAll(Globals.hwndEdit, &efrTS, true);
}
}
break;
@ -6179,7 +6176,17 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
break;
case CMD_JUMP2SELEND:
EditSetCaretToSelectionEnd();
if (!EditSetCaretToSelectionEnd() && Sci_IsMultiOrRectangleSelection()) {
size_t const n = SciCall_GetSelections();
DocLn const lineStart = SciCall_LineFromPosition(SciCall_GetSelectionStart());
SciCall_ClearSelections();
DocPos const beg = SciCall_GetLineEndPosition(lineStart);
SciCall_SetSelection(beg, beg);
for (size_t i = 1; i < n; ++i) {
DocPos const pos = SciCall_GetLineEndPosition(lineStart + i);
SciCall_AddSelection(pos, pos);
}
}
SciCall_ChooseCaretX();
break;
@ -7348,10 +7355,8 @@ static LRESULT _MsgNotifyFromEdit(HWND hwnd, const LPNMHDR pnmh, const SCNotific
}
break;
case SCN_MARGINRIGHTCLICK:
break;
//case SCN_MARGINRIGHTCLICK:
// break;
// ~~~ Not used in Windows ~~~
// see: CMD_ALTUP / CMD_ALTDOWN
@ -10937,17 +10942,16 @@ void CALLBACK PasteBoardTimer(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime)
{
if ((s_dwLastCopyTime > 0) && ((GetTickCount() - s_dwLastCopyTime) > 200)) {
if (SendMessage(Globals.hwndEdit,SCI_CANPASTE,0,0)) {
if (SciCall_CanPaste()) {
bool bAutoIndent2 = Settings.AutoIndent;
Settings.AutoIndent = 0;
EditJumpTo(Globals.hwndEdit,-1,0);
_BEGIN_UNDO_ACTION_
if (SendMessage(Globals.hwndEdit, SCI_GETLENGTH, 0, 0) > 0) {
SendMessage(Globals.hwndEdit, SCI_NEWLINE, 0, 0);
if (!Sci_IsDocEmpty()) {
SciCall_NewLine();
}
SendMessage(Globals.hwndEdit,SCI_PASTE,0,0);
SendMessage(Globals.hwndEdit,SCI_NEWLINE,0,0);
SciCall_Paste();
SciCall_NewLine();
_END_UNDO_ACTION_
EditEnsureSelectionVisible();
Settings.AutoIndent = bAutoIndent2;

View File

@ -181,6 +181,9 @@ DeclareSciCallV2(SetSelectionNCaretVirtualSpace, SETSELECTIONNCARETVIRTUALSPACE,
DeclareSciCallV2(SetSelectionNAnchorVirtualSpace, SETSELECTIONNANCHORVIRTUALSPACE, DocPosU, selnum, DocPos, position)
DeclareSciCallR1(GetSelectionNStart, GETSELECTIONNSTART, DocPos, DocPosU, selnum)
DeclareSciCallR1(GetSelectionNEnd, GETSELECTIONNEND, DocPos, DocPosU, selnum)
DeclareSciCallR1(GetSelectionNStartVirtualSpace, GETSELECTIONNSTARTVIRTUALSPACE, DocPos, DocPosU, selnum)
DeclareSciCallR1(GetSelectionNEndVirtualSpace, GETSELECTIONNENDVIRTUALSPACE, DocPos, DocPosU, selnum)
DeclareSciCallV0(SwapMainAnchorCaret, SWAPMAINANCHORCARET)
DeclareSciCallV0(MultipleSelectAddEach, MULTIPLESELECTADDEACH)
DeclareSciCallV0(RotateSelection, ROTATESELECTION)
@ -212,6 +215,7 @@ DeclareSciCallV0(DelLineRight, DELLINERIGHT)
DeclareSciCallV0(LineDelete, LINEDELETE)
DeclareSciCallV1(LinesSplit, LINESSPLIT, int, pix)
DeclareSciCallV0(LinesJoin, LINESJOIN)
DeclareSciCallV0(EditToggleOverType, EDITTOGGLEOVERTYPE)
// Commands
DeclareSciCallV0(LineDuplicate, LINEDUPLICATE)
@ -541,6 +545,8 @@ DeclareSciCallR0(IsIMEModeCJK, ISIMEMODECJK, bool)
DeclareSciCallR0(IsSelectionEmpty, GETSELECTIONEMPTY, bool)
DeclareSciCallR0(IsSelectionRectangle, SELECTIONISRECTANGLE, bool)
#define Sci_IsDocEmpty() (SciCall_GetTextLength() <= 0LL)
#define Sci_IsThinSelection() (SciCall_GetSelectionMode() == SC_SEL_THIN)
#define Sci_IsMultiSelection() ((SciCall_GetSelections() > 1) && !SciCall_IsSelectionRectangle())
#define Sci_IsMultiOrRectangleSelection() ((SciCall_GetSelections() > 1) || SciCall_IsSelectionRectangle())

View File

@ -655,6 +655,9 @@ typedef struct _themeFiles
#define NOTEPAD3_MODULE_DIR_ENV_VAR L"NOTEPAD3MODULEDIR"
//#define NP3_VIRTUAL_SPACE_ACCESS_OPTIONS (Settings2.DenyVirtualSpaceAccess ? SCVS_NONE : (SCVS_RECTANGULARSELECTION | SCVS_NOWRAPLINESTART | SCVS_USERACCESSIBLE))
#define NP3_VIRTUAL_SPACE_ACCESS_OPTIONS (Settings2.DenyVirtualSpaceAccess ? SCVS_NONE : (SCVS_RECTANGULARSELECTION | SCVS_NOWRAPLINESTART))
// from <wininet.h>
#define INTERNET_MAX_PATH_LENGTH 2048
#define INTERNET_MAX_SCHEME_LENGTH 32 // longest protocol name length

View File

@ -9,7 +9,7 @@
#define VERSION_MAJOR 5
#define VERSION_MINOR 20
#define VERSION_REV 212
#define VERSION_BUILD 2
#define VERSION_BUILD 3
#define SCINTILLA_VER 430
#define ONIGURUMA_REGEX_VER 6.9.4
#define UCHARDET_VER 2018.09.27