Add support for the "concealed" graphic rendition attribute #9567

Closed
opened 2026-01-31 01:57:59 +00:00 by claunia · 6 comments
Owner

Originally created by @j4james on GitHub (Jul 11, 2020).

Description of the new feature/enhancement

The ANSI SGR 8 rendition attribute is used to indicate that text to which it's applied should be rendered invisible. I'm not sure how widely it's used, but it is supported by most terminal emulators, so I think it's probably worth doing. And most of the framework is already in place, so it's an easy addition for us.

Proposed technical implementation details (optional)

I think all that's required is an update to the TextAttribute::CalculateRgbColors method, adjusting the colors to make the foreground and background the same when the attribute is set. Something like:

if (IsInvisible())
{
    fg = bg;
}

In testing this on other terminals, I found that XTerm also prevented the invisible content being copied to the clipboard. However, pretty much everyone else allowed it to be copied, so I'm more inclined to follow the majority behaviour.

I have a PR ready to submit for this if you're happy with the idea and the proposed approach, but it'd be best if #6873 is merged first, otherwise there'll probably be conflicts in the unit tests.

Originally created by @j4james on GitHub (Jul 11, 2020). # Description of the new feature/enhancement The ANSI `SGR 8` rendition attribute is used to indicate that text to which it's applied should be rendered invisible. I'm not sure how widely it's used, but it is supported by most terminal emulators, so I think it's probably worth doing. And most of the framework is already in place, so it's an easy addition for us. # Proposed technical implementation details (optional) I think all that's required is an update to the `TextAttribute::CalculateRgbColors` method, adjusting the colors to make the foreground and background the same when the attribute is set. Something like: if (IsInvisible()) { fg = bg; } In testing this on other terminals, I found that XTerm also prevented the invisible content being copied to the clipboard. However, pretty much everyone else allowed it to be copied, so I'm more inclined to follow the majority behaviour. I have a PR ready to submit for this if you're happy with the idea and the proposed approach, but it'd be best if #6873 is merged first, otherwise there'll probably be conflicts in the unit tests.
Author
Owner

@DHowett commented on GitHub (Jul 11, 2020):

Philosophically, if it's not copyable and not rendered in xterm, is there any meaningful difference between it being concealed and it simply not existing?

For us, matching the colors and leaving it copyable sounds great. I'm r+ on this proposal!

@DHowett commented on GitHub (Jul 11, 2020): Philosophically, if it's not copyable and not rendered in xterm, is there any meaningful difference between it being concealed and it simply not existing? For us, matching the colors and leaving it copyable sounds great. I'm r+ on this proposal!
Author
Owner

@j4james commented on GitHub (Jul 11, 2020):

Philosophically, if it's not copyable and not rendered in xterm, is there any meaningful difference between it being concealed and it simply not existing?

That depends on the implementation. If they're still writing the text to the buffer, then it could potentially be revealed through other means, e.g. by changing the attributes with DECARA, or reading the content back via DECRQCRA. I couldn't get DECARA to work, but I'm not sure if that's just a bug. And I didn't try DECRQCRA, but I suspect it wouldn't work either - my guess is they're not actually storing anything.

Anyway I don't think it matters much. This is one of those things that doesn't have a clear right answer, because the ANSI/ECMA specs don't go into any detail, and the DEC terminals never had this functionality. I figure as long as we're doing what most others are doing then we're probably OK.

@j4james commented on GitHub (Jul 11, 2020): > Philosophically, if it's not copyable and not rendered in xterm, is there any meaningful difference between it being concealed and it simply not existing? That depends on the implementation. If they're still writing the text to the buffer, then it could potentially be revealed through other means, e.g. by changing the attributes with `DECARA`, or reading the content back via `DECRQCRA`. I couldn't get `DECARA` to work, but I'm not sure if that's just a bug. And I didn't try `DECRQCRA`, but I suspect it wouldn't work either - my guess is they're not actually storing anything. Anyway I don't think it matters much. This is one of those things that doesn't have a clear right answer, because the ANSI/ECMA specs don't go into any detail, and the DEC terminals never had this functionality. I figure as long as we're doing what most others are doing then we're probably OK.
Author
Owner

@jdebp commented on GitHub (Jul 13, 2020):

DECCARA is documented as only affecting specific attributes, of which this is not one. But the DEC doco does state that invisibility is rendered by making the foreground colour the same as the background colour.

Observe, furthermore, that kitty extends DECCARA to cover this attribute.

@jdebp commented on GitHub (Jul 13, 2020): `DECCARA` is documented as only affecting specific attributes, of which this is not one. But the DEC doco does state that invisibility is rendered by making the foreground colour the same as the background colour. Observe, furthermore, that kitty extends `DECCARA` to cover this attribute.
Author
Owner

@j4james commented on GitHub (Jul 13, 2020):

But the DEC doco does state that invisibility is rendered by making the foreground colour the same as the background colour.

That's good to know - thanks for pointing that out. I was under the impression that none of the DEC terminals supported the concealed/invisible attribute, possibly because it's not listed in the functions summary table of the VT520 Programmer Reference. But I see now that even the VT420 supported it.

DECCARA is documented as only affecting specific attributes, of which this is not one.

Yeah I saw that, but I thought (incorrectly) that that was just because they didn't support the concealed attribute in general. I suppose it's still possible that was an oversight in the docs.

Observe, furthermore, that kitty extends DECCARA to cover this attribute.

I thought XTerm did that too (see here), but as I mentioned above I couldn't get it to work. I don't think I tested DECCARA on kitty. Not that it matters much at the moment. We can figure out those details when we actually implement those ops.

@j4james commented on GitHub (Jul 13, 2020): > But the DEC doco does state that invisibility is rendered by making the foreground colour the same as the background colour. That's good to know - thanks for pointing that out. I was under the impression that none of the DEC terminals supported the concealed/invisible attribute, possibly because it's not listed in the functions summary table of the VT520 Programmer Reference. But I see now that even the VT420 supported it. > `DECCARA` is documented as only affecting specific attributes, of which this is not one. Yeah I saw that, but I thought (incorrectly) that that was just because they didn't support the concealed attribute in general. I suppose it's still possible that was an oversight in the docs. > Observe, furthermore, that kitty extends `DECCARA` to cover this attribute. I thought XTerm did that too (see [here](https://github.com/ThomasDickey/xterm-snapshots/blob/153d0ccc03242cd2844255a7e03e8683a17132f3/screen.c#L2722-L2724)), but as I mentioned above I couldn't get it to work. I don't think I tested `DECCARA` on kitty. Not that it matters much at the moment. We can figure out those details when we actually implement those ops.
Author
Owner

@ghost commented on GitHub (Jul 22, 2020):

:tada:This issue was addressed in #6907, which has now been successfully released as Windows Terminal Preview v1.2.2022.0.🎉

Handy links:

@ghost commented on GitHub (Jul 22, 2020): :tada:This issue was addressed in #6907, which has now been successfully released as `Windows Terminal Preview v1.2.2022.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.2.2022.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Author
Owner

@DHowett commented on GitHub (Aug 21, 2020):

🎉 As of Windows Insider build 20197, this is also supported in the traditional console.

@DHowett commented on GitHub (Aug 21, 2020): 🎉 As of Windows Insider build 20197, this is also supported in the traditional console.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#9567