GUI enhancement: Find Characters in Range dialog

- add accelerators
- add initializers

Fix #13577, close #13578
This commit is contained in:
ozone10 2023-04-23 13:49:42 +02:00 committed by Don Ho
parent 61d2d36821
commit 997ef821d1
7 changed files with 85 additions and 53 deletions

View File

@ -490,15 +490,15 @@ The comments are here for explanation, it's not necessary to translate them.
</IncrementalFind> </IncrementalFind>
<FindCharsInRange title="Find Characters in Range..."> <FindCharsInRange title="Find Characters in Range...">
<Item id="2" name="Close"/> <Item id="2" name="&amp;Close"/>
<Item id="2901" name="Non-ASCII Characters (128-255)"/> <Item id="2901" name="&amp;Non-ASCII characters (128255)"/>
<Item id="2902" name="ASCII Characters (0-127)"/> <Item id="2902" name="&amp;ASCII characters (0127)"/>
<Item id="2903" name="My range:"/> <Item id="2903" name="Custom &amp;range (0255):"/>
<Item id="2906" name="&amp;Up"/> <Item id="2906" name="&amp;Up"/>
<Item id="2907" name="&amp;Down"/> <Item id="2907" name="&amp;Down"/>
<Item id="2908" name="Direction"/> <Item id="2908" name="Direction"/>
<Item id="2909" name="Wra&amp;p around"/> <Item id="2909" name="Wra&amp;p around"/>
<Item id="2910" name="Find"/> <Item id="2910" name="&amp;Find"/>
</FindCharsInRange> </FindCharsInRange>
<GoToLine title="Go to..."> <GoToLine title="Go to...">

View File

@ -485,15 +485,15 @@ The comments are here for explanation, it's not necessary to translate them.
</IncrementalFind> </IncrementalFind>
<FindCharsInRange title="Find Characters in Range..."> <FindCharsInRange title="Find Characters in Range...">
<Item id="2" name="Close"/> <Item id="2" name="&amp;Close"/>
<Item id="2901" name="Non-ASCII Characters (128-255)"/> <Item id="2901" name="&amp;Non-ASCII characters (128255)"/>
<Item id="2902" name="ASCII Characters (0-127)"/> <Item id="2902" name="&amp;ASCII characters (0127)"/>
<Item id="2903" name="My range:"/> <Item id="2903" name="Custom &amp;range (0255):"/>
<Item id="2906" name="&amp;Up"/> <Item id="2906" name="&amp;Up"/>
<Item id="2907" name="&amp;Down"/> <Item id="2907" name="&amp;Down"/>
<Item id="2908" name="Direction"/> <Item id="2908" name="Direction"/>
<Item id="2909" name="Wra&amp;p around"/> <Item id="2909" name="Wra&amp;p around"/>
<Item id="2910" name="Find"/> <Item id="2910" name="&amp;Find"/>
</FindCharsInRange> </FindCharsInRange>
<GoToLine title="Go to..."> <GoToLine title="Go to...">

View File

@ -2160,7 +2160,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
// and defer any cleanup operations until it receives WM_ENDSESSION (with WPARAM TRUE) // and defer any cleanup operations until it receives WM_ENDSESSION (with WPARAM TRUE)
// for a bigger tidy-up/save operations we can kick off a background thread here to prepare for shutdown // for a bigger tidy-up/save operations we can kick off a background thread here to prepare for shutdown
// and when we get the WM_END­SESSION TRUE, we wait there until that background operation completes // and when we get the WM_ENDSESSION TRUE, we wait there until that background operation completes
// before telling the system, "ok, you can shut down now...", i.e. returning 0 there // before telling the system, "ok, you can shut down now...", i.e. returning 0 there
// whatever we do from here - make sure that it is ok for the operation to occur even if the shutdown // whatever we do from here - make sure that it is ok for the operation to occur even if the shutdown

View File

