cwriter

package
v8.8.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2024 License: Unlicense Imports: 6 Imported by: 0

Documentation

Overview

Package cwriter is a console writer abstraction for the underlying OS.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotTTY = errors.New("not a terminal")

ErrNotTTY not a TeleTYpewriter error.

Functions

func GetSize

func GetSize(fd int) (width, height int, err error)

GetSize returns the dimensions of the given terminal.

func IsTerminal

func IsTerminal(fd int) bool

IsTerminal returns whether the given file descriptor is a terminal.

Types

type Writer

type Writer struct {
	*bytes.Buffer
	// contains filtered or unexported fields
}

Writer is a buffered terminal writer, which moves cursor N lines up on each flush except the first one, where N is a number of lines of a previous flush.

func New

func New(out io.Writer) *Writer

New returns a new Writer with defaults.

func (*Writer) Flush

func (w *Writer) Flush(lines int) error

Flush flushes the underlying buffer. It's caller's responsibility to pass correct number of lines.

func (*Writer) GetTermSize

func (w *Writer) GetTermSize() (width, height int, err error)

GetTermSize returns WxH of underlying terminal.

func (*Writer) IsTerminal added in v8.2.0

func (w *Writer) IsTerminal() bool

IsTerminal tells whether underlying io.Writer is terminal.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL