...

Package termenv

import "github.com/muesli/termenv"
Overview
Index
Subdirectories

Overview ▾

Index ▾

Constants
Variables
func AltScreen()
func ChangeScrollingRegion(top, bottom int)
func ClearLine()
func ClearLineLeft()
func ClearLineRight()
func ClearLines(n int)
func ClearScreen()
func ConvertToRGB(c Color) colorful.Color
func Copy(str string)
func CopyPrimary(str string)
func CursorBack(n int)
func CursorDown(n int)
func CursorForward(n int)
func CursorNextLine(n int)
func CursorPrevLine(n int)
func CursorUp(n int)
func DeleteLines(n int)
func DisableBracketedPaste()
func DisableMouse()
func DisableMouseAllMotion()
func DisableMouseCellMotion()
func DisableMouseHilite()
func DisableMousePress()
func EnableBracketedPaste()
func EnableMouse()
func EnableMouseAllMotion()
func EnableMouseCellMotion()
func EnableMouseHilite()
func EnableMousePress()
func EnableVirtualTerminalProcessing(_ io.Writer) (func() error, error)
func EnvNoColor() bool
func ExitAltScreen()
func HasDarkBackground() bool
func HideCursor()
func Hyperlink(link, name string) string
func InsertLines(n int)
func MoveCursor(row int, column int)
func Notify(title, body string)
func Reset()
func RestoreCursorPosition()
func RestoreScreen()
func SaveCursorPosition()
func SaveScreen()
func SetBackgroundColor(color Color)
func SetCursorColor(color Color)
func SetDefaultOutput(o *Output)
func SetForegroundColor(color Color)
func SetWindowTitle(title string)
func ShowCursor()
func TemplateFuncs(p Profile) template.FuncMap
type ANSI256Color
    func (c ANSI256Color) Sequence(bg bool) string
    func (c ANSI256Color) String() string
type ANSIColor
    func (c ANSIColor) Sequence(bg bool) string
    func (c ANSIColor) String() string
type Color
    func BackgroundColor() Color
    func ForegroundColor() Color
type Environ
type File
type NoColor
    func (c NoColor) Sequence(_ bool) string
    func (c NoColor) String() string
type Output
    func DefaultOutput() *Output
    func NewOutput(tty io.Writer, opts ...OutputOption) *Output
    func (o Output) AltScreen()
    func (o *Output) BackgroundColor() Color
    func (o Output) ChangeScrollingRegion(top, bottom int)
    func (o Output) ClearLine()
    func (o Output) ClearLineLeft()
    func (o Output) ClearLineRight()
    func (o Output) ClearLines(n int)
    func (o Output) ClearScreen()
    func (o *Output) ColorProfile() Profile
    func (o Output) Copy(str string)
    func (o Output) CopyPrimary(str string)
    func (o Output) CursorBack(n int)
    func (o Output) CursorDown(n int)
    func (o Output) CursorForward(n int)
    func (o Output) CursorNextLine(n int)
    func (o Output) CursorPrevLine(n int)
    func (o Output) CursorUp(n int)
    func (o Output) DeleteLines(n int)
    func (o Output) DisableBracketedPaste()
    func (o Output) DisableMouse()
    func (o Output) DisableMouseAllMotion()
    func (o Output) DisableMouseCellMotion()
    func (o Output) DisableMouseExtendedMode()
    func (o Output) DisableMouseHilite()
    func (o Output) DisableMousePixelsMode()
    func (o Output) DisableMousePress()
    func (o Output) EnableBracketedPaste()
    func (o Output) EnableMouse()
    func (o Output) EnableMouseAllMotion()
    func (o Output) EnableMouseCellMotion()
    func (o Output) EnableMouseExtendedMode()
    func (o Output) EnableMouseHilite()
    func (o Output) EnableMousePixelsMode()
    func (o Output) EnableMousePress()
    func (o *Output) EnvColorProfile() Profile
    func (o *Output) EnvNoColor() bool
    func (o Output) ExitAltScreen()
    func (o *Output) ForegroundColor() Color
    func (o *Output) HasDarkBackground() bool
    func (o Output) HideCursor()
    func (o *Output) Hyperlink(link, name string) string
    func (o Output) InsertLines(n int)
    func (o Output) MoveCursor(row int, column int)
    func (o *Output) Notify(title, body string)
    func (o Output) Reset()
    func (o Output) RestoreCursorPosition()
    func (o Output) RestoreScreen()
    func (o Output) SaveCursorPosition()
    func (o Output) SaveScreen()
    func (o Output) SetBackgroundColor(color Color)
    func (o Output) SetCursorColor(color Color)
    func (o Output) SetForegroundColor(color Color)
    func (o Output) SetWindowTitle(title string)
    func (o Output) ShowCursor()
    func (o Output) TTY() File
    func (o Output) TemplateFuncs() template.FuncMap
    func (o Output) Write(p []byte) (int, error)
    func (o Output) WriteString(s string) (int, error)
