Documentation
¶
Overview ¶
Higher level helper functions for termbox TODO support theming
Index ¶
- Constants
- func DrawBorder(box Box, lineType LineType, fg, bg termbox.Attribute)
- func DrawCursor(x, y int)
- func DrawLineHorizontal(left, top, width int, ch rune, fg, bg termbox.Attribute)
- func DrawLineVertical(left, top, height int, ch rune, fg, bg termbox.Attribute)
- func DrawScrollBar(left, top, height, pos int, fg, bg termbox.Attribute)
- func DrawShadow(box Box, shadow termbox.Attribute)
- func DrawTextBox(text string, box Box, fg, bg termbox.Attribute)
- func DrawTextSimple(text string, fill bool, box Box, fg, bg termbox.Attribute)
- func FillRect(box Box, fg, bg termbox.Attribute)
- func HideCursor()
- func ScrollPos(index, count, height int) int
- type App
- type AppWindow
- type Attribute
- type BaseContainer
- func (c *BaseContainer) AddControl(ctrl Control)
- func (c *BaseContainer) Children() []Control
- func (c *BaseContainer) ChildrenDeep() []Control
- func (c *BaseContainer) DirtyChildren() bool
- func (c *BaseContainer) RepaintChildren()
- func (c *BaseContainer) SetTitle(title string)
- func (c *BaseContainer) Title() string
- type BaseControl
- type BaseElement
- func (e *BaseElement) AbsolutePosition() Box
- func (e *BaseElement) BorderBox() Box
- func (e *BaseElement) BorderColors() (fg Attribute, bg Attribute)
- func (e *BaseElement) BorderType() LineType
- func (e *BaseElement) Colors() (fg Attribute, bg Attribute)
- func (e *BaseElement) ContentBox() Box
- func (e *BaseElement) Dirty() bool
- func (e *BaseElement) Enabled() bool
- func (e *BaseElement) FocusColors() (fg Attribute, bg Attribute)
- func (e *BaseElement) GetWindow() AppWindow
- func (e *BaseElement) ID() string
- func (e *BaseElement) Init(window AppWindow, parent Container, id, themePrefix string)
- func (e *BaseElement) Margin() Sides
- func (e *BaseElement) Padding() Sides
- func (e *BaseElement) Parent() Container
- func (e *BaseElement) ParseEvent(ev *termbox.Event) (handled, repaint bool)
- func (e *BaseElement) Position() Position
- func (e *BaseElement) SetBorderColors(fg Attribute, bg Attribute)
- func (e *BaseElement) SetBorderType(border LineType)
- func (e *BaseElement) SetColors(fg Attribute, bg Attribute)
- func (e *BaseElement) SetDirty(dirty bool)
- func (e *BaseElement) SetEnabled(enabled bool)
- func (e *BaseElement) SetFocusColors(fg Attribute, bg Attribute)
- func (e *BaseElement) SetMargin(margins Sides)
- func (e *BaseElement) SetPadding(paddings Sides)
- func (e *BaseElement) SetPosition(pos Position)
- func (e *BaseElement) SetShadowColor(color Attribute)
- func (e *BaseElement) SetShadowType(shadow LineType)
- func (e *BaseElement) ShadowColor() Attribute
- func (e *BaseElement) ShadowType() LineType
- func (e *BaseElement) Theme() *Theme
- type BaseWindow
- func (win *BaseWindow) App() *App
- func (win *BaseWindow) Close()
- func (win *BaseWindow) Focus()
- func (win *BaseWindow) FocusControl(control Control)
- func (win *BaseWindow) Focused() bool
- func (win *BaseWindow) FocusedControl() Control
- func (win *BaseWindow) Init(app *App, id string)
- func (win *BaseWindow) OnClose(handler func())
- func (win *BaseWindow) ParseEvent(ev *termbox.Event) (handled, repaint bool)
- func (win *BaseWindow) Repaint()
- type Box
- type Button
- type Checkbox
- func (c *Checkbox) Checked() bool
- func (c *Checkbox) OnChange(handler func(checked bool))
- func (chk *Checkbox) ParseEvent(ev *termbox.Event) (handled, repaint bool)
- func (c *Checkbox) Repaint()
- func (c *Checkbox) SeChecked(checked bool)
- func (c *Checkbox) SetText(text string)
- func (c *Checkbox) Text() string
- type Container
- type Control
- type Edit
- type Element
- type HorizontalAlignment
- type InputDialog
- type Label
- type LineType
- type List
- type MessageDialog
- type Panel
- type Position
- type Progress
- type SelectionDialog
- type Sides
- type Theme
- type VerticalAlignment
- type Window
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 DrawCursor ¶
func DrawCursor(x, y int)
func DrawLineHorizontal ¶
func DrawLineVertical ¶
func DrawScrollBar ¶
func DrawShadow ¶
func DrawTextBox ¶
TODO support line breaking for multiline strings TODO support alignment
func DrawTextSimple ¶
func HideCursor ¶
func HideCursor()
Types ¶
type AppWindow ¶
type AppWindow interface {
Container
App() *App
Close()
FocusedControl() Control
FocusControl(control Control)
}
A window which is a top level container for controls. TODO: a better name for this interface. ideally "window"
type BaseContainer ¶
type BaseContainer struct {
// contains filtered or unexported fields
}
func (*BaseContainer) AddControl ¶
func (c *BaseContainer) AddControl(ctrl Control)
func (*BaseContainer) Children ¶
func (c *BaseContainer) Children() []Control
func (*BaseContainer) ChildrenDeep ¶
func (c *BaseContainer) ChildrenDeep() []Control
func (*BaseContainer) DirtyChildren ¶
func (c *BaseContainer) DirtyChildren() bool
func (*BaseContainer) RepaintChildren ¶
func (c *BaseContainer) RepaintChildren()
func (*BaseContainer) SetTitle ¶
func (c *BaseContainer) SetTitle(title string)
func (*BaseContainer) Title ¶
func (c *BaseContainer) Title() string
type BaseControl ¶
type BaseControl struct {
BaseElement
// contains filtered or unexported fields
}
Control is the base model for a UI control
func (*BaseControl) Cursorable ¶
func (c *BaseControl) Cursorable() bool
func (*BaseControl) Focus ¶
func (c *BaseControl) Focus()
func (*BaseControl) Focusable ¶
func (c *BaseControl) Focusable() bool
func (*BaseControl) Focused ¶
func (c *BaseControl) Focused() bool
func (*BaseControl) Repaint ¶
func (c *BaseControl) Repaint()
func (*BaseControl) SetCursorable ¶
func (c *BaseControl) SetCursorable(cursorable bool)
func (*BaseControl) SetFocusable ¶
func (c *BaseControl) SetFocusable(focusable bool)
type BaseElement ¶
type BaseElement struct {
// contains filtered or unexported fields
}
func (*BaseElement) AbsolutePosition ¶
func (e *BaseElement) AbsolutePosition() Box
func (*BaseElement) BorderBox ¶
func (e *BaseElement) BorderBox() Box
func (*BaseElement) BorderColors ¶
func (e *BaseElement) BorderColors() (fg Attribute, bg Attribute)
func (*BaseElement) BorderType ¶
func (e *BaseElement) BorderType() LineType
func (*BaseElement) Colors ¶
func (e *BaseElement) Colors() (fg Attribute, bg Attribute)
func (*BaseElement) ContentBox ¶
func (e *BaseElement) ContentBox() Box
func (*BaseElement) Dirty ¶
func (e *BaseElement) Dirty() bool
func (*BaseElement) Enabled ¶
func (e *BaseElement) Enabled() bool
func (*BaseElement) FocusColors ¶
func (e *BaseElement) FocusColors() (fg Attribute, bg Attribute)
func (*BaseElement) GetWindow ¶
func (e *BaseElement) GetWindow() AppWindow
func (*BaseElement) ID ¶
func (e *BaseElement) ID() string
func (*BaseElement) Init ¶
func (e *BaseElement) Init(window AppWindow, parent Container, id, themePrefix string)
func (*BaseElement) Margin ¶
func (e *BaseElement) Margin() Sides
func (*BaseElement) Padding ¶
func (e *BaseElement) Padding() Sides
func (*BaseElement) Parent ¶
func (e *BaseElement) Parent() Container
func (*BaseElement) ParseEvent ¶
func (e *BaseElement) ParseEvent(ev *termbox.Event) (handled, repaint bool)
func (*BaseElement) Position ¶
func (e *BaseElement) Position() Position
func (*BaseElement) SetBorderColors ¶
func (e *BaseElement) SetBorderColors(fg Attribute, bg Attribute)
func (*BaseElement) SetBorderType ¶
func (e *BaseElement) SetBorderType(border LineType)
func (*BaseElement) SetColors ¶
func (e *BaseElement) SetColors(fg Attribute, bg Attribute)
func (*BaseElement) SetDirty ¶
func (e *BaseElement) SetDirty(dirty bool)
func (*BaseElement) SetEnabled ¶
func (e *BaseElement) SetEnabled(enabled bool)
func (*BaseElement) SetFocusColors ¶
func (e *BaseElement) SetFocusColors(fg Attribute, bg Attribute)
func (*BaseElement) SetMargin ¶
func (e *BaseElement) SetMargin(margins Sides)
func (*BaseElement) SetPadding ¶
func (e *BaseElement) SetPadding(paddings Sides)
func (*BaseElement) SetPosition ¶
func (e *BaseElement) SetPosition(pos Position)
func (*BaseElement) SetShadowColor ¶
func (e *BaseElement) SetShadowColor(color Attribute)
func (*BaseElement) SetShadowType ¶
func (e *BaseElement) SetShadowType(shadow LineType)
func (*BaseElement) ShadowColor ¶
func (e *BaseElement) ShadowColor() Attribute
func (*BaseElement) ShadowType ¶
func (e *BaseElement) ShadowType() LineType
func (*BaseElement) Theme ¶
func (e *BaseElement) Theme() *Theme
type BaseWindow ¶
type BaseWindow struct {
BaseElement
BaseContainer
// contains filtered or unexported fields
}
Window is the top-level struct in gonsole library.
func (*BaseWindow) App ¶
func (win *BaseWindow) App() *App
func (*BaseWindow) Close ¶
func (win *BaseWindow) Close()
func (*BaseWindow) Focus ¶
func (win *BaseWindow) Focus()
func (*BaseWindow) FocusControl ¶
func (win *BaseWindow) FocusControl(control Control)
func (*BaseWindow) Focused ¶
func (win *BaseWindow) Focused() bool
func (*BaseWindow) FocusedControl ¶
func (win *BaseWindow) FocusedControl() Control
func (*BaseWindow) Init ¶
func (win *BaseWindow) Init(app *App, id string)
func (*BaseWindow) OnClose ¶
func (win *BaseWindow) OnClose(handler func())
func (*BaseWindow) ParseEvent ¶
func (win *BaseWindow) ParseEvent(ev *termbox.Event) (handled, repaint bool)
return true if event was parsed and should not continue bubbling up
func (*BaseWindow) Repaint ¶
func (win *BaseWindow) Repaint()
type Button ¶
type Button struct {
BaseControl
// contains filtered or unexported fields
}
type Checkbox ¶
type Checkbox struct {
BaseControl
// contains filtered or unexported fields
}
func (*Checkbox) ParseEvent ¶
type Container ¶
type Container interface {
Element
Title() string
SetTitle(title string)
AddControl(control Control)
Children() []Control
ChildrenDeep() []Control
}
An element that is a container for controls
type Control ¶
type Control interface {
Element
Focusable() bool
SetFocusable(active bool)
Cursorable() bool
SetCursorable(cursorable bool)
}
A control which is an element that can optional be focused
type Edit ¶
type Edit struct {
BaseControl
// contains filtered or unexported fields
}
func (*Edit) SetMaxWidth ¶
type Element ¶
type Element interface {
GetWindow() AppWindow
Parent() Container
ID() string
Dirty() bool
SetDirty(dirty bool)
Enabled() bool
SetEnabled(enabled bool)
Focused() bool
Focus()
Position() Position
SetPosition(pos Position)
Margin() Sides
SetMargin(margins Sides)
Padding() Sides
SetPadding(margins Sides)
Colors() (fg Attribute, bg Attribute)
SetColors(fg Attribute, bg Attribute)
FocusColors() (fg Attribute, bg Attribute)
SetFocusColors(fg Attribute, bg Attribute)
BorderType() LineType
SetBorderType(border LineType)
BorderColors() (fg Attribute, bg Attribute)
SetBorderColors(fg Attribute, bg Attribute)
AbsolutePosition() Box
BorderBox() Box
ContentBox() Box
ParseEvent(ev *termbox.Event) (handled, repaint bool)
Repaint()
Theme() *Theme
}
An UI element. It has a position, margin, padding, colors and other style properties.
type HorizontalAlignment ¶
type HorizontalAlignment int
type InputDialog ¶
type InputDialog struct {
BaseWindow
// contains filtered or unexported fields
}
func NewInputDialog ¶
func NewInputDialog(app *App, id, title, message string, buttons []string) *InputDialog
func (*InputDialog) InputValue ¶
func (d *InputDialog) InputValue() string
func (*InputDialog) SelectedButton ¶
func (d *InputDialog) SelectedButton() int
type Label ¶
type Label struct {
BaseControl
// contains filtered or unexported fields
}
type List ¶
type List struct {
BaseControl
// contains filtered or unexported fields
}
func (*List) SelectedItem ¶
func (*List) SetOptions ¶
type MessageDialog ¶
type MessageDialog struct {
BaseWindow
// contains filtered or unexported fields
}
func NewMessageDialog ¶
func NewMessageDialog(app *App, id, title, message string, buttons []string) *MessageDialog
func (*MessageDialog) SelectedButton ¶
func (d *MessageDialog) SelectedButton() int
type Panel ¶
type Panel struct {
BaseControl
BaseContainer
}
type Progress ¶
type Progress struct {
BaseControl
// contains filtered or unexported fields
}
type SelectionDialog ¶
type SelectionDialog struct {
BaseWindow
// contains filtered or unexported fields
}
func NewSelectionDialog ¶
func NewSelectionDialog(app *App, id, title, message string, buttons []string, items []string) *SelectionDialog
func (*SelectionDialog) SelectedButton ¶
func (d *SelectionDialog) SelectedButton() int
func (*SelectionDialog) SelectedItem ¶
func (d *SelectionDialog) SelectedItem() int
type VerticalAlignment ¶
type VerticalAlignment int
Source Files
¶
Click to show internal directories.
Click to hide internal directories.