Skip to content

Commit 85fa8bf

Browse files
committed
Enhance Command Line Arguments dialog: smaller & more readable
1 parent 7a21c63 commit 85fa8bf

File tree

10 files changed

+154
-47
lines changed

10 files changed

+154
-47
lines changed

PowerEditor/src/Notepad_plus.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,7 @@ LRESULT Notepad_plus::init(HWND hwnd)
723723
_colEditorDlg.init(_pPublicInterface->getHinst(), hwnd, &_pEditView);
724724
_aboutDlg.init(_pPublicInterface->getHinst(), hwnd);
725725
_debugInfoDlg.init(_pPublicInterface->getHinst(), hwnd, _isAdministrator, _pluginsManager.getLoadedPluginNames());
726+
_cmdLineArgsDlg.init(_pPublicInterface->getHinst(), hwnd);
726727
_runDlg.init(_pPublicInterface->getHinst(), hwnd);
727728
_runMacroDlg.init(_pPublicInterface->getHinst(), hwnd);
728729
_documentPeeker.init(_pPublicInterface->getHinst(), hwnd);

PowerEditor/src/Notepad_plus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ friend class FileManager;
321321
FindIncrementDlg _incrementFindDlg;
322322
AboutDlg _aboutDlg;
323323
DebugInfoDlg _debugInfoDlg;
324+
CmdLineArgsDlg _cmdLineArgsDlg;
324325
RunDlg _runDlg;
325326
HashFromFilesDlg _md5FromFilesDlg;
326327
HashFromTextDlg _md5FromTextDlg;

PowerEditor/src/Notepad_plus.rc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,6 +1418,16 @@ BEGIN
14181418
DEFPUSHBUTTON "OK",IDOK,125,175,50,14
14191419
END
14201420

1421+
IDD_COMMANDLINEARGSBOX DIALOGEX 0, 0, 420, 385
1422+
STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
1423+
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE
1424+
CAPTION "Command Line Arguments"
1425+
FONT 8, L"MS Shell Dlg", 0, 0, 0x1
1426+
BEGIN
1427+
EDITTEXT IDC_COMMANDLINEARGS_EDIT,10,10,400,345,ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL
1428+
DEFPUSHBUTTON "OK",IDOK,185,360,50,14
1429+
END
1430+
14211431
IDD_DOSAVEORNOTBOX DIALOGEX 0, 0, 312, 80
14221432
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
14231433
EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE

PowerEditor/src/Notepad_plus_Window.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,11 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const wchar_t *cmdL
411411
::MessageBoxW(NULL, wss.str().c_str(), L"Notepad++ loading time (hh:mm:ss.ms)", MB_OK);
412412
}
413413

