Merge remote-tracking branch 'upstream/development' into development-dax

* upstream/development: (84 commits)
  update profile.ps1's debug output
  Make PowerShell profile.ps1's debug and verbose working correctly
  Redirect Verbose and Debug stream
  ignore git commit
  fix line endings
  adjust comments
  Update PowerShell test to set CMDER_DEBUG env variable inline
  improve CI PowrShell profile test debug/verbose output
  Modify PowerShell test command for debug output
  fix incorrect comment
  adjust comments
  adjust comments
  adjust comments
  Avoid duplicating cmd.exe prompt definition
  Consolidate terminal conditionals and add shell integration for bash and cmd.exe
  Add OSC 133;D support for command exit code tracking
  Initial plan
  adjust comments
  simplify regex
  adjust comments
  ...
This commit is contained in:
Dax T. Games
2025-11-27 14:08:51 +00:00
29 changed files with 649 additions and 392 deletions

View File

@@ -105,11 +105,11 @@ bool FileExists(const wchar_t * filePath)
return false;
}
void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstring taskName = L"", std::wstring title = L"", std::wstring iconPath = L"", std::wstring cfgRoot = L"", bool use_user_cfg = true, std::wstring conemu_args = L"", bool admin = false)
void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstring taskName = L"", std::wstring title = L"", std::wstring iconPath = L"", std::wstring cfgRoot = L"", bool use_user_cfg = true, std::wstring conemu_args = L"")
{
#if USE_TASKBAR_API
wchar_t appId[MAX_PATH] = { 0 };
#endif
#if USE_TASKBAR_API
wchar_t appId[MAX_PATH] = { 0 };
#endif
wchar_t exeDir[MAX_PATH] = { 0 };
wchar_t icoPath[MAX_PATH] = { 0 };
wchar_t cfgPath[MAX_PATH] = { 0 };
@@ -153,9 +153,9 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
GetModuleFileName(NULL, exeDir, sizeof(exeDir));
#if USE_TASKBAR_API
wcscpy_s(appId, exeDir);
#endif
#if USE_TASKBAR_API
wcscpy_s(appId, exeDir);
#endif
PathRemoveFileSpec(exeDir);
@@ -312,7 +312,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
MessageBox(NULL,
(GetLastError() == ERROR_ACCESS_DENIED)
? L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/windows_terminal_%COMPUTERNAME%_settings.json! Access Denied."
: L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/windows_teerminal_%COMPUTERNAME%_settigns.json!", MB_TITLE, MB_ICONSTOP);
: L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/windows_terminal_%COMPUTERNAME%_settigns.json!", MB_TITLE, MB_ICONSTOP);
exit(1);
}
else if (PathFileExists(conEmuDir))
@@ -329,7 +329,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
{
if (!CopyFile(cpuCfgPath, cfgPath, FALSE))
{
if (PathFileExists(windowsTerminalDir)) {
if (PathFileExists(windowsTerminalDir)) {
MessageBox(NULL,
(GetLastError() == ERROR_ACCESS_DENIED)
? L"Failed to copy config/windows_terminal_%COMPUTERNAME%_settings.json file to vendor/windows-terminal/settings/settings.json! Access Denied."
@@ -360,7 +360,7 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
MessageBox(NULL,
(GetLastError() == ERROR_ACCESS_DENIED)
? L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/windows_terminal_settings.json! Access Denied."
: L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/windows_teerminal_settigns.json!", MB_TITLE, MB_ICONSTOP);
: L"Failed to copy vendor/windows-terminal/settings/settings.json file to config/windows_terminal_settigns.json!", MB_TITLE, MB_ICONSTOP);
exit(1);
}
else if (PathFileExists(conEmuDir))
@@ -645,44 +645,13 @@ void StartCmder(std::wstring path = L"", bool is_single_mode = false, std::wstr
STARTUPINFO si = { 0 };
si.cb = sizeof(STARTUPINFO);
#if USE_TASKBAR_API
si.lpTitle = appId;
si.dwFlags = STARTF_TITLEISAPPID;
#endif
#if USE_TASKBAR_API
si.lpTitle = appId;
si.dwFlags = STARTF_TITLEISAPPID;
#endif
PROCESS_INFORMATION pi;
// MessageBox(NULL, terminalPath, _T("Error"), MB_OK);
// MessageBox(NULL, args, _T("Error"), MB_OK);
// Let's try to rerun as Administrator
SHELLEXECUTEINFO sei = { sizeof(sei) };
sei.fMask = SEE_MASK_NOASYNC | SEE_MASK_NOCLOSEPROCESS;
sei.lpVerb = L"runas";
sei.lpFile = terminalPath;
sei.lpParameters = args;
sei.nShow = SW_SHOWNORMAL;
if (admin && ShellExecuteEx(&sei))
{
if (!sei.hProcess)
{
Sleep(500);
_ASSERTE(sei.hProcess != nullptr);
}
if (sei.hProcess)
{
WaitForSingleObject(sei.hProcess, INFINITE);
}
// int nZone = 0;
// if (!HasZoneIdentifier(lsFile, nZone)
// || (nZone != 0 /*LocalComputer*/))
// {
// // Assuming that elevated copy has fixed all zone problems
// break;
// }
}
else if (!CreateProcess(terminalPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi))
if (!CreateProcess(terminalPath, args, NULL, NULL, false, 0, NULL, NULL, &si, &pi))
{
if (PathFileExists(windowsTerminalDir))
{
@@ -813,7 +782,6 @@ struct cmderOptions
std::wstring cmderIcon = L"";
std::wstring cmderRegScope = L"USER";
std::wstring cmderTerminalArgs = L"";
bool cmderAdmin = false;
bool cmderSingle = false;
bool cmderUserCfg = true;
bool registerApp = false;
@@ -902,10 +870,6 @@ cmderOptions GetOption()
{
cmderOptions.cmderUserCfg = false;
}
else if (_wcsicmp(L"/a", szArgList[i]) == 0 && !PathFileExists(windowsTerminalDir) && !PathFileExists(conEmuDir))
{
cmderOptions.cmderAdmin = true;
}
else if (_wcsicmp(L"/register", szArgList[i]) == 0)
{
cmderOptions.registerApp = true;
@@ -1042,7 +1006,8 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
}
else
{
StartCmder(cmderOptions.cmderStart, cmderOptions.cmderSingle, cmderOptions.cmderTask, cmderOptions.cmderTitle, cmderOptions.cmderIcon, cmderOptions.cmderCfgRoot, cmderOptions.cmderUserCfg, cmderOptions.cmderTerminalArgs, cmderOptions.cmderAdmin); }
StartCmder(cmderOptions.cmderStart, cmderOptions.cmderSingle, cmderOptions.cmderTask, cmderOptions.cmderTitle, cmderOptions.cmderIcon, cmderOptions.cmderCfgRoot, cmderOptions.cmderUserCfg, cmderOptions.cmderTerminalArgs);
}
return 0;
}