rainbow

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package rainbow prints texts in beautiful rainbows in terminal. Usage is very simple:

import "github.com/arsham/rainbow/rainbow"
// ...
l := rainbow.Light{
    Reader: someReader, // to read from
    Writer: os.Stdout, // to write to
}
l.Paint() // will rainbow everything it reads from reader to writer.

If you want the rainbow to be random, you can seed it this way:

l := rainbow.Light{
    Reader: buf,
    Writer: os.Stdout,
    Seed:   rand.Int63n(256),
}

You can also use the Light as a Writer:

l := rainbow.Light{
    Writer: os.Stdout, // to write to
    Seed:   rand.Int63n(256),
}
io.Copy(l, someReader)

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNilWriter is returned when Light.Writer is nil.
	ErrNilWriter = errors.New("nil writer")
)

Functions

func Display

func Display(w io.Writer, opts *DisplayOpts)

Types

type DisplayOpts

type DisplayOpts struct {
	UserName    string
	Fingerprint string
	KeyType     string
	Width       int // -1 not tty
}

type Light

type Light struct {
	Reader io.Reader
	Writer io.Writer
	Seed   int64
}

Light reads data from the Writer and pains the contents to the Reader. You should seed it everytime otherwise you get the same results.

func (*Light) Paint

func (l *Light) Paint() error

Paint returns an error if it could not copy the data.

func (*Light) Write

func (l *Light) Write(data []byte) (int, error)

Write paints the data and writes it into l.Writer.

Jump to

Keyboard shortcuts

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