Skip to content

Commit 27e1aee

Browse files
committed
Merge branch 'main' into dev/cazamor/sui/extensions-page
2 parents 5ae13b3 + 06f736b commit 27e1aee

File tree

57 files changed

+251
-98
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+251
-98
lines changed

.github/actions/spelling/allow/apis.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ Stubless
222222
Subheader
223223
Subpage
224224
syscall
225+
syscolors
225226
SYSTEMBACKDROP
226227
TABROW
227228
TASKBARCREATED

.github/actions/spelling/expect/expect.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,6 +1679,7 @@ SMARTQUOTE
16791679
SMTO
16801680
snapcx
16811681
snapcy
1682+
snk
16821683
SOLIDBOX
16831684
Solutiondir
16841685
somefile
288 Bytes
Binary file not shown.

build/config/esrp.build.batch.wpfdotnet.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,20 @@
66
],
77
"SigningInfo": {
88
"Operations": [
9+
{
10+
"KeyCode": "CP-233904-SN",
11+
"OperationSetCode": "StrongNameSign",
12+
"ToolName": "sign",
13+
"ToolVersion": "1.0",
14+
"Parameters": []
15+
},
16+
{
17+
"KeyCode": "CP-233904-SN",
18+
"OperationSetCode": "StrongNameVerify",
19+
"ToolName": "sign",
20+
"ToolVersion": "1.0",
21+
"Parameters": []
22+
},
923
{
1024
"KeyCode": "CP-230012",
1125
"OperationSetCode": "SigntoolSign",

src/audio/midi/lib/sources.dep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
BUILD_PASS1_CONSUMES= \
2-
onecore\windows\vcpkg|PASS1 \
2+
onecore\windows\core\console\vcpkg|PASS1 \
33

src/buffer/out/ImageSlice.cpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,20 @@ bool ImageSlice::_copyCells(const ImageSlice& srcSlice, const til::CoordType src
186186
}
187187

188188
// The used destination before and after the written area must be erased.
189-
if (dstUsedBegin < dstWriteBegin)
189+
// If this results in the entire range being erased, we return true to let
190+
// the caller know that the slice should be deleted.
191+
if (dstUsedBegin < dstWriteBegin && _eraseCells(dstUsedBegin, dstWriteBegin))
190192
{
191-
_eraseCells(dstUsedBegin, dstWriteBegin);
193+
return true;
192194
}
193-
if (dstUsedEnd > dstWriteEnd)
195+
if (dstUsedEnd > dstWriteEnd && _eraseCells(dstWriteEnd, dstUsedEnd))
194196
{
195-
_eraseCells(dstWriteEnd, dstUsedEnd);
197+
return true;
196198
}
197199

198-
// If the beginning column is now not less than the end, that means the
199-
// content has been entirely erased, so we return true to let the caller
200-
// know that the slice should be deleted.
200+
// At this point, if the beginning column is not less than the end, that
201+
// means this was an empty slice into which nothing was copied, so we can
202+
// again return true to let the caller know it should be deleted.
201203
return _columnBegin >= _columnEnd;
202204
}
203205

@@ -210,10 +212,19 @@ void ImageSlice::EraseBlock(TextBuffer& buffer, const til::rect rect)
210212
}
211213
}
212214

213-
void ImageSlice::EraseCells(TextBuffer& buffer, const til::point at, const size_t distance)
215+
void ImageSlice::EraseCells(TextBuffer& buffer, const til::point at, const til::CoordType distance)
214216
{
215-
auto& row = buffer.GetMutableRowByOffset(at.y);
216-
EraseCells(row, at.x, gsl::narrow_cast<til::CoordType>(at.x + distance));
217+
auto x = at.x;
218+
auto y = at.y;
219+
auto distanceRemaining = distance;
220+
while (distanceRemaining > 0)
221+
{
222+
auto& row = buffer.GetMutableRowByOffset(y);
223+
EraseCells(row, x, x + distanceRemaining);
224+
distanceRemaining -= (static_cast<til::CoordType>(row.size()) - x);
225+
x = 0;
226+
y++;
227+
}
217228
}
218229

219230
void ImageSlice::EraseCells(ROW& row, const til::CoordType columnBegin, const til::CoordType columnEnd)

src/buffer/out/ImageSlice.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class ImageSlice
4141
static void CopyRow(const ROW& srcRow, ROW& dstRow);
4242
static void CopyCells(const ROW& srcRow, const til::CoordType srcColumn, ROW& dstRow, const til::CoordType dstColumnBegin, const til::CoordType dstColumnEnd);
4343
static void EraseBlock(TextBuffer& buffer, const til::rect rect);
44-
static void EraseCells(TextBuffer& buffer, const til::point at, const size_t distance);
44+
static void EraseCells(TextBuffer& buffer, const til::point at, const til::CoordType distance);
4545
static void EraseCells(ROW& row, const til::CoordType columnBegin, const til::CoordType columnEnd);
4646

