timui

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

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

Go to latest
Published: Feb 15, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

README

TIMUI

is a terminal ui immediate mode uiser interface library.

Focus

  • simple
  • lightweight

Backends

The manipulationg of the terminal and event handling is done via backends.

Currently there is a github.com/gdamore/tcell backend.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Transparent = RGBA(0, 0, 0, 0)
	White       = RGBA(0xff, 0xff, 0xff, 0xff)
	Black       = RGBA(0x0, 0x0, 0x0, 0xff)
)
View Source
var BorderBasic = BorderStyle{
	Rect:       [6]rune{'-', '|', '/', '\\', '\\', '/'},
	Vertical:   [3]rune{'+', '|', '+'},
	Horizontal: [3]rune{'+', '-', '+'},
}
View Source
var BorderDouble = BorderStyle{
	Rect:       [6]rune{'═', '║', '╔', '╗', '╚', '╝'},
	Vertical:   [3]rune{'╦', '║', '╩'},
	Horizontal: [3]rune{'╠', '═', '╣'},
}
View Source
var BorderNone = BorderStyle{
	Rect:       [6]rune{' ', ' ', ' ', ' ', ' ', ' '},
	Vertical:   [3]rune{' ', ' ', ' '},
	Horizontal: [3]rune{' ', ' ', ' '},
}
View Source
var BorderRoundSingle = BorderStyle{
	Rect:       [6]rune{'─', '│', '╭', '╮', '╰', '╯'},
	Vertical:   [3]rune{'┬', '│', '┴'},
	Horizontal: [3]rune{'├', '─', '┤'},
}
View Source
var BorderSingle = BorderStyle{
	Rect:       [6]rune{'─', '│', '┌', '┐', '└', '┘'},
	Vertical:   [3]rune{'┬', '│', '┴'},
	Horizontal: [3]rune{'├', '─', '┤'},
}
View Source
var DefaultTheme = Theme{
	BG:         MustRGBS("#000"),
	Text:       MustRGBS("#f33"),
	BorderLine: MustRGBS("#3ff"),
	BorderBG:   MustRGBS("#000"),
	Widget: WidgetTheme{
		BG:         MustRGBS("#004"),
		Text:       MustRGBS("#bbb"),
		Line:       MustRGBS("#a0a"),
		HoverBG:    MustRGBS("#22a"),
		InteractBG: MustRGBS("#008"),
		FocusLine:  MustRGBS("#ffa"),
	},
	BorderStyle: BorderDouble,
}

Functions

func OptionGroup

func OptionGroup[V comparable](t *Timui, name string, selected *V, f func(*OptionGroupElement[V]))

Types

type Backend

type Backend interface {
	Size() mathi.Vec2
	MousePosition() mathi.Vec2
	MousePressed(key Key) bool
	Set(pos mathi.Vec2, char rune, fg, bg uint32)
	Render()
}

type BorderStyle

type BorderStyle struct {
	Rect       [6]rune
	Horizontal [3]rune
	Vertical   [3]rune
}

type Columns

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

func (*Columns) Finish

func (s *Columns) Finish()

func (*Columns) Next

func (s *Columns) Next()

type Draggable

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

type Grid

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

func (*Grid) Columns

func (g *Grid) Columns(pos *SplitOptions, body func(rows *GridColumns))

func (*Grid) Rows

func (g *Grid) Rows(pos *SplitOptions, body func(rows *GridRows))

type GridColumns

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

func (*GridColumns) Columns

func (g *GridColumns) Columns(pos *SplitOptions, body func(columns *GridColumns))

func (*GridColumns) Next

func (g *GridColumns) Next()

func (*GridColumns) Rows

func (g *GridColumns) Rows(pos *SplitOptions, body func(rows *GridRows))

type GridRows

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

func (*GridRows) Columns

func (g *GridRows) Columns(pos *SplitOptions, body func(columns *GridColumns))

func (*GridRows) Next

func (g *GridRows) Next()

func (*GridRows) Rows

func (g *GridRows) Rows(pos *SplitOptions, body func(rows *GridRows))

type Key

type Key int
var (
	MouseButtonLeft  Key = 1_000_000
	MouseButtonRight Key = 1_000_001
)

type MouseInput

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

func (*MouseInput) Hovered

func (m *MouseInput) Hovered() int

func (*MouseInput) LeftPressed

func (m *MouseInput) LeftPressed() int

func (*MouseInput) LeftReleased

func (m *MouseInput) LeftReleased() bool

type OptionGroupElement

type OptionGroupElement[V comparable] struct {
	// contains filtered or unexported fields
}

func (OptionGroupElement[V]) Option

func (o OptionGroupElement[V]) Option(name string, value V) bool

type Panel

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

func (*Panel) Finish

func (p *Panel) Finish()

func (*Panel) HLine

func (p *Panel) HLine()

func (*Panel) Header

func (p *Panel) Header()

type RGBAColor

type RGBAColor uint32

func MustRGBAS

func MustRGBAS(s string) RGBAColor

func RGBA

func RGBA(r, g, b, a int) RGBAColor

func RGBAS

func RGBAS(s string) (RGBAColor, error)

func (RGBAColor) RGBA

func (rgba RGBAColor) RGBA() (int, int, int, int)

func (RGBAColor) String

func (rgb RGBAColor) String() string

type RGBColor

type RGBColor uint32

func MustRGBS

func MustRGBS(s string) RGBColor

func RGB

func RGB(r, g, b int) RGBColor

func RGBS

func RGBS(s string) (RGBColor, error)

func (RGBColor) Add

func (rgb RGBColor) Add(o RGBColor) RGBColor

func (RGBColor) Blend

func (rgb RGBColor) Blend(rgba RGBAColor) RGBColor

func (RGBColor) MulDiv

func (rgb RGBColor) MulDiv(factor, div int) RGBColor

func (RGBColor) RGB

func (rgb RGBColor) RGB() (int, int, int)

func (RGBColor) RGBA

func (rgb RGBColor) RGBA(a int) RGBAColor

func (RGBColor) String

func (rgb RGBColor) String() string

type Rows

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

func (*Rows) Finish

func (s *Rows) Finish()

func (*Rows) Next

func (s *Rows) Next()

type SplitOptions

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

func Split

func Split() *SplitOptions

func (*SplitOptions) Add

func (s *SplitOptions) Add(factor float32, fixed int) *SplitOptions

func (*SplitOptions) Factor

func (s *SplitOptions) Factor(factors ...float32) *SplitOptions

func (*SplitOptions) Fixed

func (s *SplitOptions) Fixed(fixed ...int) *SplitOptions

func (*SplitOptions) Pad

func (s *SplitOptions) Pad(padding int) *SplitOptions

type Theme

type Theme struct {
	BG          RGBColor
	Text        RGBColor
	BorderLine  RGBColor
	BorderBG    RGBColor
	Widget      WidgetTheme
	BorderStyle BorderStyle
}

func (*Theme) WithBorder

func (t *Theme) WithBorder(b BorderStyle, content func())

type Timui

type Timui struct {
	Theme Theme
	// contains filtered or unexported fields
}

func New

func New(backend Backend) *Timui

func (*Timui) Border

func (t *Timui) Border(style [6]rune, fg, bg RGBColor)

func (*Timui) Button

func (g *Timui) Button(name string) bool

func (*Timui) Checkbox

func (g *Timui) Checkbox(name string, checked *bool) bool

func (*Timui) ClipContains

func (t *Timui) ClipContains(pos mathi.Vec2) bool

func (*Timui) Columns

func (g *Timui) Columns(opts *SplitOptions) *Columns

func (*Timui) CurrentArea

func (t *Timui) CurrentArea() *mathi.Box2

func (*Timui) Dialog

func (t *Timui) Dialog(title string, visible *bool, content func())

func (*Timui) Draggable

func (t *Timui) Draggable(id string, area mathi.Box2, size mathi.Vec2, pos *mathi.Vec2) (bool, bool)

func (*Timui) Dropdown

func (g *Timui) Dropdown(id string, elements int, selected *int, paint func(i int, s bool))

func (*Timui) Finish

func (t *Timui) Finish()

func (*Timui) GetMousePosition

func (t *Timui) GetMousePosition() mathi.Vec2

func (*Timui) Grid

func (t *Timui) Grid(body func(grid *Grid))

func (*Timui) HLine

func (t *Timui) HLine(style [3]rune, fg, bg RGBColor)

func (*Timui) Label

func (t *Timui) Label(name string)

func (*Timui) MouseInput

func (t *Timui) MouseInput(id string) *MouseInput

MouseInput creates a mouse area for the current cursor area

func (*Timui) MouseInputForArea

func (t *Timui) MouseInputForArea(id string, area mathi.Box2) *MouseInput

MouseInputForArea creates a mouse area from given area relative to the current cursor area

func (*Timui) MouseInputForSize

func (t *Timui) MouseInputForSize(id string, size mathi.Vec2) *MouseInput

MouseInputForSize creates a mouse area from given size relative to the current cursor area

func (*Timui) Pad

func (t *Timui) Pad(top, right, bottom, left int, body func())

func (*Timui) Panel

func (t *Timui) Panel() *Panel

func (*Timui) PeekClip

func (g *Timui) PeekClip() mathi.Box2

func (*Timui) PopArea

func (t *Timui) PopArea()

func (*Timui) PopClip

func (g *Timui) PopClip()

func (*Timui) PushArea

func (t *Timui) PushArea(area mathi.Box2)

func (*Timui) PushAreaTranslation

func (t *Timui) PushAreaTranslation(dir mathi.Vec2)

func (*Timui) PushClip

func (g *Timui) PushClip(area mathi.Box2)

func (*Timui) Rows

func (g *Timui) Rows(pos *SplitOptions) *Rows

func (*Timui) ScrollAreaV

func (g *Timui) ScrollAreaV(id string, body func())

func (*Timui) Set

func (t *Timui) Set(pos mathi.Vec2, char rune, fg, bg RGBColor)

func (*Timui) SetAlpha

func (t *Timui) SetAlpha(pos mathi.Vec2, char rune, fg, bg RGBAColor)

func (*Timui) SetArea

func (t *Timui) SetArea(char rune, fg, bg RGBColor)

func (*Timui) SetAreaAlpha

func (t *Timui) SetAreaAlpha(char rune, fg, bg RGBAColor)

func (*Timui) SetBorder

func (t *Timui) SetBorder(pos mathi.Vec2, char rune, fg, bg RGBColor)

func (*Timui) Size

func (t *Timui) Size() mathi.Vec2

func (*Timui) Text

func (t *Timui) Text(name string, pos mathi.Vec2, fg, bg RGBAColor)

func (*Timui) VLine

func (t *Timui) VLine(style [3]rune, fg, bg RGBColor)

type WidgetTheme

type WidgetTheme struct {
	BG         RGBColor
	Text       RGBColor
	Line       RGBColor
	HoverBG    RGBColor
	InteractBG RGBColor
	FocusLine  RGBColor
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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