-
Couldn't load subscription status.
- Fork 7.3k
Check for terminal background color before starting pager #1917
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
Conversation
1db9152 to
383a903
Compare
383a903 to
ed40755
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! I only have style suggestions
pkg/iostreams/iostreams.go
Outdated
| func (s *IOStreams) ResolveBgColor() string { | ||
| style := os.Getenv("GLAMOUR_STYLE") | ||
| if (!s.ColorEnabled()) || | ||
| (style != "" && style != "auto") || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looks like there are now two separate packages that independently look up GLAMOUR_STYLE and compare it to "auto". Could this be consolidated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I agree. This was my biggest issue with this approach. If GLAMOUR_STYLE is set we don't want to actually detect the terminal background color because we are not going to use those results, but right now we are throwing away what the GLAMOUR_STYLE is set to. I thought about setting BgColor to be GLAMOUR_STYLE which would save use from having to do it in the markdown package but then the naming felt wrong since it is not actually the BgColor. Which is how I ended up doing the check twice. I am happy to move in the direction I outlined above, or if there are better ideas I am open to hearing them.
11ef875 to
f0d4fbf
Compare
4e06ede to
8f27cb3
Compare
This PR fixes the bug where determining the terminal background color for markdown rendering was causing a weird interaction with
PAGER. Now we will resolve the terminal background color before startingPAGER. Resolving the terminal background is a no-op if we are not outputting to TTY, the pager has already be started, or theGLAMOUR_STYLEenvironment variable is set to something other thanauto.closes #1822
cc #1930