window

package
v1.3.14 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BoldFrameStyle = FrameStyle{
	Top:       []rune{'┏', '┳', '┓'},
	Intersect: []rune{'┣', '╋', '┫'},
	Bottom:    []rune{'┗', '┻', '┛'},
	Middle:    []rune{'┃', '━'},
}
View Source
var DoubleFrameStyle = FrameStyle{
	Top:       []rune{'╔', '╦', '╗'},
	Intersect: []rune{'╠', '╬', '╣'},
	Bottom:    []rune{'╚', '╩', '╝'},
	Middle:    []rune{'║', '═'},
}
View Source
var NormalFrameStyle = FrameStyle{
	Top:       []rune{'┌', '┬', '┐'},
	Intersect: []rune{'├', '┼', '┤'},
	Bottom:    []rune{'└', '┴', '┘'},
	Middle:    []rune{'│', '─'},
}

NormalFrameStyle uses https://en.wikipedia.org/wiki/Box-drawing_characters

Functions

func NewPoint

func NewPoint(x, y func() int) func() Point

func ShrinkAreaTransformer

func ShrinkAreaTransformer(dx, dy int) func(parent Area) Area

func WholeArea

func WholeArea() func(parent Area) Area

Types

type Area

type Area struct {
	X1 int
	Y1 int
	X2 int
	Y2 int
}

func HLine

func HLine(x1, x2, y func() int) Area

func NewArea

func NewArea(x1, y1, x2, y2 int) Area

func Rectangle

func Rectangle(topLeft func() Point, rightBottom func() Point) Area

func VLine

func VLine(y1, y2, x func() int) Area

func ZeroArea

func ZeroArea() Area

func (Area) Add

func (a Area) Add(x1, y1, x2, y2 int) Area

func (Area) Bottom

func (a Area) Bottom(y int) func() int

func (Area) BottomRight

func (a Area) BottomRight() func() Point

func (Area) Copy

func (a Area) Copy() Area

func (Area) Height

func (a Area) Height() int

func (Area) Inside

func (a Area) Inside(x, y int) bool

func (Area) Left

func (a Area) Left(x int) func() int

func (Area) OnBottom

func (a Area) OnBottom() func() int

func (Area) OnLeft

func (a Area) OnLeft() func() int

func (Area) OnRight

func (a Area) OnRight() func() int

func (Area) OnTop

func (a Area) OnTop() func() int

func (Area) Right

func (a Area) Right(x int) func() int

func (Area) Top

func (a Area) Top(y int) func() int

func (Area) TopLeft

func (a Area) TopLeft() func() Point

func (Area) Valid

func (a Area) Valid() bool

func (Area) Width

func (a Area) Width() int

type AreaTransformer

type AreaTransformer func(Area) Area

type ButtonStyle

type ButtonStyle struct {
	TextColor     *Color
	FrameColor    *Color
	FrameStyle    *FrameStyle
	TextAttribute tb.Attribute
}

type Cards

type Cards struct {
	View
	// contains filtered or unexported fields
}

func CreateCards

func CreateCards(area AreaTransformer) *Cards

func (*Cards) BringUp

func (e *Cards) BringUp(id string)

func (*Cards) Children

func (e *Cards) Children() []Drawable

func (*Cards) Disabled

func (e *Cards) Disabled()

func (*Cards) Draw

func (e *Cards) Draw(c *console.Console)

func (*Cards) Enabled

func (e *Cards) Enabled()

func (*Cards) Insert

func (e *Cards) Insert(id string, c Drawable)

func (*Cards) LostFocus

func (e *Cards) LostFocus()

func (*Cards) OnEvent

func (e *Cards) OnEvent(event tb.Event)

func (*Cards) ReceiveFocus

func (e *Cards) ReceiveFocus()

func (*Cards) Remove

func (e *Cards) Remove(id string)

func (*Cards) SetHidden

func (e *Cards) SetHidden()

func (*Cards) SetVisible

func (e *Cards) SetVisible()

type Color

type Color struct {
	FG tb.Attribute
	BG tb.Attribute
}

func NewColor

func NewColor(fg tb.Attribute, bg tb.Attribute) Color

type Drawable

type Drawable interface {
	Draw(c *console.Console)
	OnEvent(event tb.Event)
	OnResize()
	GetArea() Area

	Add(child Drawable) // do not use these 3 function directly.
	SetParent(Drawable)
	Children() []Drawable

	SetVisible() // show/hide element
	SetHidden()
	IsVisible() bool

	ReceiveFocus() // tell element that it's got focus - keyboard events goes to this element
	LostFocus()
	HasFocus() bool

	Disabled() // tell element that it's disabled and no longer receives events from mause or keyboard
	Enabled()
	IsEnabled() bool
}

type FrameStyle

type FrameStyle struct {
	Top       []rune
	Middle    []rune
	Intersect []rune
	Bottom    []rune
}

type Point

type Point struct {
	X int
	Y int
}

type View

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

func (*View) Add

func (e *View) Add(child Drawable)

func (*View) Children

func (e *View) Children() []Drawable

func (*View) Disabled

func (e *View) Disabled()

func (*View) Draw

func (e *View) Draw(_ *console.Console)

func (*View) Enabled

func (e *View) Enabled()

func (*View) GetArea

func (e *View) GetArea() Area

func (*View) GetColor

func (e *View) GetColor() Color

func (*View) HasFocus

func (e *View) HasFocus() bool

func (*View) InitView

func (e *View) InitView(transformer AreaTransformer)

func (*View) IsEnabled

func (e *View) IsEnabled() bool

func (*View) IsVisible

func (e *View) IsVisible() bool

func (*View) LostFocus

func (e *View) LostFocus()

func (*View) OnEvent

func (e *View) OnEvent(_ tb.Event)

func (*View) OnResize

func (e *View) OnResize()

func (*View) ReceiveFocus

func (e *View) ReceiveFocus()

func (*View) SetColor

func (e *View) SetColor(color Color)

func (*View) SetHidden

func (e *View) SetHidden()

func (*View) SetParent

func (e *View) SetParent(parent Drawable)

func (*View) SetTransformer

func (e *View) SetTransformer(transformer AreaTransformer)

func (*View) SetVisible

func (e *View) SetVisible()

type Window

type Window struct {
	View
	C *console.Console
	// contains filtered or unexported fields
}

func New

func New(fg, bg tb.Attribute) *Window

func (*Window) Close

func (e *Window) Close()

func (*Window) DefaultButtonStyle

func (e *Window) DefaultButtonStyle(pressed bool) ButtonStyle

func (*Window) DefaultColor

func (e *Window) DefaultColor() Color

func (*Window) DrawAll

func (e *Window) DrawAll()

func (*Window) GetArea

func (e *Window) GetArea() Area

func (*Window) Run

func (e *Window) Run(exitKey tb.Key)

func (*Window) Size

func (e *Window) Size() (int, int)

func (*Window) Update

func (e *Window) Update(list ...Drawable)

Jump to

Keyboard shortcuts

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