TermUI

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: May 18, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

README

TermUI

TermUI is the pure Go UI toolkit used for most if not all of TerminalWars's built in programs, because fuck it, GTK sucks to use with Golang and all the other GUI toolkits mainly use the GPU so fuck it I'll make a goddamn GUI toolkit myself.

There's a basic example of how to use this in /examples/basic.go.

Documentation

Index

Constants

View Source
const (
	// Names for special keys.
	NameLeftArrow      = "←"
	NameRightArrow     = "→"
	NameUpArrow        = "↑"
	NameDownArrow      = "↓"
	NameReturn         = "⏎"
	NameEnter          = "⌤"
	NameEscape         = "⎋"
	NameHome           = "⇱"
	NameEnd            = "⇲"
	NameDeleteBackward = "⌫"
	NameDeleteForward  = "⌦"
	NamePageUp         = "⇞"
	NamePageDown       = "⇟"
	NameTab            = "Tab"
	NameSpace          = "Space"
	NameCtrl           = "Ctrl"
	NameShift          = "Shift"
	NameAlt            = "Alt"
	NameSuper          = "Super"
	NameCommand        = "⌘"
	NameF1             = "F1"
	NameF2             = "F2"
	NameF3             = "F3"
	NameF4             = "F4"
	NameF5             = "F5"
	NameF6             = "F6"
	NameF7             = "F7"
	NameF8             = "F8"
	NameF9             = "F9"
	NameF10            = "F10"
	NameF11            = "F11"
	NameF12            = "F12"
	NameBack           = "Back"
)
View Source
const (
	ButtonType  int8 = 0
	TextboxType int8 = 1
	LabelType   int8 = 2
)

Variables

View Source
var ButtonNum uint8 = 0
View Source
var LabelNum uint8 = 0
View Source
var MousePos struct {
	X int16
	Y int16
}
View Source
var TextboxNum uint8 = 0
View Source
var UIEventNum uint8 = 0
View Source
var UIEvents []*UIEvent = make([]*UIEvent, 255)

Functions

func DecodeKey

func DecodeKey(kc xproto.Keycode) string

func WordWrap added in v1.0.0

func WordWrap(text string, wrapAt int) (rows []string)

Types

type Context added in v1.0.0

type Context struct {
	Ctx *C.struct_xkb_context
	// contains filtered or unexported fields
}
var (
	KeyContext *Context
)

func New added in v1.0.0

func New() (*Context, error)

func (*Context) Destroy added in v1.0.0

func (x *Context) Destroy()

func (*Context) DestroyKeymapState added in v1.0.0

func (x *Context) DestroyKeymapState()

func (*Context) DispatchKey added in v1.0.0

func (x *Context) DispatchKey(keyCode uint32) string

func (*Context) Modifiers added in v1.0.0

func (x *Context) Modifiers() Modifiers

func (*Context) SetKeymap added in v1.0.0

func (x *Context) SetKeymap(xkbKeyMap, xkbState unsafe.Pointer)

SetKeymap sets the keymap and state. The context takes ownership of the keymap and state and frees them in Destroy.

func (*Context) UpdateKeymap added in v1.0.0

func (x *Context) UpdateKeymap() error

type Event

type Event interface {
	String() string
}

Generic event

type Modifiers added in v1.0.0

type Modifiers uint32

Modifiers

const (
	// ModCtrl is the ctrl modifier key.
	ModCtrl Modifiers = 1 << iota
	// ModCommand is the command modifier key
	// found on Apple keyboards.
	ModCommand
	// ModShift is the shift modifier key.
	ModShift
	// ModAlt is the alt modifier key, or the option
	// key on Apple keyboards.
	ModAlt
	// ModSuper is the "logo" modifier key, often
	// represented by a Windows logo.
	ModSuper
)

type UIElementStruct added in v1.0.0

type UIElementStruct struct {
	Buttons   []*UIEvent
	Textboxes []*UIEvent
	Labels    []*UIEvent
}

Types of elements

var UIElements UIElementStruct = UIElementStruct{
	make([]*UIEvent, 16),
	make([]*UIEvent, 16),
	make([]*UIEvent, 64),
}

func (UIElementStruct) GetByID added in v1.0.0

func (v UIElementStruct) GetByID(ID uint8, FindType int8) *UIEvent

type UIEvent

type UIEvent struct {
	Name   string
	Width  uint16
	Height uint16
	X      int16
	Y      int16
	ID     int16 // user supplied id
	State  int8  // dependent on the element, see their respective comments
	Type   int8  // 0: button, 1: textbox, 2: label
	// contains filtered or unexported fields
}

Any event that needs to be drawn and checked on

type UIHoverEvent

type UIHoverEvent struct {
	Name  string
	Event *UIEvent
}

What returns when we hover over something

func (UIHoverEvent) String

func (v UIHoverEvent) String() string

type UIPressEvent

type UIPressEvent struct {
	Name  string
	Event *UIEvent
}

