Update the default settings (#918)

* Update the default settings

  * [x] `alwaysShowTabs` -> `true`
  * [x] `experimental_showTabsInTitlebar` -> `true`
  * [x] always include Windows Powershell (`background`: `#012456`)
  * [x] include PowerShell Core separately (`background`: unset)
  * [x] drop `Courier New` for powershell
  * [x] drop `experimental_` for `experimental_showTabsInTitlebar`
  * [x] reduce default font size to 10pt.

  Fixes #869
This commit is contained in:
Mike Griese 2019-05-23 17:02:32 -05:00 committed by GitHub
parent 1191a59681
commit 2fdcb679ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 32 deletions

View file

@ -183,12 +183,11 @@ void CascadiaSettings::_CreateDefaultSchemes()
// Method Description:
// - Create a set of profiles to use as the "default" profiles when initializing
// the terminal. Currently, we create two profiles: one for cmd.exe, and
// one for powershell.
// Arguments:
// - <none>
// Return Value:
// - <none>
// the terminal. Currently, we create two or three profiles:
// * one for cmd.exe
// * one for powershell.exe (inbox Windows Powershell)
// * if Powershell Core (pwsh.exe) is installed, we'll create another for
// Powershell Core.
void CascadiaSettings::_CreateDefaultProfiles()
{
auto cmdProfile{ _CreateDefaultProfile(L"cmd") };
@ -199,30 +198,35 @@ void CascadiaSettings::_CreateDefaultProfiles()
cmdProfile.SetAcrylicOpacity(0.75);
cmdProfile.SetUseAcrylic(true);
auto powershellProfile{ _CreateDefaultProfile(L"PowerShell") };
// If the user has installed PowerShell Core, we add PowerShell Core as a default.
// PowerShell Core default folder is "%PROGRAMFILES%\PowerShell\[Version]\".
std::wstring psCmdline = L"powershell.exe";
std::filesystem::path psCoreCmdline{};
if (_IsPowerShellCoreInstalled(L"%ProgramFiles%", psCoreCmdline))
{
psCmdline = psCoreCmdline;
}
else if (_IsPowerShellCoreInstalled(L"%ProgramFiles(x86)%", psCoreCmdline))
{
psCmdline = psCoreCmdline;
}
powershellProfile.SetFontFace(L"Courier New");
powershellProfile.SetCommandline(psCmdline);
auto powershellProfile{ _CreateDefaultProfile(L"Windows PowerShell") };
powershellProfile.SetCommandline(L"powershell.exe");
powershellProfile.SetStartingDirectory(DEFAULT_STARTING_DIRECTORY);
powershellProfile.SetColorScheme({ L"Campbell" });
powershellProfile.SetDefaultBackground(RGB(1, 36, 86));
powershellProfile.SetDefaultBackground(POWERSHELL_BLUE);
powershellProfile.SetUseAcrylic(false);
// If the user has installed PowerShell Core, we add PowerShell Core as a default.
// PowerShell Core default folder is "%PROGRAMFILES%\PowerShell\[Version]\".
std::filesystem::path psCoreCmdline{};
if (_isPowerShellCoreInstalled(psCoreCmdline))
{
auto pwshProfile{ _CreateDefaultProfile(L"PowerShell Core") };
pwshProfile.SetCommandline(psCoreCmdline);
pwshProfile.SetStartingDirectory(DEFAULT_STARTING_DIRECTORY);
pwshProfile.SetColorScheme({ L"Campbell" });
// If powershell core is installed, we'll use that as the default.
// Otherwise, we'll use normal Windows Powershell as the default.
_profiles.emplace_back(pwshProfile);
_globals.SetDefaultProfile(pwshProfile.GetGuid());
}
else
{
_globals.SetDefaultProfile(powershellProfile.GetGuid());
}
_profiles.emplace_back(powershellProfile);
_profiles.emplace_back(cmdProfile);
_globals.SetDefaultProfile(powershellProfile.GetGuid());
}
// Method Description:
@ -422,14 +426,28 @@ GlobalAppSettings& CascadiaSettings::GlobalSettings()
return _globals;
}
// Function Description:
// - Returns true if the user has installed PowerShell Core. This will check
// both %ProgramFiles% and %ProgramFiles(x86)%, and will return true if
// powershell core was installed in either location.
// Arguments:
// - A ref of a path that receives the result of PowerShell Core pwsh.exe full path.
// Return Value:
// - true iff powershell core (pwsh.exe) is present.
bool CascadiaSettings::_isPowerShellCoreInstalled(std::filesystem::path& cmdline)
{
return _isPowerShellCoreInstalledInPath(L"%ProgramFiles%", cmdline) ||
_isPowerShellCoreInstalledInPath(L"%ProgramFiles(x86)%", cmdline);
}
// Function Description:
// - Returns true if the user has installed PowerShell Core.
// Arguments:
// - A string that contains an environment-variable string in the form: %variableName%.
// - A ref of a path that receives the result of PowerShell Core pwsh.exe full path.
// Return Value:
// - true or false.
bool CascadiaSettings::_IsPowerShellCoreInstalled(std::wstring_view programFileEnv, std::filesystem::path& cmdline)
// - true iff powershell core (pwsh.exe) is present in the given path
bool CascadiaSettings::_isPowerShellCoreInstalledInPath(const std::wstring_view programFileEnv, std::filesystem::path& cmdline)
{
std::filesystem::path psCorePath = ExpandEnvironmentVariableString(programFileEnv.data());
psCorePath /= L"PowerShell";

View file

@ -68,7 +68,8 @@ private:
static winrt::hstring _GetPackagedSettingsPath();
static std::optional<winrt::hstring> _LoadAsPackagedApp();
static std::optional<winrt::hstring> _LoadAsUnpackagedApp();
static bool _IsPowerShellCoreInstalled(std::wstring_view programFileEnv, std::filesystem::path& cmdline);
static bool _isPowerShellCoreInstalledInPath(const std::wstring_view programFileEnv, std::filesystem::path& cmdline);
static bool _isPowerShellCoreInstalled(std::filesystem::path& cmdline);
static std::wstring ExpandEnvironmentVariableString(std::wstring_view source);
static Profile _CreateDefaultProfile(const std::wstring_view name);
};

