area

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package area implements a matrix of Characters

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EachChange added in v0.0.3

func EachChange(area1, area2 *Area, fn func(Row, Col int, a1Char, a2Char char.Charer))

EachChange compares two areas and invoke the callback every time there is a difference. It only covers the area of area1.

Types

type Area

type Area struct {
	Rows, Cols int

	Fixed bool
	// contains filtered or unexported fields
}

Area represents a rectangular area of Chars. An empty Area is a valid one.

func Diff added in v0.0.3

func Diff(area1, area2 *Area) *Area

Diff returns a new fixed area of the size of area1 with all the Char of area1 that are not equal in area2

func (*Area) Each

func (a *Area) Each(fn func(Row, Col int, char char.Charer))

Each iterates over each column and row. The rows and the columns starts with 1

func (*Area) Get

func (a *Area) Get(Row, Col int) (char.Charer, error)

Get will return the character at the given position. A row or col smaller than 1 will return nil and error. For a fixed area a row and col bigger than the actual size will also return an error

func (*Area) Set

func (a *Area) Set(row, col int, c char.Charer) error

Set will change the given Char in the row,col position. If the area is fixed, it will return an error if a char is being set outside the area A row or col smaller than 1 will also return an error

func (*Area) SetSize

func (a *Area) SetSize(rows, cols int)

SetSize changes the current area size an sets the area to Fixed.

func (*Area) Size

func (a *Area) Size() (rows, cols int)

Size returns the current Size.

Jump to

Keyboard shortcuts

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