MCPcopy Create free account
hub / github.com/ConEmu/ConEmu / CmdTaskGetDefaultShell

Method CmdTaskGetDefaultShell

src/ConEmu/Options.cpp:5217–5269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5215#undef IsLuaMacroOk
5216
5217bool Settings::CmdTaskGetDefaultShell(RConStartArgsEx& args, CEStr& lsTitle)
5218{
5219 lsTitle.Clear();
5220
5221 // User defined default shell task? (Win+X)
5222 int nGroup = 0;
5223 const CommandTasks* pGrp = nullptr;
5224 while ((pGrp = gpSet->CmdTaskGet(nGroup++)))
5225 {
5226 if (pGrp->pszName && *pGrp->pszName
5227 && (pGrp->Flags & CETF_CMD_DEFAULT))
5228 {
5229 // Process "/dir ..." and other switches
5230 pGrp->ParseGuiArgs(&args);
5231 SafeFree(args.pszSpecialCmd);
5232
5233 // Run all tabs of the task, if they were specified
5234 args.pszSpecialCmd = lstrdup(pGrp->pszName).Detach();
5235 lsTitle.Set(pGrp->pszName);
5236 break;
5237 }
5238 }
5239
5240 if (!args.pszSpecialCmd)
5241 {
5242 args.pszSpecialCmd = GetComspec(&gpSet->ComSpec).Detach(); //lstrdup(L"cmd");
5243 if (!args.pszSpecialCmd)
5244 {
5245 _ASSERTE(FALSE && "Memory allocation failure");
5246 return false;
5247 }
5248
5249 CmdArg lsExe; LPCWSTR pszTemp = args.pszSpecialCmd;
5250 if ((pszTemp = NextArg(pszTemp, lsExe)))
5251 lsTitle.Set(PointToName(lsExe));
5252 if (lsTitle.IsEmpty())
5253 lsTitle.Set(L"cmd.exe");
5254
5255 CEStr merged(args.pszSpecialCmd, L" /k \"%ConEmuBaseDir%\\CmdInit.cmd\"");
5256 if (merged)
5257 {
5258 SafeFree(args.pszSpecialCmd);
5259 args.pszSpecialCmd = merged.Detach();
5260 }
5261 }
5262
5263 if (!args.pszStartupDir)
5264 {
5265 args.pszStartupDir = lstrdup(L"%CD%").Detach();
5266 }
5267
5268 return true;
5269}
5270
5271const CommandTasks* Settings::CmdTaskGet(int anIndex)
5272{

Callers 2

GetDescriptionMethod · 0.80
key_MultiCmdMethod · 0.80

Calls 10

lstrdupFunction · 0.85
GetComspecFunction · 0.85
PointToNameFunction · 0.85
CmdTaskGetMethod · 0.80
ParseGuiArgsMethod · 0.80
NextArgFunction · 0.50
ClearMethod · 0.45
DetachMethod · 0.45
SetMethod · 0.45
IsEmptyMethod · 0.45

Tested by

no test coverage detected