View file

@ -19,8 +19,7 @@ static constexpr std::wstring_view INITIALROWS_KEY{ L"initialRows" };
static constexpr std::wstring_view INITIALCOLS_KEY{ L"initialCols" };
static constexpr std::wstring_view SHOW_TITLE_IN_TITLEBAR_KEY{ L"showTerminalTitleInTitlebar" };
static constexpr std::wstring_view REQUESTED_THEME_KEY{ L"requestedTheme" };
static constexpr std::wstring_view SHOW_TABS_IN_TITLEBAR_KEY{ L"experimental_showTabsInTitlebar" };
static constexpr std::wstring_view SHOW_TABS_IN_TITLEBAR_KEY{ L"showTabsInTitlebar" };
static constexpr std::wstring_view LIGHT_THEME_VALUE{ L"light" };
static constexpr std::wstring_view DARK_THEME_VALUE{ L"dark" };
@ -30,11 +29,11 @@ GlobalAppSettings::GlobalAppSettings() :
_keybindings{},
_colorSchemes{},
_defaultProfile{},
_alwaysShowTabs{ false },
_alwaysShowTabs{ true },
_initialRows{ DEFAULT_ROWS },
_initialCols{ DEFAULT_COLS },
_showTitleInTitlebar{ true },
_showTabsInTitlebar{ false },
_showTabsInTitlebar{ true },
_requestedTheme{ ElementTheme::Default }
{

View file

@ -22,9 +22,12 @@ constexpr COLORREF DEFAULT_FOREGROUND = COLOR_WHITE;
constexpr COLORREF DEFAULT_FOREGROUND_WITH_ALPHA = OPACITY_OPAQUE | DEFAULT_FOREGROUND;
constexpr COLORREF DEFAULT_BACKGROUND = COLOR_BLACK;
constexpr COLORREF DEFAULT_BACKGROUND_WITH_ALPHA = OPACITY_OPAQUE | DEFAULT_BACKGROUND;
constexpr COLORREF POWERSHELL_BLUE = RGB(1, 36, 86);
constexpr short DEFAULT_HISTORY_SIZE = 9001;
const std::wstring DEFAULT_FONT_FACE { L"Consolas" };
constexpr int DEFAULT_FONT_SIZE = 12;
constexpr int DEFAULT_FONT_SIZE = 10;
constexpr int DEFAULT_ROWS = 30;
constexpr int DEFAULT_COLS = 120;