4747
private:

src/buffer/out/lib/sources.dep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
BUILD_PASS1_CONSUMES= \
2-
onecore\windows\vcpkg|PASS1 \
2+
onecore\windows\core\console\vcpkg|PASS1 \
33

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
BUILD_PASS1_CONSUMES= \
2-
onecore\windows\vcpkg|PASS1 \
2+
onecore\windows\core\console\vcpkg|PASS1 \
33

src/cascadia/TerminalControl/HwndTerminal.cpp

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,79 @@ using namespace ::Microsoft::Terminal::Core;
1919

2020
static LPCWSTR term_window_class = L"HwndTerminalClass";
2121

22+
STDMETHODIMP HwndTerminal::TsfDataProvider::QueryInterface(REFIID, void**) noexcept
23+
{
24+
return E_NOTIMPL;
25+
}
26+
27+
ULONG STDMETHODCALLTYPE HwndTerminal::TsfDataProvider::AddRef() noexcept
28+
{
29+
return 1;
30+
}
31+
32+
ULONG STDMETHODCALLTYPE HwndTerminal::TsfDataProvider::Release() noexcept
33+
{
34+
return 1;
35+
}
36+
37+
HWND HwndTerminal::TsfDataProvider::GetHwnd()
38+
{
39+
return _terminal->GetHwnd();
40+
}
41+
42+
RECT HwndTerminal::TsfDataProvider::GetViewport()
43+
{
44+
const auto hwnd = GetHwnd();
45+
46+
RECT rc;
47+
GetClientRect(hwnd, &rc);
48+
49+
// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getclientrect
50+
// > The left and top members are zero. The right and bottom members contain the width and height of the window.
51+
// --> We can turn the client rect into a screen-relative rect by adding the left/top position.
52+
ClientToScreen(hwnd, reinterpret_cast<POINT*>(&rc));
53+
rc.right += rc.left;
54+
rc.bottom += rc.top;
55+
56+
return rc;
57+
}
58+
59+
RECT HwndTerminal::TsfDataProvider::GetCursorPosition()
60+
{
61+
// Convert from columns/rows to pixels.
62+
til::point cursorPos;
63+
til::size fontSize;
64+
{
65+
const auto lock = _terminal->_terminal->LockForReading();
66+
cursorPos = _terminal->_terminal->GetCursorPosition(); // measured in terminal cells
67+
fontSize = _terminal->_actualFont.GetSize(); // measured in pixels, not DIP
68+
}
69+
POINT ptSuggestion = {
70+
.x = cursorPos.x * fontSize.width,
71+
.y = cursorPos.y * fontSize.height,
72+
};
73+
74+
ClientToScreen(GetHwnd(), &ptSuggestion);
75+
76+
// Final measurement should be in pixels
77+
return {
78+
.left = ptSuggestion.x,
79+
.top = ptSuggestion.y,
80+
.right = ptSuggestion.x + fontSize.width,
81+
.bottom = ptSuggestion.y + fontSize.height,
82+
};
83+
}
84+
85+
void HwndTerminal::TsfDataProvider::HandleOutput(std::wstring_view text)
86+
{
87+
_terminal->_WriteTextToConnection(text);
88+
}
89+
90+
Microsoft::Console::Render::Renderer* HwndTerminal::TsfDataProvider::GetRenderer()
91+
{
92+
return _terminal->_renderer.get();
93+
}
94+
2295
// This magic flag is "documented" at https://msdn.microsoft.com/en-us/library/windows/desktop/ms646301(v=vs.85).aspx
2396
// "If the high-order bit is 1, the key is down; otherwise, it is up."
2497
static constexpr short KeyPressed{ gsl::narrow_cast<short>(0x8000) };
@@ -242,6 +315,7 @@ try
242315
{
243316
// As a rule, detach resources from the Terminal before shutting them down.
244317
// This ensures that teardown is reentrant.
318+
_tsfHandle = {};
245319

246320
// Shut down the renderer (and therefore the thread) before we implode
247321
_renderer.reset();
@@ -941,6 +1015,16 @@ void __stdcall TerminalSetFocus(void* terminal)
9411015
{
9421016
LOG_IF_FAILED(uiaEngine->Enable());
9431017
}
1018+
publicTerminal->_FocusTSF();
1019+
}
1020+
1021+
void HwndTerminal::_FocusTSF() noexcept
1022+
{
1023+
if (!_tsfHandle)
1024+
{
1025+
_tsfHandle = Microsoft::Console::TSF::Handle::Create();
1026+
_tsfHandle.AssociateFocus(&_tsfDataProvider);
1027+
}
9441028
}
9451029

9461030
void __stdcall TerminalKillFocus(void* terminal)

0 commit comments

Comments
 (0)