Add stripIgnoredParams to implement "Wish: "ignore first item" command line argument (for replacing Notepad)"

Closes #852
This commit is contained in:
Silent 2018-07-02 17:41:59 +02:00
parent 74d39b1cec
commit f0821d9835
No known key found for this signature in database
GPG Key ID: AE53149BB0C45AF1

View File

@ -90,6 +90,27 @@ ParamVector parseCommandLine(const TCHAR* commandLine)
return result;
}
// Looks for -z arguments and strips command line arguments following those, if any
void stripIgnoredParams(ParamVector & params)
{
for ( auto it = params.begin(); it != params.end(); )
{
if (lstrcmp(it->c_str(), TEXT("-z")) == 0)
{
auto nextIt = std::next(it);
if ( nextIt != params.end() )
{
params.erase(nextIt);
}
it = params.erase(it);
}
else
{
++it;
}
}
}
bool isInList(const TCHAR *token2Find, ParamVector& params, bool eraseArg = true)
{
for (auto it = params.begin(); it != params.end(); ++it)
@ -258,6 +279,7 @@ void doException(Notepad_plus_Window & notepad_plus_plus)
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
{
ParamVector params = parseCommandLine(::GetCommandLine());
stripIgnoredParams(params);
MiniDumper mdump; //for debugging purposes.