414+
if (cmdLineParams->_displayCmdLineArgs)
415+
{
416+
_notepad_plus_plus_core.command(IDM_CMDLINEARGUMENTS);
417+
}
418+
414419
bool isSnapshotMode = nppGUI.isSnapshotMode();
415420
if (isSnapshotMode)
416421
{

PowerEditor/src/Notepad_plus_Window.h

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,6 @@
1818

1919
constexpr int splitterSize = 8;
2020

21-
const wchar_t COMMAND_ARG_HELP[] = L"Usage :\r\
22-
\r\
23-
notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-udl=\"My UDL Name\"] [-LlangCode] [-nLineNumber] [-cColumnNumber] [-pPosition] [-xLeftPos] [-yTopPos] [-monitor] [-nosession] [-notabbar] [-ro] [-systemtray] [-loadingTime] [-alwaysOnTop] [-openSession] [-r] [-qn=\"Easter egg name\" | -qt=\"a text to display.\" | -qf=\"D:\\my quote.txt\"] [-qSpeed1|2|3] [-quickPrint] [-settingsDir=\"d:\\your settings dir\\\"] [-openFoldersAsWorkspace] [-titleAdd=\"additional title bar text\"][filePath]\r\
24-
\r\
25-
--help : This help message\r\
26-
-multiInst : Launch another Notepad++ instance\r\
27-
-noPlugin : Launch Notepad++ without loading any plugin\r\
28-
-l : Open file or Ghost type with syntax highlighting of choice\r\
29-
-udl=\"My UDL Name\": Open file by applying User Defined Language\r\
30-
-L : Apply indicated localization, langCode is browser language code\r\
31-
-n : Scroll to indicated line on filePath\r\
32-
-c : Scroll to indicated column on filePath\r\
33-
-p : Scroll to indicated position on filePath\r\
34-
-x : Move Notepad++ to indicated left side position on the screen\r\
35-
-y : Move Notepad++ to indicated top position on the screen\r\
36-
-monitor: Open file with file monitoring enabled\r\
37-
-nosession : Launch Notepad++ without previous session\r\
38-
-notabbar : Launch Notepad++ without tab bar\r\
39-
-ro : Make the filePath read-only\r\
40-
-fullReadOnly : Open all files read-only by default,\r\
41-
toggling the R/O off and saving is allowed\r\
42-
-fullReadOnlySavingForbidden : Open all files read-only by default,\r\
43-
toggling the R/O off and saving is disabled\r\
44-
-systemtray : Launch Notepad++ directly in system tray\r\
45-
-loadingTime : Display Notepad++ loading time\r\
46-
-alwaysOnTop : Make Notepad++ always on top\r\
47-
-openSession : Open a session. filePath must be a session file\r\
48-
-r : Open files recursively. This argument will be ignored\r\
49-
if filePath contains no wildcard character\r\
50-
-qn=\"Easter egg name\": Ghost type easter egg via its name\r\
51-
-qt=\"text to display.\": Ghost type the given text\r\
52-
-qf=\"D:\\my quote.txt\": Ghost type a file content via the file path\r\
53-
-qSpeed : Ghost typing speed. Value from 1 to 3 for slow, fast and fastest\r\
54-
-quickPrint : Print the file given as argument then quit Notepad++\r\
55-
-settingsDir=\"d:\\your settings dir\\\": Override the default settings dir\r\
56-
-openFoldersAsWorkspace: open filePath of folder(s) as workspace\r\
57-
-titleAdd=\"string\": add string to Notepad++ title bar\r\
58-
filePath : file or folder name to open (absolute or relative path name)\r\
59-
";
60-
6121

6222
class Notepad_plus_Window : public Window
6323
{

PowerEditor/src/NppCommands.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3551,8 +3551,7 @@ void Notepad_plus::command(int id)
35513551

35523552
case IDM_CMDLINEARGUMENTS:
35533553
{
3554-
// Not translatable
3555-
::MessageBox(_pPublicInterface->getHSelf(), COMMAND_ARG_HELP, L"Notepad++ Command Argument Help", MB_OK | MB_APPLMODAL);
3554+
_cmdLineArgsDlg.doDialog();
35563555
break;
35573556
}
35583557

PowerEditor/src/Parameters.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ struct CmdLineParams
276276
bool _isPreLaunch = false;
277277
bool _showLoadingTime = false;
278278
bool _alwaysOnTop = false;
279+
bool _displayCmdLineArgs = false;
279280
intptr_t _line2go = -1;
280281
intptr_t _column2go = -1;
281282
intptr_t _pos2go = -1;

PowerEditor/src/WinControls/AboutDlg/AboutDlg.cpp

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,122 @@ void DebugInfoDlg::refreshDebugInfo()
646646
}
647647

648648

649+
const wchar_t COMMAND_ARG_HELP[] = L"Usage:\r\n\
650+
\r\n\
651+
notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-udl=\"My UDL Name\"] [-LlangCode] [-nLineNumber]\r\n\
652+
[-cColumnNumber] [-pPosition] [-xLeftPos] [-yTopPos] [-monitor] [-nosession] [-notabbar] [-systemtray]\r\n\
653+
[-loadingTime] [-ro] [-fullReadOnly] [-fullReadOnlySavingForbidden] [-alwaysOnTop] [-openSession] [-r]\r\n\
654+
[-qn=\"Easter egg name\" | -qt=\"a text to display.\" | -qf=\"D:\\my quote.txt\"] [-qSpeed1|2|3] [-quickPrint]\r\n\
655+
[-settingsDir=\"d:\\your settings dir\\\"] [-openFoldersAsWorkspace] [-titleAdd=\"additional title bar text\"]\r\n\
656+
[filePath]\r\n\
657+
\r\n\
658+
--help: This help message\r\n\
659+
-multiInst: Launch another Notepad++ instance\r\n\
660+
-noPlugin: Launch Notepad++ without loading any plugin\r\n\
661+
-l: Open file or Ghost type with syntax highlighting of choice\r\n\
662+
-udl=\"My UDL Name\": Open file by applying User Defined Language\r\n\
663+
-L: Apply indicated localization, langCode is browser language code\r\n\
664+
-n: Scroll to indicated line on filePath\r\n\
665+
-c: Scroll to indicated column on filePath\r\n\
666+
-p: Scroll to indicated position on filePath\r\n\
667+
-x: Move Notepad++ to indicated left side position on the screen\r\n\
668+
-y: Move Notepad++ to indicated top position on the screen\r\n\
669+
-monitor: Open file with file monitoring enabled\r\n\
670+
-nosession: Launch Notepad++ without previous session\r\n\
671+
-notabbar: Launch Notepad++ without tab bar\r\n\
672+
-ro: Make the filePath read-only\r\n\
673+
-fullReadOnly: Open all files read-only by default, toggling the R/O off and saving is allowed\r\n\
674+
-fullReadOnlySavingForbidden: Open all files read-only by default, toggling the R/O off and saving is disabled\r\n\
675+
-systemtray: Launch Notepad++ directly in system tray\r\n\
676+
-loadingTime: Display Notepad++ loading time\r\n\
677+
-alwaysOnTop: Make Notepad++ always on top\r\n\
678+
-openSession: Open a session. filePath must be a session file\r\n\
679+
-r: Open files recursively. This argument will be ignored if filePath contains no wildcard character\r\n\
680+
-qn=\"Easter egg name\": Ghost type easter egg via its name\r\n\
681+
-qt=\"text to display.\": Ghost type the given text\r\n\
682+
-qf=\"D:\\my quote.txt\": Ghost type a file content via the file path\r\n\
683+
-qSpeed: Ghost typing speed. Value from 1 to 3 for slow, fast and fastest\r\n\
684+
-quickPrint: Print the file given as argument then quit Notepad++\r\n\
685+
-settingsDir=\"d:\\your settings dir\\\": Override the default settings dir\r\n\
686+
-openFoldersAsWorkspace: open filePath of folder(s) as workspace\r\n\
687+
-titleAdd=\"string\": add string to Notepad++ title bar\r\n\
688+
filePath: file or folder name to open (absolute or relative path name)\r\n\
689+
";
690+
691+
void CmdLineArgsDlg::doDialog()
692+
{
693+
if (!isCreated())
694+
create(IDD_COMMANDLINEARGSBOX);
695+
696+
::SetDlgItemText(_hSelf, IDC_COMMANDLINEARGS_EDIT, COMMAND_ARG_HELP);
697+
698+
moveForDpiChange();
699+
goToCenter(SWP_SHOWWINDOW | SWP_NOSIZE);
700+
}
701+
702+
intptr_t CALLBACK CmdLineArgsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
703+
{
704+
switch (message)
705+
{
706+
case WM_INITDIALOG:
707+
{
708+
NppDarkMode::autoSubclassAndThemeChildControls(_hSelf);
709+
return TRUE;
710+
}
711+
712+
case WM_CTLCOLORDLG:
713+
case WM_CTLCOLORSTATIC:
714+
{
715+
return NppDarkMode::onCtlColorDlg(reinterpret_cast<HDC>(wParam));
716+
}
717+
718+
case WM_PRINTCLIENT:
719+
{
720+
if (NppDarkMode::isEnabled())
721+
{
722+
return TRUE;
723+
}
724+
break;
725+
}
726+
727+
case NPPM_INTERNAL_REFRESHDARKMODE:
728+
{
729+
NppDarkMode::autoThemeChildControls(_hSelf);
730+
return TRUE;
731+
}
732+
733+
case WM_DPICHANGED:
734+
{
735+
_dpiManager.setDpiWP(wParam);
736+
setPositionDpi(lParam);
737+
getWindowRect(_rc);
738+
739+
return TRUE;
740+
}
741+
742+
case WM_COMMAND:
743+
{
744+
switch (wParam)
745+
{
746+
case IDCANCEL:
747+
case IDOK:
748+
display(false);
749+
return TRUE;
750+
751+
default:
752+
break;
753+
}
754+
break;
755+
}
756+
757+
case WM_DESTROY:
758+
{
759+
return TRUE;
760+
}
761+
}
762+
return FALSE;
763+
}
764+
649765
void DoSaveOrNotBox::doDialog(bool isRTL)
650766
{
651767

PowerEditor/src/WinControls/AboutDlg/AboutDlg.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,23 @@ class DebugInfoDlg : public StaticDialog
9292
std::wstring _loadedPlugins;
9393
};
9494

95+
96+
class CmdLineArgsDlg : public StaticDialog
97+
{
98+
public:
99+
CmdLineArgsDlg() = default;
100+
101+
void init(HINSTANCE hInst, HWND parent) {
102+
Window::init(hInst, parent);
103+
};
104+
105+
void doDialog();
106+
void destroy() override {};
107+
108+
protected:
109+
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
110+
};
111+
95112
class DoSaveOrNotBox : public StaticDialog
96113
{
97114
public:

PowerEditor/src/winmain.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -574,12 +574,12 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance
574574
}
575575

576576
bool isParamePresent;
577-
bool showHelp = isInList(FLAG_HELP, params);
578577
bool isMultiInst = isInList(FLAG_MULTI_INSTANCE, params);
579578
bool doFunctionListExport = isInList(FLAG_FUNCLSTEXPORT, params);
580579
bool doPrintAndQuit = isInList(FLAG_PRINTANDQUIT, params);
581580

582581
CmdLineParams cmdLineParams;
582+
cmdLineParams._displayCmdLineArgs = isInList(FLAG_HELP, params);
583583
cmdLineParams._isNoTab = isInList(FLAG_NOTABBAR, params);
584584
cmdLineParams._isNoPlugin = isInList(FLAG_NO_PLUGIN, params);
585585
cmdLineParams._isReadOnly = isInList(FLAG_READONLY, params);
@@ -657,9 +657,6 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance
657657
cmdLineParams._udlName = udlName;
658658
}
659659

660-
if (showHelp)
661-
::MessageBox(NULL, COMMAND_ARG_HELP, L"Notepad++ Command Argument Help", MB_OK);
662-
663660
if (cmdLineParams._localizationPath != L"")
664661
{
665662
// setStartWithLocFileName() should be called before parameters are loaded
@@ -793,7 +790,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE /*hPrevInstance
793790

794791
bool isUpExist = nppGui._doesExistUpdater = doesFileExist(updaterFullPath.c_str());
795792

796-
// wingup doesn't work with the obsolete security layer (API) under xp since downloads are secured with SSL on notepad_plus_plus.org
793+
// wingup doesn't work with the obsolete security layer (API) under xp since downloads are secured with SSL on notepad-plus-plus.org
797794
winVer ver = nppParameters.getWinVersion();
798795
bool isGtXP = ver > WV_XP;
799796

0 commit comments

Comments
 (0)