Enhance ghost typing command line argument feature

Enhance ghost typing command line argument feature by changing its format:
With it's new format -qX="string contains white space" (where X is 't', 'n' or 'f'), the white spaces can be contained between double quote, so no need to use %20 anymore for substituting white spacees.
This commit is contained in:
Don HO 2020-12-21 17:54:10 +01:00
parent b6a66ba2b1
commit f617325006
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
2 changed files with 13 additions and 15 deletions

View File

@ -31,12 +31,12 @@
const TCHAR COMMAND_ARG_HELP[] = TEXT("Usage :\r\
\r\
notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-LlangCode] [-nLineNumber] [-cColumnNumber] [-pPosition] [-xLeftPos] [-yTopPos] [-nosession] [-notabbar] [-ro] [-systemtray] [-loadingTime] [-alwaysOnTop] [-openSession] [-r] [-qnEasterEggName | -qtText | -qfCntentFileName] [-qSpeed1|2|3] [-quickPrint] [-settingsDir=\"d:\\your settings dir\\\"] [-openFoldersAsWorkspace] [filePath]\r\
notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-LlangCode] [-nLineNumber] [-cColumnNumber] [-pPosition] [-xLeftPos] [-yTopPos] [-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] [filePath]\r\
\r\
--help : This help message\r\
-multiInst : Launch another Notepad++ instance\r\
-noPlugin : Launch Notepad++ without loading any plugin\r\
-l : Open file or display ghost typing with syntax highlighting of choice\r\
-l : Open file or Ghost type with syntax highlighting of choice\r\
-L : Apply indicated localization, langCode is browser language code\r\
-n : Scroll to indicated line on filePath\r\
-c : Scroll to indicated column on filePath\r\
@ -52,9 +52,9 @@ notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-LlangCode] [-nLineNum
-openSession : Open a session. filePath must be a session file\r\
-r : Open files recursively. This argument will be ignored\r\
if filePath contain no wildcard character\r\
-qn : Launch ghost typing to display easter egg via its name\r\
-qt : Launch ghost typing to display a text via the given text\r\
-qf : Launch ghost typing to display a file content via the file path\r\
-qn=\"Easter egg name\": Ghost type easter egg via its name\r\
-qt=\"text to display.\": Ghost type the given text\r\
-qf=\"D:\\my quote.txt\": Ghost type a file content via the file path\r\
-qSpeed : Ghost typing speed. Value from 1 to 3 for slow, fast and fastest\r\
-quickPrint : Print the file given as argument then quit Notepad++\r\
-settingsDir=\"d:\\your settings dir\\\": Override the default settings dir\r\

View File

@ -262,15 +262,14 @@ int getNumberFromParam(char paramName, ParamVector & params, bool & isParamePres
generic_string getEasterEggNameFromParam(ParamVector & params, unsigned char & type)
{
generic_string EasterEggName;
if (!getParamValFromString(TEXT("-qn"), params, EasterEggName)) // get internal easter egg
if (!getParamValFromString(TEXT("-qn="), params, EasterEggName)) // get internal easter egg
{
if (!getParamValFromString(TEXT("-qt"), params, EasterEggName)) // get user quote from cmdline argument
if (!getParamValFromString(TEXT("-qt="), params, EasterEggName)) // get user quote from cmdline argument
{
if (!getParamValFromString(TEXT("-qf"), params, EasterEggName)) // get user quote from a content of file
if (!getParamValFromString(TEXT("-qf="), params, EasterEggName)) // get user quote from a content of file
return TEXT("");
else
{
EasterEggName = relativeFilePathToFullFilePath(EasterEggName.c_str());
type = 2; // quote content in file
}
}
@ -280,15 +279,14 @@ generic_string getEasterEggNameFromParam(ParamVector & params, unsigned char & t
else
type = 0; // easter egg
generic_string percentTwentyStr = TEXT("%20");
generic_string spaceStr = TEXT(" ");
size_t start_pos = 0;
while ((start_pos = EasterEggName.find(percentTwentyStr, start_pos)) != std::string::npos)
if (EasterEggName.c_str()[0] == '"' && EasterEggName.c_str()[EasterEggName.length() - 1] == '"')
{
EasterEggName.replace(start_pos, percentTwentyStr.length(), spaceStr);
start_pos += spaceStr.length(); // Handles case where 'to' is a substring of 'from'
EasterEggName = EasterEggName.substr(1, EasterEggName.length() - 2);
}
if (type == 2)
EasterEggName = relativeFilePathToFullFilePath(EasterEggName.c_str());
return EasterEggName;
}