terminal

package
v0.0.0-...-2a19efb Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KEY_QUIT   = 'q'
	KEY_CYCLE  = 'c'
	KEY_HSPLIT = 'x'
	KEY_VSPLIT = 'z'
	KEY_ADDSIB = 's'
)
View Source
const (
	BOLD    = 1
	NO_BOLD = 22

	UNDERLINE    = 4
	NO_UNDERLINE = 24

	NEGATIVE = 7
	POSITIVE = 27

	FG_BLACK   = 30
	FG_RED     = 31
	FG_GREEN   = 32
	FG_YELLOW  = 33
	FG_BLUE    = 34
	FG_MAGENTA = 35
	FG_CYAN    = 36
	FG_WHITE   = 37
	FG_EXT     = 38
	FG_DEFAULT = 39

	BG_BLACK   = 40
	BG_RED     = 41
	BG_GREEN   = 42
	BG_YELLOW  = 43
	BG_BLUE    = 44
	BG_MAGENTA = 45
	BG_CYAN    = 46
	BG_WHITE   = 47
	BG_EXT     = 48
	BG_DEFAULT = 49

	FG_BLACK_B   = 90
	FG_RED_B     = 91
	FG_GREEN_B   = 92
	FG_YELLOW_B  = 93
	FG_BLUE_B    = 94
	FG_MAGENTA_B = 95
	FG_CYAN_B    = 96
	FG_WHITE_B   = 97

	BG_BLACK_B   = 100
	BG_RED_B     = 101
	BG_GREEN_B   = 102
	BG_YELLOW_B  = 103
	BG_BLUE_B    = 104
	BG_MAGENTA_B = 105
	BG_CYAN_B    = 106
	BG_WHITE_B   = 107
)
View Source
const (
	ESC      = '\x1b'
	BOX_S_H  = '─'
	BOX_S_V  = '│'
	BOX_S_TL = '┌'
	BOX_S_TR = '┐'
	BOX_S_BL = '└'
	BOX_S_BR = '┘'
)
View Source
const (
	LINE_START = '├'
	LINE_MID   = '─'
	LINE_END   = '┤'

	CURSOR_START = '┠'
	CURSOR_MID   = '┼'
	CURSOR_END   = '┨'
)
View Source
const (
	KEY_DOWN   = 'j'
	KEY_UP     = 'k'
	KEY_SELECT = '\x0D'
)

Variables

This section is empty.

Functions

func BG_RGB

func BG_RGB(r int, g int, b int) (int, int, int, int, int)

func DrawInfo

func DrawInfo(builder *CommandBuilder, source audio.Metadata, lines []int, pos int64, dims area)

func DrawMetadata

func DrawMetadata(builder *CommandBuilder, source audio.Metadata, lines []int, dims area)

func DrawQueue

func DrawQueue(builder *CommandBuilder, queue []audio.Metadata, curIdx, maxIdxLen, w, h int)

func DrawTrack

func DrawTrack(builder *CommandBuilder, source audio.Metadata, pos int64, trackHeight int, dims area)

func FG_RGB

func FG_RGB(r int, g int, b int) (int, int, int, int, int)

func GetWindowDimensionsFunc

func GetWindowDimensionsFunc(commandChan chan<- Command, dimChan <-chan int) func() (int, int)

func ReadTo

func ReadTo(b byte) string

Types

type BaseWindow

type BaseWindow struct {
	Box
	// contains filtered or unexported fields
}

func (*BaseWindow) Deselect

func (win *BaseWindow) Deselect()

func (*BaseWindow) Encapsulate

func (win *BaseWindow) Encapsulate(parentCreator parentWindowCreator)

func (*BaseWindow) Exec

func (win *BaseWindow) Exec(command Command)

func (*BaseWindow) GetChildren

func (win *BaseWindow) GetChildren() []Window

func (*BaseWindow) GetCommandBuilder

func (win *BaseWindow) GetCommandBuilder() *CommandBuilder

func (*BaseWindow) GetDimensions

func (win *BaseWindow) GetDimensions() (w int, h int)

func (*BaseWindow) GetParent

func (win *BaseWindow) GetParent() ParentWindow

func (*BaseWindow) Resize

func (win *BaseWindow) Resize(b Box)

func (*BaseWindow) ResolveInput

func (win *BaseWindow) ResolveInput(b byte) bool

func (*BaseWindow) Select

func (win *BaseWindow) Select()

func (*BaseWindow) SetController

func (win *BaseWindow) SetController(c Controller)

