Add new command line optio -p : Scroll to indicated position on given filePath

Closes #1777, closes #1776
This commit is contained in:
yuyaryshev 2016-04-19 21:00:55 +03:00 committed by Don Ho
parent d26f910ece
commit 9708382bfe
4 changed files with 11 additions and 2 deletions

View File

@ -4998,6 +4998,7 @@ void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, CmdLineParam
LangType lt = pCmdParams->_langType; LangType lt = pCmdParams->_langType;
int ln = pCmdParams->_line2go; int ln = pCmdParams->_line2go;
int cn = pCmdParams->_column2go; int cn = pCmdParams->_column2go;
int cpos = pCmdParams->_pos2go;
bool recursive = pCmdParams->_isRecursive; bool recursive = pCmdParams->_isRecursive;
bool readOnly = pCmdParams->_isReadOnly; bool readOnly = pCmdParams->_isReadOnly;
@ -5019,11 +5020,16 @@ void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, CmdLineParam
pBuf->setLangType(lt); pBuf->setLangType(lt);
} }
if (ln != -1) if (ln != -1 || cpos != -1)
{ //we have to move the cursor manually { //we have to move the cursor manually
int iView = currentView(); //store view since fileswitch can cause it to change int iView = currentView(); //store view since fileswitch can cause it to change
switchToFile(bufID); //switch to the file. No deferred loading, but this way we can easily move the cursor to the right position switchToFile(bufID); //switch to the file. No deferred loading, but this way we can easily move the cursor to the right position
if (cpos != -1)
{
_pEditView->execute(SCI_GOTOPOS, cpos);
}
else
if (cn == -1) if (cn == -1)
{ {
_pEditView->execute(SCI_GOTOLINE, ln-1); _pEditView->execute(SCI_GOTOLINE, ln-1);

View File

@ -31,7 +31,7 @@
const TCHAR COMMAND_ARG_HELP[] = TEXT("Usage :\r\ const TCHAR COMMAND_ARG_HELP[] = TEXT("Usage :\r\
\r\ \r\
notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-LlangCode] [-nLineNumber] [-cColumnNumber] [-xLeftPos] [-yTopPos] [-nosession] [-notabbar] [-ro] [-systemtray] [-loadingTime] [-alwaysOnTop] [-openSession] [-r] [-qnEsterEggName | -qtText | -qfCntentFileName] [filePath]\r\ notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-LlangCode] [-nLineNumber] [-cColumnNumber] [-pPosition] [-xLeftPos] [-yTopPos] [-nosession] [-notabbar] [-ro] [-systemtray] [-loadingTime] [-alwaysOnTop] [-openSession] [-r] [-qnEsterEggName | -qtText | -qfCntentFileName] [filePath]\r\
\r\ \r\
--help : This help message\r\ --help : This help message\r\
-multiInst : Launch another Notepad++ instance\r\ -multiInst : Launch another Notepad++ instance\r\
@ -40,6 +40,7 @@ notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-LlangCode] [-nLineNum
-L : Apply indicated localization, langCode is browser language code\r\ -L : Apply indicated localization, langCode is browser language code\r\
-n : Scroll to indicated line on filePath\r\ -n : Scroll to indicated line on filePath\r\
-c : Scroll to indicated column on filePath\r\ -c : Scroll to indicated column on filePath\r\
-p : Scroll to indicated position on filePath\r\
-x : Move Notepad++ to indicated left side position on the screen\r\ -x : Move Notepad++ to indicated left side position on the screen\r\
-y : Move Notepad++ to indicated top position on the screen\r\ -y : Move Notepad++ to indicated top position on the screen\r\
-nosession : Launch Notepad++ without previous session\r\ -nosession : Launch Notepad++ without previous session\r\

View File

@ -212,6 +212,7 @@ struct CmdLineParams
bool _alwaysOnTop = false; bool _alwaysOnTop = false;
int _line2go = -1; int _line2go = -1;
int _column2go = -1; int _column2go = -1;
int _pos2go = -1;
POINT _point; POINT _point;
bool _isPointXValid = false; bool _isPointXValid = false;

View File

@ -298,6 +298,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
cmdLineParams._localizationPath = getLocalizationPathFromParam(params); cmdLineParams._localizationPath = getLocalizationPathFromParam(params);
cmdLineParams._line2go = getNumberFromParam('n', params, isParamePresent); cmdLineParams._line2go = getNumberFromParam('n', params, isParamePresent);
cmdLineParams._column2go = getNumberFromParam('c', params, isParamePresent); cmdLineParams._column2go = getNumberFromParam('c', params, isParamePresent);
cmdLineParams._pos2go = getNumberFromParam('p', params, isParamePresent);
cmdLineParams._point.x = getNumberFromParam('x', params, cmdLineParams._isPointXValid); cmdLineParams._point.x = getNumberFromParam('x', params, cmdLineParams._isPointXValid);
cmdLineParams._point.y = getNumberFromParam('y', params, cmdLineParams._isPointYValid); cmdLineParams._point.y = getNumberFromParam('y', params, cmdLineParams._isPointYValid);
cmdLineParams._easterEggName = getEasterEggNameFromParam(params, cmdLineParams._quoteType); cmdLineParams._easterEggName = getEasterEggNameFromParam(params, cmdLineParams._quoteType);