What returns when we click something

func (UIPressEvent) String

func (v UIPressEvent) String() string

type UIReleaseEvent

type UIReleaseEvent struct {
	Name  string
	Event *UIEvent
}

What returns when we release our click on something

func (UIReleaseEvent) String

func (v UIReleaseEvent) String() string

type UITextboxSubmitEvent added in v1.0.0

type UITextboxSubmitEvent struct {
	Name  string
	Event *UIEvent
}

What returns when we hit enter on a textbox

func (UITextboxSubmitEvent) String added in v1.0.0

func (v UITextboxSubmitEvent) String() string

type Window

type Window struct {
	Conn   *xgb.Conn
	Screen *xproto.ScreenInfo
	Window xproto.Window
	Width  uint16
	Height uint16
	// contains filtered or unexported fields
}

func NewWindow

func NewWindow(Width uint16, Height uint16, Flags []uint32) (Window Window, Error error)

Function for creating a new window, with default options in place.

func NewWindowComplex

func NewWindowComplex(Width uint16, Height uint16, BorderWidth uint16, Mask uint32, Flags []uint32) (win Window, err error)

Function for creating a new window without any default options in place

func (*Window) Base

func (win *Window) Base(Width uint16, Height uint16, X int16, Y int16, colors [5]uint32)

func (*Window) BaseRaised

func (win *Window) BaseRaised(Width uint16, Height uint16, X int16, Y int16)

func (*Window) BaseSunken

func (win *Window) BaseSunken(Width uint16, Height uint16, X int16, Y int16)

func (*Window) Button

func (win *Window) Button(Name string, ID int16, Width uint16, Height uint16, X int16, Y int16) *UIEvent

func (*Window) CheckKeyPress

func (win *Window) CheckKeyPress(ev xgb.Event)

func (*Window) CheckKeyRelease

func (win *Window) CheckKeyRelease(ev xgb.Event)

func (*Window) CheckMouseHover

func (win *Window) CheckMouseHover(ev xgb.Event)

func (*Window) CheckMousePress

func (win *Window) CheckMousePress(ev xgb.Event)

func (*Window) CheckMouseRelease

func (win *Window) CheckMouseRelease(ev xgb.Event)

func (*Window) DefaultListeners

func (win *Window) DefaultListeners(ev xgb.Event)

goroutine for a switch that listens for all the default shit we usually want.

func (*Window) DrawText

func (win *Window) DrawText(Text string, X int16, Y int16, Size int16, FGColor uint32, BGColor uint32) error

func (*Window) DrawUIButton

func (win *Window) DrawUIButton(i uint8)

Draw a UI button

func (*Window) DrawUIButtons added in v1.0.0

func (win *Window) DrawUIButtons()

func (*Window) DrawUIElement

func (win *Window) DrawUIElement(ev *UIEvent)

Draw one UI Element

func (*Window) DrawUIElements

func (win *Window) DrawUIElements()

Draw all UI elements.

func (*Window) DrawUILabel added in v1.0.0

func (win *Window) DrawUILabel(i uint8)

Draw a UI label

func (*Window) DrawUILabels added in v1.0.0

func (win *Window) DrawUILabels()

func (*Window) DrawUITextbox

func (win *Window) DrawUITextbox(i uint8)

Draw a UI textbox

func (*Window) DrawUITextboxes added in v1.0.0

func (win *Window) DrawUITextboxes()

func (*Window) Label added in v1.0.0

func (win *Window) Label(Name string, ID int16, Width uint16, Height uint16, X int16, Y int16, State int8) *UIEvent

func (*Window) NewUIEvent

func (win *Window) NewUIEvent(Name string, ID int16, Width uint16, Height uint16, X int16, Y int16, eventType int8, id uint8) *UIEvent

Make a new UI event

func (*Window) NewUIEventWithPresetState added in v1.0.0

func (win *Window) NewUIEventWithPresetState(Name string, ID int16, Width uint16, Height uint16, X int16, Y int16, eventType int8, id uint8, defaultState int8) *UIEvent

func (*Window) NoMoreUIEvents

func (win *Window) NoMoreUIEvents() bool

Check if we have any UI events left

func (*Window) PercentOfHeight added in v1.0.0

func (win *Window) PercentOfHeight(per uint16) int16

func (*Window) PercentOfWidth added in v1.0.0

func (win *Window) PercentOfWidth(per uint16) int16

func (*Window) Square

func (win *Window) Square(Width uint16, Height uint16, X int16, Y int16, Colors []uint32)

Draw a simple square

func (*Window) Textbox

func (win *Window) Textbox(Name string, ID int16, Width uint16, Height uint16, X int16, Y int16) *UIEvent

func (*Window) TextboxBase

func (win *Window) TextboxBase(Width uint16, Height uint16, X int16, Y int16)

func (*Window) WaitForUIEvent

func (win *Window) WaitForUIEvent() Event

Wait for a UI event

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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