2021-10-02 20:44:06 +08:00
|
|
|
// Package sys provide system utilities with the same API across OSes.
|
2021-10-02 20:14:00 +08:00
|
|
|
//
|
2021-10-02 20:44:06 +08:00
|
|
|
// The subpackages eunix and ewindows provide OS-specific utilities.
|
2014-03-09 15:16:56 +08:00
|
|
|
package sys
|
2020-04-26 11:26:22 +08:00
|
|
|
|
2021-10-02 20:14:00 +08:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/mattn/go-isatty"
|
|
|
|
)
|
|
|
|
|
2020-04-26 11:26:22 +08:00
|
|
|
const sigsChanBufferSize = 256
|
2021-10-02 20:14:00 +08:00
|
|
|
|
|
|
|
// NotifySignals returns a channel on which all signals gets delivered.
|
|
|
|
func NotifySignals() chan os.Signal { return notifySignals() }
|
|
|
|
|
|
|
|
// SIGWINCH is the window size change signal.
|
|
|
|
const SIGWINCH = sigWINCH
|
|
|
|
|
|
|
|
// Winsize queries the size of the terminal referenced by the given file.
|
|
|
|
func WinSize(file *os.File) (row, col int) { return winSize(file) }
|
|
|
|
|
|
|
|
// IsATTY determines whether the given file is a terminal.
|
2022-11-21 00:16:22 +08:00
|
|
|
func IsATTY(fd uintptr) bool {
|
|
|
|
return isatty.IsTerminal(fd) || isatty.IsCygwinTerminal(fd)
|
2021-10-02 20:14:00 +08:00
|
|
|
}
|