2019-05-03 00:29:04 +02:00
|
|
|
// Copyright (c) Microsoft Corporation.
|
|
|
|
// Licensed under the MIT license.
|
|
|
|
|
|
|
|
#include "pch.h"
|
|
|
|
#include "TerminalSettings.h"
|
|
|
|
#include <DefaultSettings.h>
|
|
|
|
|
2019-05-23 19:36:29 +02:00
|
|
|
#include "TerminalSettings.g.cpp"
|
|
|
|
|
2019-05-03 00:29:04 +02:00
|
|
|
namespace winrt::Microsoft::Terminal::Settings::implementation
|
|
|
|
{
|
|
|
|
TerminalSettings::TerminalSettings() :
|
|
|
|
_defaultForeground{ DEFAULT_FOREGROUND_WITH_ALPHA },
|
|
|
|
_defaultBackground{ DEFAULT_BACKGROUND_WITH_ALPHA },
|
2019-11-13 19:17:39 +01:00
|
|
|
_selectionBackground{ DEFAULT_FOREGROUND },
|
2019-05-03 00:29:04 +02:00
|
|
|
_colorTable{},
|
|
|
|
_historySize{ DEFAULT_HISTORY_SIZE },
|
|
|
|
_initialRows{ 30 },
|
|
|
|
_initialCols{ 80 },
|
|
|
|
_snapOnInput{ true },
|
|
|
|
_cursorColor{ DEFAULT_CURSOR_COLOR },
|
|
|
|
_cursorShape{ CursorStyle::Vintage },
|
|
|
|
_cursorHeight{ DEFAULT_CURSOR_HEIGHT },
|
2019-07-12 01:06:18 +02:00
|
|
|
_wordDelimiters{ DEFAULT_WORD_DELIMITERS },
|
2019-08-20 18:42:17 +02:00
|
|
|
_copyOnSelect{ false },
|
2019-05-03 00:29:04 +02:00
|
|
|
_useAcrylic{ false },
|
|
|
|
_tintOpacity{ 0.5 },
|
|
|
|
_padding{ DEFAULT_PADDING },
|
|
|
|
_fontFace{ DEFAULT_FONT_FACE },
|
|
|
|
_fontSize{ DEFAULT_FONT_SIZE },
|
2019-05-29 20:35:46 +02:00
|
|
|
_backgroundImage{},
|
|
|
|
_backgroundImageOpacity{ 1.0 },
|
|
|
|
_backgroundImageStretchMode{ winrt::Windows::UI::Xaml::Media::Stretch::UniformToFill },
|
2019-07-25 06:47:06 +02:00
|
|
|
_backgroundImageHorizontalAlignment{ winrt::Windows::UI::Xaml::HorizontalAlignment::Center },
|
|
|
|
_backgroundImageVerticalAlignment{ winrt::Windows::UI::Xaml::VerticalAlignment::Center },
|
2019-05-03 00:29:04 +02:00
|
|
|
_keyBindings{ nullptr },
|
|
|
|
_scrollbarState{ ScrollbarState::Visible }
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t TerminalSettings::DefaultForeground()
|
|
|
|
{
|
|
|
|
return _defaultForeground;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::DefaultForeground(uint32_t value)
|
|
|
|
{
|
|
|
|
_defaultForeground = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t TerminalSettings::DefaultBackground()
|
|
|
|
{
|
|
|
|
return _defaultBackground;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::DefaultBackground(uint32_t value)
|
|
|
|
{
|
|
|
|
_defaultBackground = value;
|
|
|
|
}
|
2019-11-13 19:17:39 +01:00
|
|
|
|
|
|
|
uint32_t TerminalSettings::SelectionBackground()
|
|
|
|
{
|
|
|
|
return _selectionBackground;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::SelectionBackground(uint32_t value)
|
|
|
|
{
|
|
|
|
_selectionBackground = value;
|
|
|
|
}
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
uint32_t TerminalSettings::GetColorTableEntry(int32_t index) const
|
|
|
|
{
|
|
|
|
return _colorTable[index];
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::SetColorTableEntry(int32_t index, uint32_t value)
|
|
|
|
{
|
2019-08-06 20:33:32 +02:00
|
|
|
auto const colorTableCount = gsl::narrow_cast<decltype(index)>(_colorTable.size());
|
|
|
|
THROW_HR_IF(E_INVALIDARG, index >= colorTableCount);
|
2019-05-03 00:29:04 +02:00
|
|
|
_colorTable[index] = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t TerminalSettings::HistorySize()
|
|
|
|
{
|
|
|
|
return _historySize;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::HistorySize(int32_t value)
|
|
|
|
{
|
|
|
|
_historySize = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t TerminalSettings::InitialRows()
|
|
|
|
{
|
|
|
|
return _initialRows;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::InitialRows(int32_t value)
|
|
|
|
{
|
|
|
|
_initialRows = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t TerminalSettings::InitialCols()
|
|
|
|
{
|
|
|
|
return _initialCols;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::InitialCols(int32_t value)
|
|
|
|
{
|
|
|
|
_initialCols = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TerminalSettings::SnapOnInput()
|
|
|
|
{
|
|
|
|
return _snapOnInput;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::SnapOnInput(bool value)
|
|
|
|
{
|
|
|
|
_snapOnInput = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t TerminalSettings::CursorColor()
|
|
|
|
{
|
|
|
|
return _cursorColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::CursorColor(uint32_t value)
|
|
|
|
{
|
|
|
|
_cursorColor = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
Settings::CursorStyle TerminalSettings::CursorShape() const noexcept
|
|
|
|
{
|
|
|
|
return _cursorShape;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::CursorShape(Settings::CursorStyle const& value) noexcept
|
|
|
|
{
|
|
|
|
_cursorShape = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t TerminalSettings::CursorHeight()
|
|
|
|
{
|
|
|
|
return _cursorHeight;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::CursorHeight(uint32_t value)
|
|
|
|
{
|
|
|
|
_cursorHeight = value;
|
|
|
|
}
|
|
|
|
|
2019-07-12 01:06:18 +02:00
|
|
|
hstring TerminalSettings::WordDelimiters()
|
|
|
|
{
|
|
|
|
return _wordDelimiters;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::WordDelimiters(hstring const& value)
|
|
|
|
{
|
|
|
|
_wordDelimiters = value;
|
|
|
|
}
|
|
|
|
|
2019-08-20 18:42:17 +02:00
|
|
|
bool TerminalSettings::CopyOnSelect()
|
|
|
|
{
|
|
|
|
return _copyOnSelect;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::CopyOnSelect(bool value)
|
|
|
|
{
|
|
|
|
_copyOnSelect = value;
|
|
|
|
}
|
|
|
|
|
2019-05-03 00:29:04 +02:00
|
|
|
bool TerminalSettings::UseAcrylic()
|
|
|
|
{
|
|
|
|
return _useAcrylic;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::UseAcrylic(bool value)
|
|
|
|
{
|
|
|
|
_useAcrylic = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double TerminalSettings::TintOpacity()
|
|
|
|
{
|
|
|
|
return _tintOpacity;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::TintOpacity(double value)
|
|
|
|
{
|
|
|
|
_tintOpacity = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
hstring TerminalSettings::Padding()
|
|
|
|
{
|
|
|
|
return _padding;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::Padding(hstring value)
|
|
|
|
{
|
|
|
|
_padding = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
hstring TerminalSettings::FontFace()
|
|
|
|
{
|
|
|
|
return _fontFace;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::FontFace(hstring const& value)
|
|
|
|
{
|
|
|
|
_fontFace = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
int32_t TerminalSettings::FontSize()
|
|
|
|
{
|
|
|
|
return _fontSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::FontSize(int32_t value)
|
|
|
|
{
|
|
|
|
_fontSize = value;
|
|
|
|
}
|
|
|
|
|
2019-05-29 20:35:46 +02:00
|
|
|
void TerminalSettings::BackgroundImage(hstring const& value)
|
|
|
|
{
|
|
|
|
_backgroundImage = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
hstring TerminalSettings::BackgroundImage()
|
|
|
|
{
|
|
|
|
return _backgroundImage;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::BackgroundImageOpacity(double value)
|
|
|
|
{
|
|
|
|
_backgroundImageOpacity = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double TerminalSettings::BackgroundImageOpacity()
|
|
|
|
{
|
|
|
|
return _backgroundImageOpacity;
|
|
|
|
}
|
|
|
|
|
|
|
|
winrt::Windows::UI::Xaml::Media::Stretch TerminalSettings::BackgroundImageStretchMode()
|
|
|
|
{
|
|
|
|
return _backgroundImageStretchMode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::BackgroundImageStretchMode(winrt::Windows::UI::Xaml::Media::Stretch value)
|
|
|
|
{
|
|
|
|
_backgroundImageStretchMode = value;
|
|
|
|
}
|
|
|
|
|
2019-07-25 06:47:06 +02:00
|
|
|
winrt::Windows::UI::Xaml::HorizontalAlignment TerminalSettings::BackgroundImageHorizontalAlignment()
|
|
|
|
{
|
|
|
|
return _backgroundImageHorizontalAlignment;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::BackgroundImageHorizontalAlignment(winrt::Windows::UI::Xaml::HorizontalAlignment value)
|
|
|
|
{
|
|
|
|
_backgroundImageHorizontalAlignment = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
winrt::Windows::UI::Xaml::VerticalAlignment TerminalSettings::BackgroundImageVerticalAlignment()
|
|
|
|
{
|
|
|
|
return _backgroundImageVerticalAlignment;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::BackgroundImageVerticalAlignment(winrt::Windows::UI::Xaml::VerticalAlignment value)
|
|
|
|
{
|
|
|
|
_backgroundImageVerticalAlignment = value;
|
|
|
|
}
|
|
|
|
|
2019-05-03 00:29:04 +02:00
|
|
|
Settings::IKeyBindings TerminalSettings::KeyBindings()
|
|
|
|
{
|
|
|
|
return _keyBindings;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::KeyBindings(Settings::IKeyBindings const& value)
|
|
|
|
{
|
|
|
|
_keyBindings = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
hstring TerminalSettings::Commandline()
|
|
|
|
{
|
|
|
|
return _commandline;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::Commandline(hstring const& value)
|
|
|
|
{
|
|
|
|
_commandline = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
hstring TerminalSettings::StartingDirectory()
|
|
|
|
{
|
|
|
|
return _startingDir;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::StartingDirectory(hstring const& value)
|
|
|
|
{
|
|
|
|
_startingDir = value;
|
|
|
|
}
|
|
|
|
|
A better fix for #tab-titles-are-too-long (#2373)
### User Stories:
1. A user wants to be able to use the executable path as their starting title
- Does anyone want this?
2. A user wants to be able to set a custom starting title, but have that title be overridable
3. A user wants to be able to set an overridable starting title, different from the profile name
- Presumably someone will want this
4. A user totally wants to ignore the VT title and use something else
- This will make more sense in the post [#1320] "Support runtime variables in the custom user title" settings
### Solutions:
1. `name`, `startingTitle`, `tabTitle`
* a. `name` is only ever used as the profile name.
* b. If `startingTitle` isn't set, then the executable path is used
* c. If `startingTitle` is set, it's used as the initial title
* d. If `tabTitle` is set, it overrides the title from the terminal
* e. Current users of `tabTitle` need to manually update to the new behavior.
2. `name` as starting title, `tabTitle` as a different starting title
* a. `name` is used as the starting title and the profile name in the dropdown
* b. If `tabTitle` is set, we'll use that as the overridable starting title instead.
* c. In the future, `dynamicTabTitle` or `tabTitleOverride` could be added to support [#1320]
* d. Current users of `tabTitle` automatically get the new (different!) behavior.
* e. User Story 1 is impossible
- Does anyone want the behavior _ever_? Perhaps making that scenario impossible is good?
3. `name` unchanged, `tabTitle` as the starting title
* a. `name` is only ever used as the profile name.
* b. If `tabTitle` is set, we'll use that as the overridable starting title.
* c. In the future, `dynamicTabTitle` or `tabTitleOverride` could be added to support [#1320]
* d. Current users of `tabTitle` automatically get the new (different!) behavior.
4. `name` as starting title, `tabTitle` as different starting title, `suppressApplicationTitle` Boolean to force it to override
* a. `name`, `tabTitle` work as in Solution 2.
* b. When someone wants to be able to statically totally override that title (story 4), they can use `suppressApplicationTitle`
* c. `suppressApplicationTitle` name is WIP
* d. We'll add `suppressApplicationTitle` when someone complains
* e. If you really want story 1, use `tabTitle: c:\path\to\foo.exe` and `suppressApplicationTitle`.
[#1320]: https://github.com/microsoft/terminal/issues/1320
We've decided to pursue path 4.
2019-08-15 01:16:38 +02:00
|
|
|
hstring TerminalSettings::StartingTitle()
|
|
|
|
{
|
|
|
|
return _startingTitle;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::StartingTitle(hstring const& value)
|
|
|
|
{
|
|
|
|
_startingTitle = value;
|
|
|
|
}
|
|
|
|
|
2019-11-22 01:18:24 +01:00
|
|
|
bool TerminalSettings::SuppressApplicationTitle()
|
|
|
|
{
|
|
|
|
return _suppressApplicationTitle;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::SuppressApplicationTitle(bool value)
|
|
|
|
{
|
|
|
|
_suppressApplicationTitle = value;
|
|
|
|
}
|
|
|
|
|
2019-05-03 00:29:04 +02:00
|
|
|
hstring TerminalSettings::EnvironmentVariables()
|
|
|
|
{
|
|
|
|
return _envVars;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::EnvironmentVariables(hstring const& value)
|
|
|
|
{
|
|
|
|
_envVars = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
Settings::ScrollbarState TerminalSettings::ScrollState() const noexcept
|
|
|
|
{
|
|
|
|
return _scrollbarState;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::ScrollState(Settings::ScrollbarState const& value) noexcept
|
|
|
|
{
|
|
|
|
_scrollbarState = value;
|
|
|
|
}
|
|
|
|
|
2019-12-12 14:44:01 +01:00
|
|
|
bool TerminalSettings::RetroTerminalEffect()
|
|
|
|
{
|
|
|
|
return _retroTerminalEffect;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TerminalSettings::RetroTerminalEffect(bool value)
|
|
|
|
{
|
|
|
|
_retroTerminalEffect = value;
|
|
|
|
}
|
|
|
|
|
2019-05-03 00:29:04 +02:00
|
|
|
}
|