ansi

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2020 License: MIT Imports: 4 Imported by: 11

README

go-ansi

Write pretty terminal output the easy way.

Want your text green? ansi.Green("I am Shrek")

Want it black on a red ground? ansi.RedBG(ansi.Black("You can just combine them"))

Moving around is as simple as Specifying direction ansi.Up()

ANSI Support

Terminal Colors BG Colors Styles Movements Saving Positions
Kitty ➖¹²
Alacritty ➖¹
xTerm ✔³
st ✔³
guake ✔³
urxvt ✔²⁴
terminator ✔²³
termite ✔²³

¹) Blinking not supported ²) Conceal not supported ³) BUG: fast blinking ⁴) Strikethrough not working

this list may be inaccurate as it was created after an exhausting day of work at a time where I wasn't up to much

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Black

func Black(content ...interface{}) string

Black wraps the content in ANSI codes to make its foreground color black

func BlackBG

func BlackBG(content ...interface{}) string

BlackBG wraps the content in ANSI codes to make its background color black

func Blink(content ...interface{}) string

Blink is equivalent to SetBlink() + content + UnsetBlink(), content will thereby blink.

func Blue

func Blue(content ...interface{}) string

Blue wraps the content in ANSI codes to make its foreground color blue

func BlueBG

func BlueBG(content ...interface{}) string

BlueBG wraps the content in ANSI codes to make its background color blue

func Bold

func Bold(content ...interface{}) string

Bold is equivalent to SetBold() + content + UnsetBold(), content will thereby be printed in bold.

func ClearBegin

func ClearBegin() string

ClearBegin clears the entire screen to (0;0)

func ClearEnd

func ClearEnd() string

ClearEnd clears to the end of the screen

func ClearLeft

func ClearLeft() string

ClearLeft clears all characters left of the cursor from the display

func ClearLine

func ClearLine() string

ClearLine clears all characters on the line

func ClearRight

func ClearRight() string

ClearRight clears all characters right of the cursor from the display

func ClearScreen

func ClearScreen() string

ClearScreen clears the entire screen and moves the cursor to (0;0)

func ClearScreenBuffer

func ClearScreenBuffer() string

ClearScreenBuffer clears the entire screen and the screenbuffer

func Color256

func Color256(color int, content ...interface{}) string

Color256 sets a Term256 color that is applied to the provided text

func Color256BG

func Color256BG(color int, content ...interface{}) string

Color256BG sets a Term256 color that is applied to the provided text as the background color

func ColorTrue

func ColorTrue(r, g, b int, content ...interface{}) string

ColorTrue sets a RGB-Color that is set as the background color, writes the

func ColorTrueBG

func ColorTrueBG(r, g, b int, content ...interface{}) string

ColorTrueBG sets a RGB-Color that is set as the background color, writes the text and clears the background color

func Conceal

func Conceal(content ...interface{}) string

Conceal is equivalent to SetConceal() + content + UnsetConceal(), content will thereby be displayed as spaces. It will still be visible if written to a file

func Cyan

func Cyan(content ...interface{}) string

Cyan wraps the content in ANSI codes to make its foreground color cyan

func CyanBG

func CyanBG(content ...interface{}) string

CyanBG wraps the content in ANSI codes to make its background color cyan

func DoubleUnderscore

func DoubleUnderscore(content ...interface{}) string

DoubleUnderscore is equivalent to SetDoubleUnderscore() + content + UnsetDoubleUnderscore(), content will thereby be double-underscored.

func Down

func Down() string

Down moves the cursor down one row

func DownX

func DownX(x int) string

DownX moves the cursor down x rows

func Faint

func Faint(content ...interface{}) string

Faint is equivalent to SetFaint() + content + UnsetFaint(), content will thereby be printed in a less intense color.

func FastBlink(content ...interface{}) string

FastBlink is equivalent to SetFastBlink() + content + UnsetFastBlink(), content will thereby blink fast.

func Font

func Font(font int, content ...interface{}) string

Font applies the specified fontface to the text

func Fraktur

func Fraktur(content ...interface{}) string

Fraktur is equivalent to SetFraktur() + content + UnsetFraktur(), content will thereby be printed in Frakturschrift. This is very rarely support.

func GetLengthWithoutCodes added in v1.1.0

func GetLengthWithoutCodes(content string) int

func Green

func Green(content ...interface{}) string

Green wraps the content in ANSI codes to make its foreground color green

func GreenBG

func GreenBG(content ...interface{}) string

GreenBG wraps the content in ANSI codes to make its background color green