func (*BaseWindow) SetSelectable

func (win *BaseWindow) SetSelectable(b bool)

func (*BaseWindow) WithinBounds

func (win *BaseWindow) WithinBounds(box Box) bool

type BaseWindowController

type BaseWindowController struct {
	ControllerChannels
	// contains filtered or unexported fields
}

func NewBaseWindowController

func NewBaseWindowController(loop func(func() *CommandBuilder, ControllerChannels), inputRange string) *BaseWindowController

func (*BaseWindowController) Deselect

func (c *BaseWindowController) Deselect()

func (*BaseWindowController) Init

func (c *BaseWindowController) Init(builderFactory func() *CommandBuilder, dimensions area, selected bool)

func (*BaseWindowController) Resize

func (c *BaseWindowController) Resize(w, h int)

func (*BaseWindowController) ResolveInput

func (c *BaseWindowController) ResolveInput(b byte) bool

func (*BaseWindowController) Select

func (c *BaseWindowController) Select()

func (*BaseWindowController) Terminate

func (c *BaseWindowController) Terminate()

type BorderedWindowController

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

func (*BorderedWindowController) Deselect

func (b *BorderedWindowController) Deselect()

func (*BorderedWindowController) Draw

func (b *BorderedWindowController) Draw()

func (*BorderedWindowController) Init

func (b *BorderedWindowController) Init(builderFactory func() *CommandBuilder, dimensions area, selected bool)

func (*BorderedWindowController) Resize

func (b *BorderedWindowController) Resize(w, h int)

func (*BorderedWindowController) ResolveInput

func (b *BorderedWindowController) ResolveInput(by byte) bool

func (*BorderedWindowController) Select

func (b *BorderedWindowController) Select()

func (*BorderedWindowController) Terminate

func (b *BorderedWindowController) Terminate()

type Box

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

type Command

type Command string

type CommandBuilder

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

func NewCommand

func NewCommand() *CommandBuilder

func WriteQueueLine

func WriteQueueLine(builder *CommandBuilder, idx int, maxIdx int, metadata audio.Metadata, maxW int, highlighted bool) *CommandBuilder

func (*CommandBuilder) BuildCommand

func (cb *CommandBuilder) BuildCommand() Command

func (*CommandBuilder) ChangeDimensions

func (cb *CommandBuilder) ChangeDimensions(w, h uint) *CommandBuilder

func (*CommandBuilder) Clear

func (cb *CommandBuilder) Clear() *CommandBuilder

func (*CommandBuilder) ClearGraphicsRendition

func (cb *CommandBuilder) ClearGraphicsRendition() *CommandBuilder

func (*CommandBuilder) DrawBox

func (cb *CommandBuilder) DrawBox(box Box, title string, highlighted bool) *CommandBuilder

func (*CommandBuilder) Exec

func (cb *CommandBuilder) Exec()

func (*CommandBuilder) MoveLines

func (cb *CommandBuilder) MoveLines(lines int) *CommandBuilder

func (*CommandBuilder) MoveTo

func (cb *CommandBuilder) MoveTo(x uint, y uint) *CommandBuilder

func (*CommandBuilder) Offset

func (cb *CommandBuilder) Offset(x int, y int) *CommandBuilder

func (*CommandBuilder) PermaOffset

func (cb *CommandBuilder) PermaOffset(x, y uint) *CommandBuilder

func (*CommandBuilder) SelectGraphicsRendition

func (cb *CommandBuilder) SelectGraphicsRendition(formatOptions ...int) *CommandBuilder

func (*CommandBuilder) Write

func (cb *CommandBuilder) Write(text ...any) *CommandBuilder

type ContainerWindow

type ContainerWindow struct {
	BaseWindow
	// contains filtered or unexported fields
}

func (*ContainerWindow) AddChild

func (win *ContainerWindow) AddChild(child Window)

func (*ContainerWindow) GetChildren

func (win *ContainerWindow) GetChildren() []Window

func (*ContainerWindow) NewChild

func (win *ContainerWindow) NewChild() (child Window)

func (*ContainerWindow) ReplaceChild

func (win *ContainerWindow) ReplaceChild(old, new Window) bool

func (*ContainerWindow) Resize

func (win *ContainerWindow) Resize(b Box)

func (*ContainerWindow) SwapPos

func (win *ContainerWindow) SwapPos(a, b int)

type Controller

type Controller interface {
	Init(builderFactory func() *CommandBuilder, dimensions area, selected bool)

	Select()
	Deselect()
	Resize(int, int)

	ResolveInput(byte) bool
	Terminate()
}

