tuikit

package
v0.0.0-...-e8241b2 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2014 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MaxFps = 40
)

Variables

View Source
var (

	// Event polling channel
	Events chan Event = make(chan Event, 20)
)

Functions

func Close

func Close()

func Init

func Init() error

func SetFirstResponder

func SetFirstResponder(eh Responder)

func SetPainter

func SetPainter(p Painter)

func StartEventPolling

func StartEventPolling()

func StopEventPolling

func StopEventPolling()

func Sync

func Sync() error

Types

type AnchorEdge

type AnchorEdge uint
const (
	AnchorEdgeTop AnchorEdge = iota
	AnchorEdgeBottom
	AnchorEdgeLeft
	AnchorEdgeRight
)

type AnchoringView

type AnchoringView struct {
	*BaseView
	// contains filtered or unexported fields
}

func NewAnchoringView

func NewAnchoringView(
	anchorEdge AnchorEdge,
	anchorWidth int,
	anchor, main Painter,
) *AnchoringView

type BaseView

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

func NewBaseView

func NewBaseView() *BaseView

func (*BaseView) AttachChild

func (v *BaseView) AttachChild(child Painter, rect Rect)

func (*BaseView) ChildNeedsPaint

func (v *BaseView) ChildNeedsPaint(child Painter)

func (*BaseView) DesiredMinSize

func (v *BaseView) DesiredMinSize() Size

func (*BaseView) DetachChild

func (v *BaseView) DetachChild(child Painter)

func (*BaseView) NeedPaint

func (v *BaseView) NeedPaint()

func (*BaseView) NeedResize

func (v *BaseView) NeedResize()

func (*BaseView) PaintTo

func (v *BaseView) PaintTo(buffer *tulib.Buffer, rect Rect) error

BaseView.PaintTo does not paint anything itself, but it delegates painting to its children

func (*BaseView) SetPaintSubscriber

func (v *BaseView) SetPaintSubscriber(cb func())

func (*BaseView) SetResizeSubscriber

func (v *BaseView) SetResizeSubscriber(cb func())

func (*BaseView) SetUpdateChildrenRect

func (v *BaseView) SetUpdateChildrenRect(cb func(Rect) error)

type BlankView

type BlankView struct {
	*FillerView
}

func NewBlankView

func NewBlankView() *BlankView

type Event

type Event struct {
	*termbox.Event
	Handled bool
}

type FillerView

type FillerView struct {
	*BaseView
	// contains filtered or unexported fields
}

func NewFillerView

func NewFillerView(proto termbox.Cell) *FillerView

func (*FillerView) PaintTo

func (v *FillerView) PaintTo(buffer *tulib.Buffer, rect Rect) error

type FpsCounter

type FpsCounter struct {
	// The channel on which ticks are sent from client code
	Ticks chan<- struct{}
	// Client code receives fps values from this channel
	Fps <-chan float64
}

func NewFpsCounter

func NewFpsCounter(timeInterval time.Duration) *FpsCounter

type LinearLayout

type LinearLayout struct {
	*BaseView
	// contains filtered or unexported fields
}

func NewLinearLayout

func NewLinearLayout(children []Painter) *LinearLayout

type Orientation

type Orientation uint8
const (
	OrientationVertical Orientation = iota
	OrientationHorizontal
)

type Painter

type Painter interface {
	PaintTo(buffer *tulib.Buffer, rect Rect) error
	DesiredMinSize() Size
	SetPaintSubscriber(cb func())
	SetResizeSubscriber(cb func())
}

type Point

type Point struct {
	X, Y int
}

A Point is an X, Y coordinate pair. The axes increase right and down.

var PointZero Point

PointZero is the zero Point.

func NewPoint

func NewPoint(x, y int) Point

NewPoint is shorthand for Point{X, Y}.

func (Point) Add

func (p Point) Add(q Point) Point

Add returns the vector p+q.

func (Point) Div

func (p Point) Div(k int) Point

Div returns the vector p/k.

func (Point) Eq

func (p Point) Eq(q Point) bool

Eq reports whether p and q are equal.

func (Point) In

func (p Point) In(r Rect) bool

In reports whether p is in r.

func (Point) Mul

func (p Point) Mul(k int) Point

Mul returns the vector p*k.

func (Point) String

func (p Point) String() string

String returns a string representation of p like "(x3,y4)".

func (Point) Sub

func (p Point) Sub(q Point) Point

Sub returns the vector p-q.

type ProgressSpinner

type ProgressSpinner struct {
	*TextView
	// contains filtered or unexported fields
}

func NewProgressSpinner

func NewProgressSpinner() *ProgressSpinner

type Rect

type Rect struct {
	Point
	Size
}

A Rect is the composition of an origin Point and a Size.

var RectZero Rect

RectZero is the zero Rect.

func NewRect

func NewRect(x, y, w, h int) Rect

NewRect is shorthand for Rect{Point{X, Y}, Size{Width, Height}}.

func NewRectFromTulib

func NewRectFromTulib(rect tulib.Rect) Rect

NewRectFromTulib creates a Rect equal to rect.

func (Rect) Add

func (r Rect) Add(p Point) Rect

Add returns the rectangle r translated by p.

func (Rect) Empty

func (r Rect) Empty() bool

Empty reports whether the rectangle contains no points.

func (Rect) Eq

func (r Rect) Eq(s Rect) bool

Eq reports whether r and s are equal.

func (Rect) In

func (r Rect) In(s Rect) bool

In reports whether every point in r is in s.

func (Rect) Inset

func (r Rect) Inset(n int) Rect

Inset returns the rectangle r inset by n, which may be negative. If either of r's dimensions is less than 2*n then an empty rectangle near the center of r will be returned.

func (Rect) Intersect

func (r Rect) Intersect(s Rect) Rect

Intersect returns the largest rectangle contained by both r and s. If the two rectangles do not overlap then the zero rectangle will be returned.

func (Rect) Max

func (r Rect) Max() Point

Max returns the most bottom-right Point still inside r.

func (Rect) Overlaps

func (r Rect) Overlaps(s Rect) bool

Overlaps reports whether r and s have a non-empty intersection.

func (Rect) String

func (r Rect) String() string

String returns a string representation of r like "(x3,y4)-(w6,h5)".

func (Rect) Sub

func (r Rect) Sub(p Point) Rect

Sub returns the rectangle r translated by -p.

func (Rect) TulibRect

func (r Rect) TulibRect() tulib.Rect

TulibRect returns r as a tulib.Rect.

func (Rect) Union

func (r Rect) Union(s Rect) Rect

Union returns the smallest rectangle that contains both r and s.

func (Rect) Valid

func (r Rect) Valid() bool

Valid reports whether r is a valid Rect.

type Responder

type Responder interface {
	// HandleEvent should set Event.Handled to true if it was
	// handled so that the main loop knows to ignores it
	HandleEvent(*Event)
	SetCursorPainter(cb func(Point))
}

type Signal

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

func (*Signal) Attach

func (s *Signal) Attach(handler SignalHandler) int

func (*Signal) Detach

func (s *Signal) Detach(handle int)

type SignalHandler

type SignalHandler func()

type SignalPublisher

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

func (*SignalPublisher) Publish

func (p *SignalPublisher) Publish()

func (*SignalPublisher) Signal

func (p *SignalPublisher) Signal() *Signal

type Size

type Size struct {
	Width, Height int
}

A Size is a Width, Height pair.

var SizeZero Size

SizeZero is the zero Size.

func NewSize

func NewSize(w, h int) Size

NewSize is shorthand for Size{Width, Height}.

func (Size) Empty

func (s Size) Empty() bool

Empty reports whether the size contains no points.

func (Size) Eq

func (s Size) Eq(t Size) bool

Eq reports whether s and t are equal.

func (Size) String

func (s Size) String() string

String returns a string representation of s like "(w3,h4)".

type SplitLayout

type SplitLayout struct {
	*BaseView
	// contains filtered or unexported fields
}

func NewSplitLayout

func NewSplitLayout(split1, split2 Painter) *SplitLayout

func (*SplitLayout) SetOrientation

func (l *SplitLayout) SetOrientation(orientation Orientation)

func (*SplitLayout) SetRatio

func (l *SplitLayout) SetRatio(ratio float32)

type TextView

type TextView struct {
	*BaseView
	// contains filtered or unexported fields
}

func NewTextView

func NewTextView() *TextView

func (*TextView) PaintTo

func (v *TextView) PaintTo(buffer *tulib.Buffer, rect Rect) error

func (*TextView) SetParams

func (v *TextView) SetParams(params *tulib.LabelParams)

func (*TextView) SetText

func (v *TextView) SetText(text string)

type TextWidget

type TextWidget struct {
	*TextView
	Model TextWidgetModel
	// contains filtered or unexported fields
}

func NewTextWidget

func NewTextWidget() *TextWidget

func (*TextWidget) HandleEvent

func (v *TextWidget) HandleEvent(ev *Event)

func (*TextWidget) PaintTo

func (v *TextWidget) PaintTo(buffer *tulib.Buffer, rect Rect) error

func (*TextWidget) SetCursorPainter

func (v *TextWidget) SetCursorPainter(cb func(Point))

type TextWidgetModel

type TextWidgetModel interface {
	GetText() string
	SetText(str string)

	InputAccepted()
	InputCancelled()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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