func Italic

func Italic(content ...interface{}) string

Italic is equivalent to SetItalic() + content + UnsetItalic(), content will thereby be italic.

func Left

func Left() string

Left moves the cursor Left one row. As far as I am aware the correct term is "backward". Please be wary of potential implications in RTL context.

func LeftX

func LeftX(x int) string

LeftX moves the cursor Left x rows. As far as I am aware the correct term is "backward". Please be wary of potential implications in RTL context.

func Magenta

func Magenta(content ...interface{}) string

Magenta wraps the content in ANSI codes to make its foreground color magenta

func MagentaBG

func MagentaBG(content ...interface{}) string

MagentaBG wraps the content in ANSI codes to make its background color magenta

func MoveCursor

func MoveCursor(x, y int) string

MoveCursor moves the cursor to position (x;y)

func Red

func Red(content ...interface{}) string

Red wraps the content in ANSI codes to make its foreground color red

func RedBG

func RedBG(content ...interface{}) string

RedBG wraps the content in ANSI codes to make its background color red

func Reset

func Reset() string

Reset clears all colors and styles (bold, underscore, blink, concealed)

func RestorePos

func RestorePos() string

RestorePos restores the cursor position from the void. (see SavePos for more)

func ReverseVideo

func ReverseVideo(content ...interface{}) string

ReverseVideo is equivalent to SetReverseVideo() + content + UnsetReverseVideo(), content will thereby be inverted. This means that the background color and the foreground color will be switched.

func Right() string

Right moves the cursor right one row. As far as I am aware the correct term is "forward". Please be wary of potential implications in RTL context.

func RightX

func RightX(x int) string

RightX moves the cursor right x rows. As far as I am aware the correct term is "forward". Please be wary of potential implications in RTL context.

func SavePos

func SavePos() string

SavePos stores the current cursor position god knows where to allow restoring it.

func SetBlack

func SetBlack() string

SetBlack sets the foreground color to black

func SetBlackBG

func SetBlackBG() string

SetBlackBG sets the background color to black

func SetBlink() string

SetBlink makes the following text blink

func SetBlue

func SetBlue() string

SetBlue sets the foreground color to blue

func SetBlueBG

func SetBlueBG() string

SetBlueBG sets the background color to blue

func SetBold

func SetBold() string

SetBold makes the following text become bold

func SetColor256

func SetColor256(color int) string

SetColor256 writes the following text on the specified term256 color

func SetColor256BG

func SetColor256BG(color int) string

SetColor256BG writes the following text on the specified background color

func SetColorTrue

func SetColorTrue(r, g, b int) string

SetColorTrue sets a RGB-Color for the font

func SetColorTrueBG

func SetColorTrueBG(r, g, b int) string

SetColorTrueBG sets a RGB-Color for the background

func SetConceal

func SetConceal() string

SetConceal conceals the following text

func SetCyan

func SetCyan() string

SetCyan sets the foreground color to cyan

func SetCyanBG

func SetCyanBG() string

SetCyanBG sets the background color to cyan

func SetDoubleUnderscore

func SetDoubleUnderscore() string

SetDoubleUnderscore makes the following text become underscored

func SetFaint

func SetFaint() string

SetFaint makes the color of the following text less bright

func SetFastBlink() string

SetFastBlink makes the following text blink fast

func SetFont

func SetFont(font int) string

SetFont starts a block written in the specified font

func SetFraktur

func SetFraktur() string

SetFraktur makes the following text be printed printed in Frakturschrift

func SetGreen

func SetGreen() string

SetGreen sets the foreground color to green

func SetGreenBG

func SetGreenBG() string

SetGreenBG sets the background color to green

func SetItalic

func SetItalic() string

SetItalic makes the text following text become italic

func SetMagenta

func SetMagenta() string

SetMagenta sets the foreground color to magenta

func SetMagentaBG

func SetMagentaBG() string

SetMagentaBG sets the background color to magenta

func SetRed

func SetRed() string

SetRed sets the foreground color to red

func SetRedBG

func SetRedBG() string

SetRedBG sets the background color to red

func SetReverseVideo

func SetReverseVideo() string

SetReverseVideo makes the following text become inverted.

func SetStrikethrough

func SetStrikethrough() string

SetStrikethrough makes the following text crossed out

func SetUnderscore

func SetUnderscore() string

SetUnderscore makes the text following become underlined

func SetWhite

func SetWhite() string

SetWhite sets the foreground color to white

func SetWhiteBG

func SetWhiteBG() string

SetWhiteBG sets the background color to white

