Documentation
¶
Index ¶
- Variables
- func CreatePosition(x, y int, isPercent bool) position
- func Focus(activated bool)
- type Coordinates
- type CtCell
- func (c *CtCell) ActiveText(content string) *textElement
- func (c *CtCell) AddDebugMessage(msg ...interface{})
- func (c *CtCell) AddElement(e TcElement) (int, error)
- func (c *CtCell) CleanDebugMessages()
- func (c *CtCell) ClearElements()
- func (c *CtCell) CycleFocus()
- func (c *CtCell) DrawAll() int
- func (c *CtCell) GetElementByID(id int) TcElement
- func (c *CtCell) GetFocusedElement() TcElement
- func (c *CtCell) GetLastLoopTime() time.Duration
- func (c *CtCell) GetOutput() *CtOutput
- func (c *CtCell) GetScreen() tcell.Screen
- func (c *CtCell) GetSortedElements() []TcElement
- func (c *CtCell) GetSortedKeys() []int
- func (c *CtCell) Init() error
- func (c *CtCell) Loop()
- func (c *CtCell) MouseHoverAll(pos position)
- func (c *CtCell) MousePressAll(pos position, trigger int)
- func (c *CtCell) MouseReleaseAll(start position, end position, trigger int)
- func (c *CtCell) NewBox() *ctBox
- func (c *CtCell) NewMenu() *ctMenu
- func (c *CtCell) RemoveElement(e TcElement)
- func (c *CtCell) RemoveElementByID(id int)
- func (c *CtCell) ResetCaches()
- func (c *CtCell) Run() error
- func (c *CtCell) SendEvent(ev tcell.Event) error
- func (c *CtCell) SetDebug(debug bool) *CtCell
- func (c *CtCell) SetFocusById(id int)
- func (c *CtCell) SetMouse(mouse bool) *CtCell
- func (c *CtCell) SetNoClearScreen(noclear bool) *CtCell
- func (c *CtCell) SetScreen(s tcell.Screen) *CtCell
- func (c *CtCell) SortedCallBack(doIt func(b TcElement) bool)
- func (c *CtCell) Stop()
- func (c *CtCell) Text(content string) *textElement
- type CtOutput
- type MenuElement
- type TcElement
Constants ¶
This section is empty.
Variables ¶
var ( // is the last element that was hovered LastHoverElement TcElement // is the last element that was clicked LastMouseElement TcElement // is the element that has the focus FocusedElement TcElement // we need an incemental ID that we can use to identify the elements // this is used to identify the elements in the map ElementLastID int // messure the time we need to render the screen // this is only used for debugging RenderTime time.Duration )
Functions ¶
func CreatePosition ¶
Types ¶
type Coordinates ¶
type Coordinates struct { TopLeft position Dimensions dim }
Coordinates is a struct that contains the position and the dimensions of an element
func NewCoordinates ¶
func NewCoordinates(topLeft position, w int, h int) *Coordinates
type CtCell ¶
type CtCell struct { MouseEnabled bool // contains filtered or unexported fields }
func (*CtCell) ActiveText ¶
Text creates a new text element and returns a pointer to it. and sets the default behavior of an element to be clickable, can be focuses and can be hovered
func (*CtCell) AddDebugMessage ¶
func (c *CtCell) AddDebugMessage(msg ...interface{})
func (*CtCell) AddElement ¶
AddElement adds an element to the cell it also checks if the element is already in the cell, if an id is already set
func (*CtCell) CleanDebugMessages ¶
func (c *CtCell) CleanDebugMessages()
func (*CtCell) ClearElements ¶
func (c *CtCell) ClearElements()
ClearElements removes all elements from the cell
func (*CtCell) CycleFocus ¶
func (c *CtCell) CycleFocus()
CycleFocus will cycle the focus to the next element
func (*CtCell) GetElementByID ¶
GetElementByID returns the element with the given id
func (*CtCell) GetFocusedElement ¶
GetFocusedElement returns the element that has the focus
func (*CtCell) GetLastLoopTime ¶
func (*CtCell) GetSortedElements ¶
GetSortedElements returns all elements sorted by their z-index
func (*CtCell) GetSortedKeys ¶
GetSortedKeys returns all keys sorted
func (*CtCell) MouseHoverAll ¶
func (c *CtCell) MouseHoverAll(pos position)
MouseHoverAll is called when the mouse is hovering
func (*CtCell) MousePressAll ¶
MousePressAll is called when the mouse is pressed it will trigger the first element that is hit
func (*CtCell) MouseReleaseAll ¶
MouseReleaseAll is called when the mouse is released it will trigger the first element that is hit by the start coordinate
func (*CtCell) NewMenu ¶
func (c *CtCell) NewMenu() *ctMenu
NewMenu creates a new menu and sets the default style
func (*CtCell) RemoveElement ¶
RemoveElement removes an element from the cell
func (*CtCell) RemoveElementByID ¶
RemoveElementByID removes an element from the cell by its id
func (*CtCell) ResetCaches ¶
func (c *CtCell) ResetCaches()
ResetCaches resets the cache for the sorted elements
func (*CtCell) SetFocusById ¶
SetFocus set the focus of the element the old focus element will be unfocused
func (*CtCell) SetNoClearScreen ¶
func (*CtCell) SortedCallBack ¶
SortedCallBack will call the callback function for all elements the elements are sorted by their z-index
type CtOutput ¶
type CtOutput struct {
// contains filtered or unexported fields
}
this is the output filter for the tcell module that will be injected to ctxout
func NewCtOutput ¶
func NewCtOutputNoTty ¶
func NewCtOutputNoTty() *CtOutput
func (*CtOutput) Update ¶
func (c *CtOutput) Update(info ctxout.CtxOutBehavior)
type MenuElement ¶
type MenuElement struct { OnSelect func(*MenuElement) // the function that is called when the element is selected // contains filtered or unexported fields }
MenuElement is an element in a menu
func (*MenuElement) GetReference ¶
func (m *MenuElement) GetReference() interface{}
GetReference returns the reference of the menu element this can be nil. it is an interface{} so it can be anything also this is only valid for MenuElements created with NewMenuElementWithRef
func (*MenuElement) GetText ¶
func (m *MenuElement) GetText() *textElement
GetText returns the text Element of the menu element
type TcElement ¶
type TcElement interface { // Draw draw the element on the screen Draw(s tcell.Screen) Coordinates // MouseReleaseEvent is called when mouse is released MouseReleaseEvent(start position, end position, trigger int) // MousePressEvent is called when mouse is pressed MousePressEvent(pos position, trigger int) // MouseHoverEvent is called when mouse is hovering MouseHoverEvent(pos position) // MouseLeaveEvent is called when mouse is leaving MouseLeaveEvent() // Hit check if the element is hit by the mouse Hit(pos position, s tcell.Screen) bool // SetFocus set the focus of the element Focus(activated bool) // reports if the element is selectable and also can be focused IsSelectable() bool // reports if the element is visible. if not, it will not be drawn IsVisible() bool // set the visibility of the element SetVisible(visible bool) // set the ID of the element SetID(id int) // get the ID of the element GetID() int }