mirror of
https://github.com/microsoft/terminal.git
synced 2025-12-10 00:48:23 -06:00
Add suppressApplicationTitle as boolean (#2814)
* first take at suppressApplicationTitle rewrite * Rebased tab title fixes * updated settings doc * incomplete - not suppressing where application title is changing * added original startingTitle functionality back * moved suppressApplicationTitle to ICoreSettings * suppression is working, but tab navigation overrides it * suppression works, but not with panes * it works! * code cleanup * added suppressApplicationTitle to JSON schema * more code cleanup * changed starting title from wstring_view to wstring * Formatting fix
This commit is contained in:
parent
2915be5b51
commit
99a8337185
@ -47,6 +47,7 @@ Properties listed below are specific to each unique profile.
|
||||
| `snapOnInput` | Optional | Boolean | `true` | When set to `true`, the window will scroll to the command input line when typing. When set to `false`, the window will not scroll when you start typing. |
|
||||
| `source` | Optional | String | | Stores the name of the profile generator that originated this profile. _There are no discoverable values for this field._ |
|
||||
| `startingDirectory` | Optional | String | `%USERPROFILE%` | The directory the shell starts in when it is loaded. |
|
||||
| `suppressApplicationTitle` | Optional | Boolean | | When set to `true`, `tabTitle` overrides the default title of the tab and any title change messages from the application will be suppressed. When set to `false`, `tabTitle` behaves as normal. |
|
||||
| `tabTitle` | Optional | String | | If set, will replace the `name` as the title to pass to the shell on startup. Some shells (like `bash`) may choose to ignore this initial value, while others (`cmd`, `powershell`) may use this value over the lifetime of the application. |
|
||||
| `useAcrylic` | Optional | Boolean | `false` | When set to `true`, the window will have an acrylic background. When set to `false`, the window will have a plain, untextured background. |
|
||||
|
||||
|
||||
@ -520,6 +520,10 @@
|
||||
"description": "The directory the shell starts in when it is loaded.",
|
||||
"type": "string"
|
||||
},
|
||||
"suppressApplicationTitle": {
|
||||
"description": "When set to `true`, `tabTitle` overrides the default title of the tab and any title change messages from the application will be suppressed. When set to `false`, `tabTitle` behaves as normal.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"tabTitle": {
|
||||
"description": "If set, will replace the name as the title to pass to the shell on startup. Some shells (like bash) may choose to ignore this initial value, while others (cmd, powershell) may use this value over the lifetime of the application.",
|
||||
"type": "string"
|
||||
|
||||
@ -27,6 +27,7 @@ static constexpr std::string_view BackgroundKey{ "background" };
|
||||
static constexpr std::string_view SelectionBackgroundKey{ "selectionBackground" };
|
||||
static constexpr std::string_view ColorTableKey{ "colorTable" };
|
||||
static constexpr std::string_view TabTitleKey{ "tabTitle" };
|
||||
static constexpr std::string_view SuppressApplicationTitleKey{ "suppressApplicationTitle" };
|
||||
static constexpr std::string_view HistorySizeKey{ "historySize" };
|
||||
static constexpr std::string_view SnapOnInputKey{ "snapOnInput" };
|
||||
static constexpr std::string_view CursorColorKey{ "cursorColor" };
|
||||
@ -93,6 +94,7 @@ Profile::Profile(const std::optional<GUID>& guid) :
|
||||
_selectionBackground{},
|
||||
_colorTable{},
|
||||
_tabTitle{},
|
||||
_suppressApplicationTitle{},
|
||||
_historySize{ DEFAULT_HISTORY_SIZE },
|
||||
_snapOnInput{ true },
|
||||
_cursorColor{ DEFAULT_CURSOR_COLOR },
|
||||
@ -187,6 +189,11 @@ TerminalSettings Profile::CreateTerminalSettings(const std::unordered_map<std::w
|
||||
// use the profile name
|
||||
terminalSettings.StartingTitle(_tabTitle ? _tabTitle.value() : _name);
|
||||
|
||||
if (_suppressApplicationTitle)
|
||||
{
|
||||
terminalSettings.SuppressApplicationTitle(_suppressApplicationTitle);
|
||||
}
|
||||
|
||||
if (_schemeName)
|
||||
{
|
||||
const auto found = schemes.find(_schemeName.value());
|
||||
@ -322,6 +329,11 @@ Json::Value Profile::ToJson() const
|
||||
root[JsonKey(TabTitleKey)] = winrt::to_string(_tabTitle.value());
|
||||
}
|
||||
|
||||
if (_suppressApplicationTitle)
|
||||
{
|
||||
root[JsonKey(SuppressApplicationTitleKey)] = _suppressApplicationTitle;
|
||||
}
|
||||
|
||||
if (_startingDirectory)
|
||||
{
|
||||
root[JsonKey(StartingDirectoryKey)] = winrt::to_string(_startingDirectory.value());
|
||||
@ -669,6 +681,11 @@ void Profile::LayerJson(const Json::Value& json)
|
||||
auto useAcrylic{ json[JsonKey(UseAcrylicKey)] };
|
||||
_useAcrylic = useAcrylic.asBool();
|
||||
}
|
||||
if (json.isMember(JsonKey(SuppressApplicationTitleKey)))
|
||||
{
|
||||
auto suppressApplicationTitle{ json[JsonKey(SuppressApplicationTitleKey)] };
|
||||
_suppressApplicationTitle = suppressApplicationTitle.asBool();
|
||||
}
|
||||
if (json.isMember(JsonKey(CloseOnExitKey)))
|
||||
{
|
||||
auto closeOnExit{ json[JsonKey(CloseOnExitKey)] };
|
||||
@ -779,6 +796,15 @@ void Profile::SetTabTitle(std::wstring tabTitle) noexcept
|
||||
_tabTitle = std::move(tabTitle);
|
||||
}
|
||||
|
||||
// Method Description
|
||||
// - Sets if the application title will be suppressed in this profile.
|
||||
// Arguments:
|
||||
// - suppressApplicationTitle: boolean
|
||||
void Profile::SetSuppressApplicationTitle(bool suppressApplicationTitle) noexcept
|
||||
{
|
||||
_suppressApplicationTitle = suppressApplicationTitle;
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Sets this profile's icon path.
|
||||
// Arguments:
|
||||
@ -833,6 +859,11 @@ std::wstring_view Profile::GetName() const noexcept
|
||||
return _name;
|
||||
}
|
||||
|
||||
bool Profile::GetSuppressApplicationTitle() const noexcept
|
||||
{
|
||||
return _suppressApplicationTitle;
|
||||
}
|
||||
|
||||
bool Profile::HasConnectionType() const noexcept
|
||||
{
|
||||
return _connectionType.has_value();
|
||||
|
||||
@ -67,6 +67,7 @@ public:
|
||||
void SetColorScheme(std::optional<std::wstring> schemeName) noexcept;
|
||||
std::optional<std::wstring>& GetSchemeName() noexcept;
|
||||
void SetTabTitle(std::wstring tabTitle) noexcept;
|
||||
void SetSuppressApplicationTitle(bool suppressApplicationTitle) noexcept;
|
||||
void SetAcrylicOpacity(double opacity) noexcept;
|
||||
void SetCommandline(std::wstring cmdline) noexcept;
|
||||
void SetStartingDirectory(std::wstring startingDirectory) noexcept;
|
||||
@ -86,6 +87,7 @@ public:
|
||||
winrt::hstring GetExpandedBackgroundImagePath() const;
|
||||
|
||||
bool GetCloseOnExit() const noexcept;
|
||||
bool GetSuppressApplicationTitle() const noexcept;
|
||||
bool IsHidden() const noexcept;
|
||||
|
||||
void GenerateGuidIfNecessary() noexcept;
|
||||
@ -122,6 +124,7 @@ private:
|
||||
std::optional<uint32_t> _selectionBackground;
|
||||
std::array<uint32_t, COLOR_TABLE_SIZE> _colorTable;
|
||||
std::optional<std::wstring> _tabTitle;
|
||||
bool _suppressApplicationTitle;
|
||||
int32_t _historySize;
|
||||
bool _snapOnInput;
|
||||
uint32_t _cursorColor;
|
||||
|
||||
@ -139,6 +139,10 @@ void Terminal::UpdateSettings(winrt::Microsoft::Terminal::Settings::ICoreSetting
|
||||
|
||||
_copyOnSelect = settings.CopyOnSelect();
|
||||
|
||||
_suppressApplicationTitle = settings.SuppressApplicationTitle();
|
||||
|
||||
_startingTitle = settings.StartingTitle();
|
||||
|
||||
// TODO:MSFT:21327402 - if HistorySize has changed, resize the buffer so we
|
||||
// have a smaller scrollback. We should do this carefully - if the new buffer
|
||||
// size is smaller than where the mutable viewport currently is, we'll want
|
||||
|
||||
@ -162,12 +162,14 @@ private:
|
||||
std::unique_ptr<::Microsoft::Console::VirtualTerminal::TerminalInput> _terminalInput;
|
||||
|
||||
std::wstring _title;
|
||||
std::wstring _startingTitle;
|
||||
|
||||
std::array<COLORREF, XTERM_COLOR_TABLE_SIZE> _colorTable;
|
||||
COLORREF _defaultFg;
|
||||
COLORREF _defaultBg;
|
||||
|
||||
bool _snapOnInput;
|
||||
bool _suppressApplicationTitle;
|
||||
|
||||
#pragma region Text Selection
|
||||
enum class SelectionExpansionMode
|
||||
|
||||
@ -365,11 +365,24 @@ bool Terminal::EraseInDisplay(const DispatchTypes::EraseType eraseType)
|
||||
|
||||
bool Terminal::SetWindowTitle(std::wstring_view title)
|
||||
{
|
||||
// Set the title on Terminal load
|
||||
if (_title.empty())
|
||||
{
|
||||
_title = title;
|
||||
_pfnTitleChanged(title);
|
||||
}
|
||||
|
||||
_title = title;
|
||||
|
||||
if (_pfnTitleChanged)
|
||||
// If this is removed, the tab object assumes the application title is the title
|
||||
if (_suppressApplicationTitle)
|
||||
{
|
||||
_pfnTitleChanged(title);
|
||||
_title = _startingTitle;
|
||||
}
|
||||
|
||||
if (_pfnTitleChanged && !_suppressApplicationTitle)
|
||||
{
|
||||
_pfnTitleChanged(_title);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -32,7 +32,6 @@ namespace Microsoft.Terminal.Settings
|
||||
|
||||
String Commandline;
|
||||
String StartingDirectory;
|
||||
String StartingTitle;
|
||||
String EnvironmentVariables;
|
||||
|
||||
String BackgroundImage;
|
||||
|
||||
@ -27,6 +27,8 @@ namespace Microsoft.Terminal.Settings
|
||||
UInt32 CursorColor;
|
||||
CursorStyle CursorShape;
|
||||
UInt32 CursorHeight;
|
||||
String StartingTitle;
|
||||
Boolean SuppressApplicationTitle;
|
||||
String WordDelimiters;
|
||||
Boolean CopyOnSelect;
|
||||
};
|
||||
|
||||
@ -321,6 +321,16 @@ namespace winrt::Microsoft::Terminal::Settings::implementation
|
||||
_startingTitle = value;
|
||||
}
|
||||
|
||||
bool TerminalSettings::SuppressApplicationTitle()
|
||||
{
|
||||
return _suppressApplicationTitle;
|
||||
}
|
||||
|
||||
void TerminalSettings::SuppressApplicationTitle(bool value)
|
||||
{
|
||||
_suppressApplicationTitle = value;
|
||||
}
|
||||
|
||||
hstring TerminalSettings::EnvironmentVariables()
|
||||
{
|
||||
return _envVars;
|
||||
|
||||
@ -90,6 +90,9 @@ namespace winrt::Microsoft::Terminal::Settings::implementation
|
||||
hstring StartingTitle();
|
||||
void StartingTitle(hstring const& value);
|
||||
|
||||
bool SuppressApplicationTitle();
|
||||
void SuppressApplicationTitle(bool value);
|
||||
|
||||
hstring EnvironmentVariables();
|
||||
void EnvironmentVariables(hstring const& value);
|
||||
|
||||
@ -125,6 +128,7 @@ namespace winrt::Microsoft::Terminal::Settings::implementation
|
||||
hstring _commandline;
|
||||
hstring _startingDir;
|
||||
hstring _startingTitle;
|
||||
bool _suppressApplicationTitle;
|
||||
hstring _envVars;
|
||||
Settings::IKeyBindings _keyBindings;
|
||||
Settings::ScrollbarState _scrollbarState;
|
||||
|
||||
@ -33,6 +33,8 @@ namespace TerminalCoreUnitTests
|
||||
uint32_t CursorHeight() { return 42UL; }
|
||||
winrt::hstring WordDelimiters() { return winrt::to_hstring(DEFAULT_WORD_DELIMITERS.c_str()); }
|
||||
bool CopyOnSelect() { return _copyOnSelect; }
|
||||
winrt::hstring StartingTitle() { return _startingTitle; }
|
||||
bool SuppressApplicationTitle() { return _suppressApplicationTitle; }
|
||||
uint32_t SelectionBackground() { return COLOR_WHITE; }
|
||||
|
||||
// other implemented methods
|
||||
@ -50,6 +52,8 @@ namespace TerminalCoreUnitTests
|
||||
void CursorHeight(uint32_t) {}
|
||||
void WordDelimiters(winrt::hstring) {}
|
||||
void CopyOnSelect(bool copyOnSelect) { _copyOnSelect = copyOnSelect; }
|
||||
void StartingTitle(winrt::hstring const& value) { _startingTitle = value; }
|
||||
void SuppressApplicationTitle(bool suppressApplicationTitle) { _suppressApplicationTitle = suppressApplicationTitle; }
|
||||
void SelectionBackground(uint32_t) {}
|
||||
|
||||
// other unimplemented methods
|
||||
@ -60,5 +64,7 @@ namespace TerminalCoreUnitTests
|
||||
int32_t _initialRows;
|
||||
int32_t _initialCols;
|
||||
bool _copyOnSelect{ false };
|
||||
bool _suppressApplicationTitle{ false };
|
||||
winrt::hstring _startingTitle;
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user