Documentation ¶
Overview ¶
Package term provides support functions for dealing with terminals, as commonly found on UNIX systems.
Putting a terminal into raw mode is the most common requirement:
oldState, err := term.MakeRaw(int(os.Stdin.Fd())) if err != nil { panic(err) } defer term.Restore(int(os.Stdin.Fd()), oldState)
Note that on non-Unix systems os.Stdin.Fd() may not be 0
Index ¶
- Constants
- Variables
- func Debug(v ...any) (int, error)
- func Debugf(format string, v ...any) (int, error)
- func DoColor(o *termenv.Output) bool
- func EnableANSI() func()
- func Error(v ...any) (int, error)
- func Errorf(format string, v ...any) (int, error)
- func Fatal(msg any)
- func Fatalf(format string, v ...any)
- func ForceColor(color bool)
- func Fprint(w *termenv.Output, c Color, v ...any) (int, error)
- func Fprintf(w *termenv.Output, c Color, format string, v ...any) (int, error)
- func Fprintln(w *termenv.Output, c Color, v ...any) (int, error)
- func Info(v ...any) (int, error)
- func Infof(format string, v ...any) (int, error)
- func NewNonBlockingStdin() io.ReadCloser
- func Print(c Color, v ...any) (int, error)
- func Printf(c Color, format string, v ...any) (int, error)
- func Println(c Color, v ...any) (int, error)
- func Restore(fd int, oldState *State) error
- func Warn(v ...any) (int, error)
- func Warnf(format string, v ...any) (int, error)
- type Color
- type State
Constants ¶
View Source
const ( BrightCyan = termenv.ANSIBrightCyan InfoColor = termenv.ANSIBrightMagenta ErrorColor = termenv.ANSIBrightRed WarnColor = termenv.ANSIBrightYellow DebugColor = termenv.ANSIBrightBlack // Gray )
Variables ¶
View Source
var ( IsTerminal = term.IsTerminal(int(os.Stdout.Fd())) && term.IsTerminal(int(os.Stdin.Fd())) && isTerminal() Stdout = termenv.NewOutput(os.Stdout) Stderr = termenv.NewOutput(os.Stderr) CanColor = DoColor(Stdout) CanColorErr = DoColor(Stderr) DoDebug bool HadWarnings bool )
View Source
var ErrClosed = errors.New("closed")
Functions ¶
func EnableANSI ¶
func EnableANSI() func()
func ForceColor ¶
func ForceColor(color bool)
func NewNonBlockingStdin ¶
func NewNonBlockingStdin() io.ReadCloser
Types ¶
Click to show internal directories.
Click to hide internal directories.