mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-25 23:05:13 +02:00
Add file monitoring command line argument [-monitor]
Fix #10562, close #11539
This commit is contained in:
parent
c32da953cf
commit
1dffb05e0a
@ -6177,6 +6177,7 @@ std::vector<generic_string> Notepad_plus::loadCommandlineParams(const TCHAR * co
|
|||||||
bool recursive = pCmdParams->_isRecursive;
|
bool recursive = pCmdParams->_isRecursive;
|
||||||
bool readOnly = pCmdParams->_isReadOnly;
|
bool readOnly = pCmdParams->_isReadOnly;
|
||||||
bool openFoldersAsWorkspace = pCmdParams->_openFoldersAsWorkspace;
|
bool openFoldersAsWorkspace = pCmdParams->_openFoldersAsWorkspace;
|
||||||
|
bool monitorFiles = pCmdParams->_monitorFiles;
|
||||||
|
|
||||||
if (openFoldersAsWorkspace)
|
if (openFoldersAsWorkspace)
|
||||||
{
|
{
|
||||||
@ -6238,6 +6239,12 @@ std::vector<generic_string> Notepad_plus::loadCommandlineParams(const TCHAR * co
|
|||||||
|
|
||||||
switchEditViewTo(iView); //restore view
|
switchEditViewTo(iView); //restore view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (monitorFiles)
|
||||||
|
{
|
||||||
|
monitoringStartOrStopAndUpdateUI(pBuf, true);
|
||||||
|
createMonitoringThread(pBuf);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (lastOpened != BUFFER_INVALID)
|
if (lastOpened != BUFFER_INVALID)
|
||||||
{
|
{
|
||||||
@ -8109,6 +8116,13 @@ void Notepad_plus::monitoringStartOrStopAndUpdateUI(Buffer* pBuf, bool isStartin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Notepad_plus::createMonitoringThread(Buffer* pBuf)
|
||||||
|
{
|
||||||
|
MonitorInfo *monitorInfo = new Notepad_plus::MonitorInfo(pBuf, _pPublicInterface->getHSelf());
|
||||||
|
HANDLE hThread = ::CreateThread(NULL, 0, monitorFileOnChange, (void *)monitorInfo, 0, NULL); // will be deallocated while quitting thread
|
||||||
|
::CloseHandle(hThread);
|
||||||
|
}
|
||||||
|
|
||||||
// Fill names into the shortcut list.
|
// Fill names into the shortcut list.
|
||||||
// Each command shortcut has two names:
|
// Each command shortcut has two names:
|
||||||
// - The menu name, to be displayed in the menu
|
// - The menu name, to be displayed in the menu
|
||||||
|
@ -636,5 +636,6 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
void monitoringStartOrStopAndUpdateUI(Buffer* pBuf, bool isStarting);
|
void monitoringStartOrStopAndUpdateUI(Buffer* pBuf, bool isStarting);
|
||||||
|
void createMonitoringThread(Buffer* pBuf);
|
||||||
void updateCommandShortcuts();
|
void updateCommandShortcuts();
|
||||||
};
|
};
|
||||||
|
@ -20,7 +20,7 @@ const int splitterSize = 8;
|
|||||||
|
|
||||||
const TCHAR COMMAND_ARG_HELP[] = TEXT("Usage :\r\
|
const TCHAR COMMAND_ARG_HELP[] = TEXT("Usage :\r\
|
||||||
\r\
|
\r\
|
||||||
notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-udl=\"My UDL Name\"] [-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] [-titleAdd=\"additional title bar text\"][filePath]\r\
|
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\
|
||||||
\r\
|
\r\
|
||||||
--help : This help message\r\
|
--help : This help message\r\
|
||||||
-multiInst : Launch another Notepad++ instance\r\
|
-multiInst : Launch another Notepad++ instance\r\
|
||||||
@ -33,6 +33,7 @@ notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-udl=\"My UDL Name\"]
|
|||||||
-p : Scroll to indicated position 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\
|
||||||
|
-monitor: Open file with file monitoring enabled\r\
|
||||||
-nosession : Launch Notepad++ without previous session\r\
|
-nosession : Launch Notepad++ without previous session\r\
|
||||||
-notabbar : Launch Notepad++ without tabbar\r\
|
-notabbar : Launch Notepad++ without tabbar\r\
|
||||||
-ro : Make the filePath read only\r\
|
-ro : Make the filePath read only\r\
|
||||||
|
@ -2517,10 +2517,7 @@ void Notepad_plus::command(int id)
|
|||||||
{
|
{
|
||||||
// Monitoring firstly for making monitoring icon
|
// Monitoring firstly for making monitoring icon
|
||||||
monitoringStartOrStopAndUpdateUI(curBuf, true);
|
monitoringStartOrStopAndUpdateUI(curBuf, true);
|
||||||
|
createMonitoringThread(curBuf);
|
||||||
MonitorInfo *monitorInfo = new MonitorInfo(curBuf, _pPublicInterface->getHSelf());
|
|
||||||
HANDLE hThread = ::CreateThread(NULL, 0, monitorFileOnChange, (void *)monitorInfo, 0, NULL); // will be deallocated while quitting thread
|
|
||||||
::CloseHandle(hThread);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -242,6 +242,7 @@ struct CmdLineParams
|
|||||||
bool _isSessionFile = false;
|
bool _isSessionFile = false;
|
||||||
bool _isRecursive = false;
|
bool _isRecursive = false;
|
||||||
bool _openFoldersAsWorkspace = false;
|
bool _openFoldersAsWorkspace = false;
|
||||||
|
bool _monitorFiles = false;
|
||||||
|
|
||||||
LangType _langType = L_EXTERNAL;
|
LangType _langType = L_EXTERNAL;
|
||||||
generic_string _localizationPath;
|
generic_string _localizationPath;
|
||||||
@ -271,6 +272,7 @@ struct CmdLineParamsDTO
|
|||||||
bool _isSessionFile = false;
|
bool _isSessionFile = false;
|
||||||
bool _isRecursive = false;
|
bool _isRecursive = false;
|
||||||
bool _openFoldersAsWorkspace = false;
|
bool _openFoldersAsWorkspace = false;
|
||||||
|
bool _monitorFiles = false;
|
||||||
|
|
||||||
intptr_t _line2go = 0;
|
intptr_t _line2go = 0;
|
||||||
intptr_t _column2go = 0;
|
intptr_t _column2go = 0;
|
||||||
@ -287,6 +289,7 @@ struct CmdLineParamsDTO
|
|||||||
dto._isSessionFile = params._isSessionFile;
|
dto._isSessionFile = params._isSessionFile;
|
||||||
dto._isRecursive = params._isRecursive;
|
dto._isRecursive = params._isRecursive;
|
||||||
dto._openFoldersAsWorkspace = params._openFoldersAsWorkspace;
|
dto._openFoldersAsWorkspace = params._openFoldersAsWorkspace;
|
||||||
|
dto._monitorFiles = params._monitorFiles;
|
||||||
|
|
||||||
dto._line2go = params._line2go;
|
dto._line2go = params._line2go;
|
||||||
dto._column2go = params._column2go;
|
dto._column2go = params._column2go;
|
||||||
|
@ -312,6 +312,7 @@ const TCHAR FLAG_OPEN_FOLDERS_AS_WORKSPACE[] = TEXT("-openFoldersAsWorkspace");
|
|||||||
const TCHAR FLAG_SETTINGS_DIR[] = TEXT("-settingsDir=");
|
const TCHAR FLAG_SETTINGS_DIR[] = TEXT("-settingsDir=");
|
||||||
const TCHAR FLAG_TITLEBAR_ADD[] = TEXT("-titleAdd=");
|
const TCHAR FLAG_TITLEBAR_ADD[] = TEXT("-titleAdd=");
|
||||||
const TCHAR FLAG_APPLY_UDL[] = TEXT("-udl=");
|
const TCHAR FLAG_APPLY_UDL[] = TEXT("-udl=");
|
||||||
|
const TCHAR FLAG_MONITOR_FILES[] = TEXT("-monitor");
|
||||||
|
|
||||||
void doException(Notepad_plus_Window & notepad_plus_plus)
|
void doException(Notepad_plus_Window & notepad_plus_plus)
|
||||||
{
|
{
|
||||||
@ -443,6 +444,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int)
|
|||||||
cmdLineParams._isSessionFile = isInList(FLAG_OPENSESSIONFILE, params);
|
cmdLineParams._isSessionFile = isInList(FLAG_OPENSESSIONFILE, params);
|
||||||
cmdLineParams._isRecursive = isInList(FLAG_RECURSIVE, params);
|
cmdLineParams._isRecursive = isInList(FLAG_RECURSIVE, params);
|
||||||
cmdLineParams._openFoldersAsWorkspace = isInList(FLAG_OPEN_FOLDERS_AS_WORKSPACE, params);
|
cmdLineParams._openFoldersAsWorkspace = isInList(FLAG_OPEN_FOLDERS_AS_WORKSPACE, params);
|
||||||
|
cmdLineParams._monitorFiles = isInList(FLAG_MONITOR_FILES, params);
|
||||||
|
|
||||||
cmdLineParams._langType = getLangTypeFromParam(params);
|
cmdLineParams._langType = getLangTypeFromParam(params);
|
||||||
cmdLineParams._localizationPath = getLocalizationPathFromParam(params);
|
cmdLineParams._localizationPath = getLocalizationPathFromParam(params);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user