Skip to content
This repository has been archived by the owner on Oct 13, 2021. It is now read-only.

Commit

Permalink
Update UI documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusolsson committed Jan 4, 2018
1 parent 6ff2798 commit e15c085
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 4 additions & 2 deletions example/color/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ type StyledBox struct {
Style string
*tui.Box
}

// Draw decorates the Draw call to the widget with a style.
func (s *StyledBox) Draw(p *tui.Painter) {
p.WithStyle(s.Style, func(p *tui.Painter) {
s.Box.Draw(p)
Expand All @@ -33,7 +35,7 @@ func main() {
t.SetStyle("list.item", tui.Style{Bg: tui.ColorCyan, Fg: tui.ColorMagenta})
t.SetStyle("list.item.selected", tui.Style{Bg: tui.ColorRed, Fg: tui.ColorWhite})

// The style name is appended to the widget name to support coloring of
// The style name is appended to the widget name to support coloring of
// individual labels.
warning := tui.NewLabel("WARNING: This is a warning")
warning.SetStyleName("warning")
Expand All @@ -50,7 +52,7 @@ func main() {
message2 := tui.NewLabel(" message from our sponsors.")
message := &StyledBox{
Style: "bsod",
Box: tui.NewHBox(message1, emphasis, message2, tui.NewSpacer()),
Box: tui.NewHBox(message1, emphasis, message2, tui.NewSpacer()),
}

emphasis.SetStyleName("emphasis")
Expand Down
12 changes: 8 additions & 4 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@ package tui

// UI defines the operations needed by the underlying engine.
type UI interface {
// Change the root widget of the UI.
// SetWidget sets the root widget of the UI.
SetWidget(w Widget)
// SetTheme sets the current theme of the UI.
SetTheme(p *Theme)
// SetKeybinding sets the callback for when a key sequence is pressed.
SetKeybinding(seq string, fn func())
// ClearKeybindings removes all previous set keybindings.
ClearKeybindings()
// SetFocusChain sets a chain of widgets that determines focus order.
SetFocusChain(ch FocusChain)
// Start the UI thread; wait for it to complete, either via error or Quit.
// Run starts the UI goroutine and blocks either Quit was called or an error occurred.
Run() error
// Schedule work in the UI thread and await its completion.
// Update schedules work in the UI thread and await its completion.
// Note that calling Update from the UI thread will result in deadlock.
Update(fn func())
// Shut down the UI thread.
// Quit shuts down the UI goroutine.
Quit()
}

Expand Down

0 comments on commit e15c085

Please sign in to comment.