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

Render using default foreground and background colors #22

Open
fedarovich opened this issue Apr 4, 2018 · 6 comments
Open

Render using default foreground and background colors #22

fedarovich opened this issue Apr 4, 2018 · 6 comments
Assignees
Labels
Milestone

Comments

@fedarovich
Copy link

In the version 1.0 if foreground or background colors are not specified, the white and black colors are used for them. It looks unnatural if other colors are used in the terminal by default, like in Mas OS X Terminal.

It would be nice if it is possible to render the user interface using default colors.

As a workaround, it is possible to set Color to Console.ForegroundColor and Background to Console.BackgroundColor but it works only on Windows. On Linux and Mas OS these properties return (ConsoleColor)(-1) and it looks like there is no easy and universal way to determine the actual colors.

@fedarovich fedarovich changed the title Render using default foreground and background Render using default foreground and background colors Apr 4, 2018
@Athari Athari self-assigned this Apr 5, 2018
@Athari Athari added the type:feature Feature label Apr 5, 2018
@Athari
Copy link
Owner

Athari commented Apr 5, 2018

@fedarovich
You can find another workaround which works on any platform in the discussion of the issue RenderDocumentToText adds an extra newline. According to the bug reporter, it even works faster.

But yes, it's something I need to do and looks like I can't delay it until implementing the whole set of OS-specific features planned for 2.0. 😆 I'd certainly prefer being able to "inherit" default/current console colors, but with formatting in *nix being built around ANSI codes, there's no way to get them.

I guess the only option I have is adding render preferences for things like colors. Line formatter should probably go there too.

Hmm, when "reset" ANSI code ([0m) is used, to which colors does it reset on macOS? Does Console.ResetColor() emit that on *nix? I think it resets to user-provided colors from app's settings on Windows, but I need to test it. If .NET Core went with that (ConsoleColor)(-1) value, maybe I can treat it specifically as a reset...

@fedarovich
Copy link
Author

fedarovich commented Apr 5, 2018

On Mac OS (and I guess on other *nix) Console.ResetColor() resets the colors to their default values (set in Terminal options). So I suppose using ResetColor() is the right way to go.

One more interesting thing I've discovered is that the default colors are not among the 16 ANSI colors in Mac OS Terminal. The default BG and FG colors and white and black correspondingly (in the default theme) but if you try to use ConsoleColor.White, it is rendered like light gray, not white. The actual settings of default BG and FG colors and ANSI colors mapping are done in the Terminal settings. I guess it may work the same way in some Linux terminals too. So it looks like ResetColor() is the only way to support default BG and FG on *nix.

@Athari Athari added this to the 1.1 milestone Apr 5, 2018
@Athari
Copy link
Owner

Athari commented Apr 5, 2018

@fedarovich

One more interesting thing I've discovered is that the default colors are not among the 16 ANSI colors in Mac OS Terminal.

I guess 16 "standard" colors can be mapped to any colors. It works even on Windows, where 16 colors can be set for system and per application. RGB values vary a lot between systems and terminals even wihout any customization.

Or do you mean you've actually tested all 16 colors and colors which are produced after a reset are not among them?

@fedarovich
Copy link
Author

Yes, I mean exactly that. I've tested all 16 colors and the color after reset (or before any changes to back/fore ground) are not among them.
screen shot 2018-04-06 at 12 19 31 am
But it's even more interesting. You can set background image for the terminal in Mac OS (and I guess in some Linux terminals too).
screen shot 2018-04-06 at 12 21 53 am
As you can see on the screenshot above, in this case text background after reset is actually transparent.

@Athari
Copy link
Owner

Athari commented Apr 6, 2018

@fedarovich
Well, that's new. Haven't considered that. Thanks for the info.

@fedarovich
Copy link
Author

Yes, that was a surprise for me too.
Meanwhile, I've checked Ubuntu terminal. It also has the similar features. It's even possible to make semitransparent background:
screenshot from 2018-04-06 10-34-09

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants