2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-30 08:44:02 +00:00
restic/internal/ui/termstatus/terminal_unix.go

36 lines
893 B
Go
Raw Normal View History

2018-04-22 09:57:11 +00:00
// +build !windows
package termstatus
import (
"io"
"os"
"golang.org/x/crypto/ssh/terminal"
2018-04-22 09:57:11 +00:00
)
// clearCurrentLine removes all characters from the current line and resets the
// cursor position to the first column.
func clearCurrentLine(wr io.Writer, fd uintptr) func(io.Writer, uintptr) {
return posixClearCurrentLine
}
// moveCursorUp moves the cursor to the line n lines above the current one.
func moveCursorUp(wr io.Writer, fd uintptr) func(io.Writer, uintptr, int) {
return posixMoveCursorUp
2018-04-22 09:57:11 +00:00
}
// canUpdateStatus returns true if status lines can be printed, the process
// output is not redirected to a file or pipe.
func canUpdateStatus(fd uintptr) bool {
if !terminal.IsTerminal(int(fd)) {
return false
}
term := os.Getenv("TERM")
if term == "" {
return false
}
// TODO actually read termcap db and detect if terminal supports what we need
return term != "dumb"
2018-04-22 09:57:11 +00:00
}