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