From 4228c315fd53298dad0712a0bce74452fd69994b Mon Sep 17 00:00:00 2001 From: Waldi Ravens Date: Tue, 6 Aug 2019 12:01:04 +0200 Subject: [PATCH] Make cmd cli ("Open Containing Folder in cmd") customizable Add "commandLineInterpreter" setting in config.xml No UI to set it, user has to add the fowllowing line into config.xml: powershell (Use your shell to replace powershell) Close #7737, close #7738 --- PowerEditor/src/NppCommands.cpp | 2 +- PowerEditor/src/Parameters.cpp | 20 +++++++++++++++++-- PowerEditor/src/Parameters.h | 2 ++ .../WinControls/FileBrowser/fileBrowser.cpp | 4 +--- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index d43ed45c..f42bef57 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -89,7 +89,7 @@ void Notepad_plus::command(int id) case IDM_FILE_OPEN_CMD: { - Command cmd(TEXT("cmd")); + Command cmd(NppParameters::getInstance().getNppGUI()._commandLineInterpreter.c_str()); cmd.run(_pPublicInterface->getHSelf(), TEXT("$(CURRENT_DIRECTORY)")); } break; diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index d7bed691..1bbbd30e 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -2076,7 +2076,6 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session *p (childNode->ToElement())->Attribute(TEXT("endPos"), &position._endPos); (childNode->ToElement())->Attribute(TEXT("selMode"), &position._selMode); (childNode->ToElement())->Attribute(TEXT("scrollWidth"), &position._scrollWidth); - MapPosition mapPosition; int32_t mapPosVal; const TCHAR *mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapFirstVisibleDisplayLine"), &mapPosVal); @@ -5096,7 +5095,16 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) const TCHAR * optDocPeekOnMap = element->Attribute(TEXT("docPeekOnMap")); if (optDocPeekOnMap) _nppGUI._isDocPeekOnMap = (lstrcmp(optDocPeekOnMap, TEXT("yes")) == 0); - + } + else if (!lstrcmp(nm, TEXT("commandLineInterpreter"))) + { + TiXmlNode *node = childNode->FirstChild(); + if (node) + { + const TCHAR *cli = node->Value(); + if (cli && cli[0]) + _nppGUI._commandLineInterpreter.assign(cli); + } } } } @@ -5861,6 +5869,14 @@ void NppParameters::createXmlTreeFromGUIParams() GUIConfigElement->SetAttribute(TEXT("onAnotherView"), _nppGUI._smartHiliteOnAnotherView ? TEXT("yes") : TEXT("no")); } + // powershell + if (_nppGUI._commandLineInterpreter.compare(TEXT("cmd"))) + { + TiXmlElement *GUIConfigElement = (newGUIRoot->InsertEndChild(TiXmlElement(TEXT("GUIConfig"))))->ToElement(); + GUIConfigElement->SetAttribute(TEXT("name"), TEXT("commandLineInterpreter")); + GUIConfigElement->InsertEndChild(TiXmlText(_nppGUI._commandLineInterpreter.c_str())); + } + // writeScintillaParams(); diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index 715be818..f37edc86 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -857,6 +857,8 @@ struct NppGUI final generic_string _definedSessionExt; generic_string _definedWorkspaceExt; + generic_string _commandLineInterpreter = TEXT("cmd"); + struct AutoUpdateOptions { bool _doAutoUpdate = true; diff --git a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp index 5ef8c3ef..ddee5a31 100644 --- a/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp +++ b/PowerEditor/src/WinControls/FileBrowser/fileBrowser.cpp @@ -779,9 +779,7 @@ void FileBrowser::popupMenuCmd(int cmdID) generic_string path = getNodePath(selectedNode); if (::PathFileExists(path.c_str())) { - TCHAR cmdStr[1024]; - wsprintf(cmdStr, TEXT("cmd")); - Command cmd(cmdStr); + Command cmd(NppParameters::getInstance().getNppGUI()._commandLineInterpreter.c_str()); cmd.run(nullptr, path.c_str()); } }