-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Only access ControlInteractivity through the projection #10051
Changes from all commits
e4478ee
400b35f
42b970b
4578c13
d8cc047
21a97b6
2e861d8
e20caae
d667f3b
62cbf30
445bdf6
1376721
a1ce7cb
03fb764
5e7d270
6e031e5
47410c9
0869456
dace0c4
12b78f5
e340fe9
b7b23a8
086710a
21a6370
4efdf39
59e911d
6f07004
ff3b808
559d1de
804a114
0f0af03
95300d4
1de9485
1bc27d0
3cace60
265bd9f
c8a2957
074f67c
5a0840a
f5665c5
056c354
e643885
33653e0
3d59a67
5a598f7
3797d52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -426,7 +426,16 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
// - Updates last hovered cell, renders / removes rendering of hyper-link if required | ||
// Arguments: | ||
// - terminalPosition: The terminal position of the pointer | ||
void ControlCore::UpdateHoveredCell(const std::optional<til::point>& terminalPosition) | ||
void ControlCore::SetHoveredCell(Core::Point pos) | ||
{ | ||
_updateHoveredCell(std::optional<til::point>{ pos }); | ||
} | ||
void ControlCore::ClearHoveredCell() | ||
{ | ||
_updateHoveredCell(std::nullopt); | ||
} | ||
|
||
void ControlCore::_updateHoveredCell(const std::optional<til::point> terminalPosition) | ||
{ | ||
if (terminalPosition == _lastHoveredCell) | ||
{ | ||
|
@@ -477,7 +486,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
return winrt::hstring{ _terminal->GetHyperlinkAtPosition(pos) }; | ||
} | ||
|
||
winrt::hstring ControlCore::GetHoveredUriText() const | ||
winrt::hstring ControlCore::HoveredUriText() const | ||
{ | ||
auto lock = _terminal->LockForReading(); // Lock for the duration of our reads. | ||
if (_lastHoveredCell.has_value()) | ||
|
@@ -487,9 +496,9 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
return {}; | ||
} | ||
|
||
std::optional<til::point> ControlCore::GetHoveredCell() const | ||
Windows::Foundation::IReference<Core::Point> ControlCore::HoveredCell() const | ||
{ | ||
return _lastHoveredCell; | ||
return _lastHoveredCell.has_value() ? Windows::Foundation::IReference<Core::Point>{ _lastHoveredCell.value() } : nullptr; | ||
} | ||
|
||
// Method Description: | ||
|
@@ -895,6 +904,24 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
return _actualFont; | ||
} | ||
|
||
winrt::Windows::Foundation::Size ControlCore::FontSize() const noexcept | ||
{ | ||
const auto fontSize = GetFont().GetSize(); | ||
return { | ||
::base::saturated_cast<float>(fontSize.X), | ||
::base::saturated_cast<float>(fontSize.Y) | ||
}; | ||
} | ||
winrt::hstring ControlCore::FontFaceName() const noexcept | ||
{ | ||
return winrt::hstring{ GetFont().GetFaceName() }; | ||
} | ||
|
||
uint16_t ControlCore::FontWeight() const noexcept | ||
{ | ||
return static_cast<uint16_t>(GetFont().GetWeight()); | ||
} | ||
|
||
til::size ControlCore::FontSizeInDips() const | ||
{ | ||
const til::size fontSize{ GetFont().GetSize() }; | ||
|
@@ -1077,10 +1104,18 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
return _settings.CopyOnSelect(); | ||
} | ||
|
||
std::vector<std::wstring> ControlCore::SelectedText(bool trimTrailingWhitespace) const | ||
Windows::Foundation::Collections::IVector<winrt::hstring> ControlCore::SelectedText(bool trimTrailingWhitespace) const | ||
{ | ||
// RetrieveSelectedTextFromBuffer will lock while it's reading | ||
return _terminal->RetrieveSelectedTextFromBuffer(trimTrailingWhitespace).text; | ||
const auto internalResult{ _terminal->RetrieveSelectedTextFromBuffer(trimTrailingWhitespace).text }; | ||
|
||
auto result = winrt::single_threaded_vector<winrt::hstring>(); | ||
|
||
for (const auto& row : internalResult) | ||
{ | ||
result.Append(winrt::hstring{ row }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Idly, I wonder if there's a string-move constructor for hstring. Since we don't need the copy that lives in the vector any longer, if there is it could be a way to save a whole string copy. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't look like there's a way to make a |
||
} | ||
return result; | ||
} | ||
|
||
::Microsoft::Console::Types::IUiaData* ControlCore::GetUiaData() const | ||
|
@@ -1124,7 +1159,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
} | ||
} | ||
|
||
void ControlCore::SetBackgroundOpacity(const float opacity) | ||
void ControlCore::SetBackgroundOpacity(const double opacity) | ||
{ | ||
if (_renderEngine) | ||
{ | ||
|
@@ -1176,15 +1211,15 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
} | ||
} | ||
|
||
HANDLE ControlCore::GetSwapChainHandle() const | ||
uint64_t ControlCore::SwapChainHandle() const | ||
{ | ||
// This is called by: | ||
// * TermControl::RenderEngineSwapChainChanged, who is only registered | ||
// after Core::Initialize() is called. | ||
// * TermControl::_InitializeTerminal, after the call to Initialize, for | ||
// _AttachDxgiSwapChainToXaml. | ||
// In both cases, we'll have a _renderEngine by then. | ||
return _renderEngine->GetSwapChainHandle(); | ||
return reinterpret_cast<uint64_t>(_renderEngine->GetSwapChainHandle()); | ||
} | ||
|
||
void ControlCore::_rendererWarning(const HRESULT hr) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,97 @@ import "EventArgs.idl"; | |
namespace Microsoft.Terminal.Control | ||
{ | ||
|
||
// This is a mirror of | ||
// ::Microsoft::Console::VirtualTerminal::TerminalInput::MouseButtonState, | ||
// but projectable. | ||
// !! LOAD BEARING !! If you make this a struct with Booleans (like they | ||
// make the most sense as), then the app will crash trying to toss one of | ||
// these across the process boundary. I haven't the damndest idea why. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well that's weird. |
||
[flags] | ||
enum MouseButtonState | ||
{ | ||
IsLeftButtonDown = 0x1, | ||
IsMiddleButtonDown = 0x2, | ||
IsRightButtonDown = 0x4 | ||
}; | ||
|
||
[default_interface] runtimeclass ControlCore : ICoreState | ||
{ | ||
ControlCore(IControlSettings settings, | ||
Microsoft.Terminal.TerminalConnection.ITerminalConnection connection); | ||
|
||
Boolean Initialize(Double actualWidth, | ||
Double actualHeight, | ||
Double compositionScale); | ||
|
||
void UpdateSettings(IControlSettings settings); | ||
void UpdateAppearance(IControlAppearance appearance); | ||
|
||
UInt64 SwapChainHandle { get; }; | ||
|
||
Windows.Foundation.Size FontSize { get; }; | ||
String FontFaceName { get; }; | ||
UInt16 FontWeight { get; }; | ||
|
||
Boolean TrySendKeyEvent(Int16 vkey, | ||
Int16 scanCode, | ||
Microsoft.Terminal.Core.ControlKeyStates modifiers, | ||
Boolean keyDown); | ||
Boolean SendCharEvent(Char ch, | ||
Int16 scanCode, | ||
Microsoft.Terminal.Core.ControlKeyStates modifiers); | ||
void SendInput(String text); | ||
void PasteText(String text); | ||
|
||
void SetHoveredCell(Microsoft.Terminal.Core.Point terminalPosition); | ||
void ClearHoveredCell(); | ||
|
||
void ResetFontSize(); | ||
void AdjustFontSize(Int32 fontSizeDelta); | ||
void SizeChanged(Double width, Double height); | ||
void ScaleChanged(Double scale); | ||
|
||
void ToggleShaderEffects(); | ||
void ToggleReadOnlyMode(); | ||
|
||
Microsoft.Terminal.Core.Point CursorPosition { get; }; | ||
void ResumeRendering(); | ||
void BlinkAttributeTick(); | ||
void UpdatePatternLocations(); | ||
void Search(String text, Boolean goForward, Boolean caseSensitive); | ||
void SetBackgroundOpacity(Double opacity); | ||
Microsoft.Terminal.Core.Color BackgroundColor { get; }; | ||
|
||
Boolean HasSelection { get; }; | ||
IVector<String> SelectedText(Boolean trimTrailingWhitespace); | ||
|
||
String HoveredUriText { get; }; | ||
Windows.Foundation.IReference<Microsoft.Terminal.Core.Point> HoveredCell { get; }; | ||
|
||
void Close(); | ||
void BlinkCursor(); | ||
Boolean IsInReadOnlyMode { get; }; | ||
Boolean CursorOn; | ||
void EnablePainting(); | ||
|
||
event FontSizeChangedEventArgs FontSizeChanged; | ||
|
||
event Windows.Foundation.TypedEventHandler<Object, CopyToClipboardEventArgs> CopyToClipboard; | ||
event Windows.Foundation.TypedEventHandler<Object, TitleChangedEventArgs> TitleChanged; | ||
event Windows.Foundation.TypedEventHandler<Object, Object> WarningBell; | ||
event Windows.Foundation.TypedEventHandler<Object, Object> TabColorChanged; | ||
event Windows.Foundation.TypedEventHandler<Object, Object> BackgroundColorChanged; | ||
event Windows.Foundation.TypedEventHandler<Object, ScrollPositionChangedArgs> ScrollPositionChanged; | ||
event Windows.Foundation.TypedEventHandler<Object, Object> CursorPositionChanged; | ||
event Windows.Foundation.TypedEventHandler<Object, Object> TaskbarProgressChanged; | ||
event Windows.Foundation.TypedEventHandler<Object, Object> ConnectionStateChanged; | ||
event Windows.Foundation.TypedEventHandler<Object, Object> HoveredHyperlinkChanged; | ||
event Windows.Foundation.TypedEventHandler<Object, Object> RendererEnteredErrorState; | ||
event Windows.Foundation.TypedEventHandler<Object, Object> SwapChainChanged; | ||
event Windows.Foundation.TypedEventHandler<Object, RendererWarningArgs> RendererWarning; | ||
event Windows.Foundation.TypedEventHandler<Object, NoticeEventArgs> RaiseNotice; | ||
event Windows.Foundation.TypedEventHandler<Object, TransparencyChangedEventArgs> TransparencyChanged; | ||
event Windows.Foundation.TypedEventHandler<Object, Object> ReceivedOutput; | ||
|
||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
depending on how often this is called, it could be quite expensive. an IReference is a heap allocation for every .. thing.