Enhance Run Macro dialog
- reorder tab focus. - add key accelerators. - optimize dark mode. fix #13544, close #13545
This commit is contained in:
parent
1a1ce04caa
commit
87e34c1f7b
|
@ -1265,7 +1265,7 @@ You can define several column markers by using white space to separate the diffe
|
|||
<MultiMacro title="Run a Macro Multiple Times">
|
||||
<Item id="1" name="&Run"/>
|
||||
<Item id="2" name="&Cancel"/>
|
||||
<Item id="8006" name="Macro to run :"/>
|
||||
<Item id="8006" name="Macro to run"/>
|
||||
<Item id="8001" name="Run"/>
|
||||
<Item id="8005" name="times"/>
|
||||
<Item id="8002" name="Run until the &end of file"/>
|
||||
|
|
|
@ -1260,7 +1260,7 @@ You can define several column markers by using white space to separate the diffe
|
|||
<MultiMacro title="Run a Macro Multiple Times">
|
||||
<Item id="1" name="&Run"/>
|
||||
<Item id="2" name="&Cancel"/>
|
||||
<Item id="8006" name="Macro to run :"/>
|
||||
<Item id="8006" name="Macro to run"/>
|
||||
<Item id="8001" name="Run"/>
|
||||
<Item id="8005" name="times"/>
|
||||
<Item id="8002" name="Run until the &end of file"/>
|
||||
|
|
|
@ -1463,13 +1463,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
{
|
||||
if (!_recordingMacro) // if we're not currently recording, then playback the recorded keystrokes
|
||||
{
|
||||
int times = 1;
|
||||
if (_runMacroDlg.getMode() == RM_RUN_MULTI)
|
||||
times = _runMacroDlg.getTimes();
|
||||
else if (_runMacroDlg.getMode() == RM_RUN_EOF)
|
||||
times = -1;
|
||||
else
|
||||
break;
|
||||
int times = _runMacroDlg.isMulti() ? _runMacroDlg.getTimes() : -1;
|
||||
|
||||
int counter = 0;
|
||||
intptr_t lastLine = _pEditView->execute(SCI_GETLINECOUNT) - 1;
|
||||
|
|
|
@ -40,9 +40,9 @@ void RunMacroDlg::initMacroList()
|
|||
_macroIndex = 0;
|
||||
}
|
||||
|
||||
intptr_t CALLBACK RunMacroDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
|
||||
intptr_t CALLBACK RunMacroDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG :
|
||||
{
|
||||
|
@ -50,47 +50,42 @@ intptr_t CALLBACK RunMacroDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
|
|||
|
||||
initMacroList();
|
||||
::SetDlgItemInt(_hSelf, IDC_M_RUN_TIMES, _times, FALSE);
|
||||
switch (_mode)
|
||||
{
|
||||
case RM_RUN_MULTI:
|
||||
check(IDC_M_RUN_MULTI);
|
||||
break;
|
||||
case RM_RUN_EOF:
|
||||
check(IDC_M_RUN_EOF);
|
||||
break;
|
||||
}
|
||||
setChecked(IDC_M_RUN_MULTI);
|
||||
|
||||
::SendDlgItemMessage(_hSelf, IDC_M_RUN_TIMES, EM_LIMITTEXT, 4, 0);
|
||||
goToCenter();
|
||||
goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_CTLCOLOREDIT:
|
||||
{
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
|
||||
}
|
||||
break;
|
||||
return NppDarkMode::onCtlColorSofter(reinterpret_cast<HDC>(wParam));
|
||||
}
|
||||
|
||||
case WM_CTLCOLORLISTBOX:
|
||||
{
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
return NppDarkMode::onCtlColor(reinterpret_cast<HDC>(wParam));
|
||||
}
|
||||
break;
|
||||
return NppDarkMode::onCtlColorListbox(wParam, lParam);
|
||||
}
|
||||
|
||||
case WM_CTLCOLORDLG:
|
||||
{
|
||||
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
|
||||
}
|
||||
|
||||
case WM_CTLCOLORSTATIC:
|
||||
{
|
||||
if (NppDarkMode::isEnabled())
|
||||
auto hdcStatic = reinterpret_cast<HDC>(wParam);
|
||||
const auto dlgCtrlID = ::GetDlgCtrlID(reinterpret_cast<HWND>(lParam));
|
||||
|
||||
const bool isStaticText = (dlgCtrlID == IDC_TIMES_STATIC);
|
||||
//set the static text colors to show enable/disable instead of ::EnableWindow which causes blurry text
|
||||
if (isStaticText)
|
||||
{
|
||||
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
|
||||
const bool isTextEnabled = isCheckedOrNot(IDC_M_RUN_MULTI);
|
||||
return NppDarkMode::onCtlColorDarkerBGStaticText(hdcStatic, isTextEnabled);
|
||||
}
|
||||
break;
|
||||
return NppDarkMode::onCtlColorDarker(hdcStatic);
|
||||
}
|
||||
|
||||
case WM_PRINTCLIENT:
|
||||
|
@ -108,39 +103,34 @@ intptr_t CALLBACK RunMacroDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
case WM_COMMAND :
|
||||
case WM_COMMAND:
|
||||
{
|
||||
if (HIWORD(wParam) == EN_CHANGE)
|
||||
{
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_M_RUN_TIMES:
|
||||
check(IDC_M_RUN_MULTI);
|
||||
return TRUE;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
switch (wParam)
|
||||
{
|
||||
case IDCANCEL :
|
||||
case IDC_M_RUN_MULTI:
|
||||
case IDC_M_RUN_EOF:
|
||||
{
|
||||
const bool isMulti = (wParam == IDC_M_RUN_MULTI);
|
||||
if (isMulti)
|
||||
{
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_M_RUN_TIMES), TRUE);
|
||||
_times = ::GetDlgItemInt(_hSelf, IDC_M_RUN_TIMES, NULL, FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
::EnableWindow(::GetDlgItem(_hSelf, IDC_M_RUN_TIMES), FALSE);
|
||||
}
|
||||
redrawDlgItem(IDC_TIMES_STATIC);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
case IDCANCEL:
|
||||
::ShowWindow(_hSelf, SW_HIDE);
|
||||
return TRUE;
|
||||
|
||||
case IDOK :
|
||||
if ( isCheckedOrNot(IDC_M_RUN_MULTI) )
|
||||
{
|
||||
_mode = RM_RUN_MULTI;
|
||||
_times = ::GetDlgItemInt(_hSelf, IDC_M_RUN_TIMES, NULL, FALSE);
|
||||
}
|
||||
else if ( isCheckedOrNot(IDC_M_RUN_EOF) )
|
||||
{
|
||||
_mode = RM_RUN_EOF;
|
||||
}
|
||||
|
||||
if (::SendDlgItemMessage(_hSelf, IDC_MACRO_COMBO, CB_GETCOUNT, 0, 0))
|
||||
case IDOK:
|
||||
if (::SendDlgItemMessage(_hSelf, IDC_MACRO_COMBO, CB_GETCOUNT, 0, 0) > 0)
|
||||
::SendMessage(_hParent, WM_MACRODLGRUNMACRO, 0, 0);
|
||||
|
||||
return TRUE;
|
||||
|
@ -157,21 +147,6 @@ intptr_t CALLBACK RunMacroDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void RunMacroDlg::check(int id)
|
||||
{
|
||||
// IDC_M_RUN_MULTI
|
||||
if ( id == IDC_M_RUN_MULTI )
|
||||
::SendDlgItemMessage(_hSelf, IDC_M_RUN_MULTI, BM_SETCHECK, BST_CHECKED, 0);
|
||||
else
|
||||
::SendDlgItemMessage(_hSelf, IDC_M_RUN_MULTI, BM_SETCHECK, BST_UNCHECKED, 0);
|
||||
|
||||
// IDC_M_RUN_EOF
|
||||
if ( id == IDC_M_RUN_EOF )
|
||||
::SendDlgItemMessage(_hSelf, IDC_M_RUN_EOF, BM_SETCHECK, BST_CHECKED, 0);
|
||||
else
|
||||
::SendDlgItemMessage(_hSelf, IDC_M_RUN_EOF, BM_SETCHECK, BST_UNCHECKED, 0);
|
||||
}
|
||||
|
||||
int RunMacroDlg::getMacro2Exec() const
|
||||
{
|
||||
bool isCurMacroPresent = static_cast<MacroStatus>(::SendMessage(_hParent, NPPM_GETCURRENTMACROSTATUS, 0, 0)) == MacroStatus::RecordingStopped;
|
||||
|
|
|
@ -21,20 +21,12 @@
|
|||
#include "RunMacroDlg_rc.h"
|
||||
#include "StaticDialog.h"
|
||||
|
||||
#define RM_CANCEL -1
|
||||
#define RM_RUN_MULTI 1
|
||||
#define RM_RUN_EOF 2
|
||||
|
||||
class RunMacroDlg : public StaticDialog
|
||||
{
|
||||
public :
|
||||
RunMacroDlg() = default;
|
||||
~RunMacroDlg() = default;
|
||||
|
||||
void init(HINSTANCE hInst, HWND hPere/*, ScintillaEditView **ppEditView*/) {
|
||||
Window::init(hInst, hPere);
|
||||
};
|
||||
|
||||
void doDialog(bool isRTL = false) {
|
||||
if (!isCreated())
|
||||
create(IDD_RUN_MACRO_DLG, isRTL);
|
||||
|
@ -49,15 +41,13 @@ public :
|
|||
|
||||
void initMacroList();
|
||||
|
||||
int getMode() const {return _mode;};
|
||||
int isMulti() const { return isCheckedOrNot(IDC_M_RUN_MULTI); };
|
||||
int getTimes() const {return _times;};
|
||||
int getMacro2Exec() const;
|
||||
|
||||
private :
|
||||
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
void check(int);
|
||||
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
|
||||
|
||||
int _mode = RM_RUN_MULTI;
|
||||
int _times = 1;
|
||||
int _macroIndex = 0;
|
||||
};
|
||||
|
|
|
@ -19,18 +19,22 @@
|
|||
#include <windows.h>
|
||||
#include "RunMacroDlg_rc.h"
|
||||
|
||||
IDD_RUN_MACRO_DLG DIALOGEX 0, 0, 168, 110
|
||||
IDD_RUN_MACRO_DLG DIALOGEX 0, 0, 168, 95
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
|
||||
CAPTION "Run a Macro Multiple Times"
|
||||
FONT 8, TEXT("MS Shell Dlg"), 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "&Run",IDOK,27,82,50,14
|
||||
PUSHBUTTON "&Cancel",IDCANCEL,91,82,50,14
|
||||
CONTROL "Run",IDC_M_RUN_MULTI,"Button",BS_AUTORADIOBUTTON,18,38,47,10
|
||||
CONTROL "Run until the &end of file", IDC_M_RUN_EOF,"Button", BS_AUTORADIOBUTTON,18,56,140,10
|
||||
EDITTEXT IDC_M_RUN_TIMES,67,35,25,14,ES_AUTOHSCROLL | ES_NUMBER | WS_EX_DLGMODALFRAME
|
||||
COMBOBOX IDC_MACRO_COMBO,67,10,96,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
RTEXT "Macro to run :",IDC_MACRO2RUN_STATIC,5,12,59,8
|
||||
LTEXT "times",IDC_TIMES_STATIC,97,38,65,8
|
||||
GROUPBOX "&Macro to run",IDC_MACRO2RUN_STATIC,7,3,154,30,BS_CENTER
|
||||
COMBOBOX IDC_MACRO_COMBO,14,14,140,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
|
||||
CONTROL "R&un",IDC_M_RUN_MULTI,"Button",BS_AUTORADIOBUTTON,18,42,47,10
|
||||
|
||||
CONTROL "Run until the &end of file", IDC_M_RUN_EOF,"Button",BS_AUTORADIOBUTTON,18,57,140,10
|
||||
|
||||
EDITTEXT IDC_M_RUN_TIMES,67,40,25,12, ES_CENTER | ES_AUTOHSCROLL | ES_NUMBER
|
||||
LTEXT "times",IDC_TIMES_STATIC,97,42,65,10
|
||||
|
||||
DEFPUSHBUTTON "&Run",IDOK,32,75,50,14
|
||||
PUSHBUTTON "&Cancel",IDCANCEL,86,75,50,14
|
||||
END
|
||||
|
|
Loading…
Reference in New Issue