Documentation ¶
Overview ¶
Higher level helper functions for termbox TODO support theming
Index ¶
- Constants
- func ClearRect(box Box, color, backgroundColor termbox.Attribute)
- func DrawBorder(box Box, lineType LineType, color, backgroundColor termbox.Attribute)
- func DrawCursor()
- func DrawLineHorizontal(left, top, width int, lineType LineType, ...)
- func DrawLineVertical(left, top, height int, lineType LineType, ...)
- func DrawTextBox(text string, box Box, foreground termbox.Attribute, ...)
- func DrawTextSimple(text string, box Box, foreground termbox.Attribute, ...)
- func FillRect(box Box, color, backgroundColor termbox.Attribute)
- type App
- type BasicControl
- func (ctrl *BasicControl) AddEventListener(eventType string, handler func(ev *Event) bool)
- func (ctrl *BasicControl) Border() LineType
- func (ctrl *BasicControl) BorderBox() Box
- func (ctrl *BasicControl) ContentBox() Box
- func (ctrl *BasicControl) Dirty() bool
- func (ctrl *BasicControl) DrawBorder()
- func (ctrl *BasicControl) Focus()
- func (ctrl *BasicControl) Focussable() bool
- func (ctrl *BasicControl) Focussed() bool
- func (ctrl *BasicControl) GetAbsolutePosition() Box
- func (ctrl *BasicControl) HasBorder() bool
- func (ctrl *BasicControl) ID() string
- func (ctrl *BasicControl) Init(id string)
- func (ctrl *BasicControl) Parent() Control
- func (ctrl *BasicControl) ParseEvent(ev *termbox.Event) bool
- func (ctrl *BasicControl) Pollute()
- func (ctrl *BasicControl) Repaint()
- func (ctrl *BasicControl) SetBorder(border LineType)
- func (ctrl *BasicControl) SetFocussable(focussable bool)
- func (ctrl *BasicControl) SetID(id string)
- func (ctrl *BasicControl) SetParent(parent Control)
- func (ctrl *BasicControl) SetWindow(win *Window)
- func (ctrl *BasicControl) SubmitEvent(ev *Event)
- func (ctrl *BasicControl) Window() *Window
- type Box
- type Button
- type Checkbox
- type Container
- type ContainerControl
- type Control
- type Event
- type EventDispatcher
- type HorizontalAlignment
- type Label
- type LineType
- type Panel
- type Position
- type Sides
- type VerticalAlignment
- type Window
- func (win *Window) AddControl(ctrl Control)
- func (win *Window) FocusNext()
- func (win *Window) FocusPrev()
- func (win *Window) FocussedControl() Control
- func (win *Window) FullRepaint()
- func (win *Window) GetControls() []Control
- func (win *Window) IsDirty() bool
- func (win *Window) ParseEvent(ev *termbox.Event) bool
- func (win *Window) Pollute()
- func (win *Window) Repaint()
- func (win *Window) SetFocussedControl(ctrl Control)
Constants ¶
View Source
const ( LineNone = iota LineTransparent LineSingle LineSingleCorners LineDouble LineDoubleCorners LineDashed LineDotted )
View Source
const ( HorizontalAlignmentLeft = iota HorizontalAlignmentCenter HorizontalAlignmentRight )
View Source
const ( HorizontalAlignmentTop = iota HorizontalAlignmentMiddle HorizontalAlignmentBottom )
Variables ¶
This section is empty.
Functions ¶
func DrawBorder ¶
func DrawCursor ¶
func DrawCursor()
func DrawLineHorizontal ¶
func DrawLineVertical ¶
func DrawTextBox ¶
TODO support line breaking for multiline strings TODO support alignment
func DrawTextSimple ¶
Types ¶
type App ¶
type App struct { CloseKey termbox.Key EventDispatcher *EventDispatcher // contains filtered or unexported fields }
App holds the global gonsole state.
func (*App) ActivateWindow ¶
type BasicControl ¶
type BasicControl struct { Position Position Visible bool Enabled bool ZIndex int TabIndex int // styling Foreground termbox.Attribute Background termbox.Attribute HAlign HorizontalAlignment VAlign VerticalAlignment Margin Sides Padding Sides // contains filtered or unexported fields }
Control is the base model for a UI control
func (*BasicControl) AddEventListener ¶
func (ctrl *BasicControl) AddEventListener(eventType string, handler func(ev *Event) bool)
func (*BasicControl) Border ¶
func (ctrl *BasicControl) Border() LineType
func (*BasicControl) BorderBox ¶
func (ctrl *BasicControl) BorderBox() Box
func (*BasicControl) ContentBox ¶
func (ctrl *BasicControl) ContentBox() Box
func (*BasicControl) Dirty ¶
func (ctrl *BasicControl) Dirty() bool
func (*BasicControl) DrawBorder ¶
func (ctrl *BasicControl) DrawBorder()
func (*BasicControl) Focus ¶
func (ctrl *BasicControl) Focus()
func (*BasicControl) Focussable ¶
func (ctrl *BasicControl) Focussable() bool
func (*BasicControl) Focussed ¶
func (ctrl *BasicControl) Focussed() bool
func (*BasicControl) GetAbsolutePosition ¶
func (ctrl *BasicControl) GetAbsolutePosition() Box
func (*BasicControl) HasBorder ¶
func (ctrl *BasicControl) HasBorder() bool
func (*BasicControl) ID ¶
func (ctrl *BasicControl) ID() string
func (*BasicControl) Init ¶
func (ctrl *BasicControl) Init(id string)
func (*BasicControl) Parent ¶
func (ctrl *BasicControl) Parent() Control
func (*BasicControl) ParseEvent ¶
func (ctrl *BasicControl) ParseEvent(ev *termbox.Event) bool
func (*BasicControl) Pollute ¶
func (ctrl *BasicControl) Pollute()
func (*BasicControl) Repaint ¶
func (ctrl *BasicControl) Repaint()
func (*BasicControl) SetBorder ¶
func (ctrl *BasicControl) SetBorder(border LineType)
func (*BasicControl) SetFocussable ¶
func (ctrl *BasicControl) SetFocussable(focussable bool)
func (*BasicControl) SetID ¶
func (ctrl *BasicControl) SetID(id string)
func (*BasicControl) SetParent ¶
func (ctrl *BasicControl) SetParent(parent Control)
func (*BasicControl) SetWindow ¶
func (ctrl *BasicControl) SetWindow(win *Window)
func (*BasicControl) SubmitEvent ¶
func (ctrl *BasicControl) SubmitEvent(ev *Event)
func (*BasicControl) Window ¶
func (ctrl *BasicControl) Window() *Window
type Checkbox ¶
type Checkbox struct { BasicControl // custom Text string Checked bool // contains filtered or unexported fields }
func NewCheckbox ¶
func (*Checkbox) ParseEvent ¶
type ContainerControl ¶
type ContainerControl struct { BasicControl // contains filtered or unexported fields }
func (*ContainerControl) AddControl ¶
func (ctrl *ContainerControl) AddControl(control Control)
func (*ContainerControl) Children ¶
func (ctrl *ContainerControl) Children() []Control
func (*ContainerControl) ChildrenDeep ¶
func (ctrl *ContainerControl) ChildrenDeep() []Control
func (*ContainerControl) Repaint ¶
func (ctrl *ContainerControl) Repaint()
type Control ¶
type Control interface { ID() string SetID(id string) Init(id string) Focussed() bool Focus() Focussable() bool SetFocussable(focussable bool) SetWindow(win *Window) Window() *Window Parent() Control SetParent(parent Control) Border() LineType SetBorder(lineType LineType) HasBorder() bool Dirty() bool Pollute() Repaint() GetAbsolutePosition() Box ContentBox() Box // return true if event was parsed and should not continue bubbling up ParseEvent(ev *termbox.Event) bool SubmitEvent(ev *Event) AddEventListener(eventType string, handler func(ev *Event) bool) }
type EventDispatcher ¶
type EventDispatcher struct {
// contains filtered or unexported fields
}
func NewEventDispatcher ¶
func NewEventDispatcher() *EventDispatcher
func (*EventDispatcher) AddEventListener ¶
func (ed *EventDispatcher) AddEventListener(source Control, eventType string, handler func(ev *Event) bool)
func (*EventDispatcher) SubmitEvent ¶
func (ed *EventDispatcher) SubmitEvent(ev *Event)
type HorizontalAlignment ¶
type HorizontalAlignment int
type Label ¶
type Label struct { BasicControl Text string }
type Panel ¶
type Panel struct { ContainerControl // custom Title string }
type VerticalAlignment ¶
type VerticalAlignment int
type Window ¶
type Window struct { App *App ID string Width int Height int Background termbox.Attribute Foreground termbox.Attribute // contains filtered or unexported fields }
Window is the top-level struct in gonsole library.
func (*Window) AddControl ¶
func (*Window) FocussedControl ¶
func (*Window) FullRepaint ¶
func (win *Window) FullRepaint()
func (*Window) GetControls ¶
func (*Window) ParseEvent ¶
return true if event was parsed and should not continue bubbling up
func (*Window) SetFocussedControl ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.