tui

package module
v0.0.0-...-fb62bfe Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

README

tui

terminal ui library for golang

Documentation

Index

Constants

View Source
const (
	AlignmentNone = 1 << iota
	AlignmentCenter
	AlignmentLeft
	AlignmentRight
	AlignmentTop
	AlignmentBottom
)
View Source
const (
	SizeAuto = iota
	SizeAbsolute
	SizeRelative
)
View Source
const (
	Percent = 0.01
)

Variables

View Source
var LayoutDefault = Layout{}
View Source
var LogLevel = logrus.PanicLevel
View Source
var Logger *logrus.Logger
View Source
var TextStyleDefault = tcell.StyleDefault

Functions

func DimInt

func DimInt(x, y int) int

func DrawBorder

func DrawBorder(c Canvas, style TextStyle)

=========================================

func LogEntry

func LogEntry() *logrus.Entry

func SetLogger

func SetLogger(l *logrus.Logger)

Types

type Alignment

type Alignment uint8

type App

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

func NewApp

func NewApp() *App

func NewAppWithCanvas

func NewAppWithCanvas(canvas *SimCanvas) *App

func (*App) AddEventListener

func (app *App) AddEventListener(fn EventListener)

func (*App) HandleEvent

func (app *App) HandleEvent() Event

func (*App) Run

func (app *App) Run()

func (*App) SetRootLayer

func (app *App) SetRootLayer(layer Layer)

func (*App) Shutdown

func (app *App) Shutdown()

func (*App) Update

func (app *App) Update()

func (*App) WaitForShutdown

func (app *App) WaitForShutdown()

type BaseLayer

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

func NewBaseLayer

func NewBaseLayer() *BaseLayer

=========== BaseLayout ====================

func (*BaseLayer) AddView

func (l *BaseLayer) AddView(v View)

func (*BaseLayer) Layout

func (l *BaseLayer) Layout() Layout

func (*BaseLayer) Resize

func (l *BaseLayer) Resize(x, y, width, height int)

TODO confirm if resize is needed

func (*BaseLayer) SetCanvas

func (l *BaseLayer) SetCanvas(canvas Canvas)

func (*BaseLayer) SetLayout

func (l *BaseLayer) SetLayout(layout Layout) *BaseLayer

func (*BaseLayer) Size

func (l *BaseLayer) Size() (width, height int)

type BaseList

type BaseList struct {
	BaseWidget
	// contains filtered or unexported fields
}

func NewList

func NewList(
	defaultStyle TextStyle,
	selStyle TextStyle,
	border bool,
) *BaseList

func (*BaseList) AddCells

func (l *BaseList) AddCells(cells ...Cell)

func (*BaseList) Backward

func (l *BaseList) Backward() bool

func (*BaseList) Clear

func (l *BaseList) Clear()

func (*BaseList) CurrentCell

func (l *BaseList) CurrentCell() (int, Cell)

func (*BaseList) Forward

func (l *BaseList) Forward() bool

func (*BaseList) HandleEvent

func (l *BaseList) HandleEvent(ev Event) error

func (*BaseList) MoveTo

func (l *BaseList) MoveTo(index int) bool

func (*BaseList) OnKeyEvent

func (l *BaseList) OnKeyEvent(fn KeyFn)

func (*BaseList) Resize

func (l *BaseList) Resize(x, y, width, height int)

func (*BaseList) SetCanvas

func (l *BaseList) SetCanvas(canvas Canvas)

type BaseWidget

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

func (*BaseWidget) HandleEvent

func (b *BaseWidget) HandleEvent(ev Event) error

func (*BaseWidget) Hidden

func (b *BaseWidget) Hidden(h bool)

func (*BaseWidget) Layout

func (b *BaseWidget) Layout() Layout

func (*BaseWidget) Refresh

func (b *BaseWidget) Refresh()

func (*BaseWidget) Resize

func (b *BaseWidget) Resize(x, y, width, height int)

func (*BaseWidget) SetCanvas

func (b *BaseWidget) SetCanvas(v Canvas)

func (*BaseWidget) SetLayout

func (b *BaseWidget) SetLayout(l Layout) *BaseWidget

func (*BaseWidget) SetStyle

func (b *BaseWidget) SetStyle(s TextStyle) *BaseWidget

func (*BaseWidget) Size

func (b *BaseWidget) Size() (int, int)

func (*BaseWidget) Style

func (b *BaseWidget) Style() TextStyle

type Canvas

type Canvas interface {
	Id() string
	SetContent(x, y int, r rune, comb []rune, sytle TextStyle)
	SetString(x, y int, str string, style TextStyle) (width int)
	ShowCursor(x, y int)
	HideCursor()
	Clear()
	Fill(TextStyle)
	Resize(x, y, width, height int)
	Refresh()
	Update()
	Size() (width, height int)
}

type Cell

type Cell interface {
	Name() string
	Value() interface{}
	TextStyle() TextStyle
	SetName(string)
	SetValue(interface{})
	SetTextStyle(TextStyle)
	Hidden(bool)
	Refresh()

	SetCanvas(Canvas)
	Resize(x, y, width, height int)
}

func NewCell

func NewCell() Cell

type Event

type Event = tcell.Event

type EventError

type EventError = tcell.EventError

type EventInterrupt

type EventInterrupt = tcell.EventInterrupt

type EventKey

type EventKey = tcell.EventKey

type EventListener

type EventListener func(Event) error

type EventPaste

type EventPaste = tcell.EventPaste

type EventResize

type EventResize = tcell.EventResize

type EventTime

type EventTime = tcell.EventTime

type HorizontalLayer

type HorizontalLayer struct {
	BaseLayer
}

func NewHorizontalLayout

func NewHorizontalLayout() *HorizontalLayer

=============== Horizontal Layout =======================

type Key

type Key = tcell.Key

type KeyFn

type KeyFn func(*EventKey, List) error

type Label

type Label struct {
	BaseWidget
	// contains filtered or unexported fields
}

func NewLabel

func NewLabel(text string, style TextStyle, width Size) *Label

func (*Label) GetText

func (t *Label) GetText() string

func (*Label) HandleEvent

func (t *Label) HandleEvent(ev Event) error

func (*Label) Layout

func (l *Label) Layout() Layout

func (*Label) Refresh

func (l *Label) Refresh()

func (*Label) Resize

func (l *Label) Resize(x, y, width, height int)

func (*Label) SetText

func (t *Label) SetText(text string)

type Layer

type Layer interface {
	View
	AddView(View)
}

type Layout

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

func (Layout) Height

func (l Layout) Height() Size

func (Layout) SetHeight

func (l Layout) SetHeight(h Size) Layout

func (Layout) SetWidth

func (l Layout) SetWidth(w Size) Layout

func (Layout) Width

func (l Layout) Width() Size

type List

type List interface {
	Widget

	AddCells(cells ...Cell)
	Clear()
	Forward() bool
	Backward() bool
	MoveTo(index int) bool
	CurrentCell() (index int, cell Cell)
	OnKeyEvent(KeyFn)
}

type LogicCanvas

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

func NewLogicCanvas

func NewLogicCanvas(parent Canvas) *LogicCanvas

============ LogicView ==============

func (*LogicCanvas) Clear

func (v *LogicCanvas) Clear()

func (*LogicCanvas) Fill

func (v *LogicCanvas) Fill(style TextStyle)

func (*LogicCanvas) HideCursor

func (s *LogicCanvas) HideCursor()

func (*LogicCanvas) Id

func (v *LogicCanvas) Id() string

func (*LogicCanvas) Refresh

func (v *LogicCanvas) Refresh()

func (*LogicCanvas) Resize

func (v *LogicCanvas) Resize(x, y, width, height int)

func (*LogicCanvas) SetContent

func (v *LogicCanvas) SetContent(
	x, y int, r rune, comb []rune, style TextStyle,
)

func (*LogicCanvas) SetString

func (v *LogicCanvas) SetString(x, y int, str string, style TextStyle) int

func (*LogicCanvas) ShowCursor

func (v *LogicCanvas) ShowCursor(x, y int)

func (*LogicCanvas) Size

func (v *LogicCanvas) Size() (int, int)

func (*LogicCanvas) Update

func (v *LogicCanvas) Update()

type ModMask

type ModMask = tcell.ModMask

type Padding

type Padding struct {
	Left   int
	Right  int
	Top    int
	Bottom int
}

type SimCanvas

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

func NewSimCanvas

func NewSimCanvas() *SimCanvas

==================== SimView ====================

func (*SimCanvas) Clear

func (s *SimCanvas) Clear()

func (*SimCanvas) Fill

func (s *SimCanvas) Fill(style TextStyle)

func (*SimCanvas) GetContent

func (s *SimCanvas) GetContent(x, y int) (rune, []rune, TextStyle, int)

func (*SimCanvas) HideCursor

func (s *SimCanvas) HideCursor()

func (*SimCanvas) Id

func (s *SimCanvas) Id() string

func (*SimCanvas) InjectKey

func (s *SimCanvas) InjectKey(key Key, r rune, mod ModMask)

func (*SimCanvas) Refresh

func (s *SimCanvas) Refresh()

func (*SimCanvas) Resize

func (s *SimCanvas) Resize(x, y, width, height int)

func (*SimCanvas) SetContent

func (s *SimCanvas) SetContent(x, y int, r rune, comb []rune, style TextStyle)

func (*SimCanvas) SetParentView

func (s *SimCanvas) SetParentView(view Canvas)

func (*SimCanvas) SetSize

func (s *SimCanvas) SetSize(width, height int)

func (*SimCanvas) SetString

func (s *SimCanvas) SetString(x, y int, str string, style TextStyle) int

func (*SimCanvas) ShowCursor

func (s *SimCanvas) ShowCursor(x, y int)

func (*SimCanvas) Size

func (s *SimCanvas) Size() (int, int)

func (*SimCanvas) Update

func (s *SimCanvas) Update()

type SimpleCell

type SimpleCell struct {
	Label
	// contains filtered or unexported fields
}

func (*SimpleCell) Name

func (c *SimpleCell) Name() string

func (*SimpleCell) SetName

func (c *SimpleCell) SetName(name string)

func (*SimpleCell) SetTextStyle

func (c *SimpleCell) SetTextStyle(style TextStyle)

func (*SimpleCell) SetValue

func (c *SimpleCell) SetValue(value interface{})

func (*SimpleCell) TextStyle

func (c *SimpleCell) TextStyle() TextStyle

func (*SimpleCell) Value

func (c *SimpleCell) Value() interface{}

type Size

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

func AbsoluteSize

func AbsoluteSize(v int) Size

func AutoSize

func AutoSize() Size

func RelativeSize

func RelativeSize(v int) Size

func (Size) Type

func (s Size) Type() SizeType

func (Size) Value

func (s Size) Value() int

type SizeType

type SizeType uint8

type TextStyle

type TextStyle = tcell.Style

type VerticalLayer

type VerticalLayer struct {
	BaseLayer
}

func NewVerticalLayout

func NewVerticalLayout() *VerticalLayer

============== VerticalLayout =================

type View

type View interface {
	SetCanvas(Canvas)
	Resize(x, y, width, height int)
	Size() (width, height int)
	Layout() Layout
}

type Widget

type Widget interface {
	View
	HandleEvent(Event) error
}

Directories

Path Synopsis
internal
vc

Jump to

Keyboard shortcuts

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