mirror of
https://github.com/restic/restic.git
synced 2025-12-11 18:47:50 +00:00
termstatus: centralize OutputIsTerminal checks
This commit is contained in:
@@ -10,18 +10,11 @@ func StdinIsTerminal() bool {
|
||||
return term.IsTerminal(int(os.Stdin.Fd()))
|
||||
}
|
||||
|
||||
func StdoutIsTerminal() bool {
|
||||
func OutputIsTerminal(fd uintptr) bool {
|
||||
// mintty on windows can use pipes which behave like a posix terminal,
|
||||
// but which are not a terminal handle
|
||||
return term.IsTerminal(int(os.Stdout.Fd())) || StdoutCanUpdateStatus()
|
||||
}
|
||||
|
||||
func StdoutCanUpdateStatus() bool {
|
||||
return CanUpdateStatus(os.Stdout.Fd())
|
||||
}
|
||||
|
||||
func StdoutWidth() int {
|
||||
return Width(os.Stdout.Fd())
|
||||
// but which are not a terminal handle. Thus also check `CanUpdateStatus`,
|
||||
// which is able to detect such pipes.
|
||||
return term.IsTerminal(int(fd)) || CanUpdateStatus(fd)
|
||||
}
|
||||
|
||||
func Width(fd uintptr) int {
|
||||
|
||||
Reference in New Issue
Block a user