From 2fdcb679ab1f1f1edc542e3b86327dacea78f7ac Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Thu, 23 May 2019 17:02:32 -0500 Subject: [PATCH] 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 --- src/cascadia/TerminalApp/CascadiaSettings.cpp | 70 ++++++++++++------- src/cascadia/TerminalApp/CascadiaSettings.h | 3 +- .../TerminalApp/GlobalAppSettings.cpp | 7 +- src/inc/DefaultSettings.h | 5 +- 4 files changed, 53 insertions(+), 32 deletions(-) diff --git a/src/cascadia/TerminalApp/CascadiaSettings.cpp b/src/cascadia/TerminalApp/CascadiaSettings.cpp index 6016eb800c..f0e31ea9c0 100644 --- a/src/cascadia/TerminalApp/CascadiaSettings.cpp +++ b/src/cascadia/TerminalApp/CascadiaSettings.cpp @@ -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: -// - -// Return Value: -// - +// 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"; diff --git a/src/cascadia/TerminalApp/CascadiaSettings.h b/src/cascadia/TerminalApp/CascadiaSettings.h index b9e223a671..fd350fc062 100644 --- a/src/cascadia/TerminalApp/CascadiaSettings.h +++ b/src/cascadia/TerminalApp/CascadiaSettings.h @@ -68,7 +68,8 @@ private: static winrt::hstring _GetPackagedSettingsPath(); static std::optional _LoadAsPackagedApp(); static std::optional _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); }; diff --git a/src/cascadia/TerminalApp/GlobalAppSettings.cpp b/src/cascadia/TerminalApp/GlobalAppSettings.cpp index 1ae7d99e7e..16f26a80df 100644 --- a/src/cascadia/TerminalApp/GlobalAppSettings.cpp +++ b/src/cascadia/TerminalApp/GlobalAppSettings.cpp @@ -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 } { diff --git a/src/inc/DefaultSettings.h b/src/inc/DefaultSettings.h index d959e41f7d..145bba02b7 100644 --- a/src/inc/DefaultSettings.h +++ b/src/inc/DefaultSettings.h @@ -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;