@ -20,11 +20,11 @@
#include "Parameters.h" #include "Parameters.h"
#include "localization.h" #include "localization.h"
intptr_t CALLBACK FindCharsInRangeDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) intptr_t CALLBACK FindCharsInRangeDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{ {
switch (message) switch (message)
{ {
case WM_INITDIALOG : case WM_INITDIALOG:
{ {
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf); NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
@ -32,27 +32,40 @@ intptr_t CALLBACK FindCharsInRangeDlg::run_dlgProc(UINT message, WPARAM wParam,
::SendDlgItemMessage(_hSelf, IDC_RANGEEND_EDIT, EM_LIMITTEXT, 3, 0); ::SendDlgItemMessage(_hSelf, IDC_RANGEEND_EDIT, EM_LIMITTEXT, 3, 0);
::SendDlgItemMessage(_hSelf, IDC_NONASCCI_RADIO, BM_SETCHECK, TRUE, 0); ::SendDlgItemMessage(_hSelf, IDC_NONASCCI_RADIO, BM_SETCHECK, TRUE, 0);
::SendDlgItemMessage(_hSelf, ID_FINDCHAR_DIRDOWN, BM_SETCHECK, TRUE, 0); ::SendDlgItemMessage(_hSelf, ID_FINDCHAR_DIRDOWN, BM_SETCHECK, TRUE, 0);
goToCenter();
::SetDlgItemInt(_hSelf, IDC_RANGESTART_EDIT, 0, FALSE);
::SetDlgItemInt(_hSelf, IDC_RANGEEND_EDIT, 255, FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_RANGESTART_EDIT), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_RANGEEND_EDIT), FALSE);
goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE);
return TRUE; return TRUE;
} }
case WM_CTLCOLOREDIT: case WM_CTLCOLOREDIT:
{ {
if (NppDarkMode::isEnabled()) return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
{
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
}
break;
} }
case WM_CTLCOLORDLG: case WM_CTLCOLORDLG:
{
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
}
case WM_CTLCOLORSTATIC: case WM_CTLCOLORSTATIC:
{ {
if (NppDarkMode::isEnabled()) const auto hdcStatic = reinterpret_cast<HDC>(wParam);
const auto dlgCtrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(lParam));
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
if (dlgCtrlID == IDC_STATIC)
{ {
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam)); const bool isTextEnabled = isCheckedOrNot(IDC_MYRANGE_RADIO);
return NppDarkMode::onCtlColorDarkerBGStaticText(hdcStatic, isTextEnabled);
} }
break; return NppDarkMode::onCtlColorDarker(hdcStatic);
} }
case WM_PRINTCLIENT: case WM_PRINTCLIENT:
@ -68,7 +81,7 @@ intptr_t CALLBACK FindCharsInRangeDlg::run_dlgProc(UINT message, WPARAM wParam,
{ {
if (NppDarkMode::isEnabled()) if (NppDarkMode::isEnabled())
{ {
RECT rc = {}; RECT rc{};
getClientRect(rc); getClientRect(rc);
::FillRect(reinterpret_cast<HDC>(wParam), &rc, NppDarkMode::getDarkerBackgroundBrush()); ::FillRect(reinterpret_cast<HDC>(wParam), &rc, NppDarkMode::getDarkerBackgroundBrush());
return TRUE; return TRUE;
@ -82,11 +95,30 @@ intptr_t CALLBACK FindCharsInRangeDlg::run_dlgProc(UINT message, WPARAM wParam,
return TRUE; return TRUE;
} }
case WM_COMMAND : case WM_COMMAND:
{ {
switch (wParam) switch (wParam)
{ {
case IDCANCEL : // Close case IDC_NONASCCI_RADIO:
case IDC_ASCCI_RADIO:
{
::EnableWindow(::GetDlgItem(_hSelf, IDC_RANGESTART_EDIT), FALSE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_RANGEEND_EDIT), FALSE);
redrawDlgItem(IDC_STATIC);
return TRUE;
}
case IDC_MYRANGE_RADIO:
{
::EnableWindow(::GetDlgItem(_hSelf, IDC_RANGESTART_EDIT), TRUE);
::EnableWindow(::GetDlgItem(_hSelf, IDC_RANGEEND_EDIT), TRUE);
redrawDlgItem(IDC_STATIC);
return TRUE;
}
case IDCANCEL: // Close
display(false); display(false);
return TRUE; return TRUE;
@ -204,7 +236,8 @@ bool FindCharsInRangeDlg::getRangeFromUI(unsigned char & startRange, unsigned ch
if (isCheckedOrNot(IDC_MYRANGE_RADIO)) if (isCheckedOrNot(IDC_MYRANGE_RADIO))
{ {
BOOL startBool, endBool; BOOL startBool = FALSE;
BOOL endBool = FALSE;
int start = ::GetDlgItemInt(_hSelf, IDC_RANGESTART_EDIT, &startBool, FALSE); int start = ::GetDlgItemInt(_hSelf, IDC_RANGESTART_EDIT, &startBool, FALSE);
int end = ::GetDlgItemInt(_hSelf, IDC_RANGEEND_EDIT, &endBool, FALSE); int end = ::GetDlgItemInt(_hSelf, IDC_RANGEEND_EDIT, &endBool, FALSE);

View File

@ -32,25 +32,21 @@ public :
_ppEditView = ppEditView; _ppEditView = ppEditView;
}; };
virtual void create(int dialogID, bool isRTL = false, bool msgDestParent = true) {
StaticDialog::create(dialogID, isRTL, msgDestParent);
};
void doDialog(bool isRTL = false) { void doDialog(bool isRTL = false) {
if (!isCreated()) if (!isCreated())
create(IDD_FINDCHARACTERS, isRTL); create(IDD_FINDCHARACTERS, isRTL);
display(); display();
}; };
virtual void display(bool toShow = true) const { void display(bool toShow = true) const override {
Window::display(toShow); Window::display(toShow);
}; };
protected : protected :
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
private : private :
ScintillaEditView **_ppEditView = nullptr; ScintillaEditView **_ppEditView = nullptr;
bool findCharInRange(unsigned char beginRange, unsigned char endRange, intptr_t startPos, bool direction, bool wrap); bool findCharInRange(unsigned char beginRange, unsigned char endRange, intptr_t startPos, bool direction, bool wrap);
bool getRangeFromUI(unsigned char & startRange, unsigned char & endRange); bool getRangeFromUI(unsigned char & startRange, unsigned char & endRange);
void getDirectionFromUI(bool & whichDirection, bool & isWrap); void getDirectionFromUI(bool & whichDirection, bool & isWrap);

View File

@ -14,26 +14,30 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#pragma code_page(65001)
#include <windows.h> #include <windows.h>
#include "findCharsInRange_rc.h" #include "findCharsInRange_rc.h"
IDD_FINDCHARACTERS DIALOGEX 26, 41, 263, 126 IDD_FINDCHARACTERS DIALOGEX 0, 0, 267, 99
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
CAPTION "Find Characters in Range..." CAPTION "Find Characters in Range..."
FONT 8, "MS Shell Dlg", 0, 0, 0x0 FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN BEGIN
CONTROL "Non-ASCII Characters (128-255)",IDC_NONASCCI_RADIO,"Button",BS_AUTORADIOBUTTON,22,13,146,10 CONTROL "&Non-ASCII characters (128255)",IDC_NONASCCI_RADIO,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,7,6,160,10
CONTROL "ASCII Characters (0 - 127)",IDC_ASCCI_RADIO,"Button",BS_AUTORADIOBUTTON,22,32,151,10 CONTROL "&ASCII characters (0127)",IDC_ASCCI_RADIO,"Button",BS_AUTORADIOBUTTON,7,21,160,10
CONTROL "My Range:",IDC_MYRANGE_RADIO,"Button",BS_AUTORADIOBUTTON,22,51,67,10 CONTROL "Custom &range (0255):",IDC_MYRANGE_RADIO,"Button",BS_AUTORADIOBUTTON,7,36,110,10
EDITTEXT IDC_RANGESTART_EDIT,91,49,25,14,ES_AUTOHSCROLL | ES_NUMBER EDITTEXT IDC_RANGESTART_EDIT,120,35,20,12,ES_AUTOHSCROLL | ES_CENTER | ES_NUMBER
LTEXT "-",IDC_STATIC,122,52,8,8 CTEXT "",IDC_STATIC,143,37,8,8
EDITTEXT IDC_RANGEEND_EDIT,129,49,25,14,ES_AUTOHSCROLL | ES_NUMBER EDITTEXT IDC_RANGEEND_EDIT,154,35,20,12,ES_AUTOHSCROLL | ES_CENTER | ES_NUMBER
CONTROL "&Up",ID_FINDCHAR_DIRUP,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,25,91,64,12
CONTROL "&Down",ID_FINDCHAR_DIRDOWN,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,25,103,63,12 GROUPBOX "Direction",IDC_FINDCHAR_DIR_STATIC,7,56,74,36,WS_GROUP
GROUPBOX "Direction",IDC_FINDCHAR_DIR_STATIC,19,79,74,42,WS_GROUP CONTROL "&Up",ID_FINDCHAR_DIRUP,"Button",BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,13,68,64,10
CONTROL "Wra&p around",ID_FINDCHAR_WRAP,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,105,102,110,15 CONTROL "&Down",ID_FINDCHAR_DIRDOWN,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,13,80,63,10
DEFPUSHBUTTON "Find",ID_FINDCHAR_NEXT,182,8,70,14,BS_NOTIFY
PUSHBUTTON "Close",IDCANCEL,181,27,70,14,BS_NOTIFY CONTROL "Wra&p around",ID_FINDCHAR_WRAP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,85,80,110,10
DEFPUSHBUTTON "&Find",ID_FINDCHAR_NEXT,190,6,70,14
PUSHBUTTON "&Close",IDCANCEL,190,24,70,14
END END

View File

@ -33,7 +33,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>4456;4457;4459</DisableSpecificWarnings> <DisableSpecificWarnings>4456;4457;4459</DisableSpecificWarnings>
<AdditionalOptions>/w15262 %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions>/Zc:__cplusplus /source-charset:utf-8 /Zc:strictStrings /w15262 %(AdditionalOptions)</AdditionalOptions>
<ConformanceMode>true</ConformanceMode> <ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard> <LanguageStandard>stdcpp20</LanguageStandard>
<TreatAngleIncludeAsExternal>true</TreatAngleIncludeAsExternal> <TreatAngleIncludeAsExternal>true</TreatAngleIncludeAsExternal>
@ -57,7 +57,7 @@
<ItemDefinitionGroup Condition="'$(PlatformToolset)'=='ClangCL'"> <ItemDefinitionGroup Condition="'$(PlatformToolset)'=='ClangCL'">
<ClCompile> <ClCompile>
<TreatWarningAsError>false</TreatWarningAsError> <TreatWarningAsError>false</TreatWarningAsError>
<AdditionalOptions>-Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-reserved-id-macro -Wno-pragma-pack -Wno-unknown-pragmas -Wno-unused-command-line-argument -Wno-overloaded-virtual %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions>-Wextra -Wimplicit-fallthrough -Wformat=2 -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-reserved-id-macro -Wno-pragma-pack -Wno-unknown-pragmas -Wno-unused-command-line-argument -Wno-overloaded-virtual %(AdditionalOptions)</AdditionalOptions>
</ClCompile> </ClCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'"> <ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
@ -66,7 +66,6 @@
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>UninitializedLocalUsageCheck</BasicRuntimeChecks> <BasicRuntimeChecks>UninitializedLocalUsageCheck</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<AdditionalOptions>/Zc:strictStrings %(AdditionalOptions)</AdditionalOptions>
</ClCompile> </ClCompile>
<Link> <Link>
<FixedBaseAddress>false</FixedBaseAddress> <FixedBaseAddress>false</FixedBaseAddress>
@ -77,7 +76,7 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile> <ClCompile>
<AdditionalOptions>/Zc:strictStrings /analyze:WX- %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions>/analyze:WX- %(AdditionalOptions)</AdditionalOptions>
<EnablePREfast>true</EnablePREfast> <EnablePREfast>true</EnablePREfast>
</ClCompile> </ClCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
@ -90,7 +89,7 @@
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalOptions>/Zc:strictStrings /Gw %(AdditionalOptions)</AdditionalOptions> <AdditionalOptions>/Gw /GA %(AdditionalOptions)</AdditionalOptions>
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
</ClCompile> </ClCompile>
<Link> <Link>