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

Support conceal ANSI escape on Windows #439

Closed
sindresorhus opened this issue Jul 13, 2015 · 5 comments
Closed

Support conceal ANSI escape on Windows #439

sindresorhus opened this issue Jul 13, 2015 · 5 comments

Comments

@sindresorhus
Copy link

The conceal ANSI escape is used to visually hide the output while it still being there.

This is important for consistency between Unix-based systems and Windows in CLI tools.

Info

https://en.wikipedia.org/wiki/ANSI_escape_code

Unfortunately, this one isn't supported by any Windows API afaik.

I was thinking that it might be possible to emulate it setting the text color to the default background color of the console.

Test case

node -e "console.log('\u001b[8municorn\u001b[28m');"

OS X

screen shot 2015-07-13 at 15 16 01

Node.js 0.12.5, OS X 10.10, Terminal.app

Windows

screen shot 2015-07-13 at 15 16 40

Node.js 0.12.5, Windows 8.1, cmd.exe

@saghul
Copy link
Member

saghul commented Jul 13, 2015

I was thinking that it might be possible to emulate it setting the text color to the default background color of the console.

Then selecting it with the mouse would reveal it, right?

@sindresorhus
Copy link
Author

Yes, but I don't think that matters. On OS X, you can select and copy to get the value anyways, or disable colors in a colorizer like chalk. So it's definitely not intended for sensitive stuff. I would use it to hide noisy info while still being there if you copy/redirect the output.

@saghul
Copy link
Member

saghul commented Jul 13, 2015

I see. Then adjusting the color to match the one in the background would indeed work.

@Qix-
Copy link
Contributor

Qix- commented Jul 13, 2015

Common misconception with conceal is that it has the effect that, say, typing a password into an SSH login prompt does. It doesn't. Terminals that emulate the conceal code this way are doing it incorrectly.

I'm speculating, but since the conceal escape seems to be historical, I would imagine copy/paste wasn't an issue on terminals that didn't have mice. The cursor position still advances, iirc. @sindresorhus is correct in suggesting to set it to [30m.

However, I'd go so far as to include [40m as well ([30;40m). [30m by itself would cause issues for those that have changed the color palette on CMD to something other than a black background, allowing the text to be visible. [30;40m would give it a 'redacted' appearance for those users - which is essentially the intention of the escape to begin with.

@stale
Copy link

stale bot commented Aug 10, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 10, 2019
@stale stale bot closed this as completed Aug 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants