ansi

package
v0.0.0-...-a0d5c4c Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Reset = csi + resetParam + sgrFinalByte
)

Control Sequence Introducer Parameters

Variables

This section is empty.

Functions

func SGRSequence

func SGRSequence(param ...Param) func(string) string

Types

type Param

type Param string

func ParamMust

func ParamMust(p Param, err error) Param

type ParamFunc

type ParamFunc func(int) Param

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer wraps an io.Writer and optionally handles: - converting '\n' → '\n\x1b[G' - raw mode enabling/restoring

func NewErrWriter

func NewErrWriter() (*Writer, error)

func NewOutWriter

func NewOutWriter() (*Writer, error)

func NewWriter

func NewWriter(w io.Writer) (*Writer, error)

NewWriter wraps the given io.Writer. It enables newline reset and raw mode if writing to a TTY. Returns a WriteCloser for deferred cleanup.

func (*Writer) ClearLine

func (w *Writer) ClearLine()

func (*Writer) ClearLineRight

func (w *Writer) ClearLineRight()

func (*Writer) ClearScreen

func (w *Writer) ClearScreen()

func (*Writer) ClearScreenBelow

func (w *Writer) ClearScreenBelow()

func (*Writer) Close

func (w *Writer) Close() error

Close restores the terminal if raw mode was enabled.

func (*Writer) CursorHome

func (w *Writer) CursorHome()

func (*Writer) CursorPos

func (w *Writer) CursorPos(row, col int)

func (*Writer) DisableBlinkingCursor

func (w *Writer) DisableBlinkingCursor()

func (*Writer) EnableBlinkingCursor

func (w *Writer) EnableBlinkingCursor()

Works reliably in xterm, iTerm2, and most Linux TTYs. Does not work in Windows Terminal or cmd.exe It’s safe to call even if unsupported; it’ll just be ignored.

func (*Writer) HideCursor

func (w *Writer) HideCursor()

func (*Writer) MoveDown

func (w *Writer) MoveDown()

func (*Writer) MoveDownRows

func (w *Writer) MoveDownRows(rows int)

func (*Writer) MoveLeft

func (w *Writer) MoveLeft()

func (*Writer) MoveLeftCols

func (w *Writer) MoveLeftCols(cols int)

func (*Writer) MoveRight

func (w *Writer) MoveRight()

func (*Writer) MoveRightCols

func (w *Writer) MoveRightCols(cols int)

func (*Writer) MoveUp

func (w *Writer) MoveUp()

func (*Writer) MoveUpRows

func (w *Writer) MoveUpRows(rows int)

func (*Writer) Newline

func (w *Writer) Newline()

Newline prints a newline and moves the cursor to column 0.

func (*Writer) ResetLine

func (w *Writer) ResetLine()

func (*Writer) RestoreCursor

func (w *Writer) RestoreCursor()

func (*Writer) SaveCursor

func (w *Writer) SaveCursor()

func (*Writer) ShowCursor

func (w *Writer) ShowCursor()

func (*Writer) Write

func (w *Writer) Write(p []byte) (int, error)

Write implements io.Writer, replacing '\n' with '\n\x1b[G' in TTY mode.

Jump to

Keyboard shortcuts

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