func NewBorderedWindowController

func NewBorderedWindowController(title string, inner Controller) Controller

func NewPlayerWindowController

func NewPlayerWindowController(player *audio.Player) Controller

func NewQueueWindowController

func NewQueueWindowController(player *audio.Player) Controller

func NewSelectorWindowController

func NewSelectorWindowController(possibleControllers []struct {
	title   string
	factory func() Controller
}, setController func(Controller)) Controller

type ControllerChannels

type ControllerChannels struct {
	InputChan     chan byte
	ResizeChan    chan area
	TerminateChan chan struct{}
	SelectChan    chan bool
}

func NewControllerChannels

func NewControllerChannels() ControllerChannels

type HorizontalStackWindow

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

func (*HorizontalStackWindow) AddChild

func (win *HorizontalStackWindow) AddChild(child Window)

func (*HorizontalStackWindow) GetChildren

func (win *HorizontalStackWindow) GetChildren() []Window

func (*HorizontalStackWindow) NewChild

func (win *HorizontalStackWindow) NewChild() (child Window)

func (*HorizontalStackWindow) ReplaceChild

func (win *HorizontalStackWindow) ReplaceChild(old Window, new Window) bool

func (*HorizontalStackWindow) Resize

func (win *HorizontalStackWindow) Resize(b Box)

func (*HorizontalStackWindow) SwapPos

func (win *HorizontalStackWindow) SwapPos(a, b int)

type ParentWindow

type ParentWindow interface {
	Window

	NewChild() Window
	ReplaceChild(Window, Window) bool
	AddChild(Window)
	SwapPos(int, int)
}

func NewContainerWindow

func NewContainerWindow(b *BaseWindow) ParentWindow

func NewHorizontalStackWindow

func NewHorizontalStackWindow(b *BaseWindow) ParentWindow

func NewVerticalStackWindow

func NewVerticalStackWindow(b *BaseWindow) ParentWindow

type SelectorWindowController

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

TODO: add new window to select from other windows

func (*SelectorWindowController) Deselect

func (s *SelectorWindowController) Deselect()

func (*SelectorWindowController) Init

func (s *SelectorWindowController) Init(builderFactory func() *CommandBuilder, dimensions area, selected bool)

func (*SelectorWindowController) Resize

func (s *SelectorWindowController) Resize(w, h int)

func (*SelectorWindowController) ResolveInput

func (s *SelectorWindowController) ResolveInput(b byte) bool

func (*SelectorWindowController) Select

func (s *SelectorWindowController) Select()

func (*SelectorWindowController) Terminate

func (s *SelectorWindowController) Terminate()

type VerticalStackWindow

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

func (*VerticalStackWindow) AddChild

func (win *VerticalStackWindow) AddChild(child Window)

func (*VerticalStackWindow) GetChildren

func (win *VerticalStackWindow) GetChildren() []Window

func (*VerticalStackWindow) NewChild

func (win *VerticalStackWindow) NewChild() (child Window)

func (*VerticalStackWindow) ReplaceChild

func (win *VerticalStackWindow) ReplaceChild(old Window, new Window) bool

func (*VerticalStackWindow) Resize

func (win *VerticalStackWindow) Resize(b Box)

func (*VerticalStackWindow) SwapPos

func (win *VerticalStackWindow) SwapPos(a, b int)

type Window

type Window interface {
	GetParent() ParentWindow

	Encapsulate(parentWindowCreator)

	GetChildren() []Window

	GetDimensions() (int, int)

	Resize(b Box)

	GetCommandBuilder() *CommandBuilder
	Exec(Command)

	SetController(Controller)
	ResolveInput(b byte) bool
	Select()
	Deselect()

	SetSelectable(bool)
	// contains filtered or unexported methods
}

func GetRoot

func GetRoot(w Window) Window

func HSplit

func HSplit(w Window) Window

func InitTerminalLoop

func InitTerminalLoop(controllerFactories map[string]func() Controller) (root Window, quit chan struct{}, globalInput chan byte)

func VSplit

func VSplit(w Window) Window

type WindowVisitor

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

func NewWindowVisitor

func NewWindowVisitor(win Window) *WindowVisitor

func (*WindowVisitor) Current

func (v *WindowVisitor) Current() Window

func (*WindowVisitor) Next

func (v *WindowVisitor) Next() Window

func (*WindowVisitor) TravelTo

func (v *WindowVisitor) TravelTo(w Window)

Jump to

Keyboard shortcuts

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