ansi

package
v2.0.0-...-4b7107c Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: MIT Imports: 1 Imported by: 0

README

ANSI Controls (Color, Navigation)

Description

A simple color printing and cursor control library because life is not meant to be black and white. This project allows command-line control over the cursor navigation and color without any complicated libraries/dependencies. It's just old-school ANSI codes doing things in Linux, MacOS, WSL the same way we did it in DOS. No frills, no fuss.

Status

Go Tests

Usage

Installation

go get "github.com/sam-caldwell/go/v2"

Printing colors...
	ansi.
		Black().Print("black").LF().
		Red().Print("red|").Space().Print("|").LF().
		Green().Printf("%s", "green").LF().
		Yellow().Print("yellow|").Tab().Print("|").LF().
		Blue().Println("blue").
		Magenta().Println("magenta").
		Cyan().Println("cyan").
		White().Println("white").
		Reset().Println("reset")
But wait! There's more...Navigation...
    ansi.Clear()  //clear the screen
    ansi.
        BgRed().Green().Blink().Bold().Print("We can move places").
        Reset().LF().LF().
        Underline().Print("Style").LF().
        Up(1).Print("Move up one").Reset().
        Left(2).Print("Move Left two").
        Hidden().Print("My secret").Reset().
        Right(3).Print("Move right three").
        Down(2).Print("Move down 2").LF().
        Strikethrough().Print("This is too much").
        Reset()

Documentation

Index

Constants

View Source
const (
	LineFeed = "\n"
	Space    = " "
	Tab      = "\t"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Color

type Color struct{}

Color - Provide a function to make it all simple

func BgBlack

func BgBlack() *Color

BgBlack - set color and return a new color object

func BgBlue

func BgBlue() *Color

BgBlue - set color and return a new color object

func BgCyan

func BgCyan() *Color

BgCyan - set color and return a new color object

func BgGreen

func BgGreen() *Color

BgGreen - set color and return a new color object

func BgMagenta

func BgMagenta() *Color

BgMagenta - set color and return a new color object

func BgRed

func BgRed() *Color

BgRed - set color and return a new color object

func BgWhite

func BgWhite() *Color

BgWhite - set color and return a new color object

func BgYellow

func BgYellow() *Color

BgYellow - set color and return a new color object

func Black

func Black() *Color

Black - set color and return a new color object

func Blink() *Color

Blink - set format attribute and return a new color object

func Blue

func Blue() *Color

Blue - set color and return a new color object

func Bold

func Bold() *Color

Bold - set format attribute and return a new color object

func Clear

func Clear() *Color

Clear - set format attribute and return a new color object

func Cyan

func Cyan() *Color

Cyan - set color and return a new color object

func Dim

func Dim() *Color

Dim - decrease intensity and return a new color object

func Down

func Down(n int) *Color

Down - move cursor n units and return a new color object

func Green

func Green() *Color

Green - set color and return a new color object

func Hidden

func Hidden() *Color

Hidden - set format attribute and return a new color object

func Left

func Left(n int) *Color

Left - move cursor n units and return a new color object

func Magenta

func Magenta() *Color

Magenta - set color and return a new color object

func Print

func Print(message string) *Color

Print - print text to stdout and return color object

func Printf

func Printf(format string, a ...any) *Color

Printf - print text to stdout and return color object

func Println

func Println(message string) *Color

Println - print text to stdout and return color object

func Red

func Red() *Color

Red - set color and return a new color object

func Reset

func Reset() *Color

Reset - Send Reset to stdout and return new color object

func Reverse

func Reverse() *Color

Reverse - set format attribute and return a new color object

func Right(n int) *Color

Right - move cursor n units and return a new color object

func Strikethrough

func Strikethrough() *Color

Strikethrough - set format attribute and return a new color object

func TopLeft

func TopLeft() *Color

TopLeft - Move cursor to top left and return a new color object

func Underline

func Underline() *Color

Underline - set format attribute and return a new color object

func Up

func Up(n int) *Color

Up - move cursor n units and return a new color object

func White

func White() *Color

White - set color and return a new color object

func Yellow

func Yellow() *Color

Yellow - set color and return a new color object

func (*Color) BgBlack

func (c *Color) BgBlack() *Color

BgBlack - Set color

func (*Color) BgBlue

func (c *Color) BgBlue() *Color

BgBlue - Set color

func (*Color) BgCyan

func (c *Color) BgCyan() *Color

BgCyan - Set color

func (*Color) BgGreen

func (c *Color) BgGreen() *Color

BgGreen - Set color

func (*Color) BgMagenta

func (c *Color) BgMagenta() *Color

BgMagenta - Set color

func (*Color) BgRed

func (c *Color) BgRed() *Color

BgRed - Set color

func (*Color) BgWhite

func (c *Color) BgWhite() *Color

BgWhite - Set color

func (*Color) BgYellow

func (c *Color) BgYellow() *Color

BgYellow - Set color

func (*Color) Black

func (c *Color) Black() *Color

Black - Set color

func (c *Color) Blink() *Color

Blink - Set format attribute

func (*Color) Blue

func (c *Color) Blue() *Color

Blue - Set color

func (*Color) Bold

func (c *Color) Bold() *Color

Bold - Set format attribute

func (*Color) Clear

func (c *Color) Clear() *Color

Clear - Set format attribute

func (*Color) Cyan

func (c *Color) Cyan() *Color

Cyan - Set color

func (*Color) Dim

func (c *Color) Dim() *Color

Dim - decrease intensity

func (*Color) Down

func (c *Color) Down(n int) *Color

Down - move cursor n units

func (*Color) Green

func (c *Color) Green() *Color

Green - Set color

func (*Color) Hidden

func (c *Color) Hidden() *Color

Hidden - Set format attribute

func (*Color) LF

func (c *Color) LF() *Color

LF - print a line feed char

func (*Color) Left

func (c *Color) Left(n int) *Color

Left - move cursor n units

func (*Color) Magenta

func (c *Color) Magenta() *Color

Magenta - Set color

func (*Color) Print

func (c *Color) Print(message string) *Color

Print - print text to stdout

func (*Color) Printf

func (c *Color) Printf(format string, a ...any) *Color

Printf - print text to stdout

func (*Color) Println

func (c *Color) Println(message string) *Color

Println - print text to stdout

func (*Color) Red

func (c *Color) Red() *Color

Red - Set color

func (*Color) Reset

func (c *Color) Reset() *Color

Reset - Send Reset to stdout

func (*Color) Reverse

func (c *Color) Reverse() *Color

Reverse - Set format attribute

func (*Color) Right

func (c *Color) Right(n int) *Color

Right - move cursor n units

func (*Color) Space

func (c *Color) Space() *Color

Space - print a Space character

func (*Color) Strikethrough

func (c *Color) Strikethrough() *Color

Strikethrough - Set format attribute

func (*Color) Tab

func (c *Color) Tab() *Color

Tab - print a Tab char

func (*Color) TopLeft

func (c *Color) TopLeft() *Color

TopLeft - Move cursor to top left

func (*Color) Underline

func (c *Color) Underline() *Color

Underline - Set format attribute

func (*Color) Up

func (c *Color) Up(n int) *Color

Up - move cursor n units

func (*Color) White

func (c *Color) White() *Color

White - set color

func (*Color) Yellow

func (c *Color) Yellow() *Color

Yellow - set color

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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