Enhance combobox & edit field in dark mode
1. Allow function list search to use dark mode error background. 2. Make combobox more dark and allow to use custom colors (borders, arrow head and background). 3. Use dark listbox in combobox. Fix #10178, close #10179pull/10199/head
parent
aa69711d4c
commit
81b21aae2a
|
@ -1,4 +1,4 @@
|
||||||
#include "nppDarkMode.h"
|
#include "nppDarkMode.h"
|
||||||
|
|
||||||
#include "DarkMode/DarkMode.h"
|
#include "DarkMode/DarkMode.h"
|
||||||
#include "DarkMode/UAHMenuBar.h"
|
#include "DarkMode/UAHMenuBar.h"
|
||||||
|
@ -45,7 +45,7 @@ namespace NppDarkMode
|
||||||
::DeleteObject(background);
|
::DeleteObject(background);
|
||||||
::DeleteObject(softerBackground);
|
::DeleteObject(softerBackground);
|
||||||
::DeleteObject(hotBackground);
|
::DeleteObject(hotBackground);
|
||||||
::DeleteObject(pureBackground);
|
::DeleteObject(pureBackground);
|
||||||
::DeleteObject(errorBackground);
|
::DeleteObject(errorBackground);
|
||||||
|
|
||||||
background = ::CreateSolidBrush(colors.background);
|
background = ::CreateSolidBrush(colors.background);
|
||||||
|
@ -103,7 +103,7 @@ namespace NppDarkMode
|
||||||
HEXRGB(0x808080), // disabledTextColor
|
HEXRGB(0x808080), // disabledTextColor
|
||||||
HEXRGB(0x908080) // edgeColor
|
HEXRGB(0x908080) // edgeColor
|
||||||
};
|
};
|
||||||
|
|
||||||
// green tone
|
// green tone
|
||||||
static const Colors darkGreenColors{
|
static const Colors darkGreenColors{
|
||||||
HEXRGB(0x203020), // background
|
HEXRGB(0x203020), // background
|
||||||
|
@ -116,7 +116,6 @@ namespace NppDarkMode
|
||||||
HEXRGB(0x808080), // disabledTextColor
|
HEXRGB(0x808080), // disabledTextColor
|
||||||
HEXRGB(0x809080) // edgeColor
|
HEXRGB(0x809080) // edgeColor
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// blue tone
|
// blue tone
|
||||||
static const Colors darkBlueColors{
|
static const Colors darkBlueColors{
|
||||||
|
@ -130,7 +129,7 @@ namespace NppDarkMode
|
||||||
HEXRGB(0x808080), // disabledTextColor
|
HEXRGB(0x808080), // disabledTextColor
|
||||||
HEXRGB(0x8080A0) // edgeColor
|
HEXRGB(0x8080A0) // edgeColor
|
||||||
};
|
};
|
||||||
|
|
||||||
// purple tone
|
// purple tone
|
||||||
static const Colors darkPurpleColors{
|
static const Colors darkPurpleColors{
|
||||||
HEXRGB(0x302040), // background
|
HEXRGB(0x302040), // background
|
||||||
|
@ -219,7 +218,7 @@ namespace NppDarkMode
|
||||||
Theme tO(darkOliveColors);
|
Theme tO(darkOliveColors);
|
||||||
|
|
||||||
Theme tCustom(darkCustomizedColors);
|
Theme tCustom(darkCustomizedColors);
|
||||||
|
|
||||||
|
|
||||||
Theme& getTheme()
|
Theme& getTheme()
|
||||||
{
|
{
|
||||||
|
@ -373,7 +372,7 @@ namespace NppDarkMode
|
||||||
HPEN getEdgePen() { return getTheme()._pens.edgePen; }
|
HPEN getEdgePen() { return getTheme()._pens.edgePen; }
|
||||||
|
|
||||||
void setBackgroundColor(COLORREF c)
|
void setBackgroundColor(COLORREF c)
|
||||||
{
|
{
|
||||||
Colors clrs = getTheme()._colors;
|
Colors clrs = getTheme()._colors;
|
||||||
clrs.background = c;
|
clrs.background = c;
|
||||||
getTheme().change(clrs);
|
getTheme().change(clrs);
|
||||||
|
@ -792,14 +791,14 @@ namespace NppDarkMode
|
||||||
|
|
||||||
if (nState & BST_CHECKED) iStateID += 4;
|
if (nState & BST_CHECKED) iStateID += 4;
|
||||||
|
|
||||||
if (BufferedPaintRenderAnimation(hwnd, hdc))
|
if (BufferedPaintRenderAnimation(hwnd, hdc))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
BP_ANIMATIONPARAMS animParams = { sizeof(animParams) };
|
BP_ANIMATIONPARAMS animParams = { sizeof(animParams) };
|
||||||
animParams.style = BPAS_LINEAR;
|
animParams.style = BPAS_LINEAR;
|
||||||
if (iStateID != buttonData.iStateID)
|
if (iStateID != buttonData.iStateID)
|
||||||
{
|
{
|
||||||
GetThemeTransitionDuration(buttonData.hTheme, iPartID, buttonData.iStateID, iStateID, TMT_TRANSITIONDURATIONS, &animParams.dwDuration);
|
GetThemeTransitionDuration(buttonData.hTheme, iPartID, buttonData.iStateID, iStateID, TMT_TRANSITIONDURATIONS, &animParams.dwDuration);
|
||||||
}
|
}
|
||||||
|
@ -1144,7 +1143,7 @@ namespace NppDarkMode
|
||||||
ScreenToClient(hWnd, &ptCursor);
|
ScreenToClient(hWnd, &ptCursor);
|
||||||
|
|
||||||
int nTabs = TabCtrl_GetItemCount(hWnd);
|
int nTabs = TabCtrl_GetItemCount(hWnd);
|
||||||
|
|
||||||
int nSelTab = TabCtrl_GetCurSel(hWnd);
|
int nSelTab = TabCtrl_GetCurSel(hWnd);
|
||||||
for (int i = 0; i < nTabs; ++i)
|
for (int i = 0; i < nTabs; ++i)
|
||||||
{
|
{
|
||||||
|
@ -1223,6 +1222,109 @@ namespace NppDarkMode
|
||||||
SetWindowSubclass(hwnd, TabSubclass, g_tabSubclassID, 0);
|
SetWindowSubclass(hwnd, TabSubclass, g_tabSubclassID, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
constexpr UINT_PTR g_comboBoxSubclassID = 42;
|
||||||
|
|
||||||
|
LRESULT CALLBACK ComboBoxSubclass(
|
||||||
|
HWND hWnd,
|
||||||
|
UINT uMsg,
|
||||||
|
WPARAM wParam,
|
||||||
|
LPARAM lParam,
|
||||||
|
UINT_PTR uIdSubclass,
|
||||||
|
DWORD_PTR /*dwRefData*/
|
||||||
|
)
|
||||||
|
{
|
||||||
|
switch (uMsg)
|
||||||
|
{
|
||||||
|
case WM_PAINT:
|
||||||
|
{
|
||||||
|
if (!NppDarkMode::isEnabled())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
RECT rc = { 0 };
|
||||||
|
::GetClientRect(hWnd, &rc);
|
||||||
|
|
||||||
|
PAINTSTRUCT ps;
|
||||||
|
auto hdc = ::BeginPaint(hWnd, &ps);
|
||||||
|
|
||||||
|
auto holdPen = static_cast<HPEN>(::SelectObject(hdc, NppDarkMode::getEdgePen()));
|
||||||
|
::SelectObject(hdc, reinterpret_cast<HFONT>(::SendMessage(hWnd, WM_GETFONT, 0, 0)));
|
||||||
|
::SetBkColor(hdc, NppDarkMode::getBackgroundColor());
|
||||||
|
|
||||||
|
::SelectObject(hdc, ::GetStockObject(NULL_BRUSH)); // to avoid text flicker, use only border
|
||||||
|
::Rectangle(hdc, 0, 0, rc.right, rc.bottom);
|
||||||
|
|
||||||
|
auto holdBrush = ::SelectObject(hdc, NppDarkMode::getBackgroundBrush());
|
||||||
|
|
||||||
|
// CBS_DROPDOWN text is handled by parent by WM_CTLCOLOREDIT
|
||||||
|
auto style = ::GetWindowLongPtr(hWnd, GWL_STYLE);
|
||||||
|
if ((style & CBS_DROPDOWNLIST) == CBS_DROPDOWNLIST)
|
||||||
|
{
|
||||||
|
auto index = static_cast<int>(::SendMessage(hWnd, CB_GETCURSEL, 0, 0));
|
||||||
|
if (index != CB_ERR)
|
||||||
|
{
|
||||||
|
::SetTextColor(hdc, NppDarkMode::getTextColor());
|
||||||
|
auto bufferLen = static_cast<size_t>(::SendMessage(hWnd, CB_GETLBTEXTLEN, index, 0));
|
||||||
|
TCHAR* buffer = new TCHAR[(bufferLen + 1)];
|
||||||
|
::SendMessage(hWnd, CB_GETLBTEXT, index, reinterpret_cast<LPARAM>(buffer));
|
||||||
|
RECT textRc = rc;
|
||||||
|
textRc.left += NppParameters::getInstance()._dpiManager.scaleX(4);
|
||||||
|
textRc.right -= NppParameters::getInstance()._dpiManager.scaleX(23);
|
||||||
|
::DrawText(hdc, buffer, -1, &textRc, DT_EDITCONTROL | DT_NOPREFIX | DT_LEFT | DT_VCENTER | DT_SINGLELINE);
|
||||||
|
delete[]buffer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RECT arrowRc = {
|
||||||
|
rc.right - NppParameters::getInstance()._dpiManager.scaleX(17), rc.top + 1,
|
||||||
|
rc.right - 1, rc.bottom - 1
|
||||||
|
};
|
||||||
|
|
||||||
|
POINT ptCursor = { 0 };
|
||||||
|
::GetCursorPos(&ptCursor);
|
||||||
|
ScreenToClient(hWnd, &ptCursor);
|
||||||
|
|
||||||
|
bool isHot = PtInRect(&rc, ptCursor);
|
||||||
|
|
||||||
|
::SetTextColor(hdc, isHot ? NppDarkMode::getTextColor() : NppDarkMode::getDarkerTextColor());
|
||||||
|
::SetBkColor(hdc, isHot ? NppDarkMode::getHotBackgroundColor() : NppDarkMode::getBackgroundColor());
|
||||||
|
::ExtTextOut(hdc,
|
||||||
|
rc.right - NppParameters::getInstance()._dpiManager.scaleX(13),
|
||||||
|
rc.top + 4,
|
||||||
|
ETO_OPAQUE | ETO_CLIPPED,
|
||||||
|
&arrowRc, L"˅",
|
||||||
|
1,
|
||||||
|
nullptr);
|
||||||
|
::SetBkColor(hdc, NppDarkMode::getBackgroundColor());
|
||||||
|
|
||||||
|
POINT edge[] = {
|
||||||
|
{rc.right - NppParameters::getInstance()._dpiManager.scaleX(18), rc.top + 1},
|
||||||
|
{rc.right - NppParameters::getInstance()._dpiManager.scaleX(18), rc.bottom - 1}
|
||||||
|
};
|
||||||
|
::Polyline(hdc, edge, _countof(edge));
|
||||||
|
|
||||||
|
::SelectObject(hdc, holdPen);
|
||||||
|
::SelectObject(hdc, holdBrush);
|
||||||
|
|
||||||
|
::EndPaint(hWnd, &ps);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
case WM_NCDESTROY:
|
||||||
|
{
|
||||||
|
::RemoveWindowSubclass(hWnd, ComboBoxSubclass, uIdSubclass);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return DefSubclassProc(hWnd, uMsg, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
void subclassComboBoxControl(HWND hwnd)
|
||||||
|
{
|
||||||
|
SetWindowSubclass(hwnd, ComboBoxSubclass, g_comboBoxSubclassID, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void autoSubclassAndThemeChildControls(HWND hwndParent, bool subclass, bool theme)
|
void autoSubclassAndThemeChildControls(HWND hwndParent, bool subclass, bool theme)
|
||||||
{
|
{
|
||||||
struct Params
|
struct Params
|
||||||
|
@ -1232,45 +1334,58 @@ namespace NppDarkMode
|
||||||
bool theme = false;
|
bool theme = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
Params p{
|
Params p{
|
||||||
NppDarkMode::isEnabled() ? L"DarkMode_Explorer" : L"Button"
|
NppDarkMode::isEnabled() ? L"DarkMode_Explorer" : nullptr
|
||||||
, subclass
|
, subclass
|
||||||
, theme
|
, theme
|
||||||
};
|
};
|
||||||
|
|
||||||
EnumChildWindows(hwndParent, [](HWND hwnd, LPARAM lParam) {
|
EnumChildWindows(hwndParent, [](HWND hwnd, LPARAM lParam) {
|
||||||
auto& p = *reinterpret_cast<Params*>(lParam);
|
auto& p = *reinterpret_cast<Params*>(lParam);
|
||||||
wchar_t className[16] = { 0 };
|
const size_t classNameLen = 16;
|
||||||
GetClassName(hwnd, className, 9);
|
TCHAR className[classNameLen] = { 0 };
|
||||||
if (wcscmp(className, L"Button"))
|
GetClassName(hwnd, className, classNameLen);
|
||||||
|
|
||||||
|
if (wcscmp(className, WC_COMBOBOX) == 0)
|
||||||
{
|
{
|
||||||
|
auto style = ::GetWindowLongPtr(hwnd, GWL_STYLE);
|
||||||
|
|
||||||
|
if ((style & CBS_DROPDOWNLIST) == CBS_DROPDOWNLIST || (style & CBS_DROPDOWN) == CBS_DROPDOWN)
|
||||||
|
{
|
||||||
|
NppDarkMode::subclassComboBoxControl(hwnd);
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
DWORD nButtonStyle = (DWORD)GetWindowLong(hwnd, GWL_STYLE) & 0xF;
|
|
||||||
switch (nButtonStyle)
|
if (wcscmp(className, WC_BUTTON) == 0)
|
||||||
{
|
{
|
||||||
case BS_CHECKBOX:
|
auto nButtonStyle = ::GetWindowLongPtr(hwnd, GWL_STYLE) & 0xF;
|
||||||
case BS_AUTOCHECKBOX:
|
switch (nButtonStyle)
|
||||||
case BS_RADIOBUTTON:
|
|
||||||
case BS_AUTORADIOBUTTON:
|
|
||||||
if (p.subclass)
|
|
||||||
{
|
{
|
||||||
NppDarkMode::subclassButtonControl(hwnd);
|
case BS_CHECKBOX:
|
||||||
|
case BS_AUTOCHECKBOX:
|
||||||
|
case BS_RADIOBUTTON:
|
||||||
|
case BS_AUTORADIOBUTTON:
|
||||||
|
if (p.subclass)
|
||||||
|
{
|
||||||
|
NppDarkMode::subclassButtonControl(hwnd);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BS_GROUPBOX:
|
||||||
|
if (p.subclass)
|
||||||
|
{
|
||||||
|
NppDarkMode::subclassGroupboxControl(hwnd);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BS_DEFPUSHBUTTON:
|
||||||
|
case BS_PUSHBUTTON:
|
||||||
|
if (p.theme)
|
||||||
|
{
|
||||||
|
SetWindowTheme(hwnd, p.themeClassName, nullptr);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
return TRUE;
|
||||||
case BS_GROUPBOX:
|
|
||||||
if (p.subclass)
|
|
||||||
{
|
|
||||||
NppDarkMode::subclassGroupboxControl(hwnd);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case BS_DEFPUSHBUTTON:
|
|
||||||
case BS_PUSHBUTTON:
|
|
||||||
if (p.theme)
|
|
||||||
{
|
|
||||||
SetWindowTheme(hwnd, p.themeClassName, nullptr);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}, reinterpret_cast<LPARAM>(&p));
|
}, reinterpret_cast<LPARAM>(&p));
|
||||||
|
@ -1278,7 +1393,7 @@ namespace NppDarkMode
|
||||||
|
|
||||||
void autoThemeChildControls(HWND hwndParent)
|
void autoThemeChildControls(HWND hwndParent)
|
||||||
{
|
{
|
||||||
autoSubclassAndThemeChildControls(hwndParent, false, true);
|
autoSubclassAndThemeChildControls(hwndParent, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDarkTitleBar(HWND hwnd)
|
void setDarkTitleBar(HWND hwnd)
|
||||||
|
@ -1381,4 +1496,25 @@ namespace NppDarkMode
|
||||||
{
|
{
|
||||||
SetWindowTheme(hwnd, nullptr, nullptr);
|
SetWindowTheme(hwnd, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LRESULT onCtlColor(HDC hdc)
|
||||||
|
{
|
||||||
|
::SetTextColor(hdc, NppDarkMode::getTextColor());
|
||||||
|
::SetBkColor(hdc, NppDarkMode::getBackgroundColor());
|
||||||
|
return reinterpret_cast<LRESULT>(NppDarkMode::getBackgroundBrush());
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT onCtlColorSofter(HDC hdc)
|
||||||
|
{
|
||||||
|
::SetTextColor(hdc, NppDarkMode::getTextColor());
|
||||||
|
::SetBkColor(hdc, NppDarkMode::getSofterBackgroundColor());
|
||||||
|
return reinterpret_cast<LRESULT>(NppDarkMode::getSofterBackgroundBrush());
|
||||||
|
}
|
||||||
|
|
||||||
|
LRESULT onCtlColorError(HDC hdc)
|
||||||
|
{
|
||||||
|
::SetTextColor(hdc, NppDarkMode::getTextColor());
|
||||||
|
::SetBkColor(hdc, NppDarkMode::getErrorBackgroundColor());
|
||||||
|
return reinterpret_cast<LRESULT>(NppDarkMode::getErrorBackgroundBrush());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace NppDarkMode
|
||||||
bool enable = false;
|
bool enable = false;
|
||||||
bool enableMenubar = false;
|
bool enableMenubar = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class ToolTipsType
|
enum class ToolTipsType
|
||||||
{
|
{
|
||||||
tooltip,
|
tooltip,
|
||||||
|
@ -118,6 +118,7 @@ namespace NppDarkMode
|
||||||
void subclassGroupboxControl(HWND hwnd);
|
void subclassGroupboxControl(HWND hwnd);
|
||||||
void subclassToolbarControl(HWND hwnd);
|
void subclassToolbarControl(HWND hwnd);
|
||||||
void subclassTabControl(HWND hwnd);
|
void subclassTabControl(HWND hwnd);
|
||||||
|
void subclassComboBoxControl(HWND hwnd);
|
||||||
|
|
||||||
void autoSubclassAndThemeChildControls(HWND hwndParent, bool subclass = true, bool theme = true);
|
void autoSubclassAndThemeChildControls(HWND hwndParent, bool subclass = true, bool theme = true);
|
||||||
void autoThemeChildControls(HWND hwndParent);
|
void autoThemeChildControls(HWND hwndParent);
|
||||||
|
@ -131,4 +132,8 @@ namespace NppDarkMode
|
||||||
|
|
||||||
void disableVisualStyle(HWND hwnd, bool doDisable);
|
void disableVisualStyle(HWND hwnd, bool doDisable);
|
||||||
void setTreeViewStyle(HWND hwnd);
|
void setTreeViewStyle(HWND hwnd);
|
||||||
|
|
||||||
|
LRESULT onCtlColor(HDC hdc);
|
||||||
|
LRESULT onCtlColorSofter(HDC hdc);
|
||||||
|
LRESULT onCtlColorError(HDC hdc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ void delLeftWordInEdit(HWND hEdit)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int length)
|
int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int length)
|
||||||
{ //query may equal to result, since it always gets smaller
|
{ //query may equal to result, since it always gets smaller
|
||||||
int i = 0, j = 0;
|
int i = 0, j = 0;
|
||||||
int charLeft = length;
|
int charLeft = length;
|
||||||
|
@ -111,7 +111,7 @@ int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int
|
||||||
case 'd':
|
case 'd':
|
||||||
case 'o':
|
case 'o':
|
||||||
case 'x':
|
case 'x':
|
||||||
case 'u':
|
case 'u':
|
||||||
{
|
{
|
||||||
int size = 0, base = 0;
|
int size = 0, base = 0;
|
||||||
if (current == 'b')
|
if (current == 'b')
|
||||||
|
@ -134,8 +134,8 @@ int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int
|
||||||
{ //0xCDCD
|
{ //0xCDCD
|
||||||
size = 4, base = 16;
|
size = 4, base = 16;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (charLeft >= size)
|
if (charLeft >= size)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
if (Searching::readBase(query+(i+1), &res, base, size))
|
if (Searching::readBase(query+(i+1), &res, base, size))
|
||||||
|
@ -147,8 +147,8 @@ int Searching::convertExtendedToString(const TCHAR * query, TCHAR * result, int
|
||||||
}
|
}
|
||||||
//not enough chars to make parameter, use default method as fallback
|
//not enough chars to make parameter, use default method as fallback
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{ //unknown sequence, treat as regular text
|
{ //unknown sequence, treat as regular text
|
||||||
result[j] = '\\';
|
result[j] = '\\';
|
||||||
++j;
|
++j;
|
||||||
|
@ -177,7 +177,7 @@ bool Searching::readBase(const TCHAR * str, int * value, int base, int size)
|
||||||
while (i < size)
|
while (i < size)
|
||||||
{
|
{
|
||||||
current = str[i];
|
current = str[i];
|
||||||
if (current >= 'A')
|
if (current >= 'A')
|
||||||
{
|
{
|
||||||
current &= 0xdf;
|
current &= 0xdf;
|
||||||
current -= ('A' - '0' - 10);
|
current -= ('A' - '0' - 10);
|
||||||
|
@ -200,7 +200,7 @@ bool Searching::readBase(const TCHAR * str, int * value, int base, int size)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Searching::displaySectionCentered(int posStart, int posEnd, ScintillaEditView * pEditView, bool isDownwards)
|
void Searching::displaySectionCentered(int posStart, int posEnd, ScintillaEditView * pEditView, bool isDownwards)
|
||||||
{
|
{
|
||||||
// Make sure target lines are unfolded
|
// Make sure target lines are unfolded
|
||||||
pEditView->execute(SCI_ENSUREVISIBLE, pEditView->execute(SCI_LINEFROMPOSITION, posStart));
|
pEditView->execute(SCI_ENSUREVISIBLE, pEditView->execute(SCI_LINEFROMPOSITION, posStart));
|
||||||
|
@ -264,7 +264,7 @@ void FindReplaceDlg::create(int dialogID, bool isRTL, bool msgDestParent)
|
||||||
fillFindHistory();
|
fillFindHistory();
|
||||||
_currentStatus = REPLACE_DLG;
|
_currentStatus = REPLACE_DLG;
|
||||||
initOptionsFromDlg();
|
initOptionsFromDlg();
|
||||||
|
|
||||||
_statusBar.init(GetModuleHandle(NULL), _hSelf, 0);
|
_statusBar.init(GetModuleHandle(NULL), _hSelf, 0);
|
||||||
_statusBar.display();
|
_statusBar.display();
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ void FindReplaceDlg::create(int dialogID, bool isRTL, bool msgDestParent)
|
||||||
NppDarkMode::subclassTabControl(_tab.getHSelf());
|
NppDarkMode::subclassTabControl(_tab.getHSelf());
|
||||||
int tabDpiDynamicalHeight = NppParameters::getInstance()._dpiManager.scaleY(13);
|
int tabDpiDynamicalHeight = NppParameters::getInstance()._dpiManager.scaleY(13);
|
||||||
_tab.setFont(TEXT("Tahoma"), tabDpiDynamicalHeight);
|
_tab.setFont(TEXT("Tahoma"), tabDpiDynamicalHeight);
|
||||||
|
|
||||||
const TCHAR *find = TEXT("Find");
|
const TCHAR *find = TEXT("Find");
|
||||||
const TCHAR *replace = TEXT("Replace");
|
const TCHAR *replace = TEXT("Replace");
|
||||||
const TCHAR *findInFiles = TEXT("Find in Files");
|
const TCHAR *findInFiles = TEXT("Find in Files");
|
||||||
|
@ -292,13 +292,13 @@ void FindReplaceDlg::create(int dialogID, bool isRTL, bool msgDestParent)
|
||||||
_tab.display();
|
_tab.display();
|
||||||
|
|
||||||
_initialClientWidth = rect.right - rect.left;
|
_initialClientWidth = rect.right - rect.left;
|
||||||
|
|
||||||
//fill min dialog size info
|
//fill min dialog size info
|
||||||
this->getWindowRect(_initialWindowRect);
|
this->getWindowRect(_initialWindowRect);
|
||||||
_initialWindowRect.right = _initialWindowRect.right - _initialWindowRect.left;
|
_initialWindowRect.right = _initialWindowRect.right - _initialWindowRect.left;
|
||||||
_initialWindowRect.left = 0;
|
_initialWindowRect.left = 0;
|
||||||
_initialWindowRect.bottom = _initialWindowRect.bottom - _initialWindowRect.top;
|
_initialWindowRect.bottom = _initialWindowRect.bottom - _initialWindowRect.top;
|
||||||
_initialWindowRect.top = 0;
|
_initialWindowRect.top = 0;
|
||||||
|
|
||||||
ETDTProc enableDlgTheme = (ETDTProc)::SendMessage(_hParent, NPPM_GETENABLETHEMETEXTUREFUNC, 0, 0);
|
ETDTProc enableDlgTheme = (ETDTProc)::SendMessage(_hParent, NPPM_GETENABLETHEMETEXTUREFUNC, 0, 0);
|
||||||
if (enableDlgTheme)
|
if (enableDlgTheme)
|
||||||
|
@ -325,7 +325,7 @@ void FindReplaceDlg::fillFindHistory()
|
||||||
fillComboHistory(IDFINDWHAT, findHistory._findHistoryFinds);
|
fillComboHistory(IDFINDWHAT, findHistory._findHistoryFinds);
|
||||||
fillComboHistory(IDREPLACEWITH, findHistory._findHistoryReplaces);
|
fillComboHistory(IDREPLACEWITH, findHistory._findHistoryReplaces);
|
||||||
fillComboHistory(IDD_FINDINFILES_FILTERS_COMBO, findHistory._findHistoryFilters);
|
fillComboHistory(IDD_FINDINFILES_FILTERS_COMBO, findHistory._findHistoryFilters);
|
||||||
fillComboHistory(IDD_FINDINFILES_DIR_COMBO, findHistory._findHistoryPaths);
|
fillComboHistory(IDD_FINDINFILES_DIR_COMBO, findHistory._findHistoryPaths);
|
||||||
|
|
||||||
::SendDlgItemMessage(_hSelf, IDWRAP, BM_SETCHECK, findHistory._isWrap, 0);
|
::SendDlgItemMessage(_hSelf, IDWRAP, BM_SETCHECK, findHistory._isWrap, 0);
|
||||||
::SendDlgItemMessage(_hSelf, IDWHOLEWORD, BM_SETCHECK, findHistory._isMatchWord, 0);
|
::SendDlgItemMessage(_hSelf, IDWHOLEWORD, BM_SETCHECK, findHistory._isMatchWord, 0);
|
||||||
|
@ -334,7 +334,7 @@ void FindReplaceDlg::fillFindHistory()
|
||||||
|
|
||||||
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_INHIDDENDIR_CHECK, BM_SETCHECK, findHistory._isFifInHiddenFolder, 0);
|
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_INHIDDENDIR_CHECK, BM_SETCHECK, findHistory._isFifInHiddenFolder, 0);
|
||||||
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_RECURSIVE_CHECK, BM_SETCHECK, findHistory._isFifRecuisive, 0);
|
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_RECURSIVE_CHECK, BM_SETCHECK, findHistory._isFifRecuisive, 0);
|
||||||
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK, BM_SETCHECK, findHistory._isFolderFollowDoc, 0);
|
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK, BM_SETCHECK, findHistory._isFolderFollowDoc, 0);
|
||||||
|
|
||||||
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_PROJECT1_CHECK, BM_SETCHECK, findHistory._isFifProjectPanel_1, 0);
|
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_PROJECT1_CHECK, BM_SETCHECK, findHistory._isFifProjectPanel_1, 0);
|
||||||
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_PROJECT2_CHECK, BM_SETCHECK, findHistory._isFifProjectPanel_2, 0);
|
::SendDlgItemMessage(_hSelf, IDD_FINDINFILES_PROJECT2_CHECK, BM_SETCHECK, findHistory._isFifProjectPanel_2, 0);
|
||||||
|
@ -357,11 +357,11 @@ void FindReplaceDlg::fillFindHistory()
|
||||||
::SendDlgItemMessage(_hSelf, IDC_BACKWARDDIRECTION, BM_SETCHECK, BST_UNCHECKED, 0);
|
::SendDlgItemMessage(_hSelf, IDC_BACKWARDDIRECTION, BM_SETCHECK, BST_UNCHECKED, 0);
|
||||||
enableFindDlgItem(IDC_BACKWARDDIRECTION, nppParams.regexBackward4PowerUser());
|
enableFindDlgItem(IDC_BACKWARDDIRECTION, nppParams.regexBackward4PowerUser());
|
||||||
enableFindDlgItem(IDC_FINDPREV, nppParams.regexBackward4PowerUser());
|
enableFindDlgItem(IDC_FINDPREV, nppParams.regexBackward4PowerUser());
|
||||||
|
|
||||||
// If the search mode from history is regExp then enable the checkbox (. matches newline)
|
// If the search mode from history is regExp then enable the checkbox (. matches newline)
|
||||||
enableFindDlgItem(IDREDOTMATCHNL);
|
enableFindDlgItem(IDREDOTMATCHNL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nppParams.isTransparentAvailable())
|
if (nppParams.isTransparentAvailable())
|
||||||
{
|
{
|
||||||
showFindDlgItem(IDC_TRANSPARENT_CHECK);
|
showFindDlgItem(IDC_TRANSPARENT_CHECK);
|
||||||
|
@ -369,10 +369,10 @@ void FindReplaceDlg::fillFindHistory()
|
||||||
showFindDlgItem(IDC_TRANSPARENT_LOSSFOCUS_RADIO);
|
showFindDlgItem(IDC_TRANSPARENT_LOSSFOCUS_RADIO);
|
||||||
showFindDlgItem(IDC_TRANSPARENT_ALWAYS_RADIO);
|
showFindDlgItem(IDC_TRANSPARENT_ALWAYS_RADIO);
|
||||||
showFindDlgItem(IDC_PERCENTAGE_SLIDER);
|
showFindDlgItem(IDC_PERCENTAGE_SLIDER);
|
||||||
|
|
||||||
::SendDlgItemMessage(_hSelf, IDC_PERCENTAGE_SLIDER, TBM_SETRANGE, FALSE, MAKELONG(20, 200));
|
::SendDlgItemMessage(_hSelf, IDC_PERCENTAGE_SLIDER, TBM_SETRANGE, FALSE, MAKELONG(20, 200));
|
||||||
::SendDlgItemMessage(_hSelf, IDC_PERCENTAGE_SLIDER, TBM_SETPOS, TRUE, findHistory._transparency);
|
::SendDlgItemMessage(_hSelf, IDC_PERCENTAGE_SLIDER, TBM_SETPOS, TRUE, findHistory._transparency);
|
||||||
|
|
||||||
if (findHistory._transparencyMode == FindHistory::none)
|
if (findHistory._transparencyMode == FindHistory::none)
|
||||||
{
|
{
|
||||||
enableFindDlgItem(IDC_TRANSPARENT_GRPBOX, false);
|
enableFindDlgItem(IDC_TRANSPARENT_GRPBOX, false);
|
||||||
|
@ -383,7 +383,7 @@ void FindReplaceDlg::fillFindHistory()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
::SendDlgItemMessage(_hSelf, IDC_TRANSPARENT_CHECK, BM_SETCHECK, TRUE, 0);
|
::SendDlgItemMessage(_hSelf, IDC_TRANSPARENT_CHECK, BM_SETCHECK, TRUE, 0);
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
if (findHistory._transparencyMode == FindHistory::onLossingFocus)
|
if (findHistory._transparencyMode == FindHistory::onLossingFocus)
|
||||||
{
|
{
|
||||||
|
@ -618,7 +618,7 @@ bool Finder::canFind(const TCHAR *fileName, size_t lineNumber) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Finder::gotoNextFoundResult(int direction)
|
void Finder::gotoNextFoundResult(int direction)
|
||||||
|
@ -628,7 +628,7 @@ void Finder::gotoNextFoundResult(int direction)
|
||||||
auto lno = _scintView.execute(SCI_LINEFROMPOSITION, currentPos);
|
auto lno = _scintView.execute(SCI_LINEFROMPOSITION, currentPos);
|
||||||
auto total_lines = _scintView.execute(SCI_GETLINECOUNT);
|
auto total_lines = _scintView.execute(SCI_GETLINECOUNT);
|
||||||
if (total_lines <= 1) return;
|
if (total_lines <= 1) return;
|
||||||
|
|
||||||
if (lno == total_lines - 1) lno--; // last line doesn't belong to any search, use last search
|
if (lno == total_lines - 1) lno--; // last line doesn't belong to any search, use last search
|
||||||
|
|
||||||
auto init_lno = lno;
|
auto init_lno = lno;
|
||||||
|
@ -650,7 +650,7 @@ void Finder::gotoNextFoundResult(int direction)
|
||||||
assert(min_lno <= max_lno);
|
assert(min_lno <= max_lno);
|
||||||
|
|
||||||
lno += increment;
|
lno += increment;
|
||||||
|
|
||||||
if (lno > max_lno) lno = min_lno;
|
if (lno > max_lno) lno = min_lno;
|
||||||
else if (lno < min_lno) lno = max_lno;
|
else if (lno < min_lno) lno = max_lno;
|
||||||
|
|
||||||
|
@ -682,7 +682,7 @@ void FindInFinderDlg::initFromOptions()
|
||||||
|
|
||||||
setChecked(IDWHOLEWORD_FIFOLDER, _options._searchType != FindRegex && _options._isWholeWord);
|
setChecked(IDWHOLEWORD_FIFOLDER, _options._searchType != FindRegex && _options._isWholeWord);
|
||||||
::EnableWindow(::GetDlgItem(_hSelf, IDWHOLEWORD_FIFOLDER), _options._searchType != FindRegex);
|
::EnableWindow(::GetDlgItem(_hSelf, IDWHOLEWORD_FIFOLDER), _options._searchType != FindRegex);
|
||||||
|
|
||||||
setChecked(IDMATCHCASE_FIFOLDER, _options._isMatchCase);
|
setChecked(IDMATCHCASE_FIFOLDER, _options._isMatchCase);
|
||||||
|
|
||||||
setChecked(IDNORMAL_FIFOLDER, _options._searchType == FindNormal);
|
setChecked(IDNORMAL_FIFOLDER, _options._searchType == FindNormal);
|
||||||
|
@ -759,7 +759,7 @@ INT_PTR CALLBACK FindInFinderDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||||
::EnableWindow(GetDlgItem(_hSelf, IDREDOTMATCHNL_FIFOLDER), false);
|
::EnableWindow(GetDlgItem(_hSelf, IDREDOTMATCHNL_FIFOLDER), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -832,7 +832,7 @@ std::mutex findOps_mutex;
|
||||||
|
|
||||||
INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_GETMINMAXINFO:
|
case WM_GETMINMAXINFO:
|
||||||
{
|
{
|
||||||
|
@ -850,30 +850,44 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_CTLCOLOREDIT:
|
case WM_CTLCOLOREDIT:
|
||||||
|
{
|
||||||
|
if (NppDarkMode::isEnabled())
|
||||||
|
{
|
||||||
|
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_CTLCOLORDLG:
|
case WM_CTLCOLORDLG:
|
||||||
case WM_CTLCOLORSTATIC:
|
case WM_CTLCOLORSTATIC:
|
||||||
|
case WM_CTLCOLORLISTBOX:
|
||||||
{
|
{
|
||||||
if (!NppDarkMode::isEnabled())
|
if (NppDarkMode::isEnabled())
|
||||||
{
|
{
|
||||||
break;
|
return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
SetTextColor((HDC)wParam, NppDarkMode::getTextColor());
|
|
||||||
SetBkColor((HDC)wParam, NppDarkMode::getBackgroundColor());
|
|
||||||
return (LRESULT)NppDarkMode::getBackgroundBrush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_PRINTCLIENT:
|
case WM_PRINTCLIENT:
|
||||||
|
{
|
||||||
|
if (NppDarkMode::isEnabled())
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case WM_ERASEBKGND:
|
case WM_ERASEBKGND:
|
||||||
{
|
{
|
||||||
if (!NppDarkMode::isEnabled())
|
if (NppDarkMode::isEnabled())
|
||||||
{
|
{
|
||||||
break;
|
RECT rc = { 0 };
|
||||||
|
getClientRect(rc);
|
||||||
|
FillRect(reinterpret_cast<HDC>(wParam), &rc, NppDarkMode::getBackgroundBrush());
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
RECT rc = { 0 };
|
break;
|
||||||
getClientRect(rc);
|
|
||||||
FillRect((HDC)wParam, &rc, NppDarkMode::getBackgroundBrush());
|
|
||||||
SetWindowLongPtr(_hSelf, DWLP_MSGRESULT, TRUE);
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case NPPM_INTERNAL_REFRESHDARKMODE:
|
case NPPM_INTERNAL_REFRESHDARKMODE:
|
||||||
|
@ -1053,7 +1067,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||||
|
|
||||||
_options._isInSelection = isCheckedOrNot(IDC_IN_SELECTION_CHECK)?1:0;
|
_options._isInSelection = isCheckedOrNot(IDC_IN_SELECTION_CHECK)?1:0;
|
||||||
int checkVal = _options._isInSelection?BST_CHECKED:BST_UNCHECKED;
|
int checkVal = _options._isInSelection?BST_CHECKED:BST_UNCHECKED;
|
||||||
|
|
||||||
if (!_options._isInSelection)
|
if (!_options._isInSelection)
|
||||||
{
|
{
|
||||||
if (nbSelected <= 1024)
|
if (nbSelected <= 1024)
|
||||||
|
@ -1067,7 +1081,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||||
_options._isInSelection = true;
|
_options._isInSelection = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Searching/replacing in multiple selections or column selection is not allowed
|
// Searching/replacing in multiple selections or column selection is not allowed
|
||||||
if (((*_ppEditView)->execute(SCI_GETSELECTIONMODE) == SC_SEL_RECTANGLE) || ((*_ppEditView)->execute(SCI_GETSELECTIONS) > 1))
|
if (((*_ppEditView)->execute(SCI_GETSELECTIONMODE) == SC_SEL_RECTANGLE) || ((*_ppEditView)->execute(SCI_GETSELECTIONS) > 1))
|
||||||
{
|
{
|
||||||
checkVal = BST_UNCHECKED;
|
checkVal = BST_UNCHECKED;
|
||||||
|
@ -1083,7 +1097,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||||
}
|
}
|
||||||
::SendDlgItemMessage(_hSelf, IDC_IN_SELECTION_CHECK, BM_SETCHECK, checkVal, 0);
|
::SendDlgItemMessage(_hSelf, IDC_IN_SELECTION_CHECK, BM_SETCHECK, checkVal, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCheckedOrNot(IDC_TRANSPARENT_LOSSFOCUS_RADIO))
|
if (isCheckedOrNot(IDC_TRANSPARENT_LOSSFOCUS_RADIO))
|
||||||
{
|
{
|
||||||
if (LOWORD(wParam) == WA_INACTIVE && isVisible())
|
if (LOWORD(wParam) == WA_INACTIVE && isVisible())
|
||||||
|
@ -1114,7 +1128,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||||
case NPPM_MODELESSDIALOG :
|
case NPPM_MODELESSDIALOG :
|
||||||
return ::SendMessage(_hParent, NPPM_MODELESSDIALOG, wParam, lParam);
|
return ::SendMessage(_hParent, NPPM_MODELESSDIALOG, wParam, lParam);
|
||||||
|
|
||||||
case WM_COMMAND :
|
case WM_COMMAND :
|
||||||
{
|
{
|
||||||
bool isMacroRecording = (::SendMessage(_hParent, WM_GETCURRENTMACROSTATUS,0,0) == MACRO_RECORDING_IN_PROGRESS);
|
bool isMacroRecording = (::SendMessage(_hParent, WM_GETCURRENTMACROSTATUS,0,0) == MACRO_RECORDING_IN_PROGRESS);
|
||||||
NppParameters& nppParamInst = NppParameters::getInstance();
|
NppParameters& nppParamInst = NppParameters::getInstance();
|
||||||
|
@ -1248,8 +1262,8 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||||
if (_currentStatus == FIND_DLG)
|
if (_currentStatus == FIND_DLG)
|
||||||
{
|
{
|
||||||
setStatusbarMessage(TEXT(""), FSNoMessage);
|
setStatusbarMessage(TEXT(""), FSNoMessage);
|
||||||
HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
|
HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
|
||||||
combo2ExtendedMode(IDFINDWHAT);
|
combo2ExtendedMode(IDFINDWHAT);
|
||||||
_options._str2Search = getTextFromCombo(hFindCombo);
|
_options._str2Search = getTextFromCombo(hFindCombo);
|
||||||
updateCombo(IDFINDWHAT);
|
updateCombo(IDFINDWHAT);
|
||||||
|
|
||||||
|
@ -1265,7 +1279,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||||
{
|
{
|
||||||
setStatusbarMessage(TEXT(""), FSNoMessage);
|
setStatusbarMessage(TEXT(""), FSNoMessage);
|
||||||
HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
|
HWND hFindCombo = ::GetDlgItem(_hSelf, IDFINDWHAT);
|
||||||
combo2ExtendedMode(IDFINDWHAT);
|
combo2ExtendedMode(IDFINDWHAT);
|
||||||
_options._str2Search = getTextFromCombo(hFindCombo);
|
_options._str2Search = getTextFromCombo(hFindCombo);
|
||||||
updateCombo(IDFINDWHAT);
|
updateCombo(IDFINDWHAT);
|
||||||
|
|
||||||
|
@ -1414,7 +1428,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||||
nppParamInst._isFindReplacing = false;
|
nppParamInst._isFindReplacing = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case IDREPLACEALL :
|
case IDREPLACEALL :
|
||||||
|
@ -1523,7 +1537,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||||
nppParamInst._isFindReplacing = true;
|
nppParamInst._isFindReplacing = true;
|
||||||
int nbMarked = processAll(ProcessMarkAll, &_options);
|
int nbMarked = processAll(ProcessMarkAll, &_options);
|
||||||
nppParamInst._isFindReplacing = false;
|
nppParamInst._isFindReplacing = false;
|
||||||
|
|
||||||
generic_string result;
|
generic_string result;
|
||||||
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
|
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
|
||||||
if (nbMarked < 0)
|
if (nbMarked < 0)
|
||||||
|
@ -1581,7 +1595,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||||
|
|
||||||
case IDNORMAL:
|
case IDNORMAL:
|
||||||
case IDEXTENDED:
|
case IDEXTENDED:
|
||||||
case IDREGEXP :
|
case IDREGEXP :
|
||||||
{
|
{
|
||||||
if (isCheckedOrNot(IDREGEXP))
|
if (isCheckedOrNot(IDREGEXP))
|
||||||
{
|
{
|
||||||
|
@ -1603,8 +1617,8 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isRegex = (_options._searchType == FindRegex);
|
bool isRegex = (_options._searchType == FindRegex);
|
||||||
if (isRegex)
|
if (isRegex)
|
||||||
{
|
{
|
||||||
//regex doesn't allow whole word
|
//regex doesn't allow whole word
|
||||||
_options._isWholeWord = false;
|
_options._isWholeWord = false;
|
||||||
::SendDlgItemMessage(_hSelf, IDWHOLEWORD, BM_SETCHECK, _options._isWholeWord?BST_CHECKED:BST_UNCHECKED, 0);
|
::SendDlgItemMessage(_hSelf, IDWHOLEWORD, BM_SETCHECK, _options._isWholeWord?BST_CHECKED:BST_UNCHECKED, 0);
|
||||||
|
@ -1628,7 +1642,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||||
enableFindDlgItem(IDC_BACKWARDDIRECTION, doEnable);
|
enableFindDlgItem(IDC_BACKWARDDIRECTION, doEnable);
|
||||||
enableFindDlgItem(IDC_FINDPREV, doEnable);
|
enableFindDlgItem(IDC_FINDPREV, doEnable);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
case IDWRAP :
|
case IDWRAP :
|
||||||
|
@ -1708,7 +1722,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||||
{
|
{
|
||||||
if (_currentStatus == FINDINFILES_DLG)
|
if (_currentStatus == FINDINFILES_DLG)
|
||||||
findHistory._isFifRecuisive = _options._isRecursive = isCheckedOrNot(IDD_FINDINFILES_RECURSIVE_CHECK);
|
findHistory._isFifRecuisive = _options._isRecursive = isCheckedOrNot(IDD_FINDINFILES_RECURSIVE_CHECK);
|
||||||
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
@ -1718,7 +1732,7 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||||
findHistory._isFifInHiddenFolder = _options._isInHiddenDir = isCheckedOrNot(IDD_FINDINFILES_INHIDDENDIR_CHECK);
|
findHistory._isFifInHiddenFolder = _options._isInHiddenDir = isCheckedOrNot(IDD_FINDINFILES_INHIDDENDIR_CHECK);
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case IDD_FINDINFILES_PROJECT1_CHECK:
|
case IDD_FINDINFILES_PROJECT1_CHECK:
|
||||||
case IDD_FINDINFILES_PROJECT2_CHECK:
|
case IDD_FINDINFILES_PROJECT2_CHECK:
|
||||||
case IDD_FINDINFILES_PROJECT3_CHECK:
|
case IDD_FINDINFILES_PROJECT3_CHECK:
|
||||||
|
@ -1744,18 +1758,18 @@ INT_PTR CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
case IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK :
|
case IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK :
|
||||||
{
|
{
|
||||||
if (_currentStatus == FINDINFILES_DLG)
|
if (_currentStatus == FINDINFILES_DLG)
|
||||||
findHistory._isFolderFollowDoc = isCheckedOrNot(IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK);
|
findHistory._isFolderFollowDoc = isCheckedOrNot(IDD_FINDINFILES_FOLDERFOLLOWSDOC_CHECK);
|
||||||
|
|
||||||
|
if (findHistory._isFolderFollowDoc)
|
||||||
|
{
|
||||||
|
NppParameters& nppParam = NppParameters::getInstance();
|
||||||
|
const TCHAR * dir = nppParam.getWorkingDir();
|
||||||
|
::SetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, dir);
|
||||||
|
}
|
||||||
|
|
||||||
if (findHistory._isFolderFollowDoc)
|
|
||||||
{
|
|
||||||
NppParameters& nppParam = NppParameters::getInstance();
|
|
||||||
const TCHAR * dir = nppParam.getWorkingDir();
|
|
||||||
::SetDlgItemText(_hSelf, IDD_FINDINFILES_DIR_COMBO, dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
@ -1794,7 +1808,7 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op
|
||||||
int stringSizeFind = lstrlen(txt2find);
|
int stringSizeFind = lstrlen(txt2find);
|
||||||
TCHAR *pText = new TCHAR[stringSizeFind + 1];
|
TCHAR *pText = new TCHAR[stringSizeFind + 1];
|
||||||
wcscpy_s(pText, stringSizeFind + 1, txt2find);
|
wcscpy_s(pText, stringSizeFind + 1, txt2find);
|
||||||
|
|
||||||
if (pOptions->_searchType == FindExtended)
|
if (pOptions->_searchType == FindExtended)
|
||||||
{
|
{
|
||||||
stringSizeFind = Searching::convertExtendedToString(txt2find, pText, stringSizeFind);
|
stringSizeFind = Searching::convertExtendedToString(txt2find, pText, stringSizeFind);
|
||||||
|
@ -1808,7 +1822,7 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op
|
||||||
int startPosition = cr.cpMax;
|
int startPosition = cr.cpMax;
|
||||||
int endPosition = docLength;
|
int endPosition = docLength;
|
||||||
|
|
||||||
|
|
||||||
if (pOptions->_whichDirection == DIR_UP)
|
if (pOptions->_whichDirection == DIR_UP)
|
||||||
{
|
{
|
||||||
//When searching upwards, start is the lower part, end the upper, for backwards search
|
//When searching upwards, start is the lower part, end the upper, for backwards search
|
||||||
|
@ -1833,7 +1847,7 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op
|
||||||
{
|
{
|
||||||
// text to find is not modified, so use current position +1
|
// text to find is not modified, so use current position +1
|
||||||
startPosition = cr.cpMin + 1;
|
startPosition = cr.cpMin + 1;
|
||||||
endPosition = docLength;
|
endPosition = docLength;
|
||||||
|
|
||||||
if (pOptions->_whichDirection == DIR_UP)
|
if (pOptions->_whichDirection == DIR_UP)
|
||||||
{
|
{
|
||||||
|
@ -1864,7 +1878,7 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op
|
||||||
|
|
||||||
// Never allow a zero length match in the middle of a line end marker
|
// Never allow a zero length match in the middle of a line end marker
|
||||||
if ((*_ppEditView)->execute(SCI_GETCHARAT, startPosition - 1) == '\r'
|
if ((*_ppEditView)->execute(SCI_GETCHARAT, startPosition - 1) == '\r'
|
||||||
&& (*_ppEditView)->execute(SCI_GETCHARAT, startPosition) == '\n')
|
&& (*_ppEditView)->execute(SCI_GETCHARAT, startPosition) == '\n')
|
||||||
{
|
{
|
||||||
flags = (flags & ~SCFIND_REGEXP_EMPTYMATCH_MASK) | SCFIND_REGEXP_EMPTYMATCH_NONE;
|
flags = (flags & ~SCFIND_REGEXP_EMPTYMATCH_MASK) | SCFIND_REGEXP_EMPTYMATCH_NONE;
|
||||||
}
|
}
|
||||||
|
@ -1875,7 +1889,7 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op
|
||||||
posFind = (*_ppEditView)->searchInTarget(pText, stringSizeFind, startPosition, endPosition);
|
posFind = (*_ppEditView)->searchInTarget(pText, stringSizeFind, startPosition, endPosition);
|
||||||
if (posFind == -1) //no match found in target, check if a new target should be used
|
if (posFind == -1) //no match found in target, check if a new target should be used
|
||||||
{
|
{
|
||||||
if (pOptions->_isWrapAround)
|
if (pOptions->_isWrapAround)
|
||||||
{
|
{
|
||||||
//when wrapping, use the rest of the document (entire document is usable)
|
//when wrapping, use the rest of the document (entire document is usable)
|
||||||
if (pOptions->_whichDirection == DIR_DOWN)
|
if (pOptions->_whichDirection == DIR_DOWN)
|
||||||
|
@ -1903,13 +1917,13 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op
|
||||||
*oFindStatus = FSNotFound;
|
*oFindStatus = FSNotFound;
|
||||||
//failed, or failed twice with wrap
|
//failed, or failed twice with wrap
|
||||||
if (NotIncremental == pOptions->_incrementalType) //incremental search doesnt trigger messages
|
if (NotIncremental == pOptions->_incrementalType) //incremental search doesnt trigger messages
|
||||||
{
|
{
|
||||||
generic_string newTxt2find = stringReplace(txt2find, TEXT("&"), TEXT("&&"));
|
generic_string newTxt2find = stringReplace(txt2find, TEXT("&"), TEXT("&&"));
|
||||||
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
|
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
|
||||||
generic_string msg = pNativeSpeaker->getLocalizedStrFromID("find-status-cannot-find", TEXT("Find: Can't find the text \"$STR_REPLACE$\""));
|
generic_string msg = pNativeSpeaker->getLocalizedStrFromID("find-status-cannot-find", TEXT("Find: Can't find the text \"$STR_REPLACE$\""));
|
||||||
msg = stringReplace(msg, TEXT("$STR_REPLACE$"), newTxt2find);
|
msg = stringReplace(msg, TEXT("$STR_REPLACE$"), newTxt2find);
|
||||||
setStatusbarMessage(msg, FSNotFound);
|
setStatusbarMessage(msg, FSNotFound);
|
||||||
|
|
||||||
// if the dialog is not shown, pass the focus to his parent(ie. Notepad++)
|
// if the dialog is not shown, pass the focus to his parent(ie. Notepad++)
|
||||||
if (!::IsWindowVisible(_hSelf))
|
if (!::IsWindowVisible(_hSelf))
|
||||||
{
|
{
|
||||||
|
@ -1924,7 +1938,7 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (posFind < -1)
|
else if (posFind < -1)
|
||||||
{ // error
|
{ // error
|
||||||
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
|
NativeLangSpeaker *pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
|
||||||
generic_string msgGeneral;
|
generic_string msgGeneral;
|
||||||
|
@ -1946,14 +1960,14 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op
|
||||||
start = posFind;
|
start = posFind;
|
||||||
end = int((*_ppEditView)->execute(SCI_GETTARGETEND));
|
end = int((*_ppEditView)->execute(SCI_GETTARGETEND));
|
||||||
|
|
||||||
setStatusbarMessage(TEXT(""), FSNoMessage);
|
setStatusbarMessage(TEXT(""), FSNoMessage);
|
||||||
|
|
||||||
// to make sure the found result is visible:
|
// to make sure the found result is visible:
|
||||||
// prevent recording of absolute positioning commands issued in the process
|
// prevent recording of absolute positioning commands issued in the process
|
||||||
(*_ppEditView)->execute(SCI_STOPRECORD);
|
(*_ppEditView)->execute(SCI_STOPRECORD);
|
||||||
Searching::displaySectionCentered(start, end, *_ppEditView, pOptions->_whichDirection == DIR_DOWN);
|
Searching::displaySectionCentered(start, end, *_ppEditView, pOptions->_whichDirection == DIR_DOWN);
|
||||||
// Show a calltip for a zero length match
|
// Show a calltip for a zero length match
|
||||||
if (start == end)
|
if (start == end)
|
||||||
{
|
{
|
||||||
NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
|
NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
|
||||||
generic_string msg = pNativeSpeaker->getLocalizedStrFromID("find-regex-zero-length-match", TEXT("zero length match"));
|
generic_string msg = pNativeSpeaker->getLocalizedStrFromID("find-regex-zero-length-match", TEXT("zero length match"));
|
||||||
|
@ -1994,10 +2008,10 @@ bool FindReplaceDlg::processReplace(const TCHAR *txt2find, const TCHAR *txt2repl
|
||||||
FindStatus status;
|
FindStatus status;
|
||||||
moreMatches = processFindNext(txt2find, &replaceOptions, &status, FINDNEXTTYPE_FINDNEXTFORREPLACE);
|
moreMatches = processFindNext(txt2find, &replaceOptions, &status, FINDNEXTTYPE_FINDNEXTFORREPLACE);
|
||||||
|
|
||||||
if (moreMatches)
|
if (moreMatches)
|
||||||
{
|
{
|
||||||
Sci_CharacterRange nextFind = (*_ppEditView)->getSelection();
|
Sci_CharacterRange nextFind = (*_ppEditView)->getSelection();
|
||||||
|
|
||||||
// If the next find is the same as the last, then perform the replacement
|
// If the next find is the same as the last, then perform the replacement
|
||||||
if (nextFind.cpMin == currentSelection.cpMin && nextFind.cpMax == currentSelection.cpMax)
|
if (nextFind.cpMin == currentSelection.cpMin && nextFind.cpMax == currentSelection.cpMax)
|
||||||
{
|
{
|
||||||
|
@ -2073,7 +2087,7 @@ bool FindReplaceDlg::processReplace(const TCHAR *txt2find, const TCHAR *txt2repl
|
||||||
setStatusbarMessage(msg, FSNotFound);
|
setStatusbarMessage(msg, FSNotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
return moreMatches;
|
return moreMatches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2115,7 +2129,7 @@ int FindReplaceDlg::processAll(ProcessOperation op, const FindOption *opt, bool
|
||||||
Sci_CharacterRange cr = (*_ppEditView)->getSelection();
|
Sci_CharacterRange cr = (*_ppEditView)->getSelection();
|
||||||
int docLength = int((*_ppEditView)->execute(SCI_GETLENGTH));
|
int docLength = int((*_ppEditView)->execute(SCI_GETLENGTH));
|
||||||
|
|
||||||
// Default :
|
// Default :
|
||||||
// direction : down
|
// direction : down
|
||||||
// begin at : 0
|
// begin at : 0
|
||||||
// end at : end of doc
|
// end at : end of doc
|
||||||
|
@ -2125,7 +2139,7 @@ int FindReplaceDlg::processAll(ProcessOperation op, const FindOption *opt, bool
|
||||||
bool direction = pOptions->_whichDirection;
|
bool direction = pOptions->_whichDirection;
|
||||||
|
|
||||||
//first try limiting scope by direction
|
//first try limiting scope by direction
|
||||||
if (direction == DIR_UP)
|
if (direction == DIR_UP)
|
||||||
{
|
{
|
||||||
startPosition = 0;
|
startPosition = 0;
|
||||||
endPosition = cr.cpMax;
|
endPosition = cr.cpMax;
|
||||||
|
@ -2147,7 +2161,7 @@ int FindReplaceDlg::processAll(ProcessOperation op, const FindOption *opt, bool
|
||||||
startPosition = 0;
|
startPosition = 0;
|
||||||
endPosition = docLength;
|
endPosition = docLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
//then readjust scope if the selection override is active and allowed
|
//then readjust scope if the selection override is active and allowed
|
||||||
if ((pOptions->_isInSelection) && ((op == ProcessMarkAll) || ((op == ProcessReplaceAll || op == ProcessFindAll) && (!isEntire))))
|
if ((pOptions->_isInSelection) && ((op == ProcessMarkAll) || ((op == ProcessReplaceAll || op == ProcessFindAll) && (!isEntire))))
|
||||||
//if selection limiter and either mark all or replace all or find all w/o entire document override
|
//if selection limiter and either mark all or replace all or find all w/o entire document override
|
||||||
|
@ -2189,7 +2203,7 @@ int FindReplaceDlg::processAll(ProcessOperation op, const FindOption *opt, bool
|
||||||
int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findReplaceInfo, const FindersInfo * pFindersInfo, const FindOption *opt, int colourStyleID, ScintillaEditView *view2Process)
|
int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findReplaceInfo, const FindersInfo * pFindersInfo, const FindOption *opt, int colourStyleID, ScintillaEditView *view2Process)
|
||||||
{
|
{
|
||||||
int nbProcessed = 0;
|
int nbProcessed = 0;
|
||||||
|
|
||||||
if (!isCreated() && !findReplaceInfo._txt2find)
|
if (!isCreated() && !findReplaceInfo._txt2find)
|
||||||
return nbProcessed;
|
return nbProcessed;
|
||||||
|
|
||||||
|
@ -2224,7 +2238,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||||
wcscpy_s(pTextFind, stringSizeFind + 1, findReplaceInfo._txt2find);
|
wcscpy_s(pTextFind, stringSizeFind + 1, findReplaceInfo._txt2find);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pTextFind[0])
|
if (!pTextFind[0])
|
||||||
{
|
{
|
||||||
delete [] pTextFind;
|
delete [] pTextFind;
|
||||||
return nbProcessed;
|
return nbProcessed;
|
||||||
|
@ -2247,7 +2261,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||||
pTextReplace = new TCHAR[stringSizeReplace + 1];
|
pTextReplace = new TCHAR[stringSizeReplace + 1];
|
||||||
wcscpy_s(pTextReplace, stringSizeReplace + 1, findReplaceInfo._txt2replace);
|
wcscpy_s(pTextReplace, stringSizeReplace + 1, findReplaceInfo._txt2replace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pOptions->_searchType == FindExtended)
|
if (pOptions->_searchType == FindExtended)
|
||||||
{
|
{
|
||||||
|
@ -2257,14 +2271,14 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isRegExp = pOptions->_searchType == FindRegex;
|
bool isRegExp = pOptions->_searchType == FindRegex;
|
||||||
int flags = Searching::buildSearchFlags(pOptions) | SCFIND_REGEXP_SKIPCRLFASONE;
|
int flags = Searching::buildSearchFlags(pOptions) | SCFIND_REGEXP_SKIPCRLFASONE;
|
||||||
|
|
||||||
// Allow empty matches, but not immediately after previous match for replace all or find all.
|
// Allow empty matches, but not immediately after previous match for replace all or find all.
|
||||||
// Other search types should ignore empty matches completely.
|
// Other search types should ignore empty matches completely.
|
||||||
if (op == ProcessReplaceAll || op == ProcessFindAll)
|
if (op == ProcessReplaceAll || op == ProcessFindAll)
|
||||||
flags |= SCFIND_REGEXP_EMPTYMATCH_NOTAFTERMATCH;
|
flags |= SCFIND_REGEXP_EMPTYMATCH_NOTAFTERMATCH;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (op == ProcessMarkAll && colourStyleID == -1) //if marking, check if purging is needed
|
if (op == ProcessMarkAll && colourStyleID == -1) //if marking, check if purging is needed
|
||||||
{
|
{
|
||||||
|
@ -2279,8 +2293,8 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||||
|
|
||||||
//Initial range for searching
|
//Initial range for searching
|
||||||
pEditView->execute(SCI_SETSEARCHFLAGS, flags);
|
pEditView->execute(SCI_SETSEARCHFLAGS, flags);
|
||||||
|
|
||||||
|
|
||||||
bool findAllFileNameAdded = false;
|
bool findAllFileNameAdded = false;
|
||||||
|
|
||||||
while (targetStart >= 0)
|
while (targetStart >= 0)
|
||||||
|
@ -2302,10 +2316,10 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||||
int foundTextLen = targetEnd - targetStart;
|
int foundTextLen = targetEnd - targetStart;
|
||||||
int replaceDelta = 0;
|
int replaceDelta = 0;
|
||||||
bool processed = true;
|
bool processed = true;
|
||||||
|
|
||||||
switch (op)
|
switch (op)
|
||||||
{
|
{
|
||||||
case ProcessFindAll:
|
case ProcessFindAll:
|
||||||
{
|
{
|
||||||
const TCHAR *pFileName = TEXT("");
|
const TCHAR *pFileName = TEXT("");
|
||||||
if (pFindersInfo && pFindersInfo->_pFileName)
|
if (pFindersInfo && pFindersInfo->_pFileName)
|
||||||
|
@ -2340,7 +2354,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||||
srm._end = end_mark;
|
srm._end = end_mark;
|
||||||
_pFinder->add(FoundInfo(targetStart, targetEnd, lineNumber + 1, pFileName), srm, line.c_str());
|
_pFinder->add(FoundInfo(targetStart, targetEnd, lineNumber + 1, pFileName), srm, line.c_str());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ProcessFindInFinder:
|
case ProcessFindInFinder:
|
||||||
|
@ -2357,7 +2371,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||||
|
|
||||||
// use the static buffer
|
// use the static buffer
|
||||||
TCHAR lineBuf[SC_SEARCHRESULT_LINEBUFFERMAXLENGTH];
|
TCHAR lineBuf[SC_SEARCHRESULT_LINEBUFFERMAXLENGTH];
|
||||||
|
|
||||||
if (nbChar > SC_SEARCHRESULT_LINEBUFFERMAXLENGTH - 3)
|
if (nbChar > SC_SEARCHRESULT_LINEBUFFERMAXLENGTH - 3)
|
||||||
lend = lstart + SC_SEARCHRESULT_LINEBUFFERMAXLENGTH - 4;
|
lend = lstart + SC_SEARCHRESULT_LINEBUFFERMAXLENGTH - 4;
|
||||||
|
|
||||||
|
@ -2384,7 +2398,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ProcessReplaceAll:
|
case ProcessReplaceAll:
|
||||||
{
|
{
|
||||||
int replacedLength;
|
int replacedLength;
|
||||||
if (isRegExp)
|
if (isRegExp)
|
||||||
|
@ -2393,16 +2407,16 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||||
replacedLength = pEditView->replaceTarget(pTextReplace);
|
replacedLength = pEditView->replaceTarget(pTextReplace);
|
||||||
|
|
||||||
replaceDelta = replacedLength - foundTextLen;
|
replaceDelta = replacedLength - foundTextLen;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ProcessMarkAll:
|
case ProcessMarkAll:
|
||||||
{
|
{
|
||||||
// In theory, we can't have empty matches for a ProcessMarkAll, but because scintilla
|
// In theory, we can't have empty matches for a ProcessMarkAll, but because scintilla
|
||||||
// gets upset if we call INDICATORFILLRANGE with a length of 0, we protect against it here.
|
// gets upset if we call INDICATORFILLRANGE with a length of 0, we protect against it here.
|
||||||
// At least in version 2.27, after calling INDICATORFILLRANGE with length 0, further indicators
|
// At least in version 2.27, after calling INDICATORFILLRANGE with length 0, further indicators
|
||||||
// on the same line would simply not be shown. This may have been fixed in later version of Scintilla.
|
// on the same line would simply not be shown. This may have been fixed in later version of Scintilla.
|
||||||
if (foundTextLen > 0)
|
if (foundTextLen > 0)
|
||||||
{
|
{
|
||||||
pEditView->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE);
|
pEditView->execute(SCI_SETINDICATORCURRENT, SCE_UNIVERSAL_FOUND_STYLE);
|
||||||
pEditView->execute(SCI_INDICATORFILLRANGE, targetStart, foundTextLen);
|
pEditView->execute(SCI_INDICATORFILLRANGE, targetStart, foundTextLen);
|
||||||
|
@ -2421,9 +2435,9 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||||
pEditView->execute(SCI_MARKERADD, i, MARK_BOOKMARK);
|
pEditView->execute(SCI_MARKERADD, i, MARK_BOOKMARK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ProcessMarkAllExt:
|
case ProcessMarkAllExt:
|
||||||
{
|
{
|
||||||
// See comment by ProcessMarkAll
|
// See comment by ProcessMarkAll
|
||||||
|
@ -2457,7 +2471,7 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ProcessCountAll:
|
case ProcessCountAll:
|
||||||
{
|
{
|
||||||
//Nothing to do
|
//Nothing to do
|
||||||
break;
|
break;
|
||||||
|
@ -2469,15 +2483,15 @@ int FindReplaceDlg::processRange(ProcessOperation op, FindReplaceInfo & findRepl
|
||||||
delete [] pTextReplace;
|
delete [] pTextReplace;
|
||||||
return nbProcessed;
|
return nbProcessed;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (processed) ++nbProcessed;
|
if (processed) ++nbProcessed;
|
||||||
|
|
||||||
// After the processing of the last string occurrence the search loop should be stopped
|
// After the processing of the last string occurrence the search loop should be stopped
|
||||||
// This helps to avoid the endless replacement during the EOL ("$") searching
|
// This helps to avoid the endless replacement during the EOL ("$") searching
|
||||||
if (targetStart + foundTextLen == findReplaceInfo._endRange)
|
if (targetStart + foundTextLen == findReplaceInfo._endRange)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
findReplaceInfo._startRange = targetStart + foundTextLen + replaceDelta; //search from result onwards
|
findReplaceInfo._startRange = targetStart + foundTextLen + replaceDelta; //search from result onwards
|
||||||
findReplaceInfo._endRange += replaceDelta; //adjust end of range in case of replace
|
findReplaceInfo._endRange += replaceDelta; //adjust end of range in case of replace
|
||||||
}
|
}
|
||||||
|
@ -2600,11 +2614,11 @@ void FindReplaceDlg::findAllIn(InWhat op)
|
||||||
char ptrword[sizeof(void*)*2+1];
|
char ptrword[sizeof(void*)*2+1];
|
||||||
sprintf(ptrword, "%p", &_pFinder->_markingsStruct);
|
sprintf(ptrword, "%p", &_pFinder->_markingsStruct);
|
||||||
_pFinder->_scintView.execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("@MarkingsStruct"), reinterpret_cast<LPARAM>(ptrword));
|
_pFinder->_scintView.execute(SCI_SETPROPERTY, reinterpret_cast<WPARAM>("@MarkingsStruct"), reinterpret_cast<LPARAM>(ptrword));
|
||||||
|
|
||||||
//enable "Search Results Window" under Search Menu
|
//enable "Search Results Window" under Search Menu
|
||||||
::EnableMenuItem(::GetMenu(_hParent), IDM_FOCUS_ON_FOUND_RESULTS, MF_ENABLED | MF_BYCOMMAND);
|
::EnableMenuItem(::GetMenu(_hParent), IDM_FOCUS_ON_FOUND_RESULTS, MF_ENABLED | MF_BYCOMMAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
::SendMessage(_pFinder->getHSelf(), WM_SIZE, 0, 0);
|
::SendMessage(_pFinder->getHSelf(), WM_SIZE, 0, 0);
|
||||||
|
|
||||||
int cmdid = 0;
|
int cmdid = 0;
|
||||||
|
@ -2628,7 +2642,7 @@ void FindReplaceDlg::findAllIn(InWhat op)
|
||||||
|
|
||||||
bool isRTL = (*_ppEditView)->isTextDirectionRTL();
|
bool isRTL = (*_ppEditView)->isTextDirectionRTL();
|
||||||
_pFinder->_scintView.changeTextDirection(isRTL);
|
_pFinder->_scintView.changeTextDirection(isRTL);
|
||||||
if (_findAllResult)
|
if (_findAllResult)
|
||||||
{
|
{
|
||||||
focusOnFinder();
|
focusOnFinder();
|
||||||
}
|
}
|
||||||
|
@ -2710,7 +2724,7 @@ Finder * FindReplaceDlg::createFinder()
|
||||||
|
|
||||||
pFinder->_scintView.display();
|
pFinder->_scintView.display();
|
||||||
::UpdateWindow(_hParent);
|
::UpdateWindow(_hParent);
|
||||||
|
|
||||||
pFinder->setFinderStyle();
|
pFinder->setFinderStyle();
|
||||||
|
|
||||||
// Send the address of _MarkingsStruct to the lexer
|
// Send the address of _MarkingsStruct to the lexer
|
||||||
|
@ -2770,7 +2784,7 @@ void FindReplaceDlg::showFindDlgItem(int dlgItemID, bool isShow /* = true*/)
|
||||||
{
|
{
|
||||||
HWND h = ::GetDlgItem(_hSelf, dlgItemID);
|
HWND h = ::GetDlgItem(_hSelf, dlgItemID);
|
||||||
if (!h) return;
|
if (!h) return;
|
||||||
|
|
||||||
::ShowWindow(h, isShow ? SW_SHOW : SW_HIDE);
|
::ShowWindow(h, isShow ? SW_SHOW : SW_HIDE);
|
||||||
|
|
||||||
// when hiding a control to make it user-inaccessible, it can still be manipulated via a keyboard accelerator!
|
// when hiding a control to make it user-inaccessible, it can still be manipulated via a keyboard accelerator!
|
||||||
|
@ -3457,7 +3471,7 @@ void FindReplaceDlg::initOptionsFromDlg()
|
||||||
_options._doMarkLine = isCheckedOrNot(IDC_MARKLINE_CHECK);
|
_options._doMarkLine = isCheckedOrNot(IDC_MARKLINE_CHECK);
|
||||||
|
|
||||||
_options._whichDirection = isCheckedOrNot(IDC_BACKWARDDIRECTION) ? DIR_UP : DIR_DOWN;
|
_options._whichDirection = isCheckedOrNot(IDC_BACKWARDDIRECTION) ? DIR_UP : DIR_DOWN;
|
||||||
|
|
||||||
_options._isRecursive = isCheckedOrNot(IDD_FINDINFILES_RECURSIVE_CHECK);
|
_options._isRecursive = isCheckedOrNot(IDD_FINDINFILES_RECURSIVE_CHECK);
|
||||||
_options._isInHiddenDir = isCheckedOrNot(IDD_FINDINFILES_INHIDDENDIR_CHECK);
|
_options._isInHiddenDir = isCheckedOrNot(IDD_FINDINFILES_INHIDDENDIR_CHECK);
|
||||||
_options._isProjectPanel_1 = isCheckedOrNot(IDD_FINDINFILES_PROJECT1_CHECK);
|
_options._isProjectPanel_1 = isCheckedOrNot(IDD_FINDINFILES_PROJECT1_CHECK);
|
||||||
|
@ -3477,7 +3491,7 @@ void FindInFinderDlg::doDialog(Finder *launcher, bool isRTL)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_FINDINFINDER_DLG), _hParent, dlgProc, reinterpret_cast<LPARAM>(this));
|
::DialogBoxParam(_hInst, MAKEINTRESOURCE(IDD_FINDINFINDER_DLG), _hParent, dlgProc, reinterpret_cast<LPARAM>(this));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindReplaceDlg::doDialog(DIALOG_TYPE whichType, bool isRTL, bool toShow)
|
void FindReplaceDlg::doDialog(DIALOG_TYPE whichType, bool isRTL, bool toShow)
|
||||||
|
@ -3498,7 +3512,7 @@ void FindReplaceDlg::doDialog(DIALOG_TYPE whichType, bool isRTL, bool toShow)
|
||||||
enableReplaceFunc(whichType == REPLACE_DLG);
|
enableReplaceFunc(whichType == REPLACE_DLG);
|
||||||
|
|
||||||
::SetFocus(::GetDlgItem(_hSelf, IDFINDWHAT));
|
::SetFocus(::GetDlgItem(_hSelf, IDFINDWHAT));
|
||||||
display(toShow, true);
|
display(toShow, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT FAR PASCAL FindReplaceDlg::finderProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
LRESULT FAR PASCAL FindReplaceDlg::finderProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
|
@ -3620,43 +3634,43 @@ void FindReplaceDlg::combo2ExtendedMode(int comboID)
|
||||||
{
|
{
|
||||||
HWND hFindCombo = ::GetDlgItem(_hSelf, comboID);
|
HWND hFindCombo = ::GetDlgItem(_hSelf, comboID);
|
||||||
if (!hFindCombo) return;
|
if (!hFindCombo) return;
|
||||||
|
|
||||||
generic_string str2transform = getTextFromCombo(hFindCombo);
|
|
||||||
|
|
||||||
// Count the number of character '\n' and '\r'
|
|
||||||
size_t nbEOL = 0;
|
|
||||||
size_t str2transformLen = lstrlen(str2transform.c_str());
|
|
||||||
for (size_t i = 0 ; i < str2transformLen ; ++i)
|
|
||||||
{
|
|
||||||
if (str2transform[i] == '\r' || str2transform[i] == '\n')
|
|
||||||
++nbEOL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (nbEOL)
|
generic_string str2transform = getTextFromCombo(hFindCombo);
|
||||||
{
|
|
||||||
|
// Count the number of character '\n' and '\r'
|
||||||
|
size_t nbEOL = 0;
|
||||||
|
size_t str2transformLen = lstrlen(str2transform.c_str());
|
||||||
|
for (size_t i = 0 ; i < str2transformLen ; ++i)
|
||||||
|
{
|
||||||
|
if (str2transform[i] == '\r' || str2transform[i] == '\n')
|
||||||
|
++nbEOL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nbEOL)
|
||||||
|
{
|
||||||
TCHAR * newBuffer = new TCHAR[str2transformLen + nbEOL*2 + 1];
|
TCHAR * newBuffer = new TCHAR[str2transformLen + nbEOL*2 + 1];
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (size_t i = 0 ; i < str2transformLen ; ++i)
|
for (size_t i = 0 ; i < str2transformLen ; ++i)
|
||||||
{
|
{
|
||||||
if (str2transform[i] == '\r')
|
if (str2transform[i] == '\r')
|
||||||
{
|
{
|
||||||
newBuffer[j++] = '\\';
|
newBuffer[j++] = '\\';
|
||||||
newBuffer[j++] = 'r';
|
newBuffer[j++] = 'r';
|
||||||
}
|
}
|
||||||
else if (str2transform[i] == '\n')
|
else if (str2transform[i] == '\n')
|
||||||
{
|
{
|
||||||
newBuffer[j++] = '\\';
|
newBuffer[j++] = '\\';
|
||||||
newBuffer[j++] = 'n';
|
newBuffer[j++] = 'n';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newBuffer[j++] = str2transform[i];
|
newBuffer[j++] = str2transform[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newBuffer[j++] = '\0';
|
newBuffer[j++] = '\0';
|
||||||
setSearchText(newBuffer);
|
setSearchText(newBuffer);
|
||||||
|
|
||||||
_options._searchType = FindExtended;
|
_options._searchType = FindExtended;
|
||||||
::SendDlgItemMessage(_hSelf, IDNORMAL, BM_SETCHECK, FALSE, 0);
|
::SendDlgItemMessage(_hSelf, IDNORMAL, BM_SETCHECK, FALSE, 0);
|
||||||
::SendDlgItemMessage(_hSelf, IDEXTENDED, BM_SETCHECK, TRUE, 0);
|
::SendDlgItemMessage(_hSelf, IDEXTENDED, BM_SETCHECK, TRUE, 0);
|
||||||
::SendDlgItemMessage(_hSelf, IDREGEXP, BM_SETCHECK, FALSE, 0);
|
::SendDlgItemMessage(_hSelf, IDREGEXP, BM_SETCHECK, FALSE, 0);
|
||||||
|
@ -3705,7 +3719,7 @@ void FindReplaceDlg::drawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
|
||||||
fgColor = RGB(0x50, 0xFF, 0x50); // green
|
fgColor = RGB(0x50, 0xFF, 0x50); // green
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetTextColor(lpDrawItemStruct->hDC, fgColor);
|
SetTextColor(lpDrawItemStruct->hDC, fgColor);
|
||||||
|
|
||||||
COLORREF bgColor;
|
COLORREF bgColor;
|
||||||
|
@ -3928,7 +3942,7 @@ void Finder::addSearchHitCount(int count, int countSearched, bool isMatchLines,
|
||||||
fileOrSelection += TEXT("s");
|
fileOrSelection += TEXT("s");
|
||||||
}
|
}
|
||||||
|
|
||||||
text = TEXT("(") + nbResStr + TEXT(" ") + hitsIn + TEXT(" in ") + nbFoundFilesStr + TEXT(" ") +
|
text = TEXT("(") + nbResStr + TEXT(" ") + hitsIn + TEXT(" in ") + nbFoundFilesStr + TEXT(" ") +
|
||||||
fileOrSelection + TEXT(" of ") + nbSearchedFilesStr + TEXT(" searched") TEXT(")");
|
fileOrSelection + TEXT(" of ") + nbSearchedFilesStr + TEXT(" searched") TEXT(")");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3988,7 +4002,7 @@ void Finder::add(FoundInfo fi, SearchResultMarking mi, const TCHAR* foundline)
|
||||||
_pMainMarkings->push_back(mi);
|
_pMainMarkings->push_back(mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Finder::removeAll()
|
void Finder::removeAll()
|
||||||
{
|
{
|
||||||
_pMainFoundInfos->clear();
|
_pMainFoundInfos->clear();
|
||||||
_pMainMarkings->clear();
|
_pMainMarkings->clear();
|
||||||
|
@ -4128,7 +4142,7 @@ void Finder::beginNewFilesSearch()
|
||||||
NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
|
NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker();
|
||||||
_prefixLineStr = pNativeSpeaker->getLocalizedStrFromID("find-result-line-prefix", TEXT("Line"));
|
_prefixLineStr = pNativeSpeaker->getLocalizedStrFromID("find-result-line-prefix", TEXT("Line"));
|
||||||
|
|
||||||
// Use SCI_SETSEL(0, 0) instead of SCI_SETCURRENTPOS(0) to workaround
|
// Use SCI_SETSEL(0, 0) instead of SCI_SETCURRENTPOS(0) to workaround
|
||||||
// an eventual regression or a change of behaviour in Scintilla 4.4.6
|
// an eventual regression or a change of behaviour in Scintilla 4.4.6
|
||||||
// ref: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/9595#issuecomment-789824579
|
// ref: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/9595#issuecomment-789824579
|
||||||
//
|
//
|
||||||
|
@ -4149,14 +4163,14 @@ void Finder::finishFilesSearch(int count, int searchedCount, bool isMatchLines,
|
||||||
std::vector<SearchResultMarking>* _pOldMarkings;
|
std::vector<SearchResultMarking>* _pOldMarkings;
|
||||||
_pOldFoundInfos = _pMainFoundInfos == &_foundInfos1 ? &_foundInfos2 : &_foundInfos1;
|
_pOldFoundInfos = _pMainFoundInfos == &_foundInfos1 ? &_foundInfos2 : &_foundInfos1;
|
||||||
_pOldMarkings = _pMainMarkings == &_markings1 ? &_markings2 : &_markings1;
|
_pOldMarkings = _pMainMarkings == &_markings1 ? &_markings2 : &_markings1;
|
||||||
|
|
||||||
_pOldFoundInfos->insert(_pOldFoundInfos->begin(), _pMainFoundInfos->begin(), _pMainFoundInfos->end());
|
_pOldFoundInfos->insert(_pOldFoundInfos->begin(), _pMainFoundInfos->begin(), _pMainFoundInfos->end());
|
||||||
_pOldMarkings->insert(_pOldMarkings->begin(), _pMainMarkings->begin(), _pMainMarkings->end());
|
_pOldMarkings->insert(_pOldMarkings->begin(), _pMainMarkings->begin(), _pMainMarkings->end());
|
||||||
_pMainFoundInfos->clear();
|
_pMainFoundInfos->clear();
|
||||||
_pMainMarkings->clear();
|
_pMainMarkings->clear();
|
||||||
_pMainFoundInfos = _pOldFoundInfos;
|
_pMainFoundInfos = _pOldFoundInfos;
|
||||||
_pMainMarkings = _pOldMarkings;
|
_pMainMarkings = _pOldMarkings;
|
||||||
|
|
||||||
_markingsStruct._length = static_cast<long>(_pMainMarkings->size());
|
_markingsStruct._length = static_cast<long>(_pMainMarkings->size());
|
||||||
if (_pMainMarkings->size() > 0)
|
if (_pMainMarkings->size() > 0)
|
||||||
_markingsStruct._markings = &((*_pMainMarkings)[0]);
|
_markingsStruct._markings = &((*_pMainMarkings)[0]);
|
||||||
|
@ -4173,7 +4187,7 @@ void Finder::setFinderStyle()
|
||||||
{
|
{
|
||||||
// Set global styles for the finder
|
// Set global styles for the finder
|
||||||
_scintView.performGlobalStyles();
|
_scintView.performGlobalStyles();
|
||||||
|
|
||||||
// Set current line background color for the finder
|
// Set current line background color for the finder
|
||||||
const TCHAR * lexerName = ScintillaEditView::langNames[L_SEARCHRESULT].lexerName;
|
const TCHAR * lexerName = ScintillaEditView::langNames[L_SEARCHRESULT].lexerName;
|
||||||
LexerStyler *pStyler = (NppParameters::getInstance().getLStylerArray()).getLexerStylerByName(lexerName);
|
LexerStyler *pStyler = (NppParameters::getInstance().getLStylerArray()).getLexerStylerByName(lexerName);
|
||||||
|
@ -4187,14 +4201,14 @@ void Finder::setFinderStyle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_scintView.setSearchResultLexer();
|
_scintView.setSearchResultLexer();
|
||||||
|
|
||||||
// Override foreground & background colour by default foreground & background coulour
|
// Override foreground & background colour by default foreground & background coulour
|
||||||
StyleArray & stylers = NppParameters::getInstance().getMiscStylerArray();
|
StyleArray & stylers = NppParameters::getInstance().getMiscStylerArray();
|
||||||
int iStyleDefault = stylers.getStylerIndexByID(STYLE_DEFAULT);
|
int iStyleDefault = stylers.getStylerIndexByID(STYLE_DEFAULT);
|
||||||
if (iStyleDefault != -1)
|
if (iStyleDefault != -1)
|
||||||
{
|
{
|
||||||
Style & styleDefault = stylers.getStyler(iStyleDefault);
|
Style & styleDefault = stylers.getStyler(iStyleDefault);
|
||||||
_scintView.setStyle(styleDefault);
|
_scintView.setStyle(styleDefault);
|
||||||
|
|
||||||
GlobalOverride & go = NppParameters::getInstance().getGlobalOverrideStyle();
|
GlobalOverride & go = NppParameters::getInstance().getGlobalOverrideStyle();
|
||||||
if (go.isEnable())
|
if (go.isEnable())
|
||||||
|
@ -4216,7 +4230,7 @@ void Finder::setFinderStyle()
|
||||||
|
|
||||||
_scintView.execute(SCI_STYLESETFORE, SCE_SEARCHRESULT_DEFAULT, styleDefault._fgColor);
|
_scintView.execute(SCI_STYLESETFORE, SCE_SEARCHRESULT_DEFAULT, styleDefault._fgColor);
|
||||||
_scintView.execute(SCI_STYLESETBACK, SCE_SEARCHRESULT_DEFAULT, styleDefault._bgColor);
|
_scintView.execute(SCI_STYLESETBACK, SCE_SEARCHRESULT_DEFAULT, styleDefault._bgColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
_scintView.execute(SCI_COLOURISE, 0, -1);
|
_scintView.execute(SCI_COLOURISE, 0, -1);
|
||||||
|
|
||||||
|
@ -4227,9 +4241,9 @@ void Finder::setFinderStyle()
|
||||||
|
|
||||||
INT_PTR CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
INT_PTR CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
{
|
{
|
||||||
switch (message)
|
switch (message)
|
||||||
{
|
{
|
||||||
case WM_COMMAND :
|
case WM_COMMAND :
|
||||||
{
|
{
|
||||||
switch (wParam)
|
switch (wParam)
|
||||||
{
|
{
|
||||||
|
@ -4316,7 +4330,7 @@ INT_PTR CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_CONTEXTMENU :
|
case WM_CONTEXTMENU :
|
||||||
{
|
{
|
||||||
if (HWND(wParam) == _scintView.getHSelf())
|
if (HWND(wParam) == _scintView.getHSelf())
|
||||||
|
@ -4368,7 +4382,7 @@ INT_PTR CALLBACK Finder::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
scintillaContextmenu.enableItem(NPPM_INTERNAL_SCINTILLAFINDERCOPYVERBATIM, hasSomeSelectedText);
|
scintillaContextmenu.enableItem(NPPM_INTERNAL_SCINTILLAFINDERCOPYVERBATIM, hasSomeSelectedText);
|
||||||
|
|
||||||
scintillaContextmenu.enableItem(NPPM_INTERNAL_SCINTILLAFINDERCLEARALL, !_canBeVolatiled);
|
scintillaContextmenu.enableItem(NPPM_INTERNAL_SCINTILLAFINDERCLEARALL, !_canBeVolatiled);
|
||||||
|
|
||||||
scintillaContextmenu.enableItem(NPPM_INTERNAL_SCINTILLAFINDERPURGE, !_canBeVolatiled);
|
scintillaContextmenu.enableItem(NPPM_INTERNAL_SCINTILLAFINDERPURGE, !_canBeVolatiled);
|
||||||
scintillaContextmenu.checkItem(NPPM_INTERNAL_SCINTILLAFINDERPURGE, _purgeBeforeEverySearch && !_canBeVolatiled);
|
scintillaContextmenu.checkItem(NPPM_INTERNAL_SCINTILLAFINDERPURGE, _purgeBeforeEverySearch && !_canBeVolatiled);
|
||||||
|
|
||||||
|
@ -4412,7 +4426,7 @@ void FindIncrementDlg::init(HINSTANCE hInst, HWND hPere, FindReplaceDlg *pFRDlg,
|
||||||
|
|
||||||
void FindIncrementDlg::destroy()
|
void FindIncrementDlg::destroy()
|
||||||
{
|
{
|
||||||
if (_pRebar)
|
if (_pRebar)
|
||||||
{
|
{
|
||||||
_pRebar->removeBand(_rbBand.wID);
|
_pRebar->removeBand(_rbBand.wID);
|
||||||
_pRebar = NULL;
|
_pRebar = NULL;
|
||||||
|
@ -4442,19 +4456,17 @@ INT_PTR CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
|
||||||
// Make edit field red if not found
|
// Make edit field red if not found
|
||||||
case WM_CTLCOLOREDIT :
|
case WM_CTLCOLOREDIT :
|
||||||
{
|
{
|
||||||
|
auto hdc = reinterpret_cast<HDC>(wParam);
|
||||||
|
|
||||||
if (NppDarkMode::isEnabled())
|
if (NppDarkMode::isEnabled())
|
||||||
{
|
{
|
||||||
if (FSNotFound != getFindStatus())
|
if (FSNotFound != getFindStatus())
|
||||||
{
|
{
|
||||||
SetTextColor((HDC)wParam, NppDarkMode::getTextColor());
|
return NppDarkMode::onCtlColorSofter(hdc);
|
||||||
SetBkColor((HDC)wParam, NppDarkMode::getBackgroundColor());
|
|
||||||
return (LRESULT)NppDarkMode::getBackgroundBrush();
|
|
||||||
}
|
}
|
||||||
else // text not found
|
else // text not found
|
||||||
{
|
{
|
||||||
SetTextColor((HDC)wParam, NppDarkMode::getTextColor());
|
return NppDarkMode::onCtlColorError(hdc);
|
||||||
SetBkColor((HDC)wParam, NppDarkMode::getErrorBackgroundColor());
|
|
||||||
return (LRESULT)NppDarkMode::getErrorBackgroundBrush();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4465,9 +4477,9 @@ INT_PTR CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
|
||||||
return FALSE; // text found, use the default color
|
return FALSE; // text found, use the default color
|
||||||
|
|
||||||
// text not found
|
// text not found
|
||||||
SetTextColor((HDC)wParam, TXT_COLOR);
|
SetTextColor(hdc, TXT_COLOR);
|
||||||
SetBkColor((HDC)wParam, BCKGRD_COLOR);
|
SetBkColor(hdc, BCKGRD_COLOR);
|
||||||
return (LRESULT)hBrushBackground;
|
return reinterpret_cast<LRESULT>(hBrushBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_CTLCOLORDLG:
|
case WM_CTLCOLORDLG:
|
||||||
|
@ -4478,9 +4490,7 @@ INT_PTR CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
|
||||||
return DefWindowProc(getHSelf(), message, wParam, lParam);
|
return DefWindowProc(getHSelf(), message, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetTextColor((HDC)wParam, NppDarkMode::getTextColor());
|
return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
|
||||||
SetBkColor((HDC)wParam, NppDarkMode::getBackgroundColor());
|
|
||||||
return (LRESULT)NppDarkMode::getBackgroundBrush();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case NPPM_INTERNAL_REFRESHDARKMODE:
|
case NPPM_INTERNAL_REFRESHDARKMODE:
|
||||||
|
@ -4497,7 +4507,7 @@ INT_PTR CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
|
||||||
return lr;
|
return lr;
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_COMMAND :
|
case WM_COMMAND :
|
||||||
{
|
{
|
||||||
bool updateSearch = false;
|
bool updateSearch = false;
|
||||||
bool forward = true;
|
bool forward = true;
|
||||||
|
@ -4568,7 +4578,7 @@ INT_PTR CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
|
||||||
{
|
{
|
||||||
FindStatus findStatus = FSFound;
|
FindStatus findStatus = FSFound;
|
||||||
bool isFound = _pFRDlg->processFindNext(str2Search.c_str(), &fo, &findStatus);
|
bool isFound = _pFRDlg->processFindNext(str2Search.c_str(), &fo, &findStatus);
|
||||||
|
|
||||||
fo._str2Search = str2Search;
|
fo._str2Search = str2Search;
|
||||||
int nbCounted = _pFRDlg->processAll(ProcessCountAll, &fo);
|
int nbCounted = _pFRDlg->processAll(ProcessCountAll, &fo);
|
||||||
setFindStatus(findStatus, nbCounted);
|
setFindStatus(findStatus, nbCounted);
|
||||||
|
@ -4594,7 +4604,7 @@ INT_PTR CALLBACK FindIncrementDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
|
||||||
|
|
||||||
case WM_ERASEBKGND:
|
case WM_ERASEBKGND:
|
||||||
{
|
{
|
||||||
if (NppDarkMode::isEnabled())
|
if (NppDarkMode::isEnabled())
|
||||||
{
|
{
|
||||||
RECT rcClient = { 0 };
|
RECT rcClient = { 0 };
|
||||||
GetClientRect(_hSelf, &rcClient);
|
GetClientRect(_hSelf, &rcClient);
|
||||||
|
@ -4642,9 +4652,9 @@ void FindIncrementDlg::setFindStatus(FindStatus iStatus, int nbCounted)
|
||||||
{
|
{
|
||||||
static TCHAR findCount[128] = TEXT("");
|
static TCHAR findCount[128] = TEXT("");
|
||||||
static const TCHAR * const findStatus[] = { findCount, // FSFound
|
static const TCHAR * const findStatus[] = { findCount, // FSFound
|
||||||
TEXT("Phrase not found"), //FSNotFound
|
TEXT("Phrase not found"), //FSNotFound
|
||||||
TEXT("Reached top of page, continued from bottom"), // FSTopReached
|
TEXT("Reached top of page, continued from bottom"), // FSTopReached
|
||||||
TEXT("Reached end of page, continued from top")}; // FSEndReached
|
TEXT("Reached end of page, continued from top")}; // FSEndReached
|
||||||
if (nbCounted <= 0)
|
if (nbCounted <= 0)
|
||||||
findCount[0] = '\0';
|
findCount[0] = '\0';
|
||||||
else if (nbCounted == 1)
|
else if (nbCounted == 1)
|
||||||
|
@ -4665,7 +4675,7 @@ void FindIncrementDlg::setFindStatus(FindStatus iStatus, int nbCounted)
|
||||||
::SendDlgItemMessage(_hSelf, IDC_INCFINDSTATUS, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(findStatus[iStatus]));
|
::SendDlgItemMessage(_hSelf, IDC_INCFINDSTATUS, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(findStatus[iStatus]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindIncrementDlg::addToRebar(ReBar * rebar)
|
void FindIncrementDlg::addToRebar(ReBar * rebar)
|
||||||
{
|
{
|
||||||
if (_pRebar)
|
if (_pRebar)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -250,7 +250,7 @@ bool FunctionListPanel::serialize(const generic_string & outputFilename)
|
||||||
{
|
{
|
||||||
const TCHAR *fullFilePath = currentBuf->getFullPathName();
|
const TCHAR *fullFilePath = currentBuf->getFullPathName();
|
||||||
|
|
||||||
// Export function list from an existing file
|
// Export function list from an existing file
|
||||||
bool exportFuncntionList = (NppParameters::getInstance()).doFunctionListExport();
|
bool exportFuncntionList = (NppParameters::getInstance()).doFunctionListExport();
|
||||||
if (exportFuncntionList && ::PathFileExists(fullFilePath))
|
if (exportFuncntionList && ::PathFileExists(fullFilePath))
|
||||||
{
|
{
|
||||||
|
@ -363,7 +363,7 @@ void FunctionListPanel::reload()
|
||||||
}
|
}
|
||||||
|
|
||||||
HTREEITEM root = _treeView.getRoot();
|
HTREEITEM root = _treeView.getRoot();
|
||||||
|
|
||||||
if (root)
|
if (root)
|
||||||
{
|
{
|
||||||
currentBuf = (*_ppEditView)->getCurrentBuffer();
|
currentBuf = (*_ppEditView)->getCurrentBuffer();
|
||||||
|
@ -465,7 +465,7 @@ void FunctionListPanel::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **pp
|
||||||
{
|
{
|
||||||
DockingDlgInterface::init(hInst, hPere);
|
DockingDlgInterface::init(hInst, hPere);
|
||||||
_ppEditView = ppEditView;
|
_ppEditView = ppEditView;
|
||||||
|
|
||||||
generic_string funcListXmlPath = (NppParameters::getInstance()).getUserPath();
|
generic_string funcListXmlPath = (NppParameters::getInstance()).getUserPath();
|
||||||
PathAppend(funcListXmlPath, TEXT("functionList"));
|
PathAppend(funcListXmlPath, TEXT("functionList"));
|
||||||
|
|
||||||
|
@ -477,7 +477,7 @@ void FunctionListPanel::init(HINSTANCE hInst, HWND hPere, ScintillaEditView **pp
|
||||||
if (!doLocalConf)
|
if (!doLocalConf)
|
||||||
{
|
{
|
||||||
if (!PathFileExists(funcListXmlPath.c_str()))
|
if (!PathFileExists(funcListXmlPath.c_str()))
|
||||||
{
|
{
|
||||||
if (PathFileExists(funcListDefaultXmlPath.c_str()))
|
if (PathFileExists(funcListDefaultXmlPath.c_str()))
|
||||||
{
|
{
|
||||||
::CopyFile(funcListDefaultXmlPath.c_str(), funcListXmlPath.c_str(), TRUE);
|
::CopyFile(funcListDefaultXmlPath.c_str(), funcListXmlPath.c_str(), TRUE);
|
||||||
|
@ -769,24 +769,31 @@ INT_PTR CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPA
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto hdc = reinterpret_cast<HDC>(wParam);
|
||||||
|
|
||||||
|
if (NppDarkMode::isEnabled())
|
||||||
|
{
|
||||||
|
if (textFound)
|
||||||
|
{
|
||||||
|
return NppDarkMode::onCtlColorSofter(hdc);
|
||||||
|
}
|
||||||
|
else // text not found
|
||||||
|
{
|
||||||
|
return NppDarkMode::onCtlColorError(hdc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (textFound)
|
if (textFound)
|
||||||
{
|
{
|
||||||
if (NppDarkMode::isEnabled())
|
return FALSE;
|
||||||
{
|
|
||||||
SetTextColor((HDC)wParam, NppDarkMode::getTextColor());
|
|
||||||
SetBkColor((HDC)wParam, NppDarkMode::getBackgroundColor());
|
|
||||||
return (LRESULT)NppDarkMode::getBackgroundBrush();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// text not found
|
// text not found
|
||||||
// if the text not found modify the background color of the editor
|
// if the text not found modify the background color of the editor
|
||||||
static HBRUSH hBrushBackground = CreateSolidBrush(BCKGRD_COLOR);
|
static HBRUSH hBrushBackground = CreateSolidBrush(BCKGRD_COLOR);
|
||||||
SetTextColor((HDC)wParam, TXT_COLOR);
|
SetTextColor(hdc, TXT_COLOR);
|
||||||
SetBkColor((HDC)wParam, BCKGRD_COLOR);
|
SetBkColor(hdc, BCKGRD_COLOR);
|
||||||
return (LRESULT)hBrushBackground;
|
return reinterpret_cast<LRESULT>(hBrushBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
case WM_INITDIALOG :
|
case WM_INITDIALOG :
|
||||||
|
@ -798,7 +805,7 @@ INT_PTR CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPA
|
||||||
// Create toolbar menu
|
// Create toolbar menu
|
||||||
int style = WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | BTNS_AUTOSIZE | BTNS_SEP | TBSTYLE_TOOLTIPS;
|
int style = WS_CHILD | WS_VISIBLE | CCS_ADJUSTABLE | TBSTYLE_AUTOSIZE | TBSTYLE_FLAT | TBSTYLE_LIST | TBSTYLE_TRANSPARENT | BTNS_AUTOSIZE | BTNS_SEP | TBSTYLE_TOOLTIPS;
|
||||||
_hToolbarMenu = CreateWindowEx(0,TOOLBARCLASSNAME,NULL, style,
|
_hToolbarMenu = CreateWindowEx(0,TOOLBARCLASSNAME,NULL, style,
|
||||||
0,0,0,0,_hSelf,nullptr, _hInst, NULL);
|
0,0,0,0,_hSelf,nullptr, _hInst, NULL);
|
||||||
|
|
||||||
NppDarkMode::setDarkTooltips(_hToolbarMenu, NppDarkMode::ToolTipsType::toolbar);
|
NppDarkMode::setDarkTooltips(_hToolbarMenu, NppDarkMode::ToolTipsType::toolbar);
|
||||||
NppDarkMode::setDarkLineAbovePanelToolbar(_hToolbarMenu);
|
NppDarkMode::setDarkLineAbovePanelToolbar(_hToolbarMenu);
|
||||||
|
@ -845,9 +852,9 @@ INT_PTR CALLBACK FunctionListPanel::run_dlgProc(UINT message, WPARAM wParam, LPA
|
||||||
_reloadTipStr = pNativeSpeaker->getAttrNameStr(_reloadTipStr.c_str(), FL_FUCTIONLISTROOTNODE, FL_RELOADLOCALNODENAME);
|
_reloadTipStr = pNativeSpeaker->getAttrNameStr(_reloadTipStr.c_str(), FL_FUCTIONLISTROOTNODE, FL_RELOADLOCALNODENAME);
|
||||||
|
|
||||||
_hSearchEdit = CreateWindowEx(0, L"Edit", NULL,
|
_hSearchEdit = CreateWindowEx(0, L"Edit", NULL,
|
||||||
WS_CHILD | WS_BORDER | WS_VISIBLE | ES_AUTOVSCROLL,
|
WS_CHILD | WS_BORDER | WS_VISIBLE | ES_AUTOVSCROLL,
|
||||||
2, 2, editWidth, editHeight,
|
2, 2, editWidth, editHeight,
|
||||||
_hToolbarMenu, reinterpret_cast<HMENU>(IDC_SEARCHFIELD_FUNCLIST), _hInst, 0 );
|
_hToolbarMenu, reinterpret_cast<HMENU>(IDC_SEARCHFIELD_FUNCLIST), _hInst, 0 );
|
||||||
|
|
||||||
oldFunclstSearchEditProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSearchEdit, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(funclstSearchEditProc)));
|
oldFunclstSearchEditProc = reinterpret_cast<WNDPROC>(::SetWindowLongPtr(_hSearchEdit, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(funclstSearchEditProc)));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue