kit

package
v0.0.0-...-1d96728 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PollEvents

func PollEvents(ctx context.Context, events EventChans) error

func Update

func Update(fg, bg termbox.Attribute, update func(BufferSlice))

Types

type Area

type Area struct {
	Col  int
	Row  int
	Cols int
	Rows int

	Width  Size
	Height Size
}

func AreaAt

func AreaAt(x, y int) Area

func (Area) EachCol

func (a Area) EachCol(fn func(col int))

func (Area) EachRow

func (a Area) EachRow(fn func(row int))

func (Area) HeightCh

func (a Area) HeightCh(n int) Area

func (Area) HeightFr

func (a Area) HeightFr(n int) Area

func (Area) MaxCol

func (a Area) MaxCol() int

func (Area) MaxRow

func (a Area) MaxRow() int

func (Area) Span

func (a Area) Span(cols, rows int) Area

func (Area) WidthCh

func (a Area) WidthCh(n int) Area

func (Area) WidthFr

func (a Area) WidthFr(n int) Area

type AttrString

type AttrString struct {
	Value string
	Fg    termbox.Attribute
	Bg    termbox.Attribute
}

func (AttrString) Draw

func (a AttrString) Draw(dest BufferSlice)

func (AttrString) Width

func (a AttrString) Width() int

type BufferSlice

type BufferSlice struct {
	Width  int
	Height int
	Stride int
	// contains filtered or unexported fields
}

BufferSlice is a sub-rectangle within a larger Buffer.

func TermboxBackBuffer

func TermboxBackBuffer() BufferSlice

func (BufferSlice) Get

func (sl BufferSlice) Get(x, y int) (*termbox.Cell, bool)

Get returns a pointer to the underlying Cell in the backing buffer, or nil if out of bounds.

func (BufferSlice) SetBg

func (sl BufferSlice) SetBg(a termbox.Attribute)

func (BufferSlice) SetFg

func (sl BufferSlice) SetFg(a termbox.Attribute)

func (BufferSlice) Slice

func (sl BufferSlice) Slice(x, y, width, height int) BufferSlice

type Cell

type Cell termbox.Cell

func (Cell) Draw

func (c Cell) Draw(dest BufferSlice)

func (Cell) Width

func (c Cell) Width() int

type CellString

type CellString []termbox.Cell

func (CellString) Draw

func (cs CellString) Draw(dest BufferSlice)

func (CellString) Width

func (cs CellString) Width() int

type DeferredSizes

type DeferredSizes struct {
	// contains filtered or unexported fields
}

func NewDeferredSizes

func NewDeferredSizes(length int) *DeferredSizes

func (*DeferredSizes) Calculate

func (d *DeferredSizes) Calculate(i int) (size int, ok bool)

func (*DeferredSizes) CalculateAll

func (d *DeferredSizes) CalculateAll() []int

func (*DeferredSizes) Length

func (d *DeferredSizes) Length() int

func (*DeferredSizes) Push

func (d *DeferredSizes) Push(i int, fn di.DeferredInt)

type Dimension

type Dimension struct {
	Width  int
	Height int
}

type Drawer

type Drawer interface {
	Draw(dest BufferSlice)
}

type EventChans

type EventChans struct {
	Chars       chan<- rune
	Keys        chan<- termbox.Key
	Resizes     chan<- Dimension
	MouseCoords chan<- Point
	Errors      chan<- error
	Interrupts  chan<- bool
}

EventChans are writeable channels for the various event types.

type Events

type Events struct {
	Chars       <-chan rune
	Keys        <-chan termbox.Key
	Resizes     <-chan Dimension
	MouseCoords <-chan Point
	Errors      <-chan error
	Interrupts  <-chan bool
}

Events are readable channels for the various event types.

func StartPollEvents

func StartPollEvents(ctx context.Context) Events

StartPollEvents starts a goroutine that polls termbox events and writes them to the returned channel. It explodes the single termbox.Event into many events, each with unique channel. This makes things a bit nicer and less nested when you're going to manage the event loop manually with a big for{select...} loop.

The downside is the caller must select from every returned channel. Failing to receive and event from one channel will result in the polling loop blocking, unable to handle further events.

type Grid

type Grid struct {
	Items map[string]Drawer
	// contains filtered or unexported fields
}

func NewGrid

func NewGrid(areas map[string]Area) *Grid

func (*Grid) Clear

func (grid *Grid) Clear()

Clear clears current items from the grid.

func (*Grid) Draw

func (grid *Grid) Draw(dest BufferSlice)

func (*Grid) Layout

func (grid *Grid) Layout(width, height int) map[string]Rect

Layout the grid into a rectangle of the given dimensions. The units of the returned rectangles are in cells. The previous layout (only one previous layout) is cached internally, and the cached layout returned for subsequent calls with the same dimensions.

func (*Grid) LayoutBuffers

func (grid *Grid) LayoutBuffers(buf BufferSlice) map[string]BufferSlice

func (*Grid) RowsAndColumns

func (grid *Grid) RowsAndColumns() (int, int)

type Line

type Line []TableCell

Line is a horizontal list of TableCell

func (Line) Draw

func (line Line) Draw(buf BufferSlice)

func (Line) Width

func (line Line) Width() int

type Point

type Point struct {
	X int
	Y int
}

type Rect

type Rect struct {
	X      int
	Y      int
	Width  int
	Height int
}

func (Rect) String

func (r Rect) String() string

type Rune

type Rune rune

func (Rune) Draw

func (ch Rune) Draw(dest BufferSlice)

func (Rune) Width

func (ch Rune) Width() int

type Size

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

Size represents the size (length or width) of a screen area.

type SizeCh

type SizeCh int

SizeCh is an absolute size in screen cells (characters).

type SizeFr

type SizeFr int

SizeFr is a fractional size, or weight. All fractional sizes in a given row or column are summed to be the denominator of the fraction, which the individual size is the numerator, minus any space already consumed by absolute sized areas.

type SizesGroup

type SizesGroup struct {
	Sizes []Size
}

type String

type String string

func (String) Draw

func (s String) Draw(dest BufferSlice)

func (String) Width

func (s String) Width() int

Width calculates the width of the string after normalizing to Canonical Composition form, with the assumption that each rune in that form corrresponds to a single cell on screen.

type Table

type Table struct {
	Rows []TableRow
}

func (*Table) ColumnCount

func (table *Table) ColumnCount() int

func (*Table) ColumnWidths

func (table *Table) ColumnWidths() []int

func (*Table) Draw

func (table *Table) Draw(dest BufferSlice)

type TableCell

type TableCell interface {
	Draw(dest BufferSlice)
	Width() int
}

type TableRow

type TableRow struct {
	Cells []TableCell
	Fg    termbox.Attribute
	Bg    termbox.Attribute
}

func Row

func Row(cells ...TableCell) TableRow

func RowWithAttributes

func RowWithAttributes(fg, bg termbox.Attribute, cells ...TableCell) TableRow

Jump to

Keyboard shortcuts

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