func SetYellow

func SetYellow() string

SetYellow sets the foreground color to yellow

func SetYellowBG

func SetYellowBG() string

SetYellowBG sets the background color to yellow

func Strikethrough

func Strikethrough(content ...interface{}) string

Strikethrough is equivalent to SetStrikethrough() + content + UnsetStrikethrough(), content will thereby be displayed as crossed out

func Underscore

func Underscore(content ...interface{}) string

Underscore is equivalent to SetUnderscore() + content + UnsetUnderscore(), content will thereby be underscored.

func UnsetBlack

func UnsetBlack() string

UnsetBlack resets the foreground color from black to default.

func UnsetBlackBG

func UnsetBlackBG() string

UnsetBlackBG resets the background color from black to default.

func UnsetBlink() string

UnsetBlink stops the text from blinking

func UnsetBlue

func UnsetBlue() string

UnsetBlue resets the foreground color from blue to default.

func UnsetBlueBG

func UnsetBlueBG() string

UnsetBlueBG resets the background color from blue to default.

func UnsetBold

func UnsetBold() string

UnsetBold removes the bold property

func UnsetColor256

func UnsetColor256() string

UnsetColor256 resets the color

func UnsetColor256BG

func UnsetColor256BG() string

UnsetColor256BG resets the background color

func UnsetColorTrue

func UnsetColorTrue() string

UnsetColorTrue removes the RGB-color

func UnsetColorTrueBG

func UnsetColorTrueBG() string

UnsetColorTrueBG removes the RGB-background

func UnsetConceal

func UnsetConceal() string

UnsetConceal removes the concealed property

func UnsetCyan

func UnsetCyan() string

UnsetCyan resets the foreground color from cyan to default.

func UnsetCyanBG

func UnsetCyanBG() string

UnsetCyanBG resets the background color from cyan to default.

func UnsetDoubleUnderscore

func UnsetDoubleUnderscore() string

UnsetDoubleUnderscore removes the double-underscore attribute

func UnsetFaint

func UnsetFaint() string

UnsetFaint removes the faint property

func UnsetFastBlink() string

UnsetFastBlink stops the text from blinking fast

func UnsetFont

func UnsetFont() string

UnsetFont resets the fontface back to the default

func UnsetFraktur

func UnsetFraktur() string

UnsetFraktur resets the font to the default

func UnsetGreen

func UnsetGreen() string

UnsetGreen resets the foreground color from green to default.

func UnsetGreenBG

func UnsetGreenBG() string

UnsetGreenBG resets the background color from green to default.

func UnsetItalic

func UnsetItalic() string

UnsetItalic removes the italic property

func UnsetMagenta

func UnsetMagenta() string

UnsetMagenta resets the foreground color from magenta to default.

func UnsetMagentaBG

func UnsetMagentaBG() string

UnsetMagentaBG resets the background color from magenta to default.

func UnsetRed

func UnsetRed() string

UnsetRed resets the foreground color from red to default.

func UnsetRedBG

func UnsetRedBG() string

UnsetRedBG resets the background color from red to default.

func UnsetReverseVideo

func UnsetReverseVideo() string

UnsetReverseVideo disables the inversion

func UnsetStrikethrough

func UnsetStrikethrough() string

UnsetStrikethrough removes the strikethrough property

func UnsetUnderscore

func UnsetUnderscore() string

UnsetUnderscore removes the underscore property

func UnsetWhite

func UnsetWhite() string

UnsetWhite resets the foreground color from white to default.

func UnsetWhiteBG

func UnsetWhiteBG() string

UnsetWhiteBG resets the background color from white to default.

func UnsetYellow

func UnsetYellow() string

UnsetYellow resets the foreground color from yellow to default.

func UnsetYellowBG

func UnsetYellowBG() string

UnsetYellowBG resets the background color from yellow to default.

func Up

func Up() string

Up moves the cursor up one row

func UpX

func UpX(x int) string

UpX moves the cursor up x rows

func White

func White(content ...interface{}) string

White wraps the content in ANSI codes to make its foreground color white

func WhiteBG

func WhiteBG(content ...interface{}) string

WhiteBG wraps the content in ANSI codes to make its background color white

func Yellow

func Yellow(content ...interface{}) string

Yellow wraps the content in ANSI codes to make its foreground color yellow

func YellowBG

func YellowBG(content ...interface{}) string

YellowBG wraps the content in ANSI codes to make its background color yellow

Types

This section is empty.

Directories

Path Synopsis
demo

Jump to

Keyboard shortcuts

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