2019-05-03 00:29:04 +02:00
|
|
|
/*++
|
|
|
|
Copyright (c) Microsoft Corporation
|
|
|
|
Licensed under the MIT license.
|
|
|
|
|
|
|
|
Module Name:
|
|
|
|
- TextAttribute.hpp
|
|
|
|
|
|
|
|
Abstract:
|
|
|
|
- contains data structure for run-length-encoding of text attribute data
|
|
|
|
|
|
|
|
Author(s):
|
|
|
|
- Michael Niksa (miniksa) 10-Apr-2014
|
|
|
|
- Paul Campbell (paulcam) 10-Apr-2014
|
|
|
|
|
|
|
|
Revision History:
|
|
|
|
- From components of output.h/.c
|
|
|
|
by Therese Stowell (ThereseS) 1990-1991
|
|
|
|
- Pulled into its own file from textBuffer.hpp/cpp (AustDi, 2017)
|
|
|
|
- Pulled each of the fg/bg colors into their own abstraction (migrie, Nov 2018)
|
|
|
|
--*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include "TextColor.h"
|
|
|
|
#include "../../inc/conattrs.hpp"
|
|
|
|
|
|
|
|
#ifdef UNIT_TESTING
|
|
|
|
#include "WexTestClass.h"
|
|
|
|
#endif
|
|
|
|
|
Add support for passing through extended text attributes, like… (#2917)
## Summary of the Pull Request
Adds support for Italics, Blinking, Invisible, CrossedOut text, THROUGH CONPTY. This does **NOT** add support for those styles to conhost or the terminal.
We will store these "Extended Text Attributes" in a `TextAttribute`. When we go to render a line, we'll see if the state has changed from our previous state, and if so, we'll appropriately toggle that state with VT. Boldness has been moved from a `bool` to a single bit in these flags.
Technically, now that these are stored in the buffer, we only need to make changes to the renderers to be able to support them. That's not being done as a part of this PR however.
## References
See also #2915 and #2916, which are some follow-up tasks from this fix. I thought them too risky for 20H1.
## PR Checklist
* [x] Closes #2554
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated
<hr>
* store text with extended attributes too
* Plumb attributes through all the renderers
* parse extended attrs, though we're not renderering them right
* Render these states correctly
* Add a very extensive test
* Cleanup for PR
* a block of PR feedback
* add 512 test cases
* Fix the build
* Fix @carlos-zamora's suggestions
* @miniksa's PR feedback
2019-10-04 22:53:54 +02:00
|
|
|
#pragma pack(push, 1)
|
|
|
|
|
2019-05-03 00:29:04 +02:00
|
|
|
class TextAttribute final
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
constexpr TextAttribute() noexcept :
|
|
|
|
_wAttrLegacy{ 0 },
|
|
|
|
_foreground{},
|
|
|
|
_background{},
|
Add support for passing through extended text attributes, like… (#2917)
## Summary of the Pull Request
Adds support for Italics, Blinking, Invisible, CrossedOut text, THROUGH CONPTY. This does **NOT** add support for those styles to conhost or the terminal.
We will store these "Extended Text Attributes" in a `TextAttribute`. When we go to render a line, we'll see if the state has changed from our previous state, and if so, we'll appropriately toggle that state with VT. Boldness has been moved from a `bool` to a single bit in these flags.
Technically, now that these are stored in the buffer, we only need to make changes to the renderers to be able to support them. That's not being done as a part of this PR however.
## References
See also #2915 and #2916, which are some follow-up tasks from this fix. I thought them too risky for 20H1.
## PR Checklist
* [x] Closes #2554
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated
<hr>
* store text with extended attributes too
* Plumb attributes through all the renderers
* parse extended attrs, though we're not renderering them right
* Render these states correctly
* Add a very extensive test
* Cleanup for PR
* a block of PR feedback
* add 512 test cases
* Fix the build
* Fix @carlos-zamora's suggestions
* @miniksa's PR feedback
2019-10-04 22:53:54 +02:00
|
|
|
_extendedAttrs{ ExtendedAttributes::Normal }
|
2019-05-03 00:29:04 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr TextAttribute(const WORD wLegacyAttr) noexcept :
|
2019-08-29 22:19:01 +02:00
|
|
|
_wAttrLegacy{ gsl::narrow_cast<WORD>(wLegacyAttr & META_ATTRS) },
|
|
|
|
_foreground{ gsl::narrow_cast<BYTE>(wLegacyAttr & FG_ATTRS) },
|
|
|
|
_background{ gsl::narrow_cast<BYTE>((wLegacyAttr & BG_ATTRS) >> 4) },
|
Add support for passing through extended text attributes, like… (#2917)
## Summary of the Pull Request
Adds support for Italics, Blinking, Invisible, CrossedOut text, THROUGH CONPTY. This does **NOT** add support for those styles to conhost or the terminal.
We will store these "Extended Text Attributes" in a `TextAttribute`. When we go to render a line, we'll see if the state has changed from our previous state, and if so, we'll appropriately toggle that state with VT. Boldness has been moved from a `bool` to a single bit in these flags.
Technically, now that these are stored in the buffer, we only need to make changes to the renderers to be able to support them. That's not being done as a part of this PR however.
## References
See also #2915 and #2916, which are some follow-up tasks from this fix. I thought them too risky for 20H1.
## PR Checklist
* [x] Closes #2554
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated
<hr>
* store text with extended attributes too
* Plumb attributes through all the renderers
* parse extended attrs, though we're not renderering them right
* Render these states correctly
* Add a very extensive test
* Cleanup for PR
* a block of PR feedback
* add 512 test cases
* Fix the build
* Fix @carlos-zamora's suggestions
* @miniksa's PR feedback
2019-10-04 22:53:54 +02:00
|
|
|
_extendedAttrs{ ExtendedAttributes::Normal }
|
2019-05-03 00:29:04 +02:00
|
|
|
{
|
|
|
|
// If we're given lead/trailing byte information with the legacy color, strip it.
|
|
|
|
WI_ClearAllFlags(_wAttrLegacy, COMMON_LVB_SBCSDBCS);
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr TextAttribute(const COLORREF rgbForeground,
|
|
|
|
const COLORREF rgbBackground) noexcept :
|
|
|
|
_wAttrLegacy{ 0 },
|
|
|
|
_foreground{ rgbForeground },
|
|
|
|
_background{ rgbBackground },
|
Add support for passing through extended text attributes, like… (#2917)
## Summary of the Pull Request
Adds support for Italics, Blinking, Invisible, CrossedOut text, THROUGH CONPTY. This does **NOT** add support for those styles to conhost or the terminal.
We will store these "Extended Text Attributes" in a `TextAttribute`. When we go to render a line, we'll see if the state has changed from our previous state, and if so, we'll appropriately toggle that state with VT. Boldness has been moved from a `bool` to a single bit in these flags.
Technically, now that these are stored in the buffer, we only need to make changes to the renderers to be able to support them. That's not being done as a part of this PR however.
## References
See also #2915 and #2916, which are some follow-up tasks from this fix. I thought them too risky for 20H1.
## PR Checklist
* [x] Closes #2554
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated
<hr>
* store text with extended attributes too
* Plumb attributes through all the renderers
* parse extended attrs, though we're not renderering them right
* Render these states correctly
* Add a very extensive test
* Cleanup for PR
* a block of PR feedback
* add 512 test cases
* Fix the build
* Fix @carlos-zamora's suggestions
* @miniksa's PR feedback
2019-10-04 22:53:54 +02:00
|
|
|
_extendedAttrs{ ExtendedAttributes::Normal }
|
2019-05-03 00:29:04 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr WORD GetLegacyAttributes() const noexcept
|
|
|
|
{
|
2019-08-29 20:27:39 +02:00
|
|
|
const BYTE fg = (_foreground.GetIndex() & FG_ATTRS);
|
|
|
|
const BYTE bg = (_background.GetIndex() << 4) & BG_ATTRS;
|
|
|
|
const WORD meta = (_wAttrLegacy & META_ATTRS);
|
Add support for passing through extended text attributes, like… (#2917)
## Summary of the Pull Request
Adds support for Italics, Blinking, Invisible, CrossedOut text, THROUGH CONPTY. This does **NOT** add support for those styles to conhost or the terminal.
We will store these "Extended Text Attributes" in a `TextAttribute`. When we go to render a line, we'll see if the state has changed from our previous state, and if so, we'll appropriately toggle that state with VT. Boldness has been moved from a `bool` to a single bit in these flags.
Technically, now that these are stored in the buffer, we only need to make changes to the renderers to be able to support them. That's not being done as a part of this PR however.
## References
See also #2915 and #2916, which are some follow-up tasks from this fix. I thought them too risky for 20H1.
## PR Checklist
* [x] Closes #2554
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated
<hr>
* store text with extended attributes too
* Plumb attributes through all the renderers
* parse extended attrs, though we're not renderering them right
* Render these states correctly
* Add a very extensive test
* Cleanup for PR
* a block of PR feedback
* add 512 test cases
* Fix the build
* Fix @carlos-zamora's suggestions
* @miniksa's PR feedback
2019-10-04 22:53:54 +02:00
|
|
|
return (fg | bg | meta) | (IsBold() ? FOREGROUND_INTENSITY : 0);
|
2019-05-03 00:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Method Description:
|
|
|
|
// - Returns a WORD with legacy-style attributes for this textattribute.
|
|
|
|
// If either the foreground or background of this textattribute is not
|
|
|
|
// a legacy attribute, then instead use the provided default index as
|
|
|
|
// the value for that component.
|
|
|
|
// Arguments:
|
|
|
|
// - defaultFgIndex: the BYTE to use as the index for the foreground, should
|
|
|
|
// the foreground not be a legacy style attribute.
|
|
|
|
// - defaultBgIndex: the BYTE to use as the index for the backgound, should
|
|
|
|
// the background not be a legacy style attribute.
|
|
|
|
// Return Value:
|
|
|
|
// - a WORD with legacy-style attributes for this textattribute.
|
|
|
|
constexpr WORD GetLegacyAttributes(const BYTE defaultFgIndex,
|
|
|
|
const BYTE defaultBgIndex) const noexcept
|
|
|
|
{
|
2019-08-29 20:27:39 +02:00
|
|
|
const BYTE fgIndex = _foreground.IsLegacy() ? _foreground.GetIndex() : defaultFgIndex;
|
|
|
|
const BYTE bgIndex = _background.IsLegacy() ? _background.GetIndex() : defaultBgIndex;
|
|
|
|
const BYTE fg = (fgIndex & FG_ATTRS);
|
|
|
|
const BYTE bg = (bgIndex << 4) & BG_ATTRS;
|
|
|
|
const WORD meta = (_wAttrLegacy & META_ATTRS);
|
Add support for passing through extended text attributes, like… (#2917)
## Summary of the Pull Request
Adds support for Italics, Blinking, Invisible, CrossedOut text, THROUGH CONPTY. This does **NOT** add support for those styles to conhost or the terminal.
We will store these "Extended Text Attributes" in a `TextAttribute`. When we go to render a line, we'll see if the state has changed from our previous state, and if so, we'll appropriately toggle that state with VT. Boldness has been moved from a `bool` to a single bit in these flags.
Technically, now that these are stored in the buffer, we only need to make changes to the renderers to be able to support them. That's not being done as a part of this PR however.
## References
See also #2915 and #2916, which are some follow-up tasks from this fix. I thought them too risky for 20H1.
## PR Checklist
* [x] Closes #2554
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated
<hr>
* store text with extended attributes too
* Plumb attributes through all the renderers
* parse extended attrs, though we're not renderering them right
* Render these states correctly
* Add a very extensive test
* Cleanup for PR
* a block of PR feedback
* add 512 test cases
* Fix the build
* Fix @carlos-zamora's suggestions
* @miniksa's PR feedback
2019-10-04 22:53:54 +02:00
|
|
|
return (fg | bg | meta) | (IsBold() ? FOREGROUND_INTENSITY : 0);
|
2019-05-03 00:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
COLORREF CalculateRgbForeground(std::basic_string_view<COLORREF> colorTable,
|
|
|
|
COLORREF defaultFgColor,
|
2019-08-30 00:23:07 +02:00
|
|
|
COLORREF defaultBgColor) const noexcept;
|
2019-05-03 00:29:04 +02:00
|
|
|
COLORREF CalculateRgbBackground(std::basic_string_view<COLORREF> colorTable,
|
|
|
|
COLORREF defaultFgColor,
|
2019-08-30 00:23:07 +02:00
|
|
|
COLORREF defaultBgColor) const noexcept;
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
bool IsLeadingByte() const noexcept;
|
|
|
|
bool IsTrailingByte() const noexcept;
|
|
|
|
bool IsTopHorizontalDisplayed() const noexcept;
|
|
|
|
bool IsBottomHorizontalDisplayed() const noexcept;
|
|
|
|
bool IsLeftVerticalDisplayed() const noexcept;
|
|
|
|
bool IsRightVerticalDisplayed() const noexcept;
|
|
|
|
|
|
|
|
void SetLeftVerticalDisplayed(const bool isDisplayed) noexcept;
|
|
|
|
void SetRightVerticalDisplayed(const bool isDisplayed) noexcept;
|
|
|
|
|
|
|
|
void SetFromLegacy(const WORD wLegacy) noexcept;
|
|
|
|
|
|
|
|
void SetLegacyAttributes(const WORD attrs,
|
|
|
|
const bool setForeground,
|
|
|
|
const bool setBackground,
|
2019-08-30 00:23:07 +02:00
|
|
|
const bool setMeta) noexcept;
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
void SetIndexedAttributes(const std::optional<const BYTE> foreground,
|
|
|
|
const std::optional<const BYTE> background) noexcept;
|
|
|
|
|
|
|
|
void SetMetaAttributes(const WORD wMeta) noexcept;
|
|
|
|
WORD GetMetaAttributes() const noexcept;
|
|
|
|
|
|
|
|
void Embolden() noexcept;
|
|
|
|
void Debolden() noexcept;
|
|
|
|
|
|
|
|
void Invert() noexcept;
|
|
|
|
|
|
|
|
friend constexpr bool operator==(const TextAttribute& a, const TextAttribute& b) noexcept;
|
|
|
|
friend constexpr bool operator!=(const TextAttribute& a, const TextAttribute& b) noexcept;
|
|
|
|
friend constexpr bool operator==(const TextAttribute& attr, const WORD& legacyAttr) noexcept;
|
|
|
|
friend constexpr bool operator!=(const TextAttribute& attr, const WORD& legacyAttr) noexcept;
|
|
|
|
friend constexpr bool operator==(const WORD& legacyAttr, const TextAttribute& attr) noexcept;
|
|
|
|
friend constexpr bool operator!=(const WORD& legacyAttr, const TextAttribute& attr) noexcept;
|
|
|
|
|
|
|
|
bool IsLegacy() const noexcept;
|
Add support for passing through extended text attributes, like… (#2917)
## Summary of the Pull Request
Adds support for Italics, Blinking, Invisible, CrossedOut text, THROUGH CONPTY. This does **NOT** add support for those styles to conhost or the terminal.
We will store these "Extended Text Attributes" in a `TextAttribute`. When we go to render a line, we'll see if the state has changed from our previous state, and if so, we'll appropriately toggle that state with VT. Boldness has been moved from a `bool` to a single bit in these flags.
Technically, now that these are stored in the buffer, we only need to make changes to the renderers to be able to support them. That's not being done as a part of this PR however.
## References
See also #2915 and #2916, which are some follow-up tasks from this fix. I thought them too risky for 20H1.
## PR Checklist
* [x] Closes #2554
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated
<hr>
* store text with extended attributes too
* Plumb attributes through all the renderers
* parse extended attrs, though we're not renderering them right
* Render these states correctly
* Add a very extensive test
* Cleanup for PR
* a block of PR feedback
* add 512 test cases
* Fix the build
* Fix @carlos-zamora's suggestions
* @miniksa's PR feedback
2019-10-04 22:53:54 +02:00
|
|
|
|
|
|
|
constexpr bool IsBold() const noexcept
|
|
|
|
{
|
|
|
|
return WI_IsFlagSet(_extendedAttrs, ExtendedAttributes::Bold);
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr ExtendedAttributes GetExtendedAttributes() const noexcept
|
|
|
|
{
|
|
|
|
return _extendedAttrs;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetExtendedAttributes(const ExtendedAttributes attrs) noexcept;
|
2019-05-03 00:29:04 +02:00
|
|
|
|
2019-08-30 00:23:07 +02:00
|
|
|
void SetForeground(const COLORREF rgbForeground) noexcept;
|
|
|
|
void SetBackground(const COLORREF rgbBackground) noexcept;
|
|
|
|
void SetColor(const COLORREF rgbColor, const bool fIsForeground) noexcept;
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
void SetDefaultForeground() noexcept;
|
|
|
|
void SetDefaultBackground() noexcept;
|
|
|
|
|
|
|
|
bool ForegroundIsDefault() const noexcept;
|
|
|
|
bool BackgroundIsDefault() const noexcept;
|
|
|
|
|
|
|
|
constexpr bool IsRgb() const noexcept
|
|
|
|
{
|
|
|
|
return _foreground.IsRgb() || _background.IsRgb();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
COLORREF _GetRgbForeground(std::basic_string_view<COLORREF> colorTable,
|
2019-08-30 00:23:07 +02:00
|
|
|
COLORREF defaultColor) const noexcept;
|
2019-05-03 00:29:04 +02:00
|
|
|
COLORREF _GetRgbBackground(std::basic_string_view<COLORREF> colorTable,
|
2019-08-30 00:23:07 +02:00
|
|
|
COLORREF defaultColor) const noexcept;
|
2019-05-03 00:29:04 +02:00
|
|
|
bool _IsReverseVideo() const noexcept;
|
|
|
|
void _SetBoldness(const bool isBold) noexcept;
|
|
|
|
|
|
|
|
WORD _wAttrLegacy;
|
|
|
|
TextColor _foreground;
|
|
|
|
TextColor _background;
|
Add support for passing through extended text attributes, like… (#2917)
## Summary of the Pull Request
Adds support for Italics, Blinking, Invisible, CrossedOut text, THROUGH CONPTY. This does **NOT** add support for those styles to conhost or the terminal.
We will store these "Extended Text Attributes" in a `TextAttribute`. When we go to render a line, we'll see if the state has changed from our previous state, and if so, we'll appropriately toggle that state with VT. Boldness has been moved from a `bool` to a single bit in these flags.
Technically, now that these are stored in the buffer, we only need to make changes to the renderers to be able to support them. That's not being done as a part of this PR however.
## References
See also #2915 and #2916, which are some follow-up tasks from this fix. I thought them too risky for 20H1.
## PR Checklist
* [x] Closes #2554
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated
<hr>
* store text with extended attributes too
* Plumb attributes through all the renderers
* parse extended attrs, though we're not renderering them right
* Render these states correctly
* Add a very extensive test
* Cleanup for PR
* a block of PR feedback
* add 512 test cases
* Fix the build
* Fix @carlos-zamora's suggestions
* @miniksa's PR feedback
2019-10-04 22:53:54 +02:00
|
|
|
ExtendedAttributes _extendedAttrs;
|
2019-05-03 00:29:04 +02:00
|
|
|
|
|
|
|
#ifdef UNIT_TESTING
|
|
|
|
friend class TextBufferTests;
|
|
|
|
friend class TextAttributeTests;
|
2019-06-11 22:27:09 +02:00
|
|
|
template<typename TextAttribute>
|
|
|
|
friend class WEX::TestExecution::VerifyOutputTraits;
|
2019-05-03 00:29:04 +02:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
Add support for passing through extended text attributes, like… (#2917)
## Summary of the Pull Request
Adds support for Italics, Blinking, Invisible, CrossedOut text, THROUGH CONPTY. This does **NOT** add support for those styles to conhost or the terminal.
We will store these "Extended Text Attributes" in a `TextAttribute`. When we go to render a line, we'll see if the state has changed from our previous state, and if so, we'll appropriately toggle that state with VT. Boldness has been moved from a `bool` to a single bit in these flags.
Technically, now that these are stored in the buffer, we only need to make changes to the renderers to be able to support them. That's not being done as a part of this PR however.
## References
See also #2915 and #2916, which are some follow-up tasks from this fix. I thought them too risky for 20H1.
## PR Checklist
* [x] Closes #2554
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated
<hr>
* store text with extended attributes too
* Plumb attributes through all the renderers
* parse extended attrs, though we're not renderering them right
* Render these states correctly
* Add a very extensive test
* Cleanup for PR
* a block of PR feedback
* add 512 test cases
* Fix the build
* Fix @carlos-zamora's suggestions
* @miniksa's PR feedback
2019-10-04 22:53:54 +02:00
|
|
|
#pragma pack(pop)
|
|
|
|
// 2 for _wAttrLegacy
|
|
|
|
// 4 for _foreground
|
|
|
|
// 4 for _background
|
|
|
|
// 1 for _extendedAttrs
|
|
|
|
static_assert(sizeof(TextAttribute) <= 11 * sizeof(BYTE), "We should only need 11B for an entire TextColor. Any more than that is just waste");
|
|
|
|
|
2019-05-03 00:29:04 +02:00
|
|
|
enum class TextAttributeBehavior
|
|
|
|
{
|
|
|
|
Stored, // use contained text attribute
|
|
|
|
Current, // use text attribute of cell being written to
|
|
|
|
StoredOnly, // only use the contained text attribute and skip the insertion of anything else
|
|
|
|
};
|
|
|
|
|
|
|
|
constexpr bool operator==(const TextAttribute& a, const TextAttribute& b) noexcept
|
|
|
|
{
|
|
|
|
return a._wAttrLegacy == b._wAttrLegacy &&
|
|
|
|
a._foreground == b._foreground &&
|
|
|
|
a._background == b._background &&
|
Add support for passing through extended text attributes, like… (#2917)
## Summary of the Pull Request
Adds support for Italics, Blinking, Invisible, CrossedOut text, THROUGH CONPTY. This does **NOT** add support for those styles to conhost or the terminal.
We will store these "Extended Text Attributes" in a `TextAttribute`. When we go to render a line, we'll see if the state has changed from our previous state, and if so, we'll appropriately toggle that state with VT. Boldness has been moved from a `bool` to a single bit in these flags.
Technically, now that these are stored in the buffer, we only need to make changes to the renderers to be able to support them. That's not being done as a part of this PR however.
## References
See also #2915 and #2916, which are some follow-up tasks from this fix. I thought them too risky for 20H1.
## PR Checklist
* [x] Closes #2554
* [x] I work here
* [x] Tests added/passed
* [n/a] Requires documentation to be updated
<hr>
* store text with extended attributes too
* Plumb attributes through all the renderers
* parse extended attrs, though we're not renderering them right
* Render these states correctly
* Add a very extensive test
* Cleanup for PR
* a block of PR feedback
* add 512 test cases
* Fix the build
* Fix @carlos-zamora's suggestions
* @miniksa's PR feedback
2019-10-04 22:53:54 +02:00
|
|
|
a._extendedAttrs == b._extendedAttrs;
|
2019-05-03 00:29:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
constexpr bool operator!=(const TextAttribute& a, const TextAttribute& b) noexcept
|
|
|
|
{
|
|
|
|
return !(a == b);
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr bool operator==(const TextAttribute& attr, const WORD& legacyAttr) noexcept
|
|
|
|
{
|
|
|
|
return attr.GetLegacyAttributes() == legacyAttr;
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr bool operator!=(const TextAttribute& attr, const WORD& legacyAttr) noexcept
|
|
|
|
{
|
|
|
|
return !(attr == legacyAttr);
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr bool operator==(const WORD& legacyAttr, const TextAttribute& attr) noexcept
|
|
|
|
{
|
|
|
|
return attr == legacyAttr;
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr bool operator!=(const WORD& legacyAttr, const TextAttribute& attr) noexcept
|
|
|
|
{
|
|
|
|
return !(attr == legacyAttr);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef UNIT_TESTING
|
|
|
|
|
2019-06-11 22:27:09 +02:00
|
|
|
#define LOG_ATTR(attr) (Log::Comment(NoThrowString().Format( \
|
2019-05-03 00:29:04 +02:00
|
|
|
L#attr L"=%s", VerifyOutputTraits<TextAttribute>::ToString(attr).GetBuffer())))
|
|
|
|
|
2019-06-11 22:27:09 +02:00
|
|
|
namespace WEX
|
|
|
|
{
|
|
|
|
namespace TestExecution
|
|
|
|
{
|
2019-05-03 00:29:04 +02:00
|
|
|
template<>
|
2019-06-11 22:27:09 +02:00
|
|
|
class VerifyOutputTraits<TextAttribute>
|
2019-05-03 00:29:04 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static WEX::Common::NoThrowString ToString(const TextAttribute& attr)
|
|
|
|
{
|
|
|
|
return WEX::Common::NoThrowString().Format(
|
|
|
|
L"{FG:%s,BG:%s,bold:%d,wLegacy:(0x%04x)}",
|
|
|
|
VerifyOutputTraits<TextColor>::ToString(attr._foreground).GetBuffer(),
|
|
|
|
VerifyOutputTraits<TextColor>::ToString(attr._background).GetBuffer(),
|
|
|
|
attr.IsBold(),
|
2019-06-11 22:27:09 +02:00
|
|
|
attr._wAttrLegacy);
|
2019-05-03 00:29:04 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|