Add the commandline argument to open folders in "folder as workspace" panel
Add the ability to open folders in "folder as workspace" panel via command line argument "-openFoldersAsWorkspace". Example: notepad++ -openFoldersAsWorkspace c:\src\myProj01 c:\src\myProj02 The above command will launch notepad++ with folder as workspace panel by opening myProj01 and myProj02 in panel. Close #4253, close #5100
This commit is contained in:
parent
eef1bf0ae9
commit
57a49c3ba5
|
@ -101,6 +101,10 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
const stringVector& getFileNames() const {
|
||||
return _fileNames;
|
||||
};
|
||||
|
||||
const TCHAR * getFileName(size_t index) const {
|
||||
if (index >= _fileNames.size())
|
||||
return NULL;
|
||||
|
|
|
@ -5332,10 +5332,10 @@ void Notepad_plus::notifyBufferActivated(BufferID bufid, int view)
|
|||
_linkTriggered = true;
|
||||
}
|
||||
|
||||
void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, const CmdLineParamsDTO * pCmdParams)
|
||||
std::vector<generic_string> Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, const CmdLineParamsDTO * pCmdParams)
|
||||
{
|
||||
if (!commandLine || ! pCmdParams)
|
||||
return;
|
||||
return std::vector<generic_string>();
|
||||
|
||||
NppParameters *nppParams = NppParameters::getInstance();
|
||||
FileNameStringSplitter fnss(commandLine);
|
||||
|
@ -5348,7 +5348,7 @@ void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, const CmdLin
|
|||
{
|
||||
loadSession(session2Load);
|
||||
}
|
||||
return;
|
||||
return std::vector<generic_string>();
|
||||
}
|
||||
|
||||
LangType lt = pCmdParams->_langType;
|
||||
|
@ -5357,12 +5357,20 @@ void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, const CmdLin
|
|||
int cpos = pCmdParams->_pos2go;
|
||||
bool recursive = pCmdParams->_isRecursive;
|
||||
bool readOnly = pCmdParams->_isReadOnly;
|
||||
bool openFoldersAsWorkspace = pCmdParams->_openFoldersAsWorkspace;
|
||||
|
||||
if (openFoldersAsWorkspace)
|
||||
{
|
||||
// All the filepath in argument will be used as folder in workspace
|
||||
// call launchFileBrowser later with fnss
|
||||
return fnss.getFileNames();
|
||||
}
|
||||
|
||||
BufferID lastOpened = BUFFER_INVALID;
|
||||
for (int i = 0, len = fnss.size(); i < len ; ++i)
|
||||
{
|
||||
const TCHAR *pFn = fnss.getFileName(i);
|
||||
if (!pFn) return;
|
||||
if (!pFn) return std::vector<generic_string>();
|
||||
|
||||
BufferID bufID = doOpen(pFn, recursive, readOnly);
|
||||
if (bufID == BUFFER_INVALID) //cannot open file
|
||||
|
@ -5405,6 +5413,8 @@ void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, const CmdLin
|
|||
{
|
||||
switchToFile(lastOpened);
|
||||
}
|
||||
|
||||
return fnss.getFileNames();
|
||||
}
|
||||
|
||||
|
||||
|
@ -5909,7 +5919,7 @@ void Notepad_plus::launchAnsiCharPanel()
|
|||
_pAnsiCharPanel->display();
|
||||
}
|
||||
|
||||
void Notepad_plus::launchFileBrowser(const vector<generic_string> & folders)
|
||||
void Notepad_plus::launchFileBrowser(const vector<generic_string> & folders, bool fromScratch)
|
||||
{
|
||||
if (!_pFileBrowser)
|
||||
{
|
||||
|
@ -5950,6 +5960,11 @@ void Notepad_plus::launchFileBrowser(const vector<generic_string> & folders)
|
|||
_pFileBrowser->setForegroundColor(fgColor);
|
||||
}
|
||||
|
||||
if (fromScratch)
|
||||
{
|
||||
_pFileBrowser->deleteAllFromTree();
|
||||
}
|
||||
|
||||
for (size_t i = 0; i <folders.size(); ++i)
|
||||
{
|
||||
_pFileBrowser->addRootFolder(folders[i]);
|
||||
|
|
|
@ -576,12 +576,12 @@ private:
|
|||
bool dumpFiles(const TCHAR * outdir, const TCHAR * fileprefix = TEXT("")); //helper func
|
||||
void drawTabbarColoursFromStylerArray();
|
||||
|
||||
void loadCommandlineParams(const TCHAR * commandLine, const CmdLineParams * pCmdParams)
|
||||
std::vector<generic_string> loadCommandlineParams(const TCHAR * commandLine, const CmdLineParams * pCmdParams)
|
||||
{
|
||||
const CmdLineParamsDTO dto = CmdLineParamsDTO::FromCmdLineParams(*pCmdParams);
|
||||
loadCommandlineParams(commandLine, &dto);
|
||||
return loadCommandlineParams(commandLine, &dto);
|
||||
}
|
||||
void loadCommandlineParams(const TCHAR * commandLine, const CmdLineParamsDTO * pCmdParams);
|
||||
std::vector<generic_string> loadCommandlineParams(const TCHAR * commandLine, const CmdLineParamsDTO * pCmdParams);
|
||||
bool noOpenedDoc() const;
|
||||
bool goToPreviousIndicator(int indicID2Search, bool isWrap = true) const;
|
||||
bool goToNextIndicator(int indicID2Search, bool isWrap = true) const;
|
||||
|
@ -597,7 +597,7 @@ private:
|
|||
void launchProjectPanel(int cmdID, ProjectPanel ** pProjPanel, int panelID);
|
||||
void launchDocMap();
|
||||
void launchFunctionList();
|
||||
void launchFileBrowser(const std::vector<generic_string> & folders);
|
||||
void launchFileBrowser(const std::vector<generic_string> & folders, bool fromScratch = false);
|
||||
void showAllQuotes() const;
|
||||
static DWORD WINAPI threadTextPlayer(void *text2display);
|
||||
static DWORD WINAPI threadTextTroller(void *params);
|
||||
|
|
|
@ -185,8 +185,9 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin
|
|||
_notepad_plus_plus_core._pTrayIco->doTrayIcon(ADD);
|
||||
}
|
||||
|
||||
std::vector<generic_string> fns;
|
||||
if (cmdLine)
|
||||
_notepad_plus_plus_core.loadCommandlineParams(cmdLine, cmdLineParams);
|
||||
fns = _notepad_plus_plus_core.loadCommandlineParams(cmdLine, cmdLineParams);
|
||||
|
||||
std::vector<generic_string> fileNames;
|
||||
std::vector<generic_string> patterns;
|
||||
|
@ -234,9 +235,17 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin
|
|||
}
|
||||
}
|
||||
|
||||
// Restore all dockable panels from the last session
|
||||
for (size_t i = 0, len = _notepad_plus_plus_core._internalFuncIDs.size() ; i < len ; ++i)
|
||||
::SendMessage(_hSelf, WM_COMMAND, _notepad_plus_plus_core._internalFuncIDs[i], 0);
|
||||
|
||||
// Launch folder as workspace after all this dockable panel being restored from the last session
|
||||
// To avoid dockable panel toggle problem.
|
||||
if (cmdLineParams->_openFoldersAsWorkspace)
|
||||
{
|
||||
_notepad_plus_plus_core.launchFileBrowser(fns, true);
|
||||
}
|
||||
|
||||
// Notify plugins that Notepad++ is ready
|
||||
SCNotification scnN;
|
||||
scnN.nmhdr.code = NPPN_READY;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
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] [filePath]\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] [-openFoldersAsWorkspace] [filePath]\r\
|
||||
\r\
|
||||
--help : This help message\r\
|
||||
-multiInst : Launch another Notepad++ instance\r\
|
||||
|
@ -57,6 +57,7 @@ notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-LlangCode] [-nLineNum
|
|||
-qf : Launch ghost typing to display 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\
|
||||
-openFoldersAsWorkspace: open filePath of folder(s) as workspace\r\
|
||||
filePath : file or folder name to open (absolute or relative path name)\r\
|
||||
");
|
||||
|
||||
|
|
|
@ -218,6 +218,7 @@ struct CmdLineParams
|
|||
|
||||
bool _isSessionFile = false;
|
||||
bool _isRecursive = false;
|
||||
bool _openFoldersAsWorkspace = false;
|
||||
|
||||
LangType _langType = L_EXTERNAL;
|
||||
generic_string _localizationPath;
|
||||
|
@ -240,14 +241,15 @@ struct CmdLineParams
|
|||
// A POD class to send CmdLineParams through WM_COPYDATA and to Notepad_plus::loadCommandlineParams
|
||||
struct CmdLineParamsDTO
|
||||
{
|
||||
bool _isReadOnly;
|
||||
bool _isNoSession;
|
||||
bool _isSessionFile;
|
||||
bool _isRecursive;
|
||||
bool _isReadOnly = false;
|
||||
bool _isNoSession = false;
|
||||
bool _isSessionFile = false;
|
||||
bool _isRecursive = false;
|
||||
bool _openFoldersAsWorkspace = false;
|
||||
|
||||
int _line2go;
|
||||
int _column2go;
|
||||
int _pos2go;
|
||||
int _line2go = 0;
|
||||
int _column2go = 0;
|
||||
int _pos2go = 0;
|
||||
|
||||
LangType _langType;
|
||||
|
||||
|
@ -258,6 +260,7 @@ struct CmdLineParamsDTO
|
|||
dto._isNoSession = params._isNoSession;
|
||||
dto._isSessionFile = params._isSessionFile;
|
||||
dto._isRecursive = params._isRecursive;
|
||||
dto._openFoldersAsWorkspace = params._openFoldersAsWorkspace;
|
||||
|
||||
dto._line2go = params._line2go;
|
||||
dto._column2go = params._column2go;
|
||||
|
|
|
@ -643,9 +643,8 @@ void FileBrowser::popupMenuCmd(int cmdID)
|
|||
|
||||
switch (cmdID)
|
||||
{
|
||||
|
||||
//
|
||||
// Toolbar menu commands
|
||||
// FileBrowser menu commands
|
||||
//
|
||||
case IDM_FILEBROWSER_REMOVEROOTFOLDER:
|
||||
{
|
||||
|
@ -877,7 +876,10 @@ bool isRelatedRootFolder(const generic_string & relatedRoot, const generic_strin
|
|||
|
||||
void FileBrowser::addRootFolder(generic_string rootFolderPath)
|
||||
{
|
||||
if (not ::PathFileExists(rootFolderPath.c_str()))
|
||||
if (!::PathFileExists(rootFolderPath.c_str()))
|
||||
return;
|
||||
|
||||
if (!::PathIsDirectory(rootFolderPath.c_str()))
|
||||
return;
|
||||
|
||||
// make sure there's no '\' at the end
|
||||
|
@ -1138,7 +1140,7 @@ HTREEITEM FileBrowser::findInTree(const generic_string& rootPath, HTREEITEM node
|
|||
}
|
||||
|
||||
bool FileBrowser::deleteFromTree(const generic_string& rootPath, HTREEITEM node, std::vector<generic_string> linarPathArray)
|
||||
{
|
||||
{
|
||||
HTREEITEM foundItem = findInTree(rootPath, node, linarPathArray);
|
||||
if (foundItem == nullptr)
|
||||
return false;
|
||||
|
@ -1146,10 +1148,10 @@ bool FileBrowser::deleteFromTree(const generic_string& rootPath, HTREEITEM node,
|
|||
// found it, delete it
|
||||
_treeView.removeItem(foundItem);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool FileBrowser::renameInTree(const generic_string& rootPath, HTREEITEM node, std::vector<generic_string> linarPathArrayFrom, const generic_string & renameTo)
|
||||
{
|
||||
{
|
||||
HTREEITEM foundItem = findInTree(rootPath, node, linarPathArrayFrom);
|
||||
if (foundItem == nullptr)
|
||||
return false;
|
||||
|
|
|
@ -152,6 +152,10 @@ public:
|
|||
bool addInTree(const generic_string& rootPath, const generic_string& addItemFullPath, HTREEITEM node, std::vector<generic_string> linarPathArray);
|
||||
HTREEITEM findInTree(const generic_string& rootPath, HTREEITEM node, std::vector<generic_string> linarPathArray);
|
||||
bool deleteFromTree(const generic_string& rootPath, HTREEITEM node, std::vector<generic_string> linarPathArray);
|
||||
void deleteAllFromTree() {
|
||||
popupMenuCmd(IDM_FILEBROWSER_REMOVEALLROOTS);
|
||||
};
|
||||
|
||||
bool renameInTree(const generic_string& rootPath, HTREEITEM node, std::vector<generic_string> linarPathArrayFrom, const generic_string & renameTo);
|
||||
|
||||
std::vector<generic_string> getRoots() const;
|
||||
|
|
|
@ -284,7 +284,7 @@ const TCHAR FLAG_RECURSIVE[] = TEXT("-r");
|
|||
const TCHAR FLAG_FUNCLSTEXPORT[] = TEXT("-export=functionList");
|
||||
const TCHAR FLAG_PRINTANDQUIT[] = TEXT("-quickPrint");
|
||||
const TCHAR FLAG_NOTEPAD_COMPATIBILITY[] = TEXT("-notepadStyleCmdline");
|
||||
|
||||
const TCHAR FLAG_OPEN_FOLDERS_AS_WORKSPACE[] = TEXT("-openFoldersAsWorkspace");
|
||||
|
||||
void doException(Notepad_plus_Window & notepad_plus_plus)
|
||||
{
|
||||
|
@ -348,6 +348,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int)
|
|||
cmdLineParams._showLoadingTime = isInList(FLAG_LOADINGTIME, params);
|
||||
cmdLineParams._isSessionFile = isInList(FLAG_OPENSESSIONFILE, params);
|
||||
cmdLineParams._isRecursive = isInList(FLAG_RECURSIVE, params);
|
||||
cmdLineParams._openFoldersAsWorkspace = isInList(FLAG_OPEN_FOLDERS_AS_WORKSPACE, params);
|
||||
cmdLineParams._langType = getLangTypeFromParam(params);
|
||||
cmdLineParams._localizationPath = getLocalizationPathFromParam(params);
|
||||
cmdLineParams._easterEggName = getEasterEggNameFromParam(params, cmdLineParams._quoteType);
|
||||
|
|
Loading…
Reference in New Issue