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:
<GUIConfig name="commandLineInterpreter">powershell</GUIConfig>

(Use your shell to replace powershell)

Close #7737, close #7738
This commit is contained in:
Waldi Ravens 2019-08-06 12:01:04 +02:00 committed by Don HO
parent 1929cce416
commit 4228c315fd
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E
4 changed files with 22 additions and 6 deletions

View File

@ -89,7 +89,7 @@ void Notepad_plus::command(int id)
case IDM_FILE_OPEN_CMD: case IDM_FILE_OPEN_CMD:
{ {
Command cmd(TEXT("cmd")); Command cmd(NppParameters::getInstance().getNppGUI()._commandLineInterpreter.c_str());
cmd.run(_pPublicInterface->getHSelf(), TEXT("$(CURRENT_DIRECTORY)")); cmd.run(_pPublicInterface->getHSelf(), TEXT("$(CURRENT_DIRECTORY)"));
} }
break; break;

View File

@ -2076,7 +2076,6 @@ bool NppParameters::getSessionFromXmlTree(TiXmlDocument *pSessionDoc, Session *p
(childNode->ToElement())->Attribute(TEXT("endPos"), &position._endPos); (childNode->ToElement())->Attribute(TEXT("endPos"), &position._endPos);
(childNode->ToElement())->Attribute(TEXT("selMode"), &position._selMode); (childNode->ToElement())->Attribute(TEXT("selMode"), &position._selMode);
(childNode->ToElement())->Attribute(TEXT("scrollWidth"), &position._scrollWidth); (childNode->ToElement())->Attribute(TEXT("scrollWidth"), &position._scrollWidth);
MapPosition mapPosition; MapPosition mapPosition;
int32_t mapPosVal; int32_t mapPosVal;
const TCHAR *mapPosStr = (childNode->ToElement())->Attribute(TEXT("mapFirstVisibleDisplayLine"), &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")); const TCHAR * optDocPeekOnMap = element->Attribute(TEXT("docPeekOnMap"));
if (optDocPeekOnMap) if (optDocPeekOnMap)
_nppGUI._isDocPeekOnMap = (lstrcmp(optDocPeekOnMap, TEXT("yes")) == 0); _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")); GUIConfigElement->SetAttribute(TEXT("onAnotherView"), _nppGUI._smartHiliteOnAnotherView ? TEXT("yes") : TEXT("no"));
} }
// <GUIConfig name="commandLineInterpreter">powershell</GUIConfig>
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()));
}
// <GUIConfig name="ScintillaPrimaryView" lineNumberMargin="show" bookMarkMargin="show" indentGuideLine="show" folderMarkStyle="box" lineWrapMethod="aligned" currentLineHilitingShow="show" scrollBeyondLastLine="no" disableAdvancedScrolling="no" wrapSymbolShow="hide" Wrap="no" borderEdge="yes" edge="no" edgeNbColumn="80" zoom="0" zoom2="0" whiteSpaceShow="hide" eolShow="hide" borderWidth="2" smoothFont="no" /> // <GUIConfig name="ScintillaPrimaryView" lineNumberMargin="show" bookMarkMargin="show" indentGuideLine="show" folderMarkStyle="box" lineWrapMethod="aligned" currentLineHilitingShow="show" scrollBeyondLastLine="no" disableAdvancedScrolling="no" wrapSymbolShow="hide" Wrap="no" borderEdge="yes" edge="no" edgeNbColumn="80" zoom="0" zoom2="0" whiteSpaceShow="hide" eolShow="hide" borderWidth="2" smoothFont="no" />
writeScintillaParams(); writeScintillaParams();

View File

@ -857,6 +857,8 @@ struct NppGUI final
generic_string _definedSessionExt; generic_string _definedSessionExt;
generic_string _definedWorkspaceExt; generic_string _definedWorkspaceExt;
generic_string _commandLineInterpreter = TEXT("cmd");
struct AutoUpdateOptions struct AutoUpdateOptions
{ {
bool _doAutoUpdate = true; bool _doAutoUpdate = true;

View File

@ -779,9 +779,7 @@ void FileBrowser::popupMenuCmd(int cmdID)
generic_string path = getNodePath(selectedNode); generic_string path = getNodePath(selectedNode);
if (::PathFileExists(path.c_str())) if (::PathFileExists(path.c_str()))
{ {
TCHAR cmdStr[1024]; Command cmd(NppParameters::getInstance().getNppGUI()._commandLineInterpreter.c_str());
wsprintf(cmdStr, TEXT("cmd"));
Command cmd(cmdStr);
cmd.run(nullptr, path.c_str()); cmd.run(nullptr, path.c_str());
} }
} }