this builds at least
This commit is contained in:
parent
1413d0145a
commit
31e799859f
|
@ -115,34 +115,34 @@ namespace winrt::TerminalApp::implementation
|
|||
|
||||
// Insert that new child as the parent of the control's settings
|
||||
controlSettings.SetParent(childStruct.DefaultSettings());
|
||||
control.UpdateSettings();
|
||||
control.UpdateControlSettings(controlSettings);
|
||||
|
||||
// Take a copy of the inputs, since they are pointers anyways.
|
||||
_restorePreviewFuncs.emplace_back([=]() {
|
||||
// Get the runtime settings of the focused control
|
||||
const auto& controlSettings{ control.Settings().as<TerminalSettings>() };
|
||||
//// Get the runtime settings of the focused control
|
||||
//const auto& controlSettings{ control.Settings().as<TerminalSettings>() };
|
||||
|
||||
// Get the control's root settings, the ones that we actually
|
||||
// assigned to it.
|
||||
auto parentSettings{ controlSettings.GetParent() };
|
||||
while (parentSettings.GetParent() != nullptr)
|
||||
{
|
||||
parentSettings = parentSettings.GetParent();
|
||||
}
|
||||
//// Get the control's root settings, the ones that we actually
|
||||
//// assigned to it.
|
||||
//auto parentSettings{ controlSettings.GetParent() };
|
||||
//while (parentSettings.GetParent() != nullptr)
|
||||
//{
|
||||
// parentSettings = parentSettings.GetParent();
|
||||
//}
|
||||
|
||||
// If the root settings are the same as the ones we stashed,
|
||||
// then reset the parent of the runtime settings to the stashed
|
||||
// settings. This condition might be false if the settings
|
||||
// hot-reloaded while the palette was open. In that case, we
|
||||
// don't want to reset the settings to what they were _before_
|
||||
// the hot-reload.
|
||||
if (originalSettings == parentSettings)
|
||||
{
|
||||
// Set the original settings as the parent of the control's settings
|
||||
control.Settings().as<TerminalSettings>().SetParent(originalSettings);
|
||||
}
|
||||
//// If the root settings are the same as the ones we stashed,
|
||||
//// then reset the parent of the runtime settings to the stashed
|
||||
//// settings. This condition might be false if the settings
|
||||
//// hot-reloaded while the palette was open. In that case, we
|
||||
//// don't want to reset the settings to what they were _before_
|
||||
//// the hot-reload.
|
||||
//if (originalSettings == parentSettings)
|
||||
//{
|
||||
// // Set the original settings as the parent of the control's settings
|
||||
// control.Settings().as<TerminalSettings>().SetParent(originalSettings);
|
||||
//}
|
||||
|
||||
control.UpdateSettings();
|
||||
control.UpdateControlSettings(control.Settings());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -451,29 +451,35 @@ namespace winrt::TerminalApp::implementation
|
|||
{
|
||||
if (const auto scheme = _settings.GlobalSettings().ColorSchemes().TryLookup(realArgs.SchemeName()))
|
||||
{
|
||||
const auto res = _ApplyToActiveControls([&](auto& control) {
|
||||
// Start by getting the current settings of the control
|
||||
auto controlSettings = control.Settings().as<TerminalSettings>();
|
||||
auto parentSettings = controlSettings;
|
||||
// Those are the _runtime_ settings however. What we
|
||||
// need to do is:
|
||||
//
|
||||
// 1. Blow away any colors set in the runtime settings.
|
||||
// 2. Apply the color scheme to the parent settings.
|
||||
//
|
||||
// 1 is important to make sure that the effects of
|
||||
// something like `colortool` are cleared when setting
|
||||
// the scheme.
|
||||
if (controlSettings.GetParent() != nullptr)
|
||||
{
|
||||
parentSettings = controlSettings.GetParent();
|
||||
}
|
||||
const auto res = _ApplyToActiveControls([&](auto& /*control*/) {
|
||||
//// Start by getting the current settings of the control
|
||||
//auto controlSettings = control.Settings().as<TerminalSettings>();
|
||||
//auto parentSettings = controlSettings;
|
||||
//// Those are the _runtime_ settings however. What we
|
||||
//// need to do is:
|
||||
////
|
||||
//// 1. Blow away any colors set in the runtime settings.
|
||||
//// 2. Apply the color scheme to the parent settings.
|
||||
////
|
||||
//// 1 is important to make sure that the effects of
|
||||
//// something like `colortool` are cleared when setting
|
||||
//// the scheme.
|
||||
//if (controlSettings.GetParent() != nullptr)
|
||||
//{
|
||||
// parentSettings = controlSettings.GetParent();
|
||||
//}
|
||||
|
||||
// ApplyColorScheme(nullptr) will clear the old color scheme.
|
||||
controlSettings.ApplyColorScheme(nullptr);
|
||||
parentSettings.ApplyColorScheme(scheme);
|
||||
//// ApplyColorScheme(nullptr) will clear the old color scheme.
|
||||
//controlSettings.ApplyColorScheme(nullptr);
|
||||
//parentSettings.ApplyColorScheme(scheme);
|
||||
|
||||
control.UpdateSettings();
|
||||
//control.UpdateControlSettings();
|
||||
|
||||
// TODO!
|
||||
// We'll need a dedicated method for this. The Control's
|
||||
// settings are hosted in the Core, which could be OOP.
|
||||
// We'll need to manually tell the control to update its
|
||||
// core's scheme.
|
||||
});
|
||||
args.Handled(res);
|
||||
}
|
||||
|
|
|
@ -1476,8 +1476,8 @@ void Pane::UpdateSettings(const TerminalSettingsCreateResult& settings, const Pr
|
|||
// sure the unfocused settings inherit from that.
|
||||
unfocusedSettings.SetParent(controlSettings);
|
||||
}
|
||||
_control.UnfocusedAppearance(unfocusedSettings);
|
||||
_control.UpdateSettings();
|
||||
// _control.UnfocusedAppearance(unfocusedSettings);
|
||||
_control.UpdateControlSettings(controlSettings, unfocusedSettings);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
|
|
@ -2162,9 +2162,9 @@ namespace winrt::TerminalApp::implementation
|
|||
// Give term control a child of the settings so that any overrides go in the child
|
||||
// This way, when we do a settings reload we just update the parent and the overrides remain
|
||||
const auto child = TerminalSettings::CreateWithParent(settings);
|
||||
TermControl term{ child.DefaultSettings(), connection };
|
||||
TermControl term{ child.DefaultSettings(), child.UnfocusedSettings(), connection };
|
||||
|
||||
term.UnfocusedAppearance(child.UnfocusedSettings()); // It is okay for the unfocused settings to be null
|
||||
// term.UnfocusedAppearance(child.UnfocusedSettings()); // It is okay for the unfocused settings to be null
|
||||
|
||||
return term;
|
||||
}
|
||||
|
|
|
@ -54,15 +54,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
return initialized;
|
||||
}
|
||||
|
||||
ControlCore::ControlCore(IControlSettings settings,
|
||||
ControlCore::ControlCore(Control::IControlSettings settings,
|
||||
Control::IControlAppearance unfocusedAppearance,
|
||||
TerminalConnection::ITerminalConnection connection) :
|
||||
_connection{ connection },
|
||||
_settings{ settings },
|
||||
_desiredFont{ DEFAULT_FONT_FACE, 0, DEFAULT_FONT_WEIGHT, { 0, DEFAULT_FONT_SIZE }, CP_UTF8 },
|
||||
_actualFont{ DEFAULT_FONT_FACE, 0, DEFAULT_FONT_WEIGHT, { 0, DEFAULT_FONT_SIZE }, CP_UTF8, false }
|
||||
{
|
||||
_EnsureStaticInitialization();
|
||||
|
||||
_settings = winrt::make_self<implementation::ControlSettings>(settings, unfocusedAppearance);
|
||||
|
||||
_terminal = std::make_unique<::Microsoft::Terminal::Core::Terminal>();
|
||||
|
||||
// Subscribe to the connection's disconnected event and call our connection closed handlers.
|
||||
|
@ -78,7 +80,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
});
|
||||
|
||||
// GH#8969: pre-seed working directory to prevent potential races
|
||||
_terminal->SetWorkingDirectory(_settings.StartingDirectory());
|
||||
_terminal->SetWorkingDirectory(_settings->StartingDirectory());
|
||||
|
||||
auto pfnCopyToClipboard = std::bind(&ControlCore::_terminalCopyToClipboard, this, std::placeholders::_1);
|
||||
_terminal->SetCopyToClipboardCallback(pfnCopyToClipboard);
|
||||
|
@ -185,7 +187,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
}
|
||||
});
|
||||
|
||||
UpdateSettings(settings);
|
||||
// TODO! uh, this feels wrong aren't we just setting this above??
|
||||
UpdateSettings(settings, unfocusedAppearance);
|
||||
}
|
||||
|
||||
ControlCore::~ControlCore()
|
||||
|
@ -242,7 +245,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
LOG_IF_FAILED(_renderEngine->SetWindowSize({ viewInPixels.Width(), viewInPixels.Height() }));
|
||||
|
||||
// Update DxEngine's SelectionBackground
|
||||
_renderEngine->SetSelectionBackground(til::color{ _settings.SelectionBackground() });
|
||||
_renderEngine->SetSelectionBackground(til::color{ _settings->SelectionBackground() });
|
||||
|
||||
const auto vp = _renderEngine->GetViewportInCharacters(viewInPixels);
|
||||
const auto width = vp.Width();
|
||||
|
@ -250,10 +253,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
_connection.Resize(height, width);
|
||||
|
||||
// Override the default width and height to match the size of the swapChainPanel
|
||||
_settings.InitialCols(width);
|
||||
_settings.InitialRows(height);
|
||||
_settings->InitialCols(width);
|
||||
_settings->InitialRows(height);
|
||||
|
||||
_terminal->CreateFromSettings(_settings, *_renderer);
|
||||
_terminal->CreateFromSettings(*_settings, *_renderer);
|
||||
|
||||
// IMPORTANT! Set this callback up sooner than later. If we do it
|
||||
// after Enable, then it'll be possible to paint the frame once
|
||||
|
@ -265,17 +268,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
// We do this after we initially set the swapchain so as to avoid unnecessary callbacks (and locking problems)
|
||||
_renderEngine->SetCallback(std::bind(&ControlCore::_renderEngineSwapChainChanged, this));
|
||||
|
||||
_renderEngine->SetRetroTerminalEffect(_settings.RetroTerminalEffect());
|
||||
_renderEngine->SetPixelShaderPath(_settings.PixelShaderPath());
|
||||
_renderEngine->SetForceFullRepaintRendering(_settings.ForceFullRepaintRendering());
|
||||
_renderEngine->SetSoftwareRendering(_settings.SoftwareRendering());
|
||||
_renderEngine->SetIntenseIsBold(_settings.IntenseIsBold());
|
||||
_renderEngine->SetRetroTerminalEffect(_settings->RetroTerminalEffect());
|
||||
_renderEngine->SetPixelShaderPath(_settings->PixelShaderPath());
|
||||
_renderEngine->SetForceFullRepaintRendering(_settings->ForceFullRepaintRendering());
|
||||
_renderEngine->SetSoftwareRendering(_settings->SoftwareRendering());
|
||||
_renderEngine->SetIntenseIsBold(_settings->IntenseIsBold());
|
||||
|
||||
_updateAntiAliasingMode(_renderEngine.get());
|
||||
|
||||
// GH#5098: Inform the engine of the opacity of the default text background.
|
||||
// GH#11315: Always do this, even if they don't have acrylic on.
|
||||
_renderEngine->SetDefaultTextBackgroundOpacity(::base::saturated_cast<float>(_settings.Opacity()));
|
||||
_renderEngine->SetDefaultTextBackgroundOpacity(::base::saturated_cast<float>(_settings->Opacity()));
|
||||
|
||||
THROW_IF_FAILED(_renderEngine->Enable());
|
||||
|
||||
|
@ -450,7 +453,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
// is what the Terminal did prior to 1.12.
|
||||
if (!IsVintageOpacityAvailable())
|
||||
{
|
||||
_settings.UseAcrylic(newOpacity < 1.0);
|
||||
_runtimeUseAcrylic = newOpacity < 1.0;
|
||||
}
|
||||
|
||||
auto eventArgs = winrt::make_self<TransparencyChangedEventArgs>(newOpacity);
|
||||
|
@ -465,7 +468,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
// specify a custom pixel shader, manually enable the legacy retro
|
||||
// effect first. This will ensure that a toggle off->on will still work,
|
||||
// even if they currently have retro effect off.
|
||||
if (_settings.PixelShaderPath().empty() && !_renderEngine->GetRetroTerminalEffect())
|
||||
if (_settings->PixelShaderPath().empty() && !_renderEngine->GetRetroTerminalEffect())
|
||||
{
|
||||
// SetRetroTerminalEffect to true will enable the effect. In this
|
||||
// case, the shader effect will already be disabled (because neither
|
||||
|
@ -575,11 +578,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
// Method Description:
|
||||
// - Updates the settings of the current terminal.
|
||||
// - INVARIANT: This method can only be called if the caller DOES NOT HAVE writing lock on the terminal.
|
||||
void ControlCore::UpdateSettings(const IControlSettings& settings)
|
||||
void ControlCore::UpdateSettings(const IControlSettings& settings, const IControlAppearance& newAppearance)
|
||||
{
|
||||
auto lock = _terminal->LockForWriting();
|
||||
_settings = winrt::make_self<implementation::ControlSettings>(settings, newAppearance);
|
||||
|
||||
_settings = settings;
|
||||
auto lock = _terminal->LockForWriting();
|
||||
|
||||
_runtimeOpacity = std::nullopt;
|
||||
_runtimeUseAcrylic = std::nullopt;
|
||||
|
@ -587,15 +590,15 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
// GH#11285 - If the user is on Windows 10, and they wanted opacity, but
|
||||
// didn't explicitly request acrylic, then opt them in to acrylic.
|
||||
// On Windows 11+, this isn't needed, because we can have vintage opacity.
|
||||
if (!IsVintageOpacityAvailable() && _settings.Opacity() < 1.0 && !_settings.UseAcrylic())
|
||||
if (!IsVintageOpacityAvailable() && _settings->Opacity() < 1.0 && !_settings->UseAcrylic())
|
||||
{
|
||||
_runtimeUseAcrylic = true;
|
||||
}
|
||||
|
||||
// Initialize our font information.
|
||||
const auto fontFace = _settings.FontFace();
|
||||
const short fontHeight = ::base::saturated_cast<short>(_settings.FontSize());
|
||||
const auto fontWeight = _settings.FontWeight();
|
||||
const auto fontFace = _settings->FontFace();
|
||||
const short fontHeight = ::base::saturated_cast<short>(_settings->FontSize());
|
||||
const auto fontWeight = _settings->FontWeight();
|
||||
// The font width doesn't terribly matter, we'll only be using the
|
||||
// height to look it up
|
||||
// The other params here also largely don't matter.
|
||||
|
@ -606,7 +609,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
_desiredFont = { _actualFont };
|
||||
|
||||
// Update the terminal core with its new Core settings
|
||||
_terminal->UpdateSettings(_settings);
|
||||
_terminal->UpdateSettings(*_settings);
|
||||
|
||||
if (!_initializedTerminal)
|
||||
{
|
||||
|
@ -615,8 +618,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
return;
|
||||
}
|
||||
|
||||
_renderEngine->SetForceFullRepaintRendering(_settings.ForceFullRepaintRendering());
|
||||
_renderEngine->SetSoftwareRendering(_settings.SoftwareRendering());
|
||||
_renderEngine->SetForceFullRepaintRendering(_settings->ForceFullRepaintRendering());
|
||||
_renderEngine->SetSoftwareRendering(_settings->SoftwareRendering());
|
||||
|
||||
_updateAntiAliasingMode(_renderEngine.get());
|
||||
|
||||
|
@ -633,29 +636,29 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
// Method Description:
|
||||
// - Updates the appearance of the current terminal.
|
||||
// - INVARIANT: This method can only be called if the caller DOES NOT HAVE writing lock on the terminal.
|
||||
void ControlCore::UpdateAppearance(const IControlAppearance& newAppearance)
|
||||
{
|
||||
auto lock = _terminal->LockForWriting();
|
||||
// void ControlCore::UpdateAppearance(const IControlAppearance& newAppearance)
|
||||
// {
|
||||
// auto lock = _terminal->LockForWriting();
|
||||
|
||||
// Update the terminal core with its new Core settings
|
||||
_terminal->UpdateAppearance(newAppearance);
|
||||
// // Update the terminal core with its new Core settings
|
||||
// _terminal->UpdateAppearance(newAppearance);
|
||||
|
||||
// Update DxEngine settings under the lock
|
||||
if (_renderEngine)
|
||||
{
|
||||
// Update DxEngine settings under the lock
|
||||
_renderEngine->SetSelectionBackground(til::color{ newAppearance.SelectionBackground() });
|
||||
_renderEngine->SetRetroTerminalEffect(newAppearance.RetroTerminalEffect());
|
||||
_renderEngine->SetPixelShaderPath(newAppearance.PixelShaderPath());
|
||||
_renderEngine->SetIntenseIsBold(_settings.IntenseIsBold());
|
||||
_renderer->TriggerRedrawAll();
|
||||
}
|
||||
}
|
||||
// // Update DxEngine settings under the lock
|
||||
// if (_renderEngine)
|
||||
// {
|
||||
// // Update DxEngine settings under the lock
|
||||
// _renderEngine->SetSelectionBackground(til::color{ newAppearance.SelectionBackground() });
|
||||
// _renderEngine->SetRetroTerminalEffect(newAppearance.RetroTerminalEffect());
|
||||
// _renderEngine->SetPixelShaderPath(newAppearance.PixelShaderPath());
|
||||
// _renderEngine->SetIntenseIsBold(_settings->IntenseIsBold());
|
||||
// _renderer->TriggerRedrawAll();
|
||||
// }
|
||||
// }
|
||||
|
||||
void ControlCore::_updateAntiAliasingMode(::Microsoft::Console::Render::DxEngine* const dxEngine)
|
||||
{
|
||||
// Update DxEngine's AntialiasingMode
|
||||
switch (_settings.AntialiasingMode())
|
||||
switch (_settings->AntialiasingMode())
|
||||
{
|
||||
case TextAntialiasingMode::Cleartype:
|
||||
dxEngine->SetAntialiasingMode(D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE);
|
||||
|
@ -690,7 +693,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
if (_renderEngine)
|
||||
{
|
||||
std::unordered_map<std::wstring_view, uint32_t> featureMap;
|
||||
if (const auto fontFeatures = _settings.FontFeatures())
|
||||
if (const auto fontFeatures = _settings->FontFeatures())
|
||||
{
|
||||
featureMap.reserve(fontFeatures.Size());
|
||||
|
||||
|
@ -700,7 +703,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
}
|
||||
}
|
||||
std::unordered_map<std::wstring_view, float> axesMap;
|
||||
if (const auto fontAxes = _settings.FontAxes())
|
||||
if (const auto fontAxes = _settings->FontAxes())
|
||||
{
|
||||
axesMap.reserve(fontAxes.Size());
|
||||
|
||||
|
@ -742,8 +745,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
{
|
||||
// Make sure we have a non-zero font size
|
||||
const auto newSize = std::max<short>(gsl::narrow_cast<short>(fontSize), 1);
|
||||
const auto fontFace = _settings.FontFace();
|
||||
const auto fontWeight = _settings.FontWeight();
|
||||
const auto fontFace = _settings->FontFace();
|
||||
const auto fontWeight = _settings->FontWeight();
|
||||
_actualFont = { fontFace, 0, fontWeight.Weight, { 0, newSize }, CP_UTF8, false };
|
||||
_desiredFont = { _actualFont };
|
||||
|
||||
|
@ -767,7 +770,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
// - none
|
||||
void ControlCore::ResetFontSize()
|
||||
{
|
||||
_setFontSize(_settings.FontSize());
|
||||
_setFontSize(_settings->FontSize());
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
@ -979,7 +982,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
TextBuffer::GenHTML(bufferData,
|
||||
_actualFont.GetUnscaledSize().Y,
|
||||
_actualFont.GetFaceName(),
|
||||
til::color{ _settings.DefaultBackground() }) :
|
||||
til::color{ _settings->DefaultBackground() }) :
|
||||
"";
|
||||
|
||||
// convert to RTF format
|
||||
|
@ -987,10 +990,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
TextBuffer::GenRTF(bufferData,
|
||||
_actualFont.GetUnscaledSize().Y,
|
||||
_actualFont.GetFaceName(),
|
||||
til::color{ _settings.DefaultBackground() }) :
|
||||
til::color{ _settings->DefaultBackground() }) :
|
||||
"";
|
||||
|
||||
if (!_settings.CopyOnSelect())
|
||||
if (!_settings->CopyOnSelect())
|
||||
{
|
||||
_terminal->ClearSelection();
|
||||
_renderer->TriggerSelection();
|
||||
|
@ -1231,7 +1234,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
|
||||
bool ControlCore::CopyOnSelect() const
|
||||
{
|
||||
return _settings.CopyOnSelect();
|
||||
return _settings->CopyOnSelect();
|
||||
}
|
||||
|
||||
Windows::Foundation::Collections::IVector<winrt::hstring> ControlCore::SelectedText(bool trimTrailingWhitespace) const
|
||||
|
|
|
@ -44,7 +44,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
struct ControlCore : ControlCoreT<ControlCore>
|
||||
{
|
||||
public:
|
||||
ControlCore(IControlSettings settings,
|
||||
ControlCore(Control::IControlSettings settings,
|
||||
Control::IControlAppearance unfocusedAppearance,
|
||||
TerminalConnection::ITerminalConnection connection);
|
||||
~ControlCore();
|
||||
|
||||
|
@ -53,8 +54,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
const double compositionScale);
|
||||
void EnablePainting();
|
||||
|
||||
void UpdateSettings(const IControlSettings& settings);
|
||||
void UpdateAppearance(const IControlAppearance& newAppearance);
|
||||
void UpdateSettings(const Control::IControlSettings& settings, const IControlAppearance& newAppearance);
|
||||
// void UpdateAppearance(const Control::IControlAppearance& newAppearance);
|
||||
Control::IControlSettings Settings() const { return *_settings; };
|
||||
Control::IControlAppearance FocusedAppearance() const { return *_settings->FocusedAppearance(); };
|
||||
Control::IControlAppearance UnfocusedAppearance() const { return *_settings->UnfocusedAppearance(); };
|
||||
|
||||
void SizeChanged(const double width, const double height);
|
||||
void ScaleChanged(const double scale);
|
||||
uint64_t SwapChainHandle() const;
|
||||
|
@ -160,8 +165,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
|
||||
static bool IsVintageOpacityAvailable() noexcept;
|
||||
|
||||
RUNTIME_SETTING(double, Opacity, _settings.Opacity());
|
||||
RUNTIME_SETTING(bool, UseAcrylic, _settings.UseAcrylic());
|
||||
RUNTIME_SETTING(double, Opacity, _settings->Opacity());
|
||||
RUNTIME_SETTING(bool, UseAcrylic, _settings->UseAcrylic());
|
||||
|
||||
// -------------------------------- WinRT Events ---------------------------------
|
||||
// clang-format off
|
||||
|
@ -203,7 +208,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
std::unique_ptr<::Microsoft::Console::Render::DxEngine> _renderEngine{ nullptr };
|
||||
std::unique_ptr<::Microsoft::Console::Render::Renderer> _renderer{ nullptr };
|
||||
|
||||
IControlSettings _settings{ nullptr };
|
||||
// IControlSettings _settings{ nullptr };
|
||||
winrt::com_ptr<ControlSettings> _settings{ nullptr };
|
||||
|
||||
FontInfoDesired _desiredFont;
|
||||
FontInfo _actualFont;
|
||||
|
|
|
@ -33,14 +33,18 @@ namespace Microsoft.Terminal.Control
|
|||
[default_interface] runtimeclass ControlCore : ICoreState
|
||||
{
|
||||
ControlCore(IControlSettings settings,
|
||||
IControlAppearance unfocusedAppearance,
|
||||
Microsoft.Terminal.TerminalConnection.ITerminalConnection connection);
|
||||
|
||||
Boolean Initialize(Double actualWidth,
|
||||
Double actualHeight,
|
||||
Double compositionScale);
|
||||
|
||||
void UpdateSettings(IControlSettings settings);
|
||||
void UpdateAppearance(IControlAppearance appearance);
|
||||
void UpdateSettings(IControlSettings settings, IControlAppearance appearance);
|
||||
// void UpdateAppearance(IControlAppearance appearance);
|
||||
IControlSettings Settings { get; };
|
||||
IControlAppearance FocusedAppearance { get; };
|
||||
IControlAppearance UnfocusedAppearance { get; };
|
||||
|
||||
UInt64 SwapChainHandle { get; };
|
||||
|
||||
|
|
|
@ -39,13 +39,14 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
}
|
||||
|
||||
ControlInteractivity::ControlInteractivity(IControlSettings settings,
|
||||
Control::IControlAppearance unfocusedAppearance,
|
||||
TerminalConnection::ITerminalConnection connection) :
|
||||
_touchAnchor{ std::nullopt },
|
||||
_lastMouseClickTimestamp{},
|
||||
_lastMouseClickPos{},
|
||||
_selectionNeedsToBeCopied{ false }
|
||||
{
|
||||
_core = winrt::make_self<ControlCore>(settings, connection);
|
||||
_core = winrt::make_self<ControlCore>(settings, unfocusedAppearance, connection);
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
{
|
||||
public:
|
||||
ControlInteractivity(IControlSettings settings,
|
||||
Control::IControlAppearance unfocusedAppearance,
|
||||
TerminalConnection::ITerminalConnection connection);
|
||||
|
||||
void GotFocus();
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Microsoft.Terminal.Control
|
|||
[default_interface] runtimeclass ControlInteractivity
|
||||
{
|
||||
ControlInteractivity(IControlSettings settings,
|
||||
IControlAppearance unfocusedAppearance,
|
||||
Microsoft.Terminal.TerminalConnection.ITerminalConnection connection);
|
||||
|
||||
ControlCore Core { get; };
|
||||
|
|
|
@ -27,7 +27,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
winrt::com_ptr<ControlAppearance> _focusedAppearance{ nullptr };
|
||||
|
||||
public:
|
||||
ControlSettings(Control::IControlSettings settings, Control::IControlAppearance unfocusedAppearance)
|
||||
ControlSettings(const Control::IControlSettings& settings,
|
||||
const Control::IControlAppearance& unfocusedAppearance)
|
||||
{
|
||||
_focusedAppearance = winrt::make_self<implementation::ControlAppearance>(settings);
|
||||
_unfocusedAppearance = unfocusedAppearance ?
|
||||
|
|
|
@ -49,6 +49,7 @@ DEFINE_ENUM_FLAG_OPERATORS(winrt::Microsoft::Terminal::Control::MouseButtonState
|
|||
namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
{
|
||||
TermControl::TermControl(IControlSettings settings,
|
||||
Control::IControlAppearance unfocusedAppearance,
|
||||
TerminalConnection::ITerminalConnection connection) :
|
||||
_settings{ winrt::make_self<ControlSettings>(settings, nullptr) },
|
||||
_isInternalScrollBarUpdate{ false },
|
||||
|
@ -62,7 +63,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
{
|
||||
InitializeComponent();
|
||||
|
||||
_interactivity = winrt::make<implementation::ControlInteractivity>(settings, connection);
|
||||
_interactivity = winrt::make<implementation::ControlInteractivity>(settings, unfocusedAppearance, connection);
|
||||
_core = _interactivity.Core();
|
||||
|
||||
// These events might all be triggered by the connection, but that
|
||||
|
@ -145,7 +146,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
_autoScrollTimer.Interval(AutoScrollUpdateInterval);
|
||||
_autoScrollTimer.Tick({ this, &TermControl::_UpdateAutoScroll });
|
||||
|
||||
_ApplyUISettings(_settings);
|
||||
_ApplyUISettings();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
@ -230,28 +231,36 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
this->Focus(FocusState::Programmatic);
|
||||
}
|
||||
|
||||
|
||||
winrt::fire_and_forget TermControl::UpdateControlSettings(IControlSettings settings)
|
||||
{
|
||||
return UpdateControlSettings(settings, _core.UnfocusedAppearance());
|
||||
}
|
||||
// Method Description:
|
||||
// - Given Settings having been updated, applies the settings to the current terminal.
|
||||
// Return Value:
|
||||
// - <none>
|
||||
winrt::fire_and_forget TermControl::UpdateSettings()
|
||||
winrt::fire_and_forget TermControl::UpdateControlSettings(IControlSettings settings, IControlAppearance unfocusedAppearance)
|
||||
{
|
||||
auto weakThis{ get_weak() };
|
||||
|
||||
co_await winrt::resume_background();
|
||||
_core.UpdateSettings(settings, unfocusedAppearance);
|
||||
|
||||
// Dispatch a call to the UI thread to apply the new settings to the
|
||||
// terminal.
|
||||
co_await winrt::resume_foreground(Dispatcher());
|
||||
|
||||
_UpdateSettingsFromUIThread(_settings);
|
||||
_UpdateSettingsFromUIThread();
|
||||
|
||||
_UpdateAppearanceFromUIThread(_focused ? _settings->FocusedAppearance() : _settings->UnfocusedAppearance());
|
||||
_UpdateAppearanceFromUIThread(_focused ? _core.FocusedAppearance() : _core.UnfocusedAppearance());
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
// - Dispatches a call to the UI thread and updates the appearance
|
||||
// Arguments:
|
||||
// - newAppearance: the new appearance to set
|
||||
winrt::fire_and_forget TermControl::UpdateAppearance(winrt::com_ptr<ControlAppearance> newAppearance)
|
||||
winrt::fire_and_forget TermControl::UpdateAppearance(IControlAppearance newAppearance)
|
||||
{
|
||||
// Dispatch a call to the UI thread
|
||||
co_await winrt::resume_foreground(Dispatcher());
|
||||
|
@ -267,17 +276,17 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
// - INVARIANT: This method must be called from the UI thread.
|
||||
// Arguments:
|
||||
// - newSettings: the new settings to set
|
||||
void TermControl::_UpdateSettingsFromUIThread(winrt::com_ptr<ControlSettings> newSettings)
|
||||
void TermControl::_UpdateSettingsFromUIThread()
|
||||
{
|
||||
if (_IsClosing())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_core.UpdateSettings(newSettings.try_as<IControlSettings>()); // TODO!
|
||||
// _core.UpdateSettings(settings); // TODO!
|
||||
|
||||
// Update our control settings
|
||||
_ApplyUISettings(newSettings);
|
||||
_ApplyUISettings();
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
@ -285,16 +294,16 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
// - INVARIANT: This method must be called from the UI thread.
|
||||
// Arguments:
|
||||
// - newAppearance: the new appearance to set
|
||||
void TermControl::_UpdateAppearanceFromUIThread(winrt::com_ptr<ControlAppearance> newAppearance)
|
||||
void TermControl::_UpdateAppearanceFromUIThread(Control::IControlAppearance newAppearance)
|
||||
{
|
||||
if (_IsClosing())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!newAppearance->BackgroundImage().empty())
|
||||
if (!newAppearance.BackgroundImage().empty())
|
||||
{
|
||||
Windows::Foundation::Uri imageUri{ newAppearance->BackgroundImage() };
|
||||
Windows::Foundation::Uri imageUri{ newAppearance.BackgroundImage() };
|
||||
|
||||
// Check if the image brush is already pointing to the image
|
||||
// in the modified settings; if it isn't (or isn't there),
|
||||
|
@ -314,10 +323,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
}
|
||||
|
||||
// Apply stretch, opacity and alignment settings
|
||||
BackgroundImage().Stretch(newAppearance->BackgroundImageStretchMode());
|
||||
BackgroundImage().Opacity(newAppearance->BackgroundImageOpacity());
|
||||
BackgroundImage().HorizontalAlignment(newAppearance->BackgroundImageHorizontalAlignment());
|
||||
BackgroundImage().VerticalAlignment(newAppearance->BackgroundImageVerticalAlignment());
|
||||
BackgroundImage().Stretch(newAppearance.BackgroundImageStretchMode());
|
||||
BackgroundImage().Opacity(newAppearance.BackgroundImageOpacity());
|
||||
BackgroundImage().HorizontalAlignment(newAppearance.BackgroundImageHorizontalAlignment());
|
||||
BackgroundImage().VerticalAlignment(newAppearance.BackgroundImageVerticalAlignment());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -325,15 +334,16 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
}
|
||||
|
||||
// Update our control settings
|
||||
const auto bg = newAppearance->DefaultBackground();
|
||||
const auto bg = newAppearance.DefaultBackground();
|
||||
_changeBackgroundColor(bg);
|
||||
|
||||
// Set TSF Foreground
|
||||
Media::SolidColorBrush foregroundBrush{};
|
||||
foregroundBrush.Color(static_cast<til::color>(newAppearance->DefaultForeground()));
|
||||
foregroundBrush.Color(static_cast<til::color>(newAppearance.DefaultForeground()));
|
||||
TSFInputControl().Foreground(foregroundBrush);
|
||||
|
||||
_core.UpdateAppearance(newAppearance.try_as<IControlAppearance>());
|
||||
// TODO!
|
||||
// _core.UpdateAppearance(newAppearance.try_as<IControlAppearance>());
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
@ -368,21 +378,23 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
// - <none>
|
||||
// Return Value:
|
||||
// - <none>
|
||||
void TermControl::_ApplyUISettings(const winrt::com_ptr<ControlSettings>& newSettings)
|
||||
void TermControl::_ApplyUISettings()
|
||||
{
|
||||
_InitializeBackgroundBrush();
|
||||
|
||||
const auto bg = newSettings->FocusedAppearance()->DefaultBackground();
|
||||
// settings might be out-of-proc in the future
|
||||
auto settings{ _core.Settings() };
|
||||
const auto bg = _core.FocusedAppearance().DefaultBackground();
|
||||
_changeBackgroundColor(bg);
|
||||
|
||||
// Apply padding as swapChainPanel's margin
|
||||
const auto newMargin = ParseThicknessFromPadding(newSettings->Padding());
|
||||
const auto newMargin = ParseThicknessFromPadding(settings.Padding());
|
||||
SwapChainPanel().Margin(newMargin);
|
||||
|
||||
TSFInputControl().Margin(newMargin);
|
||||
|
||||
// Apply settings for scrollbar
|
||||
if (newSettings->ScrollState() == ScrollbarState::Hidden)
|
||||
if (settings.ScrollState() == ScrollbarState::Hidden)
|
||||
{
|
||||
// In the scenario where the user has turned off the OS setting to automatically hide scrollbars, the
|
||||
// Terminal scrollbar would still be visible; so, we need to set the control's visibility accordingly to
|
||||
|
@ -410,7 +422,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
// Method Description:
|
||||
// - Set up each layer's brush used to display the control's background.
|
||||
// - Respects the settings for acrylic, background image and opacity from
|
||||
// _settings->
|
||||
// _settings.
|
||||
// * If acrylic is not enabled, setup a solid color background, otherwise
|
||||
// use bgcolor as acrylic's tint
|
||||
// - Avoids image flickering and acrylic brush redraw if settings are changed
|
||||
|
@ -718,7 +730,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
}
|
||||
|
||||
// Now that the renderer is set up, update the appearance for initialization
|
||||
_UpdateAppearanceFromUIThread(_settings->FocusedAppearance());
|
||||
_UpdateAppearanceFromUIThread(_core.FocusedAppearance());
|
||||
|
||||
_initializedTerminal = true;
|
||||
|
||||
|
@ -1507,7 +1519,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
// appearances anyway so there's no need to switch back upon gaining focus
|
||||
if (_settings->UnfocusedAppearance())
|
||||
{
|
||||
UpdateAppearance(_settings->FocusedAppearance());
|
||||
UpdateAppearance(_core.FocusedAppearance());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1549,10 +1561,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
|
||||
// Check if there is an unfocused config we should set the appearance to
|
||||
// upon losing focus
|
||||
if (_settings->UnfocusedAppearance())
|
||||
{
|
||||
UpdateAppearance(_settings->UnfocusedAppearance());
|
||||
}
|
||||
// if (_settings->UnfocusedAppearance())
|
||||
// {
|
||||
UpdateAppearance(_core.UnfocusedAppearance());
|
||||
// }
|
||||
}
|
||||
|
||||
// Method Description:
|
||||
|
@ -2363,21 +2375,21 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
return _settings.try_as<IControlSettings>();
|
||||
}
|
||||
|
||||
void TermControl::Settings(IControlSettings newSettings)
|
||||
{
|
||||
DebugBreak();
|
||||
_settings = winrt::make_self<ControlSettings>(newSettings, nullptr);
|
||||
}
|
||||
// void TermControl::Settings(IControlSettings newSettings)
|
||||
// {
|
||||
// DebugBreak();
|
||||
// _settings = winrt::make_self<ControlSettings>(newSettings, nullptr);
|
||||
// }
|
||||
|
||||
IControlAppearance TermControl::UnfocusedAppearance() const
|
||||
{
|
||||
return *_settings->UnfocusedAppearance();
|
||||
}
|
||||
|
||||
void TermControl::UnfocusedAppearance(IControlAppearance newAppearance)
|
||||
{
|
||||
_settings = winrt::make_self<ControlSettings>(_settings.try_as<IControlSettings>(), newAppearance);
|
||||
}
|
||||
// void TermControl::UnfocusedAppearance(IControlAppearance newAppearance)
|
||||
// {
|
||||
// _settings = winrt::make_self<ControlSettings>(_settings.try_as<IControlSettings>(), newAppearance);
|
||||
// }
|
||||
|
||||
Windows::Foundation::IReference<winrt::Windows::UI::Color> TermControl::TabColor() noexcept
|
||||
{
|
||||
|
|
|
@ -26,9 +26,12 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
{
|
||||
struct TermControl : TermControlT<TermControl>
|
||||
{
|
||||
TermControl(IControlSettings settings, TerminalConnection::ITerminalConnection connection);
|
||||
TermControl(IControlSettings settings,
|
||||
Control::IControlAppearance unfocusedAppearance,
|
||||
TerminalConnection::ITerminalConnection connection);
|
||||
|
||||
winrt::fire_and_forget UpdateSettings();
|
||||
winrt::fire_and_forget UpdateControlSettings(Control::IControlSettings settings);
|
||||
winrt::fire_and_forget UpdateControlSettings(Control::IControlSettings settings, Control::IControlAppearance unfocusedAppearance);
|
||||
|
||||
hstring GetProfileName() const;
|
||||
|
||||
|
@ -89,9 +92,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
const Windows::UI::Xaml::Thickness GetPadding();
|
||||
|
||||
IControlSettings Settings() const;
|
||||
void Settings(IControlSettings newSettings);
|
||||
// void Settings(IControlSettings newSettings);
|
||||
IControlAppearance UnfocusedAppearance() const;
|
||||
void UnfocusedAppearance(IControlAppearance newSettings);
|
||||
// void UnfocusedAppearance(IControlAppearance newSettings);
|
||||
|
||||
static Windows::Foundation::Size GetProposedDimensions(IControlSettings const& settings, const uint32_t dpi);
|
||||
static Windows::Foundation::Size GetProposedDimensions(const winrt::Windows::Foundation::Size& initialSizeInChars,
|
||||
|
@ -199,10 +202,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
|||
return _closing;
|
||||
}
|
||||
|
||||
void _UpdateSettingsFromUIThread(winrt::com_ptr<ControlSettings> newSettings);
|
||||
void _UpdateAppearanceFromUIThread(winrt::com_ptr<ControlAppearance> newAppearance);
|
||||
void _ApplyUISettings(const winrt::com_ptr<ControlSettings>& newSettings);
|
||||
winrt::fire_and_forget UpdateAppearance(winrt::com_ptr<ControlAppearance> newAppearance);
|
||||
void _UpdateSettingsFromUIThread();
|
||||
void _UpdateAppearanceFromUIThread(Control::IControlAppearance newAppearance);
|
||||
void _ApplyUISettings();
|
||||
winrt::fire_and_forget UpdateAppearance(Control::IControlAppearance newAppearance);
|
||||
|
||||
void _InitializeBackgroundBrush();
|
||||
void _BackgroundColorChangedHandler(const IInspectable& sender, const IInspectable& args);
|
||||
|
|
|
@ -17,14 +17,16 @@ namespace Microsoft.Terminal.Control
|
|||
ICoreState
|
||||
{
|
||||
TermControl(IControlSettings settings,
|
||||
IControlAppearance unfocusedAppearance,
|
||||
Microsoft.Terminal.TerminalConnection.ITerminalConnection connection);
|
||||
|
||||
static Windows.Foundation.Size GetProposedDimensions(IControlSettings settings, UInt32 dpi);
|
||||
|
||||
void UpdateSettings();
|
||||
void UpdateControlSettings(IControlSettings settings);
|
||||
void UpdateControlSettings(IControlSettings settings, IControlAppearance unfocusedAppearance);
|
||||
|
||||
Microsoft.Terminal.Control.IControlSettings Settings;
|
||||
Microsoft.Terminal.Control.IControlAppearance UnfocusedAppearance;
|
||||
Microsoft.Terminal.Control.IControlSettings Settings { get; };
|
||||
Microsoft.Terminal.Control.IControlAppearance UnfocusedAppearance { get; };
|
||||
|
||||
event FontSizeChangedEventArgs FontSizeChanged;
|
||||
event Windows.Foundation.TypedEventHandler<Object, TitleChangedEventArgs> TitleChanged;
|
||||
|
|
|
@ -349,7 +349,7 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
}
|
||||
|
||||
Profiles::Profiles() :
|
||||
_previewControl{ Control::TermControl(Model::TerminalSettings{}, make<PreviewConnection>()) }
|
||||
_previewControl{ Control::TermControl(Model::TerminalSettings{}, nullptr, make<PreviewConnection>()) }
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
@ -404,26 +404,26 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
|
|||
{
|
||||
_PropertyChangedHandlers(*this, PropertyChangedEventArgs{ L"CurrentScrollState" });
|
||||
}
|
||||
_previewControl.Settings(_State.Profile().TermSettings());
|
||||
_previewControl.UpdateSettings();
|
||||
// _previewControl.Settings(_State.Profile().TermSettings());
|
||||
_previewControl.UpdateControlSettings(_State.Profile().TermSettings());
|
||||
});
|
||||
|
||||
// The Appearances object handles updating the values in the settings UI, but
|
||||
// we still need to listen to the changes here just to update the preview control
|
||||
_AppearanceViewModelChangedRevoker = _State.Profile().DefaultAppearance().PropertyChanged(winrt::auto_revoke, [=](auto&&, const PropertyChangedEventArgs& /*args*/) {
|
||||
_previewControl.Settings(_State.Profile().TermSettings());
|
||||
_previewControl.UpdateSettings();
|
||||
// _previewControl.Settings(_State.Profile().TermSettings());
|
||||
_previewControl.UpdateControlSettings(_State.Profile().TermSettings());
|
||||
});
|
||||
|
||||
// Navigate to the pivot in the provided navigation state
|
||||
ProfilesPivot().SelectedIndex(static_cast<int>(_State.LastActivePivot()));
|
||||
|
||||
_previewControl.Settings(_State.Profile().TermSettings());
|
||||
// _previewControl.Settings(_State.Profile().TermSettings());
|
||||
// There is a possibility that the control has not fully initialized yet,
|
||||
// so wait for it to initialize before updating the settings (so we know
|
||||
// that the renderer is set up)
|
||||
_previewControl.Initialized([&](auto&& /*s*/, auto&& /*e*/) {
|
||||
_previewControl.UpdateSettings();
|
||||
_previewControl.UpdateControlSettings(_State.Profile().TermSettings());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
X(til::color, CursorColor, DEFAULT_CURSOR_COLOR) \
|
||||
X(winrt::Microsoft::Terminal::Core::CursorStyle, CursorShape, winrt::Microsoft::Terminal::Core::CursorStyle::Vintage) \
|
||||
X(uint32_t, CursorHeight, DEFAULT_CURSOR_HEIGHT) \
|
||||
X(bool, IntenseIsBright, true)
|
||||
X(bool, IntenseIsBright, true) \
|
||||
X(bool, AdjustIndistinguishableColors, true)
|
||||
|
||||
// --------------------------- Control Appearance ---------------------------
|
||||
// All of these settings are defined in IControlSettings.
|
||||
|
|
Loading…
Reference in a new issue