From 9708382bfe46b0223116c7c8473ffc6b97f55111 Mon Sep 17 00:00:00 2001 From: yuyaryshev Date: Tue, 19 Apr 2016 21:00:55 +0300 Subject: [PATCH] Add new command line optio -p : Scroll to indicated position on given filePath Closes #1777, closes #1776 --- PowerEditor/src/Notepad_plus.cpp | 8 +++++++- PowerEditor/src/Notepad_plus_Window.h | 3 ++- PowerEditor/src/Parameters.h | 1 + PowerEditor/src/winmain.cpp | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index dc97358e7..3160d6e30 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -4998,6 +4998,7 @@ void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, CmdLineParam LangType lt = pCmdParams->_langType; int ln = pCmdParams->_line2go; int cn = pCmdParams->_column2go; + int cpos = pCmdParams->_pos2go; bool recursive = pCmdParams->_isRecursive; bool readOnly = pCmdParams->_isReadOnly; @@ -5019,11 +5020,16 @@ void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, CmdLineParam pBuf->setLangType(lt); } - if (ln != -1) + if (ln != -1 || cpos != -1) { //we have to move the cursor manually 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 + if (cpos != -1) + { + _pEditView->execute(SCI_GOTOPOS, cpos); + } + else if (cn == -1) { _pEditView->execute(SCI_GOTOLINE, ln-1); diff --git a/PowerEditor/src/Notepad_plus_Window.h b/PowerEditor/src/Notepad_plus_Window.h index 3bc3522c2..5aa47b0b6 100644 --- a/PowerEditor/src/Notepad_plus_Window.h +++ b/PowerEditor/src/Notepad_plus_Window.h @@ -31,7 +31,7 @@ const TCHAR COMMAND_ARG_HELP[] = TEXT("Usage :\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\ --help : This help message\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\ -n : Scroll to indicated line 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\ -y : Move Notepad++ to indicated top position on the screen\r\ -nosession : Launch Notepad++ without previous session\r\ diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 4e91e4437..acfbecafd 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -212,6 +212,7 @@ struct CmdLineParams bool _alwaysOnTop = false; int _line2go = -1; int _column2go = -1; + int _pos2go = -1; POINT _point; bool _isPointXValid = false; diff --git a/PowerEditor/src/winmain.cpp b/PowerEditor/src/winmain.cpp index 08b2726df..05ded0178 100644 --- a/PowerEditor/src/winmain.cpp +++ b/PowerEditor/src/winmain.cpp @@ -298,6 +298,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) cmdLineParams._localizationPath = getLocalizationPathFromParam(params); cmdLineParams._line2go = getNumberFromParam('n', params, isParamePresent); cmdLineParams._column2go = getNumberFromParam('c', params, isParamePresent); + cmdLineParams._pos2go = getNumberFromParam('p', params, isParamePresent); cmdLineParams._point.x = getNumberFromParam('x', params, cmdLineParams._isPointXValid); cmdLineParams._point.y = getNumberFromParam('y', params, cmdLineParams._isPointYValid); cmdLineParams._easterEggName = getEasterEggNameFromParam(params, cmdLineParams._quoteType);