Improve startingDirectory functionality (#604)

* Improve `startingDirectory` functionality

This commit adds the `startingDirectory` property to the default-created
`cmd` and `powershell` profiles, with the default value
`%HOMEDRIVE%%HOMEPATH%`.

Signed-off-by: Fred Miller <fghzxm@outlook.com>

* Use %USERPROFILE% to replace %HOMEDRIVE%%HOMEPATH%

This commit changes `%USERPROFILE%` in the default profiles to
`%HOMEDRIVE%%HOMEPATH%`.

https://stackoverflow.com/posts/36392591/revisions says `%USERPROFILE%`
is better than `%HOMEDRIVE%%HOMEPATH%`, so changed it.

Signed-off-by: Fred Miller <fghzxm@outlook.com>

* Improve `startingDirectory` functionality

This commit adds the `startingDirectory` property to the default-created
`cmd` and `powershell` profiles, with the default value
`%HOMEDRIVE%%HOMEPATH%`.

Signed-off-by: Fred Miller <fghzxm@outlook.com>

* Use %USERPROFILE% to replace %HOMEDRIVE%%HOMEPATH%

This commit changes `%USERPROFILE%` in the default profiles to
`%HOMEDRIVE%%HOMEPATH%`.

https://stackoverflow.com/posts/36392591/revisions says `%USERPROFILE%`
is better than `%HOMEDRIVE%%HOMEPATH%`, so changed it.

Signed-off-by: Fred Miller <fghzxm@outlook.com>

* Consolidate constant

Refer to the externally defined constant in code.

Signed-off-by: Fred Miller <fghzxm@outlook.com>
This commit is contained in:
fghzxm 2019-05-11 15:02:28 +08:00 committed by Dustin L. Howett (MSFT)
parent bf460ab7fe
commit 6088134832
3 changed files with 10 additions and 2 deletions

View file

@ -6,6 +6,7 @@
#include <conattrs.hpp>
#include "CascadiaSettings.h"
#include "../../types/inc/utils.hpp"
#include "../../inc/DefaultSettings.h"
using namespace winrt::Microsoft::Terminal::Settings;
using namespace ::TerminalApp;
@ -107,7 +108,6 @@ void CascadiaSettings::_CreateDefaultSchemes()
_globals.GetColorSchemes().emplace_back(_CreateCampbellScheme());
_globals.GetColorSchemes().emplace_back(_CreateSolarizedDarkScheme());
_globals.GetColorSchemes().emplace_back(_CreateSolarizedLightScheme());
}
// Method Description:
@ -123,6 +123,7 @@ void CascadiaSettings::_CreateDefaultProfiles()
Profile cmdProfile{};
cmdProfile.SetFontFace(L"Consolas");
cmdProfile.SetCommandline(L"cmd.exe");
cmdProfile.SetStartingDirectory(DEFAULT_STARTING_DIRECTORY);
cmdProfile.SetColorScheme({ L"Campbell" });
cmdProfile.SetAcrylicOpacity(0.75);
cmdProfile.SetUseAcrylic(true);
@ -143,6 +144,7 @@ void CascadiaSettings::_CreateDefaultProfiles()
}
powershellProfile.SetFontFace(L"Courier New");
powershellProfile.SetCommandline(psCmdline);
powershellProfile.SetStartingDirectory(DEFAULT_STARTING_DIRECTORY);
powershellProfile.SetColorScheme({ L"Campbell" });
powershellProfile.SetDefaultBackground(RGB(1, 36, 86));
powershellProfile.SetUseAcrylic(false);
@ -150,7 +152,7 @@ void CascadiaSettings::_CreateDefaultProfiles()
_profiles.emplace_back(powershellProfile);
_profiles.emplace_back(cmdProfile);
_globals.SetDefaultProfile(powershellProfile.GetGuid());
}

View file

@ -427,6 +427,11 @@ void Profile::SetCommandline(std::wstring cmdline) noexcept
_commandline = cmdline;
}
void Profile::SetStartingDirectory(std::wstring startingDirectory) noexcept
{
_startingDirectory = startingDirectory;
}
void Profile::SetName(std::wstring name) noexcept
{
_name = name;

View file

@ -40,6 +40,7 @@ public:
void SetColorScheme(std::optional<std::wstring> schemeName) noexcept;
void SetAcrylicOpacity(double opacity) noexcept;
void SetCommandline(std::wstring cmdline) noexcept;
void SetStartingDirectory(std::wstring startingDirectory) noexcept;
void SetName(std::wstring name) noexcept;
void SetUseAcrylic(bool useAcrylic) noexcept;
void SetDefaultForeground(COLORREF defaultForeground) noexcept;