Skip to content
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

Tweaks: normalize TextAttribute method names (adjective form) #6951

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/buffer/out/TextAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void TextAttribute::SetFaint(bool isFaint) noexcept
WI_UpdateFlag(_extendedAttrs, ExtendedAttributes::Faint, isFaint);
}

void TextAttribute::SetItalics(bool isItalic) noexcept
void TextAttribute::SetItalic(bool isItalic) noexcept
{
WI_UpdateFlag(_extendedAttrs, ExtendedAttributes::Italics, isItalic);
}
Expand All @@ -290,13 +290,13 @@ void TextAttribute::SetCrossedOut(bool isCrossedOut) noexcept
WI_UpdateFlag(_extendedAttrs, ExtendedAttributes::CrossedOut, isCrossedOut);
}

void TextAttribute::SetUnderline(bool isUnderlined) noexcept
void TextAttribute::SetUnderlined(bool isUnderlined) noexcept
{
// TODO:GH#2915 Treat underline separately from LVB_UNDERSCORE
WI_UpdateFlag(_wAttrLegacy, COMMON_LVB_UNDERSCORE, isUnderlined);
}

void TextAttribute::SetOverline(bool isOverlined) noexcept
void TextAttribute::SetOverlined(bool isOverlined) noexcept
{
WI_UpdateFlag(_wAttrLegacy, COMMON_LVB_GRID_HORIZONTAL, isOverlined);
}
Expand Down
11 changes: 6 additions & 5 deletions src/buffer/out/TextAttribute.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ class TextAttribute final

void SetBold(bool isBold) noexcept;
void SetFaint(bool isFaint) noexcept;
void SetItalics(bool isItalic) noexcept;
void SetItalic(bool isItalic) noexcept;
void SetBlinking(bool isBlinking) noexcept;
void SetInvisible(bool isInvisible) noexcept;
void SetCrossedOut(bool isCrossedOut) noexcept;
void SetUnderline(bool isUnderlined) noexcept;
void SetOverline(bool isOverlined) noexcept;
void SetUnderlined(bool isUnderlined) noexcept;
void SetOverlined(bool isOverlined) noexcept;
void SetReverseVideo(bool isReversed) noexcept;

ExtendedAttributes GetExtendedAttributes() const noexcept;
Expand Down Expand Up @@ -218,11 +218,12 @@ namespace WEX
static WEX::Common::NoThrowString ToString(const TextAttribute& attr)
{
return WEX::Common::NoThrowString().Format(
L"{FG:%s,BG:%s,bold:%d,wLegacy:(0x%04x)}",
L"{FG:%s,BG:%s,bold:%d,wLegacy:(0x%04x),ext:(0x%02x)}",
VerifyOutputTraits<TextColor>::ToString(attr._foreground).GetBuffer(),
VerifyOutputTraits<TextColor>::ToString(attr._background).GetBuffer(),
attr.IsBold(),
attr._wAttrLegacy);
attr._wAttrLegacy,
static_cast<DWORD>(attr._extendedAttrs));
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/buffer/out/textBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ const Cursor& TextBuffer::GetCursor() const noexcept
return _currentAttributes;
}

void TextBuffer::SetCurrentAttributes(const TextAttribute currentAttributes) noexcept
void TextBuffer::SetCurrentAttributes(const TextAttribute& currentAttributes) noexcept
{
_currentAttributes = currentAttributes;
}
Expand Down
2 changes: 1 addition & 1 deletion src/buffer/out/textBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class TextBuffer final

[[nodiscard]] TextAttribute GetCurrentAttributes() const noexcept;

void SetCurrentAttributes(const TextAttribute currentAttributes) noexcept;
void SetCurrentAttributes(const TextAttribute& currentAttributes) noexcept;

void Reset();

