base

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Control

type Control interface {
	// Traverse is register sub controls to FocusManager by the order by focus.
	Traverse(fm *FocusManager)

	// Update is prepare for draw to terminal.
	Update()

	// Draw is rendering Control as text, to terminal.
	Draw(g *Graphics)

	// MinimumSize is provide size of needs to print Control.
	MinimumSize(width int, height int) (Width int, Height int)

	// Move is move a Control to specified position.
	Move(x int, y int)

	// Layout is relayout sub controls within specified size.
	Layout(w int, h int)

	// IsFlexibleWidth is returns true if Control is flexible on horizontal.
	IsFlexibleWidth() bool

	// IsFlexibleHeight is returns true if Control is flexible on vertical.
	IsFlexibleHeight() bool
}

Control is graphical unit for compose a screen. Control can be contain another Control, but no distinction to interface by the see outer.

type Event

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

Event is notify a terminal updates.

func (*Event) GetRuntime

func (ev *Event) GetRuntime() Runtime

GetRuntime returns Runtime. each controls is able to access to stack of control through this object. in example, use when needs to controls show modal another controls.

func (*Event) GetSource

func (ev *Event) GetSource() tcell.Event

GetSource returns raw event of tcell.

func (*Event) Init

func (ev *Event) Init(runtime Runtime, source tcell.Event)

Init is initialize Event.

type FocusManager

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

FocusManager is manage focus order in controls.

func (*FocusManager) FocusNext

func (fm *FocusManager) FocusNext()

FocusNext is move focus to next.

func (*FocusManager) FocusPrev

func (fm *FocusManager) FocusPrev()

FocusPrev is move focus to previous.

func (*FocusManager) Grab

func (fm *FocusManager) Grab()

Grab is try to activate focus on current object.

func (*FocusManager) Handle

func (fm *FocusManager) Handle(ev Event)

Handle is process the event by focused control.

func (*FocusManager) Init

func (fm *FocusManager) Init()

Init is initialize FocusManager.

func (*FocusManager) Register

func (fm *FocusManager) Register(t Focusable)

Register is Focusable entry add to table.

func (*FocusManager) Traverse

func (fm *FocusManager) Traverse(ctrl Control)

Traverse is add all controls to table by the order of focus.

type Focusable

type Focusable interface {
	Handle(ev Event)
	Focus(on bool)
}

Focusable has distinction of focus on and off, and capture a Event.

type FocusableTree

type FocusableTree interface {
	Focusable

	// SubFocusFirst is focus to first children.
	SubFocusFirst()

	// SubFocusPrev is focus to previous children.
	SubFocusPrev() bool

	// SubFocusNext is focus to next children.
	SubFocusNext() bool

	// SubFocusLast is focus to last children.
	SubFocusLast()
}

FocusableTree is manage focus to sub controls. if implemented this interface, parent controls stealing event, but movable focus to each children. parent controls can be delegate event to children as needed.

type Graphics

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

Graphics is abstractions to operation for terminal. Graphics has bitmap for avoiding overdraw, also used to hide overwrap region by above layer.

func (*Graphics) Clear

func (g *Graphics) Clear()

Clear is clear a bitmap.

func (*Graphics) Draw

func (g *Graphics) Draw(x int, y int, primary rune, combine []rune, style tcell.Style)

Draw is set a character to specified cell, if not already settled.

func (*Graphics) Empty

func (g *Graphics) Empty(x int, y int)

Empty is mark the specified cell as used.

func (*Graphics) EmptyRange

func (g *Graphics) EmptyRange(x int, y int, width int, height int)

EmptyRange is mark the cells within specified range as used.

func (*Graphics) ForceDraw

func (g *Graphics) ForceDraw(x int, y int, primary rune, combine []rune, style tcell.Style)

ForceDraw is set a character to specified cell.

func (*Graphics) Init

func (g *Graphics) Init(screen tcell.Screen)

Init is initialize Graphics.

func (*Graphics) Resize

func (g *Graphics) Resize(width int, height int)

Resize is restructure bitmap.

type Layer

type Layer struct {
	Control         Control
	ClearBackground bool
	OnPop           func(returnCode int)
}

Layer is stackable object.

type Runtime

type Runtime interface {
	Stackable

	// BeginBackground is increment number of background tasks.
	// Runtime is ignore events while zero than bigger of number of background tasks.
	BeginBackground()

	// EndBackground is decrement number of background tasks.
	EndBackground()

	// Repaint is do request rerender terminal.
	Repaint()
}

Runtime is provide interface to for driving application. in this, contain supports stack of controls. controls able to erase self from stack through this Runtime object.

type Stackable

type Stackable interface {
	// Push is stack a layer.
	Push(layer Layer)

	// Pop is remove layer from stack top.
	Pop(returnCode int)
}

Stackable is stack of layer. by doing layers draw by index order, to represent controls overlay.

Jump to

Keyboard shortcuts

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