buffer

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package buffer implements a 2-D buffer of cells.

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 New to create an instance. Don't set cells directly, use the SetCell method instead which safely handles limits and wide unicode characters.

func New

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

New 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 ...cell.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 *cell.Options
}

Cell represents a single cell on the terminal.

func NewCell

func NewCell(r rune, opts ...cell.Option) *Cell

NewCell returns a new cell.

func NewCells added in v0.8.0

func NewCells(text string, opts ...cell.Option) []*Cell

NewCells breaks the provided text into cells and applies the options.

func (*Cell) Apply

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

Apply applies the provided options to the cell.

func (*Cell) Copy

func (c *Cell) Copy() *Cell

Copy returns a copy the cell.

func (*Cell) String added in v0.8.0

func (c *Cell) String() string

String implements fmt.Stringer.

Jump to

Keyboard shortcuts

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