type OutputOption
    func WithColorCache(v bool) OutputOption
    func WithEnvironment(environ Environ) OutputOption
    func WithProfile(profile Profile) OutputOption
    func WithTTY(v bool) OutputOption
    func WithUnsafe() OutputOption
type Profile
    func ColorProfile() Profile
    func EnvColorProfile() Profile
    func (p Profile) Color(s string) Color
    func (p Profile) Convert(c Color) Color
    func (p Profile) FromColor(c color.Color) Color
    func (p Profile) String(s ...string) Style
type RGBColor
    func (c RGBColor) Sequence(bg bool) string
type Style
    func String(s ...string) Style
    func (t Style) Background(c Color) Style
    func (t Style) Blink() Style
    func (t Style) Bold() Style
    func (t Style) CrossOut() Style
    func (t Style) Faint() Style
    func (t Style) Foreground(c Color) Style
    func (t Style) Italic() Style
    func (t Style) Overline() Style
    func (t Style) Reverse() Style
    func (t Style) String() string
    func (t Style) Styled(s string) string
    func (t Style) Underline() Style
    func (t Style) Width() int

Package files

ansicolors.go color.go constants_linux.go copy.go hyperlink.go notification.go output.go profile.go screen.go style.go templatehelper.go termenv.go termenv_posix.go termenv_unix.go

Constants

Foreground and Background sequence codes

const (
    Foreground = "38"
    Background = "48"
)
const (
    // TrueColor, 24-bit color profile
    TrueColor = Profile(iota)
    // ANSI256, 8-bit color profile
    ANSI256
    // ANSI, 4-bit color profile
    ANSI
    // Ascii, uncolored profile
    Ascii //nolint:revive
)

Sequence definitions.

const (
    // Cursor positioning.
    CursorUpSeq              = "%dA"
    CursorDownSeq            = "%dB"
    CursorForwardSeq         = "%dC"
    CursorBackSeq            = "%dD"
    CursorNextLineSeq        = "%dE"
    CursorPreviousLineSeq    = "%dF"
    CursorHorizontalSeq      = "%dG"
    CursorPositionSeq        = "%d;%dH"
    EraseDisplaySeq          = "%dJ"
    EraseLineSeq             = "%dK"
    ScrollUpSeq              = "%dS"
    ScrollDownSeq            = "%dT"
    SaveCursorPositionSeq    = "s"
    RestoreCursorPositionSeq = "u"
    ChangeScrollingRegionSeq = "%d;%dr"
    InsertLineSeq            = "%dL"
    DeleteLineSeq            = "%dM"

    // Explicit values for EraseLineSeq.
    EraseLineRightSeq  = "0K"
    EraseLineLeftSeq   = "1K"
    EraseEntireLineSeq = "2K"

    // Mouse.
    EnableMousePressSeq         = "?9h" // press only (X10)
    DisableMousePressSeq        = "?9l"
    EnableMouseSeq              = "?1000h" // press, release, wheel
    DisableMouseSeq             = "?1000l"
    EnableMouseHiliteSeq        = "?1001h" // highlight
    DisableMouseHiliteSeq       = "?1001l"
    EnableMouseCellMotionSeq    = "?1002h" // press, release, move on pressed, wheel
    DisableMouseCellMotionSeq   = "?1002l"
    EnableMouseAllMotionSeq     = "?1003h" // press, release, move, wheel
    DisableMouseAllMotionSeq    = "?1003l"
    EnableMouseExtendedModeSeq  = "?1006h" // press, release, move, wheel, extended coordinates
    DisableMouseExtendedModeSeq = "?1006l"
    EnableMousePixelsModeSeq    = "?1016h" // press, release, move, wheel, extended pixel coordinates
    DisableMousePixelsModeSeq   = "?1016l"

    // Screen.
    RestoreScreenSeq = "?47l"
    SaveScreenSeq    = "?47h"
    AltScreenSeq     = "?1049h"
    ExitAltScreenSeq = "?1049l"

    // Bracketed paste.
    // https://en.wikipedia.org/wiki/Bracketed-paste
    EnableBracketedPasteSeq  = "?2004h"
    DisableBracketedPasteSeq = "?2004l"
    StartBracketedPasteSeq   = "200~"
    EndBracketedPasteSeq     = "201~"

    // Session.
    SetWindowTitleSeq     = "2;%s" + string(BEL)
    SetForegroundColorSeq = "10;%s" + string(BEL)
    SetBackgroundColorSeq = "11;%s" + string(BEL)
    SetCursorColorSeq     = "12;%s" + string(BEL)
    ShowCursorSeq         = "?25h"
    HideCursorSeq         = "?25l"
)

