Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion query.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,16 @@ func BackgroundColor(in term.File, out term.File) (bg color.Color, err error) {
}

// NOTE: On Unix, one of the given files must be a tty.
if !term.IsTerminal(in.Fd()) || !term.IsTerminal(out.Fd()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would skip querying when input OR output is not a terminal, in other words, when the program expects data from input as a file or stream or the output is redirected to a file or pipe.

return nil, fmt.Errorf("input/output is not a terminal")
}
for _, f := range []term.File{in, out} {
if bg, err = backgroundColor(f, f); err == nil {
return bg, nil
}
}

return
return bg, err
}

// HasDarkBackground detects whether the terminal has a light or dark
Expand Down