widgets

package
v0.0.0-...-7564203 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LineBorders = Borders{
	Top:         tcell.RuneHLine,
	Bottom:      tcell.RuneHLine,
	Left:        tcell.RuneVLine,
	Right:       tcell.RuneVLine,
	TopLeft:     tcell.RuneULCorner,
	TopRight:    tcell.RuneURCorner,
	BottomLeft:  tcell.RuneLLCorner,
	BottomRight: tcell.RuneLRCorner,
}
View Source
var RoundBorders = Borders{
	Top:         LineBorders.Top,
	Bottom:      LineBorders.Bottom,
	Left:        LineBorders.Left,
	Right:       LineBorders.Right,
	TopLeft:     '╭',
	TopRight:    '╮',
	BottomLeft:  '╰',
	BottomRight: '╯',
}

Functions

func Print

func Print(screen tcell.Screen, x int, y int, style tcell.Style, text string)

Types

type Align

type Align int
const (
	AlignLeft Align = iota
	AlignCenter
	AlignRight
)

type Block

type Block struct {
	Title      string
	TitleAlign Align
	TitleStyle tcell.Style

	Border      bool
	Borders     Borders
	BorderStyle tcell.Style
	// contains filtered or unexported fields
}

Block represents a frame with optional and customizable elements such as borders and a title.

func NewBlock

func NewBlock() *Block

func (*Block) Draw

func (w *Block) Draw(screen tcell.Screen)

func (*Block) InnerSize

func (b *Block) InnerSize() (int, int, int, int)

func (*Block) Key

func (w *Block) Key(event *tcell.EventKey)

func (*Block) SetSize

func (w *Block) SetSize(x int, y int, width int, height int)

func (*Block) Size

func (w *Block) Size() (int, int, int, int)

type Borders

type Borders struct {
	Top         rune
	Bottom      rune
	Left        rune
	Right       rune
	TopLeft     rune
	TopRight    rune
	BottomLeft  rune
	BottomRight rune
}

type List

type List struct {
	*Block
	ItemStyle         tcell.Style
	SelectedItemStyle tcell.Style
	// contains filtered or unexported fields
}

List represents a vertical list of selectable items.

func NewList

func NewList() *List

func (*List) Append

func (l *List) Append(item ListItem)

Append appends an item to the list.

func (*List) Draw

func (w *List) Draw(screen tcell.Screen)

func (*List) Key

func (w *List) Key(event *tcell.EventKey)

func (*List) Remove

func (l *List) Remove(item ListItem)

Remove removes an item from the list.

type ListItem

type ListItem interface {
	String() string
}

type Widget

type Widget interface {
	Size() (x int, y int, width int, height int)
	SetSize(x int, y int, width int, height int)

	Key(event *tcell.EventKey)
	Draw(screen tcell.Screen)
}

Widget is the base interface for all widgets.

Jump to

Keyboard shortcuts

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