cell

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package cell implements cell options and attributes.

A cell is the smallest point on the terminal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Buffer

type Buffer [][]*Cell

Buffer is a 2-D buffer of cells. The axes increase right and down. Uninitialized buffer is invalid, use NewBuffer to create an instance. Don't set cells directly, use the SetCell method instead which safely handles limits and wide unicode characters.

func NewBuffer

func NewBuffer(size image.Point) (Buffer, error)

NewBuffer returns a new Buffer of the provided size.

func (Buffer) IsPartial

func (b Buffer) IsPartial(p image.Point) (bool, error)

IsPartial returns true if the cell at the specified point holds a part of a full width rune from a previous cell. See http://www.unicode.org/reports/tr11/.

func (Buffer) RemWidth

func (b Buffer) RemWidth(p image.Point) (int, error)

RemWidth returns the remaining width (horizontal row of cells) available from and inclusive of the specified point.

func (Buffer) SetCell

func (b Buffer) SetCell(p image.Point, r rune, opts ...Option) (int, error)

SetCell sets the rune of the specified cell in the buffer. Returns the number of cells the rune occupies, wide runes can occupy multiple cells when printed on the terminal. See http://www.unicode.org/reports/tr11/. Use the options to specify which attributes to modify, if an attribute option isn't specified, the attribute retains its previous value.

func (Buffer) Size

func (b Buffer) Size() image.Point

Size returns the size of the buffer.

type Cell

type Cell struct {
	// Rune is the rune stored in the cell.
	Rune rune

	// Opts are the cell options.
	Opts *Options
}

Cell represents a single cell on the terminal.

func New

func New(r rune, opts ...Option) *Cell

New returns a new cell.

func (*Cell) Apply

func (c *Cell) Apply(opts ...Option)

Apply applies the provided options to the cell.

func (*Cell) Copy

func (c *Cell) Copy() *Cell

Copy returns a copy the cell.

type Color

type Color int

Color is the color of a cell.

const (
	ColorDefault Color = iota

	// 8 "system" colors.
	ColorBlack
	ColorRed
	ColorGreen
	ColorYellow
	ColorBlue
	ColorMagenta
	ColorCyan
	ColorWhite
)

The supported terminal colors.

func ColorNumber

func ColorNumber(n int) Color

ColorNumber sets a color using its number. Make sure your terminal is set to a terminalapi.ColorMode that supports the target color. The provided value must be in the range 0-255. Larger or smaller values will be reset to the default color.

For reference on these colors see the Xterm number in: https://jonasjacek.github.io/colors/

func ColorRGB24

func ColorRGB24(r, g, b int) Color

ColorRGB24 sets a color using the 24 bit web color scheme. Make sure your terminal is set to the terminalapi.ColorMode256 mode. The provided values (r, g, b) must be in the range 0-255. Larger or smaller values will be reset to the default color.

For reference on these colors see the RGB column in: https://jonasjacek.github.io/colors/

func ColorRGB6

func ColorRGB6(r, g, b int) Color

ColorRGB6 sets a color using the 6x6x6 terminal color. Make sure your terminal is set to the terminalapi.ColorMode256 mode. The provided values (r, g, b) must be in the range 0-5. Larger or smaller values will be reset to the default color.

For reference on these colors see: https://superuser.com/questions/783656/whats-the-deal-with-terminal-colors

func (Color) String

func (cc Color) String() string

String implements fmt.Stringer()

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is used to provide options for cells on a 2-D terminal.

func BgColor

func BgColor(color Color) Option

BgColor sets the background color of the cell.

func FgColor

func FgColor(color Color) Option

FgColor sets the foreground color of the cell.

type Options

type Options struct {
	FgColor Color
	BgColor Color
}

Options stores the provided options.

func NewOptions

func NewOptions(opts ...Option) *Options

NewOptions returns a new Options instance after applying the provided options.

Directories

Path Synopsis
Package runewidth is a wrapper over github.com/mattn/go-runewidth which gives different treatment to certain runes with ambiguous width.
Package runewidth is a wrapper over github.com/mattn/go-runewidth which gives different treatment to certain runes with ambiguous width.

Jump to

Keyboard shortcuts

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