Sequence definitions.

const (
    ResetSeq     = "0"
    BoldSeq      = "1"
    FaintSeq     = "2"
    ItalicSeq    = "3"
    UnderlineSeq = "4"
    BlinkSeq     = "5"
    ReverseSeq   = "7"
    CrossOutSeq  = "9"
    OverlineSeq  = "53"
)
const (
    // Escape character
    ESC = '\x1b'
    // Bell
    BEL = '\a'
    // Control Sequence Introducer
    CSI = string(ESC) + "["
    // Operating System Command
    OSC = string(ESC) + "]"
    // String Terminator
    ST = string(ESC) + `\`
)
const (
    // timeout for OSC queries
    OSCTimeout = 5 * time.Second
)

Variables

var (
    // ErrInvalidColor gets returned when a color is invalid.
    ErrInvalidColor = errors.New("invalid color")
)
var (
    // ErrStatusReport gets returned when the terminal can't be queried.
    ErrStatusReport = errors.New("unable to retrieve status report")
)

func AltScreen

func AltScreen()

AltScreen switches to the alternate screen buffer. The former view can be restored with ExitAltScreen().

Deprecated: please use termenv.Output instead.

func ChangeScrollingRegion

func ChangeScrollingRegion(top, bottom int)

ChangeScrollingRegion sets the scrolling region of the terminal.

Deprecated: please use termenv.Output instead.

func ClearLine

func ClearLine()

ClearLine clears the current line.

Deprecated: please use termenv.Output instead.

func ClearLineLeft

func ClearLineLeft()

ClearLineLeft clears the line to the left of the cursor.

Deprecated: please use termenv.Output instead.

func ClearLineRight

func ClearLineRight()

ClearLineRight clears the line to the right of the cursor.

Deprecated: please use termenv.Output instead.

func ClearLines

func ClearLines(n int)

ClearLines clears a given number of lines.

Deprecated: please use termenv.Output instead.

func ClearScreen

func ClearScreen()

ClearScreen clears the visible portion of the terminal.

Deprecated: please use termenv.Output instead.

func ConvertToRGB

func ConvertToRGB(c Color) colorful.Color

ConvertToRGB converts a Color to a colorful.Color.

func Copy

func Copy(str string)

Copy copies text to clipboard using OSC 52 escape sequence.

func CopyPrimary

func CopyPrimary(str string)

CopyPrimary copies text to primary clipboard (X11) using OSC 52 escape sequence.

func CursorBack

func CursorBack(n int)

CursorBack moves the cursor backwards a given number of cells.

Deprecated: please use termenv.Output instead.

func CursorDown

func CursorDown(n int)

CursorDown moves the cursor down a given number of lines.

Deprecated: please use termenv.Output instead.

func CursorForward

func CursorForward(n int)

CursorForward moves the cursor up a given number of lines.

Deprecated: please use termenv.Output instead.

func CursorNextLine

func CursorNextLine(n int)

CursorNextLine moves the cursor down a given number of lines and places it at the beginning of the line.

Deprecated: please use termenv.Output instead.

func CursorPrevLine

func CursorPrevLine(n int)

CursorPrevLine moves the cursor up a given number of lines and places it at the beginning of the line.

Deprecated: please use termenv.Output instead.

func CursorUp

func CursorUp(n int)

CursorUp moves the cursor up a given number of lines.

Deprecated: please use termenv.Output instead.

func DeleteLines

func DeleteLines(n int)

DeleteLines deletes the given number of lines, pulling any lines in the scrollable region below up.

Deprecated: please use termenv.Output instead.

func DisableBracketedPaste

func DisableBracketedPaste()

DisableBracketedPaste disables bracketed paste.

Deprecated: please use termenv.Output instead.

func DisableMouse

func DisableMouse()

DisableMouse disables Mouse Tracking mode.

Deprecated: please use termenv.Output instead.

func DisableMouseAllMotion

func DisableMouseAllMotion()

DisableMouseAllMotion disables All Motion Mouse mode.

Deprecated: please use termenv.Output instead.

func DisableMouseCellMotion

func DisableMouseCellMotion()

DisableMouseCellMotion disables Cell Motion Mouse Tracking mode.

Deprecated: please use termenv.Output instead.

func DisableMouseHilite

func DisableMouseHilite()

DisableMouseHilite disables Hilite Mouse Tracking mode.

Deprecated: please use termenv.Output instead.

func DisableMousePress

func DisableMousePress()

DisableMousePress disables X10 mouse mode.

Deprecated: please use termenv.Output instead.

func EnableBracketedPaste

func EnableBracketedPaste()

EnableBracketedPaste enables bracketed paste.

Deprecated: please use termenv.Output instead.

func EnableMouse

func EnableMouse()

EnableMouse enables Mouse Tracking mode.

Deprecated: please use termenv.Output instead.

func EnableMouseAllMotion

func EnableMouseAllMotion()

EnableMouseAllMotion enables All Motion Mouse mode.

Deprecated: please use termenv.Output instead.

func EnableMouseCellMotion

func EnableMouseCellMotion()

EnableMouseCellMotion enables Cell Motion Mouse Tracking mode.

Deprecated: please use termenv.Output instead.

func EnableMouseHilite

func EnableMouseHilite()

EnableMouseHilite enables Hilite Mouse Tracking mode.

Deprecated: please use termenv.Output instead.

func EnableMousePress

func EnableMousePress()

EnableMousePress enables X10 mouse mode. Button press events are sent only.

Deprecated: please use termenv.Output instead.

func EnableVirtualTerminalProcessing

func EnableVirtualTerminalProcessing(_ io.Writer) (func() error, error)

EnableVirtualTerminalProcessing enables virtual terminal processing on Windows for w and returns a function that restores w to its previous state. On non-Windows platforms, or if w does not refer to a terminal, then it returns a non-nil no-op function and no error.

func EnvNoColor

func EnvNoColor() bool

EnvNoColor returns true if the environment variables explicitly disable color output by setting NO_COLOR (https://no-color.org/) or CLICOLOR/CLICOLOR_FORCE (https://bixense.com/clicolors/) If NO_COLOR is set, this will return true, ignoring CLICOLOR/CLICOLOR_FORCE If CLICOLOR=="0", it will be true only if CLICOLOR_FORCE is also "0" or is unset.

func ExitAltScreen

func ExitAltScreen()

ExitAltScreen exits the alternate screen buffer and returns to the former terminal view.

Deprecated: please use termenv.Output instead.

func HasDarkBackground

func HasDarkBackground() bool

HasDarkBackground returns whether terminal uses a dark-ish background.

func HideCursor

func HideCursor()

HideCursor hides the cursor.

Deprecated: please use termenv.Output instead.

func Hyperlink(link, name string) string

Hyperlink creates a hyperlink using OSC8.

func InsertLines

func InsertLines(n int)

InsertLines inserts the given number of lines at the top of the scrollable region, pushing lines below down.

Deprecated: please use termenv.Output instead.

func MoveCursor

func MoveCursor(row int, column int)

MoveCursor moves the cursor to a given position.

Deprecated: please use termenv.Output instead.

func Notify

func Notify(title, body string)

Notify triggers a notification using OSC777.

func Reset

func Reset()

Reset the terminal to its default style, removing any active styles.

Deprecated: please use termenv.Output instead.

func RestoreCursorPosition

func RestoreCursorPosition()

RestoreCursorPosition restores a saved cursor position.

Deprecated: please use termenv.Output instead.

func RestoreScreen

func RestoreScreen()

RestoreScreen restores a previously saved screen state.

Deprecated: please use termenv.Output instead.

func SaveCursorPosition

func SaveCursorPosition()

SaveCursorPosition saves the cursor position.

Deprecated: please use termenv.Output instead.

func SaveScreen

func SaveScreen()

SaveScreen saves the screen state.

Deprecated: please use termenv.Output instead.

func SetBackgroundColor

func SetBackgroundColor(color Color)

SetBackgroundColor sets the default background color.

Deprecated: please use termenv.Output instead.

func SetCursorColor

func SetCursorColor(color Color)

SetCursorColor sets the cursor color.

Deprecated: please use termenv.Output instead.

func SetDefaultOutput

func SetDefaultOutput(o *Output)

SetDefaultOutput sets the default global output.

func SetForegroundColor

func SetForegroundColor(color Color)

SetForegroundColor sets the default foreground color.

Deprecated: please use termenv.Output instead.

func SetWindowTitle

func SetWindowTitle(title string)

SetWindowTitle sets the terminal window title.

Deprecated: please use termenv.Output instead.

func ShowCursor

func ShowCursor()

ShowCursor shows the cursor.

Deprecated: please use termenv.Output instead.

func TemplateFuncs

func TemplateFuncs(p Profile) template.FuncMap

TemplateFuncs contains a few useful template helpers.

type ANSI256Color

ANSI256Color is a color (16-255) as defined by the ANSI Standard.

type ANSI256Color int

func (ANSI256Color) Sequence

func (c ANSI256Color) Sequence(bg bool) string

Sequence returns the ANSI Sequence for the color.

func (ANSI256Color) String

func (c ANSI256Color) String() string

type ANSIColor

ANSIColor is a color (0-15) as defined by the ANSI Standard.

type ANSIColor int

ANSI color codes

const (
    ANSIBlack ANSIColor = iota
    ANSIRed
    ANSIGreen
    ANSIYellow
    ANSIBlue
    ANSIMagenta
    ANSICyan
    ANSIWhite
    ANSIBrightBlack
    ANSIBrightRed
    ANSIBrightGreen
    ANSIBrightYellow
    ANSIBrightBlue
    ANSIBrightMagenta
    ANSIBrightCyan
    ANSIBrightWhite
)

func (ANSIColor) Sequence

func (c ANSIColor) Sequence(bg bool) string

Sequence returns the ANSI Sequence for the color.

func (ANSIColor) String

func (c ANSIColor) String() string

type Color

Color is an interface implemented by all colors that can be converted to an ANSI sequence.

type Color interface {
    // Sequence returns the ANSI Sequence for the color.
    Sequence(bg bool) string
}

func BackgroundColor

func BackgroundColor() Color

BackgroundColor returns the terminal's default background color.

func ForegroundColor

func ForegroundColor() Color

ForegroundColor returns the terminal's default foreground color.

type Environ

Environ is an interface for getting environment variables.

type Environ interface {
    Environ() []string
    Getenv(string) string
}

type File

File represents a file descriptor.

type File interface {
    io.ReadWriter
    Fd() uintptr
}

type NoColor

NoColor is a nop for terminals that don't support colors.

type NoColor struct{}

func (NoColor) Sequence

func (c NoColor) Sequence(_ bool) string

Sequence returns the ANSI Sequence for the color.

func (NoColor) String

func (c NoColor) String() string

type Output

Output is a terminal output.

type Output struct {
    Profile
    // contains filtered or unexported fields
}

func DefaultOutput

func DefaultOutput() *Output

DefaultOutput returns the default global output.

func NewOutput

func NewOutput(tty io.Writer, opts ...OutputOption) *Output

NewOutput returns a new Output for the given file descriptor.

func (Output) AltScreen

func (o Output) AltScreen()

AltScreen switches to the alternate screen buffer. The former view can be restored with ExitAltScreen().

func (*Output) BackgroundColor

func (o *Output) BackgroundColor() Color

BackgroundColor returns the terminal's default background color.

func (Output) ChangeScrollingRegion

func (o Output) ChangeScrollingRegion(top, bottom int)

ChangeScrollingRegion sets the scrolling region of the terminal.

func (Output) ClearLine

func (o Output) ClearLine()

ClearLine clears the current line.

func (Output) ClearLineLeft

func (o Output) ClearLineLeft()

ClearLineLeft clears the line to the left of the cursor.

func (Output) ClearLineRight

func (o Output) ClearLineRight()

ClearLineRight clears the line to the right of the cursor.

func (Output) ClearLines

func (o Output) ClearLines(n int)

ClearLines clears a given number of lines.

func (Output) ClearScreen

func (o Output) ClearScreen()

ClearScreen clears the visible portion of the terminal.

func (*Output) ColorProfile

func (o *Output) ColorProfile() Profile

ColorProfile returns the supported color profile: Ascii, ANSI, ANSI256, or TrueColor.

func (Output) Copy

func (o Output) Copy(str string)

Copy copies text to clipboard using OSC 52 escape sequence.

func (Output) CopyPrimary

func (o Output) CopyPrimary(str string)

CopyPrimary copies text to primary clipboard (X11) using OSC 52 escape sequence.

func (Output) CursorBack

func (o Output) CursorBack(n int)

CursorBack moves the cursor backwards a given number of cells.

func (Output) CursorDown

func (o Output) CursorDown(n int)

CursorDown moves the cursor down a given number of lines.

func (Output) CursorForward

func (o Output) CursorForward(n int)

CursorForward moves the cursor up a given number of lines.

func (Output) CursorNextLine

func (o Output) CursorNextLine(n int)

CursorNextLine moves the cursor down a given number of lines and places it at the beginning of the line.

func (Output) CursorPrevLine

func (o Output) CursorPrevLine(n int)

CursorPrevLine moves the cursor up a given number of lines and places it at the beginning of the line.

func (Output) CursorUp

func (o Output) CursorUp(n int)

CursorUp moves the cursor up a given number of lines.

func (Output) DeleteLines

func (o Output) DeleteLines(n int)

DeleteLines deletes the given number of lines, pulling any lines in the scrollable region below up.

func (Output) DisableBracketedPaste

func (o Output) DisableBracketedPaste()

DisableBracketedPaste disables bracketed paste.

func (Output) DisableMouse

func (o Output) DisableMouse()

DisableMouse disables Mouse Tracking mode.

func (Output) DisableMouseAllMotion

func (o Output) DisableMouseAllMotion()

DisableMouseAllMotion disables All Motion Mouse mode.

func (Output) DisableMouseCellMotion

func (o Output) DisableMouseCellMotion()

DisableMouseCellMotion disables Cell Motion Mouse Tracking mode.

func (Output) DisableMouseExtendedMode

func (o Output) DisableMouseExtendedMode()

DisableMouseExtendedMotion disables Extended Mouse mode (SGR).

func (Output) DisableMouseHilite

func (o Output) DisableMouseHilite()

DisableMouseHilite disables Hilite Mouse Tracking mode.

func (Output) DisableMousePixelsMode

func (o Output) DisableMousePixelsMode()

DisableMousePixelsMotion disables Pixel Motion Mouse mode (SGR-Pixels).

func (Output) DisableMousePress

func (o Output) DisableMousePress()

DisableMousePress disables X10 mouse mode.

func (Output) EnableBracketedPaste

func (o Output) EnableBracketedPaste()

EnableBracketedPaste enables bracketed paste.

func (Output) EnableMouse

func (o Output) EnableMouse()

EnableMouse enables Mouse Tracking mode.

func (Output) EnableMouseAllMotion

func (o Output) EnableMouseAllMotion()

EnableMouseAllMotion enables All Motion Mouse mode.

func (Output) EnableMouseCellMotion

func (o Output) EnableMouseCellMotion()

EnableMouseCellMotion enables Cell Motion Mouse Tracking mode.

func (Output) EnableMouseExtendedMode

func (o Output) EnableMouseExtendedMode()

EnableMouseExtendedMotion enables Extended Mouse mode (SGR). This should be enabled in conjunction with EnableMouseCellMotion, and EnableMouseAllMotion.

func (Output) EnableMouseHilite

func (o Output) EnableMouseHilite()

EnableMouseHilite enables Hilite Mouse Tracking mode.

func (Output) EnableMousePixelsMode

func (o Output) EnableMousePixelsMode()

EnableMousePixelsMotion enables Pixel Motion Mouse mode (SGR-Pixels). This should be enabled in conjunction with EnableMouseCellMotion, and EnableMouseAllMotion.

func (Output) EnableMousePress

func (o Output) EnableMousePress()

EnableMousePress enables X10 mouse mode. Button press events are sent only.

func (*Output) EnvColorProfile

func (o *Output) EnvColorProfile() Profile

EnvColorProfile returns the color profile based on environment variables set Supports NO_COLOR (https://no-color.org/) and CLICOLOR/CLICOLOR_FORCE (https://bixense.com/clicolors/) If none of these environment variables are set, this behaves the same as ColorProfile() It will return the Ascii color profile if EnvNoColor() returns true If the terminal does not support any colors, but CLICOLOR_FORCE is set and not "0" then the ANSI color profile will be returned.

func (*Output) EnvNoColor

func (o *Output) EnvNoColor() bool

EnvNoColor returns true if the environment variables explicitly disable color output by setting NO_COLOR (https://no-color.org/) or CLICOLOR/CLICOLOR_FORCE (https://bixense.com/clicolors/) If NO_COLOR is set, this will return true, ignoring CLICOLOR/CLICOLOR_FORCE If CLICOLOR=="0", it will be true only if CLICOLOR_FORCE is also "0" or is unset.

func (Output) ExitAltScreen

func (o Output) ExitAltScreen()

ExitAltScreen exits the alternate screen buffer and returns to the former terminal view.

func (*Output) ForegroundColor

func (o *Output) ForegroundColor() Color

ForegroundColor returns the terminal's default foreground color.

func (*Output) HasDarkBackground

func (o *Output) HasDarkBackground() bool

HasDarkBackground returns whether terminal uses a dark-ish background.

func (Output) HideCursor

func (o Output) HideCursor()

HideCursor hides the cursor.

func (o *Output) Hyperlink(link, name string) string

Hyperlink creates a hyperlink using OSC8.

func (Output) InsertLines

func (o Output) InsertLines(n int)

InsertLines inserts the given number of lines at the top of the scrollable region, pushing lines below down.

func (Output) MoveCursor

func (o Output) MoveCursor(row int, column int)

MoveCursor moves the cursor to a given position.

func (*Output) Notify

func (o *Output) Notify(title, body string)

Notify triggers a notification using OSC777.

func (Output) Reset

func (o Output) Reset()

Reset the terminal to its default style, removing any active styles.

func (Output) RestoreCursorPosition

func (o Output) RestoreCursorPosition()

RestoreCursorPosition restores a saved cursor position.

func (Output) RestoreScreen

func (o Output) RestoreScreen()

RestoreScreen restores a previously saved screen state.

func (Output) SaveCursorPosition

func (o Output) SaveCursorPosition()

SaveCursorPosition saves the cursor position.

func (Output) SaveScreen

func (o Output) SaveScreen()

SaveScreen saves the screen state.

func (Output) SetBackgroundColor

func (o Output) SetBackgroundColor(color Color)

SetBackgroundColor sets the default background color.

func (Output) SetCursorColor

func (o Output) SetCursorColor(color Color)

SetCursorColor sets the cursor color.

func (Output) SetForegroundColor

func (o Output) SetForegroundColor(color Color)

SetForegroundColor sets the default foreground color.

func (Output) SetWindowTitle

func (o Output) SetWindowTitle(title string)

SetWindowTitle sets the terminal window title.

func (Output) ShowCursor

func (o Output) ShowCursor()

ShowCursor shows the cursor.

func (Output) TTY

func (o Output) TTY() File

TTY returns the terminal's file descriptor. This may be nil if the output is not a terminal.

func (Output) TemplateFuncs

func (o Output) TemplateFuncs() template.FuncMap

TemplateFuncs returns template helpers for the given output.

func (Output) Write

func (o Output) Write(p []byte) (int, error)

func (Output) WriteString

func (o Output) WriteString(s string) (int, error)

WriteString writes the given string to the output.

type OutputOption

OutputOption sets an option on Output.

type OutputOption = func(*Output)

func WithColorCache

func WithColorCache(v bool) OutputOption

WithColorCache returns a new OutputOption with fore- and background color values pre-fetched and cached.

func WithEnvironment

func WithEnvironment(environ Environ) OutputOption

WithEnvironment returns a new OutputOption for the given environment.

func WithProfile

func WithProfile(profile Profile) OutputOption

WithProfile returns a new OutputOption for the given profile.

func WithTTY

func WithTTY(v bool) OutputOption

WithTTY returns a new OutputOption to assume whether or not the output is a TTY. This is useful when mocking console output.

func WithUnsafe

func WithUnsafe() OutputOption

WithUnsafe returns a new OutputOption with unsafe mode enabled. Unsafe mode doesn't check whether or not the terminal is a TTY.

This option supersedes WithTTY.

This is useful when mocking console output and enforcing ANSI escape output e.g. on SSH sessions.

type Profile

Profile is a color profile: Ascii, ANSI, ANSI256, or TrueColor.

type Profile int

func ColorProfile

func ColorProfile() Profile

ColorProfile returns the supported color profile: Ascii, ANSI, ANSI256, or TrueColor.

func EnvColorProfile

func EnvColorProfile() Profile

EnvColorProfile returns the color profile based on environment variables set Supports NO_COLOR (https://no-color.org/) and CLICOLOR/CLICOLOR_FORCE (https://bixense.com/clicolors/) If none of these environment variables are set, this behaves the same as ColorProfile() It will return the Ascii color profile if EnvNoColor() returns true If the terminal does not support any colors, but CLICOLOR_FORCE is set and not "0" then the ANSI color profile will be returned.

func (Profile) Color

func (p Profile) Color(s string) Color

Color creates a Color from a string. Valid inputs are hex colors, as well as ANSI color codes (0-15, 16-255).

func (Profile) Convert

func (p Profile) Convert(c Color) Color

Convert transforms a given Color to a Color supported within the Profile.

func (Profile) FromColor

func (p Profile) FromColor(c color.Color) Color

FromColor creates a Color from a color.Color.

func (Profile) String

func (p Profile) String(s ...string) Style

String returns a new Style.

type RGBColor

RGBColor is a hex-encoded color, e.g. "#abcdef".

type RGBColor string

func (RGBColor) Sequence

func (c RGBColor) Sequence(bg bool) string

Sequence returns the ANSI Sequence for the color.

type Style

Style is a string that various rendering styles can be applied to.

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

func String

func String(s ...string) Style

String returns a new Style.

func (Style) Background

func (t Style) Background(c Color) Style

Background sets a background color.

func (t Style) Blink() Style

Blink enables blink mode.

func (Style) Bold

func (t Style) Bold() Style

Bold enables bold rendering.

func (Style) CrossOut

func (t Style) CrossOut() Style

CrossOut enables crossed-out rendering.

func (Style) Faint

func (t Style) Faint() Style

Faint enables faint rendering.

func (Style) Foreground

func (t Style) Foreground(c Color) Style

Foreground sets a foreground color.

func (Style) Italic

func (t Style) Italic() Style

Italic enables italic rendering.

func (Style) Overline

func (t Style) Overline() Style

Overline enables overline rendering.

func (Style) Reverse

func (t Style) Reverse() Style

Reverse enables reverse color mode.

func (Style) String

func (t Style) String() string

func (Style) Styled

func (t Style) Styled(s string) string

Styled renders s with all applied styles.

func (Style) Underline

func (t Style) Underline() Style

Underline enables underline rendering.

func (Style) Width

func (t Style) Width() int

Width returns the width required to print all runes in Style.

Subdirectories