Skip to content

Commit edfa3ea

Browse files
authored
Remove SetTextAttributes from the ITerminalApi interface (#17685)
The only reason we had the `SetTextAttributes` method in `ITerminalApi` was to allow for conhost to remap the default color attributes when the VT PowerShell quirk was active. Since that quirk has now been removed, there's no need for this API anymore. ## References and Relevant Issues The PowerShell quirk was removed in PR #17666. ## Validation Steps Performed I've had to update all the attribute tests in adapterTest to manually check the expected attributes, since those checks were previously being handled in a `SetTextAttributes` mock which no longer exists. I've also performed some manual tests of the VT attribute operations to double check that they're still working as expected.
1 parent 9ab2870 commit edfa3ea

File tree

10 files changed

+72
-54
lines changed

10 files changed

+72
-54
lines changed

src/cascadia/TerminalCore/Terminal.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ class Microsoft::Terminal::Core::Terminal final :
132132
Microsoft::Console::VirtualTerminal::StateMachine& GetStateMachine() noexcept override;
133133
BufferState GetBufferAndViewport() noexcept override;
134134
void SetViewportPosition(const til::point position) noexcept override;
135-
void SetTextAttributes(const TextAttribute& attrs) noexcept override;
136135
void SetSystemMode(const Mode mode, const bool enabled) noexcept override;
137136
bool GetSystemMode(const Mode mode) const noexcept override;
138137
void ReturnAnswerback() override;

src/cascadia/TerminalCore/TerminalApi.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,6 @@ try
5454
}
5555
CATCH_LOG()
5656

57-
void Terminal::SetTextAttributes(const TextAttribute& attrs) noexcept
58-
{
59-
_activeBuffer().SetCurrentAttributes(attrs);
60-
}
61-
6257
void Terminal::SetSystemMode(const Mode mode, const bool enabled) noexcept
6358
{
6459
_assertLocked();

src/host/outputStream.cpp

-12
Original file line numberDiff line numberDiff line change
@@ -88,18 +88,6 @@ void ConhostInternalGetSet::SetViewportPosition(const til::point position)
8888
info.UpdateBottom();
8989
}
9090

91-
// Method Description:
92-
// - Sets the current TextAttribute of the active screen buffer. Text
93-
// written to this buffer will be written with these attributes.
94-
// Arguments:
95-
// - attrs: The new TextAttribute to use
96-
// Return Value:
97-
// - <none>
98-
void ConhostInternalGetSet::SetTextAttributes(const TextAttribute& attrs)
99-
{
100-
_io.GetActiveOutputBuffer().SetAttributes(attrs);
101-
}
102-
10391
// Routine Description:
10492
// - Sets the state of one of the system modes.
10593
// Arguments:

src/host/outputStream.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ class ConhostInternalGetSet final : public Microsoft::Console::VirtualTerminal::
3535
BufferState GetBufferAndViewport() override;
3636
void SetViewportPosition(const til::point position) override;
3737

38-
void SetTextAttributes(const TextAttribute& attrs) override;
39-
4038
void SetSystemMode(const Mode mode, const bool enabled) override;
4139
bool GetSystemMode(const Mode mode) const override;
4240

src/terminal/adapter/ITerminalApi.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ namespace Microsoft::Console::VirtualTerminal
5252

5353
virtual bool IsVtInputEnabled() const = 0;
5454

55-
virtual void SetTextAttributes(const TextAttribute& attrs) = 0;
56-
5755
enum class Mode : size_t
5856
{
5957
AutoWrap,

src/terminal/adapter/PageManager.cpp

+1-8
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,9 @@ const TextAttribute& Page::Attributes() const noexcept
4040
return _buffer.GetCurrentAttributes();
4141
}
4242

43-
void Page::SetAttributes(const TextAttribute& attr, ITerminalApi* api) const
43+
void Page::SetAttributes(const TextAttribute& attr) const noexcept
4444
{
4545
_buffer.SetCurrentAttributes(attr);
46-
// If the api parameter was specified, we need to pass the new attributes
47-
// through to the api. This occurs when there's a potential for the colors
48-
// to be changed, which may require some legacy remapping in conhost.
49-
if (api)
50-
{
51-
api->SetTextAttributes(attr);
52-
}
5346
}
5447

5548
til::size Page::Size() const noexcept

src/terminal/adapter/PageManager.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace Microsoft::Console::VirtualTerminal
2525
til::CoordType Number() const noexcept;
2626
Cursor& Cursor() const noexcept;
2727
const TextAttribute& Attributes() const noexcept;
28-
void SetAttributes(const TextAttribute& attr, ITerminalApi* api = nullptr) const;
28+
void SetAttributes(const TextAttribute& attr) const noexcept;
2929
til::size Size() const noexcept;
3030
til::CoordType Top() const noexcept;
3131
til::CoordType Bottom() const noexcept;

src/terminal/adapter/adaptDispatch.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ bool AdaptDispatch::CursorRestoreState()
555555
}
556556

557557
// Restore text attributes.
558-
page.SetAttributes(savedCursorState.Attributes, &_api);
558+
page.SetAttributes(savedCursorState.Attributes);
559559

560560
// Restore designated character sets.
561561
_termOutput.RestoreFrom(savedCursorState.TermOutput);

src/terminal/adapter/adaptDispatchGraphics.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ bool AdaptDispatch::SetGraphicsRendition(const VTParameters options)
425425
const auto page = _pages.ActivePage();
426426
auto attr = page.Attributes();
427427
_ApplyGraphicsOptions(options, attr);
428-
page.SetAttributes(attr, &_api);
428+
page.SetAttributes(attr);
429429
return true;
430430
}
431431

@@ -487,6 +487,6 @@ bool AdaptDispatch::PopGraphicsRendition()
487487
{
488488
const auto page = _pages.ActivePage();
489489
const auto& currentAttributes = page.Attributes();
490-
page.SetAttributes(_sgrStack.Pop(currentAttributes), &_api);
490+
page.SetAttributes(_sgrStack.Pop(currentAttributes));
491491
return true;
492492
}

0 commit comments

Comments
 (0)