Expand Down
12 changes: 6 additions & 6 deletions src/cascadia/TerminalCore/TerminalDispatchGraphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ bool TerminalDispatch::SetGraphicsRendition(const std::basic_string_view<Dispatc
attr.SetFaint(false);
break;
case Italics:
attr.SetItalics(true);
attr.SetItalic(true);
break;
case NotItalics:
attr.SetItalics(false);
attr.SetItalic(false);
break;
case BlinkOrXterm256Index:
attr.SetBlinking(true);
Expand All @@ -156,16 +156,16 @@ bool TerminalDispatch::SetGraphicsRendition(const std::basic_string_view<Dispatc
attr.SetReverseVideo(false);
break;
case Underline:
attr.SetUnderline(true);
attr.SetUnderlined(true);
break;
case NoUnderline:
attr.SetUnderline(false);
attr.SetUnderlined(false);
break;
case Overline:
attr.SetOverline(true);
attr.SetOverlined(true);
break;
case NoOverline:
attr.SetOverline(false);
attr.SetOverlined(false);
break;
case ForegroundBlack:
attr.SetIndexedForeground(DARK_BLACK);
Expand Down
18 changes: 9 additions & 9 deletions src/host/ut_host/ScreenBufferTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,7 @@ void ScreenBufferTests::VtNewlinePastViewport()
auto fillAttr = TextAttribute{ RGB(12, 34, 56), RGB(78, 90, 12) };
fillAttr.SetCrossedOut(true);
fillAttr.SetReverseVideo(true);
fillAttr.SetUnderline(true);
fillAttr.SetUnderlined(true);
si.SetAttributes(fillAttr);
// But note that the meta attributes are expected to be cleared.
auto expectedFillAttr = fillAttr;
Expand Down Expand Up @@ -1480,7 +1480,7 @@ void ScreenBufferTests::VtNewlinePastEndOfBuffer()
auto fillAttr = TextAttribute{ RGB(12, 34, 56), RGB(78, 90, 12) };
fillAttr.SetCrossedOut(true);
fillAttr.SetReverseVideo(true);
fillAttr.SetUnderline(true);
fillAttr.SetUnderlined(true);
si.SetAttributes(fillAttr);
// But note that the meta attributes are expected to be cleared.
auto expectedFillAttr = fillAttr;
Expand Down Expand Up @@ -3382,7 +3382,7 @@ void ScreenBufferTests::ScrollOperations()
auto fillAttr = TextAttribute{ RGB(12, 34, 56), RGB(78, 90, 12) };
fillAttr.SetCrossedOut(true);
fillAttr.SetReverseVideo(true);
fillAttr.SetUnderline(true);
fillAttr.SetUnderlined(true);
si.SetAttributes(fillAttr);
// But note that the meta attributes are expected to be cleared.
auto expectedFillAttr = fillAttr;
Expand Down Expand Up @@ -3503,7 +3503,7 @@ void ScreenBufferTests::InsertChars()
auto fillAttr = TextAttribute{ RGB(12, 34, 56), RGB(78, 90, 12) };
fillAttr.SetCrossedOut(true);
fillAttr.SetReverseVideo(true);
fillAttr.SetUnderline(true);
fillAttr.SetUnderlined(true);
si.SetAttributes(fillAttr);
// But note that the meta attributes are expected to be cleared.
auto expectedFillAttr = fillAttr;
Expand Down Expand Up @@ -3663,7 +3663,7 @@ void ScreenBufferTests::DeleteChars()
auto fillAttr = TextAttribute{ RGB(12, 34, 56), RGB(78, 90, 12) };
fillAttr.SetCrossedOut(true);
fillAttr.SetReverseVideo(true);
fillAttr.SetUnderline(true);
fillAttr.SetUnderlined(true);
si.SetAttributes(fillAttr);
// But note that the meta attributes are expected to be cleared.
auto expectedFillAttr = fillAttr;
Expand Down Expand Up @@ -3895,7 +3895,7 @@ void ScreenBufferTests::EraseTests()
auto fillAttr = TextAttribute{ RGB(12, 34, 56), RGB(78, 90, 12) };
fillAttr.SetCrossedOut(true);
fillAttr.SetReverseVideo(true);
fillAttr.SetUnderline(true);
fillAttr.SetUnderlined(true);
si.SetAttributes(fillAttr);
// But note that the meta attributes are expected to be cleared.
auto expectedFillAttr = fillAttr;
Expand Down Expand Up @@ -5206,7 +5206,7 @@ void ScreenBufferTests::TestExtendedTextAttributesWithColors()
}
if (italics)
{
expectedAttr.SetItalics(true);
expectedAttr.SetItalic(true);
vtSeq += L"\x1b[3m";
}
if (blink)
Expand Down Expand Up @@ -5315,7 +5315,7 @@ void ScreenBufferTests::TestExtendedTextAttributesWithColors()
}
if (italics)
{
expectedAttr.SetItalics(false);
expectedAttr.SetItalic(false);
vtSeq = L"\x1b[23m";
validate(expectedAttr, vtSeq);
}
Expand Down Expand Up @@ -5789,7 +5789,7 @@ void ScreenBufferTests::ScreenAlignmentPattern()
// Set the initial attributes.
auto initialAttr = TextAttribute{ RGB(12, 34, 56), RGB(78, 90, 12) };
initialAttr.SetReverseVideo(true);
initialAttr.SetUnderline(true);
initialAttr.SetUnderlined(true);
si.SetAttributes(initialAttr);

// Set some margins.
Expand Down
10 changes: 5 additions & 5 deletions src/host/ut_host/VtRendererTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ void VtRendererTest::Xterm256TestExtendedAttributes()
}
if (italics)
{
desiredAttrs.SetItalics(true);
desiredAttrs.SetItalic(true);
onSequences.push_back("\x1b[3m");
offSequences.push_back("\x1b[23m");
}
Expand Down Expand Up @@ -788,15 +788,15 @@ void VtRendererTest::Xterm256TestAttributesAcrossReset()
break;
case GraphicsOptions::Italics:
Log::Comment(L"----Set Italics Attribute----");
textAttributes.SetItalics(true);
textAttributes.SetItalic(true);
break;
case GraphicsOptions::Underline:
Log::Comment(L"----Set Underline Attribute----");
textAttributes.SetUnderline(true);
textAttributes.SetUnderlined(true);
break;
case GraphicsOptions::Overline:
Log::Comment(L"----Set Overline Attribute----");
textAttributes.SetOverline(true);
textAttributes.SetOverlined(true);
break;
case GraphicsOptions::BlinkOrXterm256Index:
Log::Comment(L"----Set Blink Attribute----");
Expand Down Expand Up @@ -1289,7 +1289,7 @@ void VtRendererTest::XtermTestAttributesAcrossReset()
break;
case GraphicsOptions::Underline:
Log::Comment(L"----Set Underline Attribute----");
textAttributes.SetUnderline(true);
textAttributes.SetUnderlined(true);
break;
case GraphicsOptions::Negative:
Log::Comment(L"----Set Negative Attribute----");
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/vt/VtSequences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ using namespace Microsoft::Console::Render;
// - isUnderlined: If true, we'll underline the text. Otherwise we'll remove the underline.
// Return Value:
// - S_OK if we succeeded, else an appropriate HRESULT for failing to allocate or write.
[[nodiscard]] HRESULT VtEngine::_SetUnderline(const bool isUnderlined) noexcept
[[nodiscard]] HRESULT VtEngine::_SetUnderlined(const bool isUnderlined) noexcept
{
return _Write(isUnderlined ? "\x1b[4m" : "\x1b[24m");
}
Expand All @@ -372,7 +372,7 @@ using namespace Microsoft::Console::Render;
// - isOverlined: If true, we'll overline the text. Otherwise we'll remove the overline.
// Return Value:
// - S_OK if we succeeded, else an appropriate HRESULT for failing to allocate or write.
[[nodiscard]] HRESULT VtEngine::_SetOverline(const bool isOverlined) noexcept
[[nodiscard]] HRESULT VtEngine::_SetOverlined(const bool isOverlined) noexcept
{
return _Write(isOverlined ? "\x1b[53m" : "\x1b[55m");
}
Expand All @@ -383,7 +383,7 @@ using namespace Microsoft::Console::Render;
// - isItalic: If true, we'll italicize the text. Otherwise we'll remove the italics.
// Return Value:
// - S_OK if we succeeded, else an appropriate HRESULT for failing to allocate or write.
[[nodiscard]] HRESULT VtEngine::_SetItalics(const bool isItalic) noexcept
[[nodiscard]] HRESULT VtEngine::_SetItalic(const bool isItalic) noexcept
{
return _Write(isItalic ? "\x1b[3m" : "\x1b[23m");
}
Expand Down
12 changes: 6 additions & 6 deletions src/renderer/vt/Xterm256Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,20 @@ Xterm256Engine::Xterm256Engine(_In_ wil::unique_hfile hPipe,

if (textAttributes.IsUnderlined() != _lastTextAttributes.IsUnderlined())
{
RETURN_IF_FAILED(_SetUnderline(textAttributes.IsUnderlined()));
_lastTextAttributes.SetUnderline(textAttributes.IsUnderlined());
RETURN_IF_FAILED(_SetUnderlined(textAttributes.IsUnderlined()));
_lastTextAttributes.SetUnderlined(textAttributes.IsUnderlined());
}

if (textAttributes.IsOverlined() != _lastTextAttributes.IsOverlined())
{
RETURN_IF_FAILED(_SetOverline(textAttributes.IsOverlined()));
_lastTextAttributes.SetOverline(textAttributes.IsOverlined());
RETURN_IF_FAILED(_SetOverlined(textAttributes.IsOverlined()));
_lastTextAttributes.SetOverlined(textAttributes.IsOverlined());
}

if (textAttributes.IsItalic() != _lastTextAttributes.IsItalic())
{
RETURN_IF_FAILED(_SetItalics(textAttributes.IsItalic()));
_lastTextAttributes.SetItalics(textAttributes.IsItalic());
RETURN_IF_FAILED(_SetItalic(textAttributes.IsItalic()));
_lastTextAttributes.SetItalic(textAttributes.IsItalic());
}

if (textAttributes.IsBlinking() != _lastTextAttributes.IsBlinking())
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/vt/XtermEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ XtermEngine::XtermEngine(_In_ wil::unique_hfile hPipe,
}
if (textAttributes.IsUnderlined() != _lastTextAttributes.IsUnderlined())
{
RETURN_IF_FAILED(_SetUnderline(textAttributes.IsUnderlined()));
_lastTextAttributes.SetUnderline(textAttributes.IsUnderlined());
RETURN_IF_FAILED(_SetUnderlined(textAttributes.IsUnderlined()));
_lastTextAttributes.SetUnderlined(textAttributes.IsUnderlined());
}

return S_OK;
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/vt/vtrenderer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,9 @@ namespace Microsoft::Console::Render

[[nodiscard]] HRESULT _SetBold(const bool isBold) noexcept;
[[nodiscard]] HRESULT _SetFaint(const bool isFaint) noexcept;
[[nodiscard]] HRESULT _SetUnderline(const bool isUnderlined) noexcept;
[[nodiscard]] HRESULT _SetOverline(const bool isUnderlined) noexcept;
[[nodiscard]] HRESULT _SetItalics(const bool isItalic) noexcept;
[[nodiscard]] HRESULT _SetUnderlined(const bool isUnderlined) noexcept;
[[nodiscard]] HRESULT _SetOverlined(const bool isOverlined) noexcept;
[[nodiscard]] HRESULT _SetItalic(const bool isItalic) noexcept;
[[nodiscard]] HRESULT _SetBlinking(const bool isBlinking) noexcept;
[[nodiscard]] HRESULT _SetInvisible(const bool isInvisible) noexcept;
[[nodiscard]] HRESULT _SetCrossedOut(const bool isCrossedOut) noexcept;
Expand Down
12 changes: 6 additions & 6 deletions src/terminal/adapter/adaptDispatchGraphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ bool AdaptDispatch::SetGraphicsRendition(const std::basic_string_view<DispatchTy
attr.SetFaint(false);
break;
case Italics:
attr.SetItalics(true);
attr.SetItalic(true);
break;
case NotItalics:
attr.SetItalics(false);
attr.SetItalic(false);
break;
case BlinkOrXterm256Index:
attr.SetBlinking(true);
Expand All @@ -165,16 +165,16 @@ bool AdaptDispatch::SetGraphicsRendition(const std::basic_string_view<DispatchTy
attr.SetReverseVideo(false);
break;
case Underline:
attr.SetUnderline(true);
attr.SetUnderlined(true);
break;
case NoUnderline:
attr.SetUnderline(false);
attr.SetUnderlined(false);
break;
case Overline:
attr.SetOverline(true);
attr.SetOverlined(true);
break;
case NoOverline:
attr.SetOverline(false);
attr.SetOverlined(false);
break;
case ForegroundBlack:
attr.SetIndexedForeground(DARK_BLACK);
Expand Down
3 changes: 1 addition & 2 deletions src/terminal/adapter/ut_adapter/adapterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class TestGetSet final : public ConGetSet
VERIFY_ARE_EQUAL(_expectedCursorPos, sbiex.dwCursorPosition);
VERIFY_ARE_EQUAL(_expectedScreenBufferSize, sbiex.dwSize);
VERIFY_ARE_EQUAL(_expectedScreenBufferViewport, sbiex.srWindow);
VERIFY_ARE_EQUAL(_expectedAttributes, sbiex.wAttributes);
VERIFY_ARE_EQUAL(_expectedAttribute, TextAttribute{ sbiex.wAttributes });
}
return _setConsoleScreenBufferInfoExResult;
}
Expand Down Expand Up @@ -764,7 +764,6 @@ class TestGetSet final : public ConGetSet

COORD _expectedScreenBufferSize = { 0, 0 };
SMALL_RECT _expectedScreenBufferViewport{ 0, 0, 0, 0 };
WORD _expectedAttributes = 0;
bool _privateSetCursorKeysModeResult = false;
bool _privateSetKeypadModeResult = false;
bool _cursorKeysApplicationMode = false;
Expand Down