mirror of
https://github.com/rizonesoft/Notepad3.git
synced 2026-06-14 21:09:05 +08:00
Merge pull request #3460 from RaiKoHoff/Dev_RC1
Fix handling of F/R dialog pattern combo-box dropdown list
This commit is contained in:
commit
1708fe7726
@ -53,7 +53,7 @@
|
||||
|
||||
using namespace Lexilla;
|
||||
|
||||
static inline bool IsNewline(const int ch) {
|
||||
constexpr bool IsNewline(const int ch) {
|
||||
return (ch == '\n' || ch == '\r');
|
||||
}
|
||||
|
||||
@ -135,36 +135,45 @@ static bool HasPrevLineContent(StyleContext &sc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool AtTermStart(StyleContext &sc) {
|
||||
constexpr bool AtTermStart(StyleContext &sc) {
|
||||
return sc.currentPos == 0 || sc.chPrev == 0 || isspacechar(sc.chPrev);
|
||||
}
|
||||
|
||||
static bool IsValidHrule(const Sci_PositionU endPos, StyleContext &sc) {
|
||||
static bool IsValidHrule(const Sci_PositionU endPos, StyleContext& sc) {
|
||||
int count = 1;
|
||||
Sci_PositionU i = 0;
|
||||
for (;;) {
|
||||
++i;
|
||||
int c = sc.GetRelative(i);
|
||||
if (c == sc.ch)
|
||||
int const ch = sc.GetRelative(i);
|
||||
if (ch == sc.ch)
|
||||
++count;
|
||||
// hit a terminating character
|
||||
else if (!IsASpaceOrTab(c) || sc.currentPos + i == endPos) {
|
||||
else if (!IsASpaceOrTab(ch) || (sc.currentPos + i) == endPos) {
|
||||
// Are we a valid HRULE
|
||||
if ((IsNewline(c) || sc.currentPos + i == endPos) &&
|
||||
count >= 3 && !HasPrevLineContent(sc)) {
|
||||
if ((IsNewline(ch) || (sc.currentPos + i) == endPos) &&
|
||||
count >= 3 && !HasPrevLineContent(sc)) {
|
||||
sc.SetState(SCE_MARKDOWN_HRULE);
|
||||
sc.Forward(i);
|
||||
sc.SetState(SCE_MARKDOWN_LINE_BEGIN);
|
||||
//@@@sc.SetState(SCE_MARKDOWN_LINE_BEGIN);
|
||||
sc.SetState(SCE_MARKDOWN_DEFAULT);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
sc.SetState(SCE_MARKDOWN_DEFAULT);
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
constexpr bool IsInHeaderState(const int state) {
|
||||
return (
|
||||
state == SCE_MARKDOWN_HEADER1 || state == SCE_MARKDOWN_HEADER2 ||
|
||||
state == SCE_MARKDOWN_HEADER3 || state == SCE_MARKDOWN_HEADER4 ||
|
||||
state == SCE_MARKDOWN_HEADER5 || state == SCE_MARKDOWN_HEADER6
|
||||
);
|
||||
}
|
||||
|
||||
static void ColorizeMarkdownDoc(Sci_PositionU startPos, Sci_Position length, int initStyle,
|
||||
WordList **, Accessor &styler) {
|
||||
Sci_PositionU endPos = startPos + length;
|
||||
@ -178,16 +187,21 @@ static void ColorizeMarkdownDoc(Sci_PositionU startPos, Sci_Position length, int
|
||||
StyleContext sc(startPos, length, initStyle, styler);
|
||||
|
||||
while (sc.More()) {
|
||||
|
||||
// Skip past escaped characters
|
||||
if (sc.ch == '\\') {
|
||||
sc.Forward();
|
||||
continue;
|
||||
}
|
||||
|
||||
// A blockquotes resets the line semantics
|
||||
if (sc.state == SCE_MARKDOWN_BLOCKQUOTE)
|
||||
if (IsInHeaderState(sc.state) && sc.atLineStart) {
|
||||
sc.SetState(SCE_MARKDOWN_LINE_BEGIN);
|
||||
}
|
||||
|
||||
// A blockquotes resets the line semantics
|
||||
if (sc.state == SCE_MARKDOWN_BLOCKQUOTE) {
|
||||
sc.SetState(SCE_MARKDOWN_LINE_BEGIN);
|
||||
}
|
||||
// Conditional state-based actions
|
||||
if (sc.state == SCE_MARKDOWN_CODE2) {
|
||||
if (sc.Match("``") && sc.GetRelative(-2) != ' ') {
|
||||
@ -263,24 +277,36 @@ static void ColorizeMarkdownDoc(Sci_PositionU startPos, Sci_Position length, int
|
||||
}
|
||||
else if (sc.state == SCE_MARKDOWN_LINE_BEGIN) {
|
||||
// Header
|
||||
if (sc.Match("######"))
|
||||
if (sc.Match("######")) {
|
||||
SetStateAndZoom(SCE_MARKDOWN_HEADER6, 6, '#', sc);
|
||||
else if (sc.Match("#####"))
|
||||
freezeCursor = true;
|
||||
}
|
||||
else if (sc.Match("#####")) {
|
||||
SetStateAndZoom(SCE_MARKDOWN_HEADER5, 5, '#', sc);
|
||||
else if (sc.Match("####"))
|
||||
SetStateAndZoom(SCE_MARKDOWN_HEADER4, 4, '#', sc);
|
||||
else if (sc.Match("###"))
|
||||
freezeCursor = true;
|
||||
}
|
||||
else if (sc.Match("####")) {
|
||||
SetStateAndZoom(SCE_MARKDOWN_HEADER4, 4, '#', sc);
|
||||
freezeCursor = true;
|
||||
}
|
||||
else if (sc.Match("###")) {
|
||||
SetStateAndZoom(SCE_MARKDOWN_HEADER3, 3, '#', sc);
|
||||
else if (sc.Match("##"))
|
||||
freezeCursor = true;
|
||||
}
|
||||
else if (sc.Match("##")) {
|
||||
SetStateAndZoom(SCE_MARKDOWN_HEADER2, 2, '#', sc);
|
||||
freezeCursor = true;
|
||||
}
|
||||
else if (sc.Match("#")) {
|
||||
// Catch the special case of an unordered list
|
||||
if (sc.chNext == '.' && IsASpaceOrTab(sc.GetRelative(2))) {
|
||||
precharCount = 0;
|
||||
sc.SetState(SCE_MARKDOWN_PRECHAR);
|
||||
}
|
||||
else
|
||||
else {
|
||||
SetStateAndZoom(SCE_MARKDOWN_HEADER1, 1, '#', sc);
|
||||
freezeCursor = true;
|
||||
}
|
||||
}
|
||||
// Code block
|
||||
else if (sc.Match("~~~")) {
|
||||
@ -303,20 +329,22 @@ static void ColorizeMarkdownDoc(Sci_PositionU startPos, Sci_Position length, int
|
||||
sc.SetState(SCE_MARKDOWN_PRECHAR);
|
||||
}
|
||||
}
|
||||
else if (IsNewline(sc.ch))
|
||||
sc.SetState(SCE_MARKDOWN_LINE_BEGIN);
|
||||
else if (sc.atLineEnd) {
|
||||
sc.ForwardSetState(SCE_MARKDOWN_LINE_BEGIN);
|
||||
freezeCursor = true;
|
||||
}
|
||||
else {
|
||||
precharCount = 0;
|
||||
sc.SetState(SCE_MARKDOWN_PRECHAR);
|
||||
}
|
||||
}
|
||||
|
||||
// The header lasts until the newline
|
||||
else if (sc.state == SCE_MARKDOWN_HEADER1 || sc.state == SCE_MARKDOWN_HEADER2 ||
|
||||
sc.state == SCE_MARKDOWN_HEADER3 || sc.state == SCE_MARKDOWN_HEADER4 ||
|
||||
sc.state == SCE_MARKDOWN_HEADER5 || sc.state == SCE_MARKDOWN_HEADER6) {
|
||||
if (IsNewline(sc.ch))
|
||||
sc.SetState(SCE_MARKDOWN_LINE_BEGIN);
|
||||
// The header lasts beyond the newline (eolfilled)
|
||||
else if (IsInHeaderState(sc.state)) {
|
||||
if (sc.atLineEnd) {
|
||||
sc.ForwardSetState(SCE_MARKDOWN_LINE_BEGIN);
|
||||
freezeCursor = true;
|
||||
}
|
||||
}
|
||||
|
||||
// New state only within the initial whitespace
|
||||
@ -427,14 +455,16 @@ static void ColorizeMarkdownDoc(Sci_PositionU startPos, Sci_Position length, int
|
||||
sc.Forward();
|
||||
}
|
||||
// Beginning of line
|
||||
else if (IsNewline(sc.ch)) {
|
||||
sc.SetState(SCE_MARKDOWN_LINE_BEGIN);
|
||||
else if (sc.atLineEnd) {
|
||||
sc.ForwardSetState(SCE_MARKDOWN_LINE_BEGIN);
|
||||
freezeCursor = true;
|
||||
}
|
||||
}
|
||||
// Advance if not holding back the cursor for this iteration.
|
||||
if (!freezeCursor)
|
||||
sc.Forward();
|
||||
freezeCursor = false;
|
||||
else
|
||||
freezeCursor = false;
|
||||
}
|
||||
sc.Complete();
|
||||
}
|
||||
|
||||
@ -4970,18 +4970,21 @@ void SetWindowReadingRTL(HWND hwnd, bool bRTL)
|
||||
// A2W: Convert Dialog Item Text form Unicode to UTF-8 and vice versa
|
||||
//
|
||||
|
||||
UINT ComboBox_GetTextLenth(HWND hDlg, int nIDDlgItem)
|
||||
UINT ComboBox_GetTextLengthEx(HWND hDlg, int nIDDlgItem)
|
||||
{
|
||||
return (UINT)ComboBox_GetTextLength(GetDlgItem(hDlg, nIDDlgItem));
|
||||
}
|
||||
|
||||
UINT ComboBox_GetTextW2MB(HWND hDlg, int nIDDlgItem, LPSTR lpString, int nMaxCount)
|
||||
{
|
||||
UINT ComboBox_GetCurSelEx(HWND hDlg, int nIDDlgItem) {
|
||||
return (UINT)ComboBox_GetCurSel(GetDlgItem(hDlg, nIDDlgItem));
|
||||
}
|
||||
|
||||
UINT ComboBox_GetTextW2MB(HWND hDlg, int nIDDlgItem, LPSTR lpString, int nMaxCount) {
|
||||
WCHAR wsz[FNDRPL_BUFFER] = { L'\0' };
|
||||
HWND const hwndCtl = GetDlgItem(hDlg, nIDDlgItem);
|
||||
UINT const uRet = (UINT)ComboBox_GetTextLength(hwndCtl);
|
||||
int const idx = ComboBox_GetCurSel(hwndCtl);
|
||||
if (-1 != idx) {
|
||||
if (idx >= 0) {
|
||||
if (uRet < COUNTOF(wsz)) {
|
||||
ComboBox_GetLBText(hwndCtl, ComboBox_GetCurSel(hwndCtl), wsz);
|
||||
}
|
||||
@ -5001,13 +5004,14 @@ void ComboBox_SetTextMB2W(HWND hDlg, int nIDDlgItem, LPCSTR lpString)
|
||||
//return SetDlgItemText(hDlg, nIDDlgItem, wsz);
|
||||
}
|
||||
|
||||
LRESULT ComboBox_AddStringMB2W(HWND hwnd, LPCSTR lpString)
|
||||
#if 0
|
||||
void ComboBox_AddStringMB2W(HWND hDlg, int nIDDlgItem, LPCSTR lpString)
|
||||
{
|
||||
WCHAR wsz[FNDRPL_BUFFER] = { L'\0' };
|
||||
MultiByteToWideChar(Encoding_SciCP, 0, lpString, -1, wsz, (int)COUNTOF(wsz));
|
||||
return SendMessageW(hwnd, CB_ADDSTRING, 0, (LPARAM)wsz);
|
||||
ComboBox_AddString(GetDlgItem(hDlg, nIDDlgItem), wsz);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
|
||||
@ -89,10 +89,11 @@ void SetWindowTransparentMode(HWND hwnd, bool bTransparentMode, int iOpacityLeve
|
||||
void SetWindowLayoutRTL(HWND hwnd, bool bRTL);
|
||||
void SetWindowReadingRTL(HWND hwnd, bool bRTL);
|
||||
|
||||
UINT ComboBox_GetTextLenth(HWND hDlg, int nIDDlgItem);
|
||||
UINT ComboBox_GetTextLengthEx(HWND hDlg, int nIDDlgItem);
|
||||
UINT ComboBox_GetCurSelEx(HWND hDlg, int nIDDlgItem);
|
||||
UINT ComboBox_GetTextW2MB(HWND hDlg, int nIDDlgItem, LPSTR lpString, int nMaxCount);
|
||||
void ComboBox_SetTextMB2W(HWND hDlg, int nIDDlgItem, LPCSTR lpString);
|
||||
LRESULT ComboBox_AddStringMB2W(HWND hwnd, LPCSTR lpString);
|
||||
//void ComboBox_AddStringMB2W(HWND hDlg, int nIDDlgItem, LPCSTR lpString);
|
||||
|
||||
POINT GetCenterOfDlgInParent(const RECT* rcDlg, const RECT* rcParent);
|
||||
HWND GetParentOrDesktop(HWND hDlg);
|
||||
|
||||
411
src/Edit.c
411
src/Edit.c
@ -5442,196 +5442,194 @@ void EditGetExcerpt(HWND hwnd,LPWSTR lpszExcerpt,DWORD cchExcerpt)
|
||||
//
|
||||
static void _SetSearchFlags(HWND hwnd, LPEDITFINDREPLACE lpefr)
|
||||
{
|
||||
if (lpefr) {
|
||||
if (hwnd) {
|
||||
char szBuf[FNDRPL_BUFFER] = { '\0' };
|
||||
bool bIsFindDlg = (GetDlgItem(Globals.hwndDlgFindReplace, IDC_REPLACE) == NULL);
|
||||
if (hwnd && lpefr) {
|
||||
|
||||
ComboBox_GetTextW2MB(hwnd, IDC_FINDTEXT, szBuf, COUNTOF(szBuf));
|
||||
if (StringCchCompareXA(szBuf, lpefr->szFind) != 0) {
|
||||
StringCchCopyA(lpefr->szFind, COUNTOF(lpefr->szFind), szBuf);
|
||||
char szBuf[FNDRPL_BUFFER] = { '\0' };
|
||||
bool bIsFindDlg = (GetDlgItem(Globals.hwndDlgFindReplace, IDC_REPLACE) == NULL);
|
||||
|
||||
ComboBox_GetTextW2MB(hwnd, IDC_FINDTEXT, szBuf, COUNTOF(szBuf));
|
||||
if (StringCchCompareXA(szBuf, lpefr->szFind) != 0) {
|
||||
StringCchCopyA(lpefr->szFind, COUNTOF(lpefr->szFind), szBuf);
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
|
||||
ComboBox_GetTextW2MB(hwnd, IDC_REPLACETEXT, szBuf, COUNTOF(szBuf));
|
||||
if (StringCchCompareXA(szBuf, lpefr->szReplace) != 0) {
|
||||
StringCchCopyA(lpefr->szReplace, COUNTOF(lpefr->szReplace), szBuf);
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
|
||||
bool bIsFlagSet = ((lpefr->fuFlags & SCFIND_MATCHCASE) != 0);
|
||||
if (IsButtonChecked(hwnd, IDC_FINDCASE)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->fuFlags |= SCFIND_MATCHCASE;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
|
||||
ComboBox_GetTextW2MB(hwnd, IDC_REPLACETEXT, szBuf, COUNTOF(szBuf));
|
||||
if (StringCchCompareXA(szBuf, lpefr->szReplace) != 0) {
|
||||
StringCchCopyA(lpefr->szReplace, COUNTOF(lpefr->szReplace), szBuf);
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->fuFlags &= ~(SCFIND_MATCHCASE);
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
bIsFlagSet = ((lpefr->fuFlags & SCFIND_WHOLEWORD) != 0);
|
||||
if (IsButtonChecked(hwnd, IDC_FINDWORD)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->fuFlags |= SCFIND_WHOLEWORD;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->fuFlags &= ~(SCFIND_WHOLEWORD);
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool bIsFlagSet = ((lpefr->fuFlags & SCFIND_MATCHCASE) != 0);
|
||||
if (IsButtonChecked(hwnd, IDC_FINDCASE)) {
|
||||
bIsFlagSet = ((lpefr->fuFlags & SCFIND_WORDSTART) != 0);
|
||||
if (IsButtonChecked(hwnd, IDC_FINDSTART)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->fuFlags |= SCFIND_WORDSTART;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->fuFlags &= ~(SCFIND_WORDSTART);
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
bIsFlagSet = lpefr->bRegExprSearch;
|
||||
if (IsButtonChecked(hwnd, IDC_FINDREGEXP)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->bRegExprSearch = true;
|
||||
lpefr->fuFlags |= SCFIND_REGEXP;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->bRegExprSearch = false;
|
||||
lpefr->fuFlags &= ~SCFIND_REGEXP;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsDialogControlEnabled(hwnd, IDC_DOT_MATCH_ALL)) {
|
||||
bIsFlagSet = ((lpefr->fuFlags & SCFIND_DOT_MATCH_ALL) != 0);
|
||||
if (IsButtonChecked(hwnd, IDC_DOT_MATCH_ALL)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->fuFlags |= SCFIND_MATCHCASE;
|
||||
lpefr->fuFlags |= SCFIND_DOT_MATCH_ALL;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->fuFlags &= ~(SCFIND_MATCHCASE);
|
||||
lpefr->fuFlags &= ~SCFIND_DOT_MATCH_ALL;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bIsFlagSet = ((lpefr->fuFlags & SCFIND_WHOLEWORD) != 0);
|
||||
if (IsButtonChecked(hwnd, IDC_FINDWORD)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->fuFlags |= SCFIND_WHOLEWORD;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->fuFlags &= ~(SCFIND_WHOLEWORD);
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
// force consistency
|
||||
if (lpefr->bRegExprSearch) {
|
||||
CheckDlgButton(hwnd, IDC_WILDCARDSEARCH, BST_UNCHECKED);
|
||||
}
|
||||
bIsFlagSet = lpefr->bWildcardSearch;
|
||||
if (IsButtonChecked(hwnd, IDC_WILDCARDSEARCH)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->bWildcardSearch = true;
|
||||
lpefr->fuFlags |= SCFIND_REGEXP; // Wildcard search based on RegExpr
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
|
||||
bIsFlagSet = ((lpefr->fuFlags & SCFIND_WORDSTART) != 0);
|
||||
if (IsButtonChecked(hwnd, IDC_FINDSTART)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->fuFlags |= SCFIND_WORDSTART;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->fuFlags &= ~(SCFIND_WORDSTART);
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
bIsFlagSet = lpefr->bRegExprSearch;
|
||||
if (IsButtonChecked(hwnd, IDC_FINDREGEXP)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->bRegExprSearch = true;
|
||||
lpefr->fuFlags |= SCFIND_REGEXP;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->bRegExprSearch = false;
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->bWildcardSearch = false;
|
||||
if (!(lpefr->bRegExprSearch)) {
|
||||
lpefr->fuFlags &= ~SCFIND_REGEXP;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsDialogControlEnabled(hwnd, IDC_DOT_MATCH_ALL)) {
|
||||
bIsFlagSet = ((lpefr->fuFlags & SCFIND_DOT_MATCH_ALL) != 0);
|
||||
if (IsButtonChecked(hwnd, IDC_DOT_MATCH_ALL)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->fuFlags |= SCFIND_DOT_MATCH_ALL;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->fuFlags &= ~SCFIND_DOT_MATCH_ALL;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
}
|
||||
bIsFlagSet = lpefr->bOverlappingFind;
|
||||
if (IsButtonChecked(hwnd, IDC_FIND_OVERLAPPING)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->bOverlappingFind = true;
|
||||
lpefr->bStateChanged = false; // no effect on state
|
||||
}
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->bOverlappingFind = false;
|
||||
lpefr->bStateChanged = false; // no effect on state
|
||||
}
|
||||
}
|
||||
|
||||
// force consistency
|
||||
if (lpefr->bRegExprSearch) {
|
||||
CheckDlgButton(hwnd, IDC_WILDCARDSEARCH, BST_UNCHECKED);
|
||||
bIsFlagSet = lpefr->bNoFindWrap;
|
||||
if (IsButtonChecked(hwnd, IDC_NOWRAP)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->bNoFindWrap = true;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
bIsFlagSet = lpefr->bWildcardSearch;
|
||||
if (IsButtonChecked(hwnd, IDC_WILDCARDSEARCH)) {
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->bNoFindWrap = false;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
bIsFlagSet = lpefr->bMarkOccurences;
|
||||
if (IsButtonChecked(hwnd, IDC_ALL_OCCURRENCES)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->bMarkOccurences = true;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->bMarkOccurences = false;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsDialogControlEnabled(hwnd, IDC_FINDTRANSFORMBS)) {
|
||||
bIsFlagSet = lpefr->bTransformBS;
|
||||
if (IsButtonChecked(hwnd, IDC_FINDTRANSFORMBS)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->bWildcardSearch = true;
|
||||
lpefr->fuFlags |= SCFIND_REGEXP; // Wildcard search based on RegExpr
|
||||
lpefr->bTransformBS = true;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->bWildcardSearch = false;
|
||||
if (!(lpefr->bRegExprSearch)) {
|
||||
lpefr->fuFlags &= ~SCFIND_REGEXP;
|
||||
}
|
||||
lpefr->bTransformBS = false;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bIsFlagSet = lpefr->bOverlappingFind;
|
||||
if (IsButtonChecked(hwnd, IDC_FIND_OVERLAPPING)) {
|
||||
if (bIsFindDlg) {
|
||||
bIsFlagSet = lpefr->bFindClose;
|
||||
if (IsButtonChecked(hwnd, IDC_FINDCLOSE)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->bOverlappingFind = true;
|
||||
lpefr->bStateChanged = false; // no effect on state
|
||||
}
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->bOverlappingFind = false;
|
||||
lpefr->bStateChanged = false; // no effect on state
|
||||
}
|
||||
}
|
||||
|
||||
bIsFlagSet = lpefr->bNoFindWrap;
|
||||
if (IsButtonChecked(hwnd, IDC_NOWRAP)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->bNoFindWrap = true;
|
||||
lpefr->bFindClose = true;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->bNoFindWrap = false;
|
||||
lpefr->bFindClose = false;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
bIsFlagSet = lpefr->bMarkOccurences;
|
||||
if (IsButtonChecked(hwnd, IDC_ALL_OCCURRENCES)) {
|
||||
} else { // replace close
|
||||
bIsFlagSet = lpefr->bReplaceClose;
|
||||
if (IsButtonChecked(hwnd, IDC_FINDCLOSE)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->bMarkOccurences = true;
|
||||
lpefr->bReplaceClose = true;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->bMarkOccurences = false;
|
||||
lpefr->bReplaceClose = false;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (IsDialogControlEnabled(hwnd, IDC_FINDTRANSFORMBS)) {
|
||||
bIsFlagSet = lpefr->bTransformBS;
|
||||
if (IsButtonChecked(hwnd, IDC_FINDTRANSFORMBS)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->bTransformBS = true;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->bTransformBS = false;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bIsFindDlg) {
|
||||
bIsFlagSet = lpefr->bFindClose;
|
||||
if (IsButtonChecked(hwnd, IDC_FINDCLOSE)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->bFindClose = true;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->bFindClose = false;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
}
|
||||
} else { // replace close
|
||||
bIsFlagSet = lpefr->bReplaceClose;
|
||||
if (IsButtonChecked(hwnd, IDC_FINDCLOSE)) {
|
||||
if (!bIsFlagSet) {
|
||||
lpefr->bReplaceClose = true;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
} else {
|
||||
if (bIsFlagSet) {
|
||||
lpefr->bReplaceClose = false;
|
||||
lpefr->bStateChanged = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // if hwnd
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5895,6 +5893,29 @@ static void _ShowZeroLengthCallTip(DocPos iPosition)
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// _EnableFRDlgCtrls()
|
||||
//
|
||||
static bool _EnableFRDlgCtrls(HWND hwnd) {
|
||||
|
||||
//bool const bEmptyFnd = (ComboBox_GetTextLengthEx(hwnd, IDC_FINDTEXT) == 0 || ComboBox_GetCurSelEx(hwnd, IDC_FINDTEXT) != CB_ERR);
|
||||
//bool const bEmptyRpl = (ComboBox_GetTextLengthEx(hwnd, IDC_REPLACETEXT) == 0 || ComboBox_GetCurSelEx(hwnd, IDC_REPLACETEXT) != CB_ERR);
|
||||
bool const bEmptyFnd = ComboBox_GetTextLengthEx(hwnd, IDC_FINDTEXT) == 0;
|
||||
bool const bEmptyRpl = ComboBox_GetTextLengthEx(hwnd, IDC_REPLACETEXT) == 0;
|
||||
bool const bEmptySel = !(SciCall_IsSelectionEmpty() || Sci_IsMultiOrRectangleSelection());
|
||||
|
||||
DialogEnableControl(hwnd, IDOK, !bEmptyFnd);
|
||||
DialogEnableControl(hwnd, IDC_FINDPREV, !bEmptyFnd);
|
||||
DialogEnableControl(hwnd, IDC_REPLACE, !bEmptyFnd);
|
||||
DialogEnableControl(hwnd, IDC_REPLACEALL, !bEmptyFnd);
|
||||
DialogEnableControl(hwnd, IDC_REPLACEINSEL, !bEmptyFnd && !bEmptySel);
|
||||
DialogEnableControl(hwnd, IDC_SWAPSTRG, !bEmptyFnd || !bEmptyRpl);
|
||||
|
||||
return !bEmptyFnd;
|
||||
}
|
||||
|
||||
|
||||
//=============================================================================
|
||||
//
|
||||
// EditFindReplaceDlgProc()
|
||||
@ -6339,79 +6360,88 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
|
||||
case IDC_FINDTEXT:
|
||||
case IDC_REPLACETEXT: {
|
||||
|
||||
bool bPatternChanged = false;
|
||||
bool bFndPatternChanged = s_pEfrDataDlg->bStateChanged;
|
||||
|
||||
switch (HIWORD(wParam)) {
|
||||
|
||||
case CBN_CLOSEUP: {
|
||||
LONG lSelEnd = 0;
|
||||
SendDlgItemMessage(hwnd, LOWORD(wParam), CB_GETEDITSEL, 0, (LPARAM)&lSelEnd);
|
||||
SendDlgItemMessage(hwnd, LOWORD(wParam), CB_SETEDITSEL, 0, MAKELPARAM(lSelEnd, lSelEnd));
|
||||
}
|
||||
break;
|
||||
|
||||
case CBN_EDITUPDATE:
|
||||
if (SendDlgItemMessage(hwnd, LOWORD(wParam), CB_GETDROPPEDSTATE, 0, 0)) {
|
||||
//~SendDlgItemMessage(hwnd, LOWORD(wParam), CB_SETCURSEL, (WPARAM)-1, 0); // clear
|
||||
SendDlgItemMessage(hwnd, LOWORD(wParam), CB_SHOWDROPDOWN, 0, 0); // hide
|
||||
}
|
||||
break;
|
||||
|
||||
case CBN_SELCHANGE: {
|
||||
LRESULT const cursel = SendDlgItemMessage(hwnd, LOWORD(wParam), CB_GETCURSEL, 0, 0);
|
||||
if (cursel != CB_ERR) {
|
||||
SendDlgItemMessage(hwnd, LOWORD(wParam), CB_SETCURSEL, (WPARAM)cursel, 0);
|
||||
}
|
||||
}
|
||||
// [fallthrough]
|
||||
case CBN_SELENDOK:
|
||||
case CBN_EDITCHANGE:
|
||||
bFndPatternChanged = (LOWORD(wParam) == IDC_FINDTEXT);
|
||||
LPSTR const buffer = bFndPatternChanged ? s_pEfrDataDlg->szFind : s_pEfrDataDlg->szReplace;
|
||||
ComboBox_GetTextW2MB(hwnd, LOWORD(wParam), buffer, FNDRPL_BUFFER);
|
||||
if (bFndPatternChanged) {
|
||||
SetFindPatternMB(s_pEfrDataDlg->szFind);
|
||||
}
|
||||
break;
|
||||
|
||||
case CBN_KILLFOCUS:
|
||||
case CBN_SELENDCANCEL:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (Globals.bFindReplCopySelOrClip) {
|
||||
char* lpszSelection = NULL;
|
||||
char *lpszSelection = NULL;
|
||||
DocPos const cchSelection = SciCall_GetSelText(NULL);
|
||||
if ((cchSelection > 1) && (LOWORD(wParam) != IDC_REPLACETEXT)) {
|
||||
lpszSelection = AllocMem(cchSelection + 1, HEAP_ZERO_MEMORY);
|
||||
SciCall_GetSelText(lpszSelection);
|
||||
} else { // (cchSelection <= 1)
|
||||
// nothing is selected in the editor:
|
||||
// if first time you bring up find/replace dialog,
|
||||
// use most recent search pattern to find box
|
||||
lpszSelection = AllocMem(FNDRPL_BUFFER, HEAP_ZERO_MEMORY);
|
||||
if (lpszSelection) {
|
||||
// if first time you bring up find/replace dialog,
|
||||
// use most recent search pattern to find box
|
||||
// in case of no history: paste clipboard
|
||||
_EditGetFindStrg(Globals.hwndEdit, s_pEfrDataDlg, lpszSelection, SizeOfMem(lpszSelection));
|
||||
}
|
||||
}
|
||||
|
||||
if (lpszSelection) {
|
||||
ComboBox_SetTextMB2W(hwnd, IDC_FINDTEXT, lpszSelection);
|
||||
FreeMem(lpszSelection);
|
||||
lpszSelection = NULL;
|
||||
bPatternChanged = true;
|
||||
bFndPatternChanged = true;
|
||||
}
|
||||
s_InitialTopLine = -1; // reset
|
||||
s_InitialTopLine = -1; // reset
|
||||
s_anyMatch = NO_MATCH;
|
||||
Globals.bFindReplCopySelOrClip = false;
|
||||
|
||||
} // Globals.bFindReplCopySelOrClip
|
||||
|
||||
switch (HIWORD(wParam)) {
|
||||
case CBN_CLOSEUP:
|
||||
case CBN_EDITCHANGE:
|
||||
bPatternChanged = (LOWORD(wParam) == IDC_FINDTEXT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
// ------------------------
|
||||
if (!bFndPatternChanged) {
|
||||
break; // return
|
||||
}
|
||||
// ------------------------
|
||||
|
||||
if (!bPatternChanged) {
|
||||
break;
|
||||
}
|
||||
|
||||
bool const bEmptyFnd = (ComboBox_GetTextLenth(hwnd, IDC_FINDTEXT) ||
|
||||
CB_ERR != SendDlgItemMessage(hwnd, IDC_FINDTEXT, CB_GETCURSEL, 0, 0));
|
||||
|
||||
bool const bEmptyRpl = (ComboBox_GetTextLenth(hwnd, IDC_REPLACETEXT) ||
|
||||
CB_ERR != SendDlgItemMessage(hwnd, IDC_REPLACETEXT, CB_GETCURSEL, 0, 0));
|
||||
|
||||
bool const bEmptySel = !(SciCall_IsSelectionEmpty() || Sci_IsMultiOrRectangleSelection());
|
||||
|
||||
DialogEnableControl(hwnd, IDOK, bEmptyFnd);
|
||||
DialogEnableControl(hwnd, IDC_FINDPREV, bEmptyFnd);
|
||||
DialogEnableControl(hwnd, IDC_REPLACE, bEmptyFnd);
|
||||
DialogEnableControl(hwnd, IDC_REPLACEALL, bEmptyFnd);
|
||||
DialogEnableControl(hwnd, IDC_REPLACEINSEL, bEmptyFnd && bEmptySel);
|
||||
DialogEnableControl(hwnd, IDC_SWAPSTRG, bEmptyFnd || bEmptyRpl);
|
||||
|
||||
if (!bEmptyFnd) {
|
||||
if (_EnableFRDlgCtrls(hwnd)) {
|
||||
s_anyMatch = NO_MATCH;
|
||||
EditSetSelectionEx(s_InitialAnchorPos, s_InitialCaretPos, -1, -1);
|
||||
}
|
||||
|
||||
if (HIWORD(wParam) == CBN_CLOSEUP) {
|
||||
LONG lSelEnd = 0;
|
||||
SendDlgItemMessage(hwnd, LOWORD(wParam), CB_GETEDITSEL, 0, (LPARAM)&lSelEnd);
|
||||
SendDlgItemMessage(hwnd, LOWORD(wParam), CB_SETEDITSEL, 0, MAKELPARAM(lSelEnd, lSelEnd));
|
||||
}
|
||||
|
||||
_SetSearchFlags(hwnd, s_pEfrDataDlg);
|
||||
|
||||
if (StrIsEmptyA(s_pEfrDataDlg->szFind)) {
|
||||
SetFindPattern(L"");
|
||||
}
|
||||
SetFindPatternMB(s_pEfrDataDlg->szFind);
|
||||
|
||||
DocPos start = s_InitialSearchStart;
|
||||
DocPos end = Sci_GetDocEndPosition();
|
||||
@ -6581,16 +6611,7 @@ static INT_PTR CALLBACK EditFindReplaceDlgProc(HWND hwnd, UINT umsg, WPARAM wPar
|
||||
CopyMemory(&s_efrSave, s_pEfrDataDlg, sizeof(EDITFINDREPLACE));
|
||||
}
|
||||
|
||||
if (!s_bSwitchedFindReplace &&
|
||||
!ComboBox_GetTextW2MB(hwnd, IDC_FINDTEXT, s_pEfrDataDlg->szFind, COUNTOF(s_pEfrDataDlg->szFind))) {
|
||||
DialogEnableControl(hwnd, IDOK, false);
|
||||
DialogEnableControl(hwnd, IDC_FINDPREV, false);
|
||||
DialogEnableControl(hwnd, IDC_REPLACE, false);
|
||||
DialogEnableControl(hwnd, IDC_REPLACEALL, false);
|
||||
DialogEnableControl(hwnd, IDC_REPLACEINSEL, false);
|
||||
if (!ComboBox_GetTextW2MB(hwnd, IDC_REPLACETEXT, s_pEfrDataDlg->szReplace, COUNTOF(s_pEfrDataDlg->szReplace))) {
|
||||
DialogEnableControl(hwnd, IDC_SWAPSTRG, false);
|
||||
}
|
||||
if (!s_bSwitchedFindReplace && !_EnableFRDlgCtrls(hwnd)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -1159,7 +1159,7 @@ void SetFindPattern(LPCWSTR wchFindPattern)
|
||||
//
|
||||
void SetFindPatternMB(LPCSTR chFindPattern)
|
||||
{
|
||||
MultiByteToWideCharEx(Encoding_SciCP, 0, chFindPattern, -1, sCurrentFindPattern, COUNTOF(sCurrentFindPattern));
|
||||
MultiByteToWideChar(Encoding_SciCP, 0, chFindPattern, -1, sCurrentFindPattern, (int)COUNTOF(sCurrentFindPattern));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user