ui

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HAlignStart = byte(iota)
	HAlignCenter
	HAlignEnd
	VAlignStart
	VAlignCenter
	VAlignEnd
)

Variables

View Source
var BoardHeight = len(boardOutline)

BoardHeight is height of BoardOutline

View Source
var BoardWidth = len(boardOutline[0])

BoardWidth is width of BoardOutline

Functions

This section is empty.

Types

type BoardWidget

type BoardWidget struct {
	Board     board.Board
	CursorPos board.Point2
	Theme     theme.BoardTheme
}

BoardWidget is an ui widget for sudoku board representation

func (*BoardWidget) Draw

func (bw *BoardWidget) Draw(context Context, x, y int)

Draw draws the board widget to the terminal

func (*BoardWidget) Height

func (bw *BoardWidget) Height() int

Height returns the height of the board widget

func (*BoardWidget) Width

func (bw *BoardWidget) Width() int

Width returns the width of the board widget

type BoxWidget

type BoxWidget struct {
	Child Widget

	HAlign    byte
	MinWidth  int
	MinHeight int

	PaddingTop    int
	PaddingBottom int
	PaddingLeft   int
	PaddingRight  int

	Fill  bool
	Color theme.ColorPair
}

BoxWidget is an simple ui wrapper for other widgets

func (*BoxWidget) Draw

func (bw *BoxWidget) Draw(context Context, x, y int)

Draw draws the box widget to the terminal

func (*BoxWidget) Height

func (bw *BoxWidget) Height() int

Height returns height of the box widget

func (*BoxWidget) Width

func (bw *BoxWidget) Width() int

Width returns width of the box widget

type Client

type Client interface {
	// Start starts the client
	Start() error
	// Stop stops the client
	Stop()

	// Size returns width and height of client screen
	Size() (int, int)

	// OnResize takes a function to run when the screen resized
	OnResize(func(width, height int))
	// OnKeyPress takes a function to run when a key pressed
	OnKeyPress(func(key string))

	// Draw draws the given widget at the given position
	Draw(x, y int, widget Widget)
	// Draw draws the given widget at the center of the screen
	DrawCenter(widget Widget)
	// Draw draws the given widget at the up right corner of the screen
	DrawAligned(widget Widget, alignments ...byte)

	// Context returns context to manipulate the screen
	Context() Context
}

func NewTCellClient

func NewTCellClient() (Client, error)

type Context

type Context interface {
	// StyleFG sets the current foreground color
	StyleFG(color string)
	// StyleBG sets the current background color
	StyleBG(color string)

	// SetContent draws the given char to the given position
	// with the current style
	SetContent(x, y int, char rune)

	// Show makes all content changes visible
	Show()

	// Clear clears the screen
	Clear()
}
type MenuWidget struct {
	Options     []string
	CursorIndex int

	HAlign   byte
	MinWidth int

	Color  theme.ColorPair
	Cursor theme.ColorPair
	// contains filtered or unexported fields
}

MenuWidget is an ui widget for menu representations

func (mw *MenuWidget) Draw(context Context, x, y int)

Draw draws the menu widget to the terminal

func (mw *MenuWidget) Height() int

Height returns the height of the menu widget

func (mw *MenuWidget) Width() int

Width returns the width of the menu widget

type NullWidget

type NullWidget struct{}

NullWidget is an nil replacement for widget interface

func (*NullWidget) Draw

func (*NullWidget) Draw(context Context, x, y int)

Draw does nothing

func (*NullWidget) Height

func (*NullWidget) Height() int

Height returns 0

func (*NullWidget) Width

func (*NullWidget) Width() int

Width returns 0

type TextWidget

type TextWidget struct {
	String string

	AlignCenter bool
	AlignRight  bool

	Color theme.ColorPair
	// contains filtered or unexported fields
}

TextWidget is an ui widget for texts

func (*TextWidget) Draw

func (tw *TextWidget) Draw(context Context, x, y int)

Draw draws the text to the terminal

func (*TextWidget) Height

func (tw *TextWidget) Height() int

Height returns number of lines

func (*TextWidget) Width

func (tw *TextWidget) Width() int

Width returns the width of the longest text line

type Widget

type Widget interface {
	Draw(context Context, x, y int)
	Width() int
	Height() int
}

Widget is representation for an ui item

Jump to

Keyboard shortcuts

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