widgets

package
v0.0.0-...-2200605 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2017 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCommitList

func NewCommitList(ui *UI) (chan<- model.Annotation, gocui.Manager)

func NewContributorsList

func NewContributorsList(ui *UI) (chan<- model.Annotation, gocui.Manager)

func NewItemDetails

func NewItemDetails(ui *UI) (chan<- *work.FetchedItem, gocui.Manager)

func NewItemsList

func NewItemsList(ui *UI) (chan<- model.Annotation, <-chan *work.FetchedItem, gocui.Manager)

func NewList

func NewList(ui *UI) (*list, chan *Selected)

func NewSourceCodeList

func NewSourceCodeList(ui *UI) (chan<- *model.File, <-chan *model.Line, gocui.Manager)

func ToBinding

func ToBinding(f func()) func(g *gocui.Gui, v *gocui.View) error

ToBinding is a convenience method used to create keybinding methods from plain methods. This allows users to ignore details of the underlying cui framework

func ToKeyString

func ToKeyString(key interface{}) (string, error)

ToKeyString converts a key to it's string representation

Types

type CommitItems

type CommitItems []*git.Commit

func (CommitItems) Display

func (c CommitItems) Display(writer io.Writer)

func (CommitItems) Len

func (c CommitItems) Len() int

type ContributorItems

type ContributorItems []*git.Contributor

func (ContributorItems) Display

func (c ContributorItems) Display(writer io.Writer)

func (ContributorItems) Len

func (c ContributorItems) Len() int

type EmptyItems

type EmptyItems struct{}

func (*EmptyItems) Display

func (e *EmptyItems) Display(w io.Writer)

func (*EmptyItems) Len

func (e *EmptyItems) Len() int

type FileItems

type FileItems model.File

func (FileItems) Display

func (f FileItems) Display(writer io.Writer)

func (FileItems) Len

func (f FileItems) Len() int

type Focusable

type Focusable interface {
	// Focus ensures the ui is updated to show that this widget is focused.
	// Focused widgets will also receive key events. If a widget isn't focused local key event handlers will not fire.
	Focus()

	// CanFocus will return true when a widget can be focused, false otherwise.
	CanFocus() bool

	// IsFocused will return true if the widget is currently focused, false otherwise.
	IsFocused() bool
}

Focusable allows callers to work with ui widgets that can be focused

type HelpDocumenter

type HelpDocumenter interface {
	// PrintHelp prints help information for this widget
	PrintHelp(writer io.Writer)
}

HelpDocumenter allows callers to ask ui widgets to give help about their functionality.

type Items

type Items interface {
	Display(w io.Writer)
	Len() int
}

type Selected

type Selected struct {
	Type  SelectionEvent
	Index int
	Items Items
}

type SelectionEvent

type SelectionEvent int
const (
	OnSelect SelectionEvent = iota
	OnEnter
)

type UI

type UI struct {
	Name    string
	Startx  float64
	Starty  float64
	Endx    float64
	Endy    float64
	Gui     *gocui.Gui
	FocusOn interface{}
	// contains filtered or unexported fields
}

UI is the base cui widget that all other ui widgets should extend

func (*UI) AddGlobalKey

func (u *UI) AddGlobalKey(key interface{}, description string, handler func())

AddGlobalKey will add a key binding for the entire app. It will respond no matter which widget is focused

func (*UI) AddLocalKey

func (u *UI) AddLocalKey(key interface{}, description string, handler func())

AddLocalKey will add a key binding for this widget only. No other widgets will respond to this key's event handler

func (*UI) AddOneUseGlobalKey

func (u *UI) AddOneUseGlobalKey(key interface{}, handler func())

AddOneUseGlobalKey will add a global key binding that will only work the first time the key is pressed. As soon as the key handler executes the key binding is removed.

func (*UI) CanFocus

func (u *UI) CanFocus() bool

CanFocus will return true when a widget can be focused, false otherwise.

func (*UI) Focus

func (u *UI) Focus()

Focus ensures the ui is updated to show that this widget is focused. Focused widgets will also receive key events. If a widget isn't focused local key event handlers will not fire.

func (*UI) IsFocused

func (u *UI) IsFocused() bool

IsFocused will return true if the widget is currently focused, false otherwise.

func (UI) Layout

func (u UI) Layout(g *gocui.Gui) error

Layout positions this widget in the cui based on the Startx, Starty, Endx and Endy. It also registers all the key bindings that have been added to this widget

func (*UI) PrintHelp

func (u *UI) PrintHelp(writer io.Writer)

PrintHelp prints information about this ui's keybindings

func (*UI) Show

func (u *UI) Show() func()

Show ensures this widget is visible with respect to other widgets. Show will also make sure this widget is focused

func (*UI) Title

func (u *UI) Title(title string)

Title changes the title of this ui widget

func (*UI) Update

func (u *UI) Update(f func(v *gocui.View))

Update this ui widget in a goroutine safe way. If the ui widget is updated with this method it is guarenteed to safe.

type WorkItems

type WorkItems []*work.FetchedItem

func (WorkItems) Display

func (items WorkItems) Display(writer io.Writer)

func (WorkItems) Len

func (items WorkItems) Len() int

Jump to

Keyboard shortcuts

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