mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-11 21:03:05 +08:00
+ enh: some multi-selection enhancements
This commit is contained in:
parent
7bf1aba7d6
commit
c72e17ab2d
@ -1 +1 @@
|
||||
2235
|
||||
2236
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<assemblyIdentity
|
||||
name="Notepad3"
|
||||
processorArchitecture="*"
|
||||
version="5.19.529.2235"
|
||||
version="5.19.530.2236"
|
||||
type="win32"
|
||||
/>
|
||||
<description>Notepad3 ONIGURUMA</description>
|
||||
|
||||
53
src/Edit.c
53
src/Edit.c
@ -6177,7 +6177,7 @@ void EditMarkAllOccurrences(HWND hwnd, bool bForceClear)
|
||||
void EditSelectionMultiSelectAll()
|
||||
{
|
||||
DocPos const iSelSize = SciCall_GetSelText(NULL);
|
||||
if (iSelSize > 1)
|
||||
if ((iSelSize > 1))
|
||||
{
|
||||
char* pszText = AllocMem(iSelSize, HEAP_ZERO_MEMORY);
|
||||
if (NULL == pszText) {
|
||||
@ -6531,6 +6531,28 @@ void EditToggleView(HWND hwnd)
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// EditSelectWordAtPos()
|
||||
//
|
||||
void EditSelectWordAtPos(const DocPos iPos, const bool bForceWord)
|
||||
{
|
||||
DocPos iWordStart = SciCall_WordStartPosition(iPos, true);
|
||||
DocPos iWordEnd = SciCall_WordEndPosition(iPos, true);
|
||||
|
||||
if ((iWordStart == iWordEnd) && bForceWord) // we are in whitespace salad...
|
||||
{
|
||||
iWordStart = SciCall_WordEndPosition(iPos, false);
|
||||
iWordEnd = SciCall_WordEndPosition(iWordStart, true);
|
||||
if (iWordStart != iWordEnd) {
|
||||
SciCall_SetSelection(iWordEnd, iWordStart);
|
||||
}
|
||||
}
|
||||
else {
|
||||
SciCall_SetSelection(iWordEnd, iWordStart);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
@ -6563,19 +6585,26 @@ void EditMarkAll(HWND hwnd, char* pszFind, int flags, DocPos rangeStart, DocPos
|
||||
{
|
||||
if (SciCall_IsSelectionEmpty()) {
|
||||
// nothing selected, get word under caret if flagged
|
||||
if (Settings.MarkOccurrencesCurrentWord && (flags & SCFIND_WHOLEWORD)) {
|
||||
DocPos const iCurrPos = SciCall_GetCurrentPos();
|
||||
DocPos const iWordStart = SciCall_WordStartPosition(iCurrPos, true);
|
||||
DocPos const iWordEnd = SciCall_WordEndPosition(iCurrPos, true);
|
||||
iFindLength = (iWordEnd - iWordStart);
|
||||
StringCchCopyNA(txtBuffer, COUNTOF(txtBuffer), SciCall_GetRangePointer(iWordStart, iFindLength), iFindLength);
|
||||
if (Settings.MarkOccurrencesCurrentWord && (flags & SCFIND_WHOLEWORD))
|
||||
{
|
||||
DocPos const iCurPos = SciCall_GetCurrentPos();
|
||||
EditSelectWordAtPos(iCurPos, false);
|
||||
size_t const len = SciCall_GetSelText(NULL);
|
||||
if ((len > 1) && (len < COUNTOF(txtBuffer))) {
|
||||
SciCall_GetSelText(txtBuffer);
|
||||
SciCall_SetSelection(iCurPos, iCurPos);
|
||||
iFindLength = len - 1;
|
||||
}
|
||||
else {
|
||||
return; // selected word empty or too big
|
||||
}
|
||||
}
|
||||
else {
|
||||
return; // no pattern, no selection and no word mark chosen
|
||||
}
|
||||
}
|
||||
else { // we have a selection
|
||||
|
||||
else // we have a selection
|
||||
{
|
||||
// get current selection
|
||||
DocPos const iSelStart = SciCall_GetSelectionStart();
|
||||
DocPos const iSelEnd = SciCall_GetSelectionEnd();
|
||||
@ -6585,7 +6614,7 @@ void EditMarkAll(HWND hwnd, char* pszFind, int flags, DocPos rangeStart, DocPos
|
||||
if ((SciCall_LineFromPosition(iSelStart) != SciCall_LineFromPosition(iSelEnd)) || (iSelCount >= COUNTOF(txtBuffer))) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
iFindLength = SciCall_GetSelText(pszText) - 1;
|
||||
|
||||
// exit if selection is not a word and Match whole words only is enabled
|
||||
@ -6619,9 +6648,9 @@ void EditMarkAll(HWND hwnd, char* pszFind, int flags, DocPos rangeStart, DocPos
|
||||
|
||||
iPos = _FindInTarget(hwnd, pszText, iFindLength, flags, &start, &end, (start == iPos), FRMOD_IGNORE);
|
||||
|
||||
if (iPos < 0)
|
||||
if (iPos < 0) {
|
||||
break; // not found
|
||||
|
||||
}
|
||||
// mark this match if not done before
|
||||
SciCall_SetIndicatorCurrent(INDIC_NP3_MARK_OCCURANCE);
|
||||
SciCall_IndicatorFillRange(iPos, (end - start));
|
||||
|
||||
@ -103,6 +103,7 @@ void EditPrintInit();
|
||||
void EditMatchBrace(HWND hwnd);
|
||||
void EditClearAllOccurrenceMarkers(HWND hwnd);
|
||||
void EditToggleView(HWND hwnd);
|
||||
void EditSelectWordAtPos(const DocPos iPos, const bool bForceWord);
|
||||
int EditAddSearchFlags(int flags, bool bRegEx, bool bWordStart, bool bMatchCase, bool bMatchWords, bool bDotMatchAll);
|
||||
void EditMarkAll(HWND hwnd, char* pszFind, int flags, DocPos rangeStart, DocPos rangeEnd);
|
||||
void EditFinalizeStyling(HWND hwnd, DocPos iEndPos);
|
||||
|
||||
@ -1496,7 +1496,7 @@ int MRU_Compare(LPMRULIST pmru,LPCWSTR psz1,LPCWSTR psz2)
|
||||
return(StringCchCompareX(psz1,psz2));
|
||||
}
|
||||
|
||||
bool MRU_Add(LPMRULIST pmru,LPCWSTR pszNew, cpi_enc_t iEnc, DocPos iPos, LPCWSTR pszBookMarks)
|
||||
bool MRU_Add(LPMRULIST pmru, LPCWSTR pszNew, cpi_enc_t iEnc, DocPos iPos, LPCWSTR pszBookMarks)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < pmru->iSize; i++) {
|
||||
|
||||
@ -3882,24 +3882,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
case IDM_EDIT_SELECTWORD:
|
||||
{
|
||||
DocPos const iPos = SciCall_GetCurrentPos();
|
||||
|
||||
if (SciCall_IsSelectionEmpty()) {
|
||||
|
||||
DocPos iWordStart = SciCall_WordStartPosition(iPos, true);
|
||||
DocPos iWordEnd = SciCall_WordEndPosition(iPos, true);
|
||||
|
||||
if (iWordStart == iWordEnd) // we are in whitespace salad...
|
||||
{
|
||||
iWordStart = SciCall_WordEndPosition(iPos, false);
|
||||
iWordEnd = SciCall_WordEndPosition(iWordStart, true);
|
||||
if (iWordStart != iWordEnd) {
|
||||
SciCall_SetSelection(iWordEnd, iWordStart);
|
||||
}
|
||||
}
|
||||
else {
|
||||
SciCall_SetSelection(iWordEnd, iWordStart);
|
||||
}
|
||||
EditSelectWordAtPos(SciCall_GetCurrentPos(), false);
|
||||
|
||||
if (!SciCall_IsSelectionEmpty()) {
|
||||
SciCall_ChooseCaretX();
|
||||
@ -3923,8 +3908,15 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
case IDM_EDIT_SELECTALLMATCHES:
|
||||
{
|
||||
EditSelectionMultiSelectAll();
|
||||
UpdateStatusbar(false);
|
||||
if (!Sci_IsMultiOrRectangleSelection()) {
|
||||
if (SciCall_IsSelectionEmpty()) {
|
||||
if (!IsMarkOccurrencesEnabled() || Settings.MarkOccurrencesCurrentWord) {
|
||||
EditSelectWordAtPos(SciCall_GetCurrentPos(), false);
|
||||
}
|
||||
}
|
||||
EditSelectionMultiSelectAll();
|
||||
UpdateStatusbar(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -4819,6 +4811,35 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
if (SciCall_GetTextLength() == 0) { break; }
|
||||
|
||||
if (Sci_IsMultiSelection()) {
|
||||
switch (iLoWParam) {
|
||||
case IDM_EDIT_SELTONEXT:
|
||||
{
|
||||
SciCall_RotateSelection();
|
||||
DocPosU const iMain = SciCall_GetMainSelection();
|
||||
SciCall_ScrollRange(SciCall_GetSelectionNAnchor(iMain), SciCall_GetSelectionNCaret(iMain));
|
||||
}
|
||||
break;
|
||||
|
||||
case IDM_EDIT_SELTOPREV:
|
||||
{
|
||||
DocPosU const iMain = SciCall_GetMainSelection();
|
||||
if (iMain > 0) {
|
||||
SciCall_SetMainSelection(iMain - 1);
|
||||
SciCall_ScrollRange(SciCall_GetSelectionNAnchor(iMain - 1), SciCall_GetSelectionNCaret(iMain - 1));
|
||||
} else {
|
||||
DocPosU const iNewMain = SciCall_GetSelections() - 1;
|
||||
SciCall_SetMainSelection(iNewMain);
|
||||
SciCall_ScrollRange(SciCall_GetSelectionNAnchor(iNewMain), SciCall_GetSelectionNCaret(iNewMain));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
break; // done
|
||||
}
|
||||
|
||||
if (IsFindPatternEmpty() && !StringCchLenA(Settings.EFR_Data.szFind, COUNTOF(Settings.EFR_Data.szFind)))
|
||||
{
|
||||
if (iLoWParam != IDM_EDIT_REPLACENEXT) {
|
||||
@ -4877,34 +4898,39 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
case CMD_FINDPREVSEL:
|
||||
case IDM_EDIT_SAVEFIND:
|
||||
{
|
||||
DocPos cchSelection = SciCall_GetSelText(NULL);
|
||||
|
||||
if (1 >= cchSelection)
|
||||
{
|
||||
SendWMCommand(hwnd, IDM_EDIT_SELECTWORD);
|
||||
cchSelection = SciCall_GetSelText(NULL);
|
||||
if (SciCall_IsSelectionEmpty()) {
|
||||
EditSelectWordAtPos(SciCall_GetCurrentPos(), true);
|
||||
}
|
||||
|
||||
if ((1 < cchSelection) && (cchSelection < FNDRPL_BUFFER))
|
||||
size_t const cchSelection = SciCall_GetSelText(NULL);
|
||||
|
||||
if (1 < cchSelection)
|
||||
{
|
||||
char mszSelection[FNDRPL_BUFFER];
|
||||
SciCall_GetSelText(mszSelection);
|
||||
char* szSelection = AllocMem(cchSelection, HEAP_ZERO_MEMORY);
|
||||
if (NULL == szSelection) {
|
||||
break;
|
||||
}
|
||||
SciCall_GetSelText(szSelection);
|
||||
|
||||
// Check lpszSelection and truncate newlines
|
||||
char *lpsz = StrChrA(mszSelection, '\n');
|
||||
char *lpsz = StrChrA(szSelection, '\n');
|
||||
if (lpsz) *lpsz = '\0';
|
||||
|
||||
lpsz = StrChrA(mszSelection, '\r');
|
||||
lpsz = StrChrA(szSelection, '\r');
|
||||
if (lpsz) *lpsz = '\0';
|
||||
|
||||
StringCchCopyA(Settings.EFR_Data.szFind, COUNTOF(Settings.EFR_Data.szFind), mszSelection);
|
||||
StringCchCopyA(Settings.EFR_Data.szFind, COUNTOF(Settings.EFR_Data.szFind), szSelection);
|
||||
Settings.EFR_Data.fuFlags &= (~(SCFIND_REGEXP | SCFIND_POSIX));
|
||||
Settings.EFR_Data.bTransformBS = false;
|
||||
|
||||
WCHAR wszBuf[FNDRPL_BUFFER];
|
||||
MultiByteToWideChar(Encoding_SciCP, 0, mszSelection, -1, wszBuf, FNDRPL_BUFFER);
|
||||
MRU_Add(Globals.pMRUfind, wszBuf, 0, 0, NULL);
|
||||
SetFindPattern(wszBuf);
|
||||
LPWSTR pszTextW = AllocMem(cchSelection * sizeof(WCHAR), HEAP_ZERO_MEMORY);
|
||||
if (pszTextW == NULL) {
|
||||
FreeMem(szSelection);
|
||||
break;
|
||||
}
|
||||
MultiByteToWideChar(Encoding_SciCP, 0, szSelection, -1, pszTextW, (MBWC_DocPos_Cast)cchSelection);
|
||||
MRU_Add(Globals.pMRUfind, pszTextW, 0, 0, NULL);
|
||||
SetFindPattern(pszTextW);
|
||||
|
||||
switch (iLoWParam) {
|
||||
|
||||
@ -4925,6 +4951,9 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
|
||||
EditFindPrev(Globals.hwndEdit, &Settings.EFR_Data, false, false);
|
||||
break;
|
||||
}
|
||||
|
||||
FreeMem(szSelection);
|
||||
FreeMem(pszTextW);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@ -223,7 +223,7 @@ BEGIN
|
||||
VK_F12, IDM_VIEW_SCHEMECONFIG, VIRTKEY, CONTROL, NOINVERT
|
||||
VK_F12, IDM_VIEW_FONT, VIRTKEY, ALT, NOINVERT
|
||||
VK_F12, IDM_VIEW_USE2NDDEFAULT, VIRTKEY, SHIFT, NOINVERT
|
||||
VK_F12, IDM_VIEW_CURRENTSCHEME, VIRTKEY, CONTROL, ALT
|
||||
VK_F12, IDM_VIEW_CURRENTSCHEME, VIRTKEY, CONTROL, ALT, NOINVERT
|
||||
VK_F2, IDM_EDIT_SELTONEXT, VIRTKEY, CONTROL, ALT, NOINVERT
|
||||
VK_F2, IDM_EDIT_SELTOPREV, VIRTKEY, SHIFT, CONTROL, ALT, NOINVERT
|
||||
VK_F2, BME_EDIT_BOOKMARKNEXT, VIRTKEY, NOINVERT
|
||||
@ -292,8 +292,8 @@ BEGIN
|
||||
"H", IDACC_REPLACE, VIRTKEY, CONTROL, NOINVERT
|
||||
"S", IDACC_SAVEPOS, VIRTKEY, CONTROL, NOINVERT
|
||||
"R", IDACC_RESETPOS, VIRTKEY, CONTROL, NOINVERT
|
||||
VK_F2, IDACC_SELTONEXT, VIRTKEY, CONTROL, ALT, NOINVERT
|
||||
VK_F2, IDACC_SELTOPREV, VIRTKEY, SHIFT, CONTROL, ALT, NOINVERT
|
||||
//VK_F2, IDACC_SELTONEXT, VIRTKEY, CONTROL, ALT, NOINVERT
|
||||
//VK_F2, IDACC_SELTOPREV, VIRTKEY, SHIFT, CONTROL, ALT, NOINVERT
|
||||
VK_F3, IDACC_FINDNEXT, VIRTKEY, NOINVERT
|
||||
VK_F3, IDACC_SAVEFIND, VIRTKEY, ALT, NOINVERT
|
||||
VK_F3, IDACC_FINDPREV, VIRTKEY, SHIFT, NOINVERT
|
||||
|
||||
@ -197,6 +197,7 @@ DeclareSciCallR1(GetSelectionNStart, GETSELECTIONNSTART, DocPos, DocPosU, selnum
|
||||
DeclareSciCallR1(GetSelectionNEnd, GETSELECTIONNEND, DocPos, DocPosU, selnum)
|
||||
DeclareSciCallV0(SwapMainAnchorCaret, SWAPMAINANCHORCARET)
|
||||
DeclareSciCallV0(MultipleSelectAddEach, MULTIPLESELECTADDEACH)
|
||||
DeclareSciCallV0(RotateSelection, ROTATESELECTION)
|
||||
|
||||
// Zoom
|
||||
DeclareSciCallR0(GetZoom, GETZOOM, int)
|
||||
|
||||
@ -7,8 +7,8 @@
|
||||
#define SAPPNAME "Notepad3"
|
||||
#define VERSION_MAJOR 5
|
||||
#define VERSION_MINOR 19
|
||||
#define VERSION_REV 529
|
||||
#define VERSION_BUILD 2235
|
||||
#define VERSION_REV 530
|
||||
#define VERSION_BUILD 2236
|
||||
#define SCINTILLA_VER 415+
|
||||
#define ONIGURUMA_REGEX_VER 6.9.2
|
||||
#define VERSION_PATCH ONIGURUMA
|
||||
|
||||
Loading…
Reference in New Issue
Block a user