DetectTerminalTheme is a utility to call before starting the output pager so that the terminal background can be reliably detected.
()
| 125 | // DetectTerminalTheme is a utility to call before starting the output pager so that the terminal background |
| 126 | // can be reliably detected. |
| 127 | func (s *IOStreams) DetectTerminalTheme() { |
| 128 | if !s.ColorEnabled() || s.pagerProcess != nil { |
| 129 | s.terminalTheme = "none" |
| 130 | return |
| 131 | } |
| 132 | |
| 133 | style := os.Getenv("GLAMOUR_STYLE") |
| 134 | if style != "" && style != "auto" { |
| 135 | // ensure GLAMOUR_STYLE takes precedence over "light" and "dark" themes |
| 136 | s.terminalTheme = "none" |
| 137 | return |
| 138 | } |
| 139 | |
| 140 | s.terminalTheme = s.term.Theme() |
| 141 | } |
| 142 | |
| 143 | // TerminalTheme returns "light", "dark", or "none" depending on the background color of the terminal. |
| 144 | func (s *IOStreams) TerminalTheme() string { |
no test coverage detected