Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No more are you sure boxes #4101

Merged
12 commits merged into from
Jan 31, 2020
1 change: 1 addition & 0 deletions doc/cascadia/SettingsSchema.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Properties listed below affect the entire window, regardless of the profile sett
| `snapToGridOnResize` | Optional | Boolean | `false` | When set to `true`, the window will snap to the nearest character boundary on resize. When `false`, the window will resize "smoothly" |
| `tabWidthMode` | Optional | String | `equal` | Sets the width of the tabs. Possible values: `"equal"`, `"titleLength"` |
| `wordDelimiters` | Optional | String | <code>&nbsp;&#x2f;&#x5c;&#x28;&#x29;&#x22;&#x27;&#x2d;&#x3a;&#x2c;&#x2e;&#x3b;&#x3c;&#x3e;&#x7e;&#x21;&#x40;&#x23;&#x24;&#x25;&#x5e;&#x26;&#x2a;&#x7c;&#x2b;&#x3d;&#x5b;&#x5d;&#x7b;&#x7d;&#x7e;&#x3f;│</code><br>_(`│` is `U+2502 BOX DRAWINGS LIGHT VERTICAL`)_ | Determines the delimiters used in a double click selection. |
| `confirmCloseAllTabs` | Optional | Boolean | `true` | When set to `true` closing a window with multiple tabs open WILL require confirmation. When set to `false` closing a window with multiple tabs open WILL NOT require confirmation. |

## Profiles
Properties listed below are specific to each unique profile.
Expand Down
5 changes: 5 additions & 0 deletions doc/cascadia/profiles.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,11 @@
"default": " ./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}~?│",
"description": "Determines the delimiters used in a double click selection.",
"type": "string"
},
"confirmCloseAllTabs": {
"default": true,
"description": " When set to `true` closing a window with multiple tabs open WILL require confirmation. When set to `false` closing a window with multiple tabs open WILL NOT require confirmation.",
"type":"boolean"
}
},
"required": [
Expand Down
16 changes: 16 additions & 0 deletions src/cascadia/TerminalApp/GlobalAppSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ static constexpr std::string_view ShowTabsInTitlebarKey{ "showTabsInTitlebar" };
static constexpr std::string_view WordDelimitersKey{ "wordDelimiters" };
static constexpr std::string_view CopyOnSelectKey{ "copyOnSelect" };
static constexpr std::string_view LaunchModeKey{ "launchMode" };
static constexpr std::string_view ConfirmCloseAllKey{ "confirmCloseAllTabs" };
static constexpr std::string_view SnapToGridOnResizeKey{ "snapToGridOnResize" };
static constexpr std::wstring_view DefaultLaunchModeValue{ L"default" };
static constexpr std::wstring_view MaximizedLaunchModeValue{ L"maximized" };
Expand All @@ -45,6 +46,7 @@ GlobalAppSettings::GlobalAppSettings() :
_colorSchemes{},
_defaultProfile{},
_alwaysShowTabs{ true },
_confirmCloseAllTabs{ true },
_initialRows{ DEFAULT_ROWS },
_initialCols{ DEFAULT_COLS },
_rowsToScroll{ DEFAULT_ROWSTOSCROLL },
Expand Down Expand Up @@ -158,6 +160,15 @@ void GlobalAppSettings::SetLaunchMode(const LaunchMode launchMode)
{
_launchMode = launchMode;
}
bool GlobalAppSettings::GetConfirmCloseAllTabs() const noexcept
{
return _confirmCloseAllTabs;
}

void GlobalAppSettings::SetConfirmCloseAllTabs(const bool confirmCloseAllTabs) noexcept
{
_confirmCloseAllTabs = confirmCloseAllTabs;
}

#pragma region ExperimentalSettings
bool GlobalAppSettings::GetShowTabsInTitlebar() const noexcept
Expand Down Expand Up @@ -223,6 +234,7 @@ Json::Value GlobalAppSettings::ToJson() const
jsonObject[JsonKey(RequestedThemeKey)] = winrt::to_string(_SerializeTheme(_requestedTheme));
jsonObject[JsonKey(TabWidthModeKey)] = winrt::to_string(_SerializeTabWidthMode(_tabWidthMode));
jsonObject[JsonKey(KeybindingsKey)] = _keybindings->ToJson();
jsonObject[JsonKey(ConfirmCloseAllKey)] = _confirmCloseAllTabs;
jsonObject[JsonKey(SnapToGridOnResizeKey)] = _SnapToGridOnResize;

return jsonObject;
Expand Down Expand Up @@ -253,6 +265,10 @@ void GlobalAppSettings::LayerJson(const Json::Value& json)
{
_alwaysShowTabs = alwaysShowTabs.asBool();
}
if (auto confirmCloseAllTabs{ json[JsonKey(ConfirmCloseAllKey)] })
{
_confirmCloseAllTabs = confirmCloseAllTabs.asBool();
}
if (auto initialRows{ json[JsonKey(InitialRowsKey)] })
{
_initialRows = initialRows.asInt();
Expand Down
4 changes: 4 additions & 0 deletions src/cascadia/TerminalApp/GlobalAppSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class TerminalApp::GlobalAppSettings final
bool GetShowTitleInTitlebar() const noexcept;
void SetShowTitleInTitlebar(const bool showTitleInTitlebar) noexcept;

bool GetConfirmCloseAllTabs() const noexcept;
void SetConfirmCloseAllTabs(const bool confirmCloseAllTabs) noexcept;

void SetRequestedTheme(const winrt::Windows::UI::Xaml::ElementTheme requestedTheme) noexcept;

void SetTabWidthMode(const winrt::Microsoft::UI::Xaml::Controls::TabViewWidthMode tabWidthMode);
Expand Down Expand Up @@ -99,6 +102,7 @@ class TerminalApp::GlobalAppSettings final
bool _showStatusline;
bool _alwaysShowTabs;
bool _showTitleInTitlebar;
bool _confirmCloseAllTabs;

bool _showTabsInTitlebar;
std::wstring _wordDelimiters;
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalApp/TerminalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ namespace winrt::TerminalApp::implementation
// than one tab opened, show a warning dialog.
void TerminalPage::CloseWindow()
{
if (_tabs.size() > 1)
if (_tabs.size() > 1 && _settings->GlobalSettings().GetConfirmCloseAllTabs())
{
_ShowCloseWarningDialog();
}
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalApp/defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"tabWidthMode": "equal",
"snapToGridOnResize": false,
"wordDelimiters": " /\\()\"'-.,:;<>~!@#$%^&*|+=[]{}~?\u2502",
"confirmCloseAllTabs": true,

"profiles":
[
Expand Down