gowid

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2022 License: MIT Imports: 18 Imported by: 75

README

# Terminal User Interface Widgets in Go

Gowid provides widgets and a framework for making terminal user interfaces. It's written in Go and inspired by urwid.

Widgets out-of-the-box include:

  • input components like button, checkbox and an editable text field with support for passwords
  • layout components for arranging widgets in columns, rows and a grid
  • structured components - a tree, an infinite list and a table
  • pre-canned widgets - a progress bar, a modal dialog, a bar graph and a menu
  • a VT220-compatible terminal widget, heavily cribbed from urwid 😃

All widgets support interaction with the mouse when the terminal allows.

Gowid is built on top of the fantastic tcell package.

There are many alternatives to gowid - see Similar Projects

The most developed gowid application is currently termshark, a terminal UI for tshark.

Installation

go get github.com/gcla/gowid/...

Examples

Make sure $GOPATH/bin is in your PATH (or ~/go/bin if GOPATH isn't set), then tab complete "gowid-" e.g.

gowid-fib

Here is a port of urwid's palette example:

Here is urwid's graph example:

And urwid's fibonacci example:

A demonstration of gowid's terminal widget, a port of urwid's terminal widget:

Finally, here is an animation of termshark in action:

Hello World

This example is an attempt to mimic urwid's "Hello World" example.

package main

import (
	"github.com/gcla/gowid"
	"github.com/gcla/gowid/widgets/divider"
	"github.com/gcla/gowid/widgets/pile"
	"github.com/gcla/gowid/widgets/styled"
	"github.com/gcla/gowid/widgets/text"
	"github.com/gcla/gowid/widgets/vpadding"
)

//======================================================================

func main() {

	palette := gowid.Palette{
		"banner":  gowid.MakePaletteEntry(gowid.ColorWhite, gowid.MakeRGBColor("#60d")),
		"streak":  gowid.MakePaletteEntry(gowid.ColorNone, gowid.MakeRGBColor("#60a")),
		"inside":  gowid.MakePaletteEntry(gowid.ColorNone, gowid.MakeRGBColor("#808")),
		"outside": gowid.MakePaletteEntry(gowid.ColorNone, gowid.MakeRGBColor("#a06")),
		"bg":      gowid.MakePaletteEntry(gowid.ColorNone, gowid.MakeRGBColor("#d06")),
	}

	div := divider.NewBlank()
	outside := styled.New(div, gowid.MakePaletteRef("outside"))
	inside := styled.New(div, gowid.MakePaletteRef("inside"))

	helloworld := styled.New(
		text.NewFromContentExt(
			text.NewContent([]text.ContentSegment{
				text.StyledContent("Hello World", gowid.MakePaletteRef("banner")),
			}),
			text.Options{
				Align: gowid.HAlignMiddle{},
			},
		),
		gowid.MakePaletteRef("streak"),
	)

	f := gowid.RenderFlow{}

	view := styled.New(
		vpadding.New(
			pile.New([]gowid.IContainerWidget{
				&gowid.ContainerWidget{IWidget: outside, D: f},
				&gowid.ContainerWidget{IWidget: inside, D: f},
				&gowid.ContainerWidget{IWidget: helloworld, D: f},
				&gowid.ContainerWidget{IWidget: inside, D: f},
				&gowid.ContainerWidget{IWidget: outside, D: f},
			}),
			gowid.VAlignMiddle{},
			f),
		gowid.MakePaletteRef("bg"),
	)

	app, _ := gowid.NewApp(gowid.AppArgs{
		View:    view,
		Palette: &palette,
	})
    
	app.SimpleMainLoop()
}

Running the example above displays this:

Documentation

Similar Projects

Gowid is late to the TUI party. There are many options from which to choose - please read https://appliedgo.net/tui/ for a nice summary for the Go language. Here is a selection:

  • urwid - one of the oldest, for those working in python
  • tview - active, polished, concise, lots of widgets, Go
  • termui - focus on graphing and dataviz, Go
  • gocui - focus on layout, good input options, mouse support, Go
  • clui - active, many widgets, mouse support, Go
  • tui-go - QT-inspired, experimental, nice examples, Go

Dependencies

Gowid depends on these great open-source packages:

  • urwid - not a Go-dependency, but the model for most of gowid's design
  • tcell - a cell based view for text terminals, like xterm, inspired by termbox
  • asciigraph - lightweight ASCII line-graphs for Go
  • logrus - structured pluggable logging for Go
  • testify - tools for testifying that your code will behave as you intend

Contact

License

Documentation

Overview

Package gowid provides widgets and tools for constructing compositional terminal user interfaces.

Index

Constants

View Source
const (
	StyleNoneSet tcell.AttrMask = 0 // Just unstyled text.
	StyleAllSet  tcell.AttrMask = tcell.AttrBold | tcell.AttrBlink | tcell.AttrReverse | tcell.AttrUnderline | tcell.AttrDim
)

These are used as bitmasks - a style is two AttrMasks. The first bitmask says whether or not the style declares an e.g. underline setting; if it's declared, the second bitmask says whether or not underline is affirmatively on or off. This allows styles to be layered e.g. the lower style declares underline is on, the upper style does not declare an underline preference, so when layered, the cell is rendered with an underline.

View Source
const (
	// Mode256Colors represents a terminal with 256-color support.
	Mode256Colors = ColorMode(iota)

	// Mode88Colors represents a terminal with 88-color support such as rxvt.
	Mode88Colors

	// Mode16Colors represents a terminal with 16-color support.
	Mode16Colors

	// Mode8Colors represents a terminal with 8-color support.
	Mode8Colors

	// Mode8Colors represents a terminal with support for monochrome only.
	ModeMonochrome

	// Mode24BitColors represents a terminal with 24-bit color support like KDE's terminal.
	Mode24BitColors
)
View Source
const (
	Forwards  = Direction(1)
	Backwards = Direction(-1)
)

Variables

View Source
var (
	CubeStart   = 16 // first index of color cube
	CubeSize256 = 6  // one side of the color cube

	// ColorNone means no preference if anything is layered underneath
	ColorNone = MakeTCellNoColor()

	// ColorDefault is an affirmative preference for the default terminal color
	ColorDefault = MakeTCellColorExt(tcell.ColorDefault)

	// Some pre-initialized color objects for use in applications e.g.
	// MakePaletteEntry(ColorBlack, ColorRed)
	ColorBlack      = MakeTCellColorExt(tcell.ColorBlack)
	ColorRed        = MakeTCellColorExt(tcell.ColorRed)
	ColorGreen      = MakeTCellColorExt(tcell.ColorGreen)
	ColorLightGreen = MakeTCellColorExt(tcell.ColorLightGreen)
	ColorYellow     = MakeTCellColorExt(tcell.ColorYellow)
	ColorBlue       = MakeTCellColorExt(tcell.ColorBlue)
	ColorLightBlue  = MakeTCellColorExt(tcell.ColorLightBlue)
	ColorMagenta    = MakeTCellColorExt(tcell.ColorDarkMagenta)
	ColorCyan       = MakeTCellColorExt(tcell.ColorDarkCyan)
	ColorWhite      = MakeTCellColorExt(tcell.ColorWhite)
	ColorDarkRed    = MakeTCellColorExt(tcell.ColorDarkRed)
	ColorDarkGreen  = MakeTCellColorExt(tcell.ColorDarkGreen)
	ColorDarkBlue   = MakeTCellColorExt(tcell.ColorDarkBlue)
	ColorLightGray  = MakeTCellColorExt(tcell.ColorLightGray)
	ColorDarkGray   = MakeTCellColorExt(tcell.ColorDarkGray)
	ColorPurple     = MakeTCellColorExt(tcell.ColorPurple)
	ColorOrange     = MakeTCellColorExt(tcell.ColorOrange)
)

AllStyleMasks is an array of all the styles that can be applied to a Cell.

View Source
var AppClosingErr = fmt.Errorf("App is closing - no more events accepted.")
View Source
var Focused = Selector{
	Focus:    true,
	Selected: true,
}
View Source
var IgnoreBase16 = false

IgnoreBase16 should be set to true if gowid should not consider colors 0-21 for closest-match when interpolating RGB colors in 256-color space. You might use this if you use base16-shell, for example, to make use of base16-themes for all terminal applications (https://github.com/chriskempson/base16-shell)

View Source
var NotSelected = Selector{
	Focus:    false,
	Selected: false,
}
View Source
var Selected = Selector{
	Focus:    false,
	Selected: true,
}

StyleBlink specifies the text should blink, but expresses no preference for other text styles.

StyleBlinkOnly specifies the text should blink, and no other styling should apply.

StyleBold specifies the text should be bold, but expresses no preference for other text styles.

StyleBoldOnly specifies the text should be bold, and no other styling should apply.

StyleDim specifies the text should be dim, but expresses no preference for other text styles.

StyleDimOnly specifies the text should be dim, and no other styling should apply.

View Source
var StyleNone = StyleAttrs{}

StyleNone expresses no preference for any text styles.

StyleReverse specifies the text should be displayed as reverse-video, but expresses no preference for other text styles.

StyleReverseOnly specifies the text should be displayed reverse-video, and no other styling should apply.

StyleUnderline specifies the text should be underlined, but expresses no preference for other text styles.

StyleUnderlineOnly specifies the text should be underlined, and no other styling should apply.

Functions

func AddWidgetCallback

func AddWidgetCallback(c ICallbacks, name interface{}, cb IWidgetChangedCallback)

func AppendBlankLines

func AppendBlankLines(c IAppendBlankLines, iters int)

func CanvasToString

func CanvasToString(c ICanvas) string

func ChangeFocus

func ChangeFocus(w IWidget, dir Direction, wrap bool, app IApp) bool

ChangeFocus is a general algorithm for applying a change of focus to a type. If the type supports IChangeFocus, then that method is called directly. If the type supports IFocusSelectable, then the next widget is found, and set. Otherwise, if the widget has a child or children, the call is passed to them.

func CopyModeUserInput

func CopyModeUserInput(w ICopyModeWidget, ev interface{}, size IRenderSize, focus Selector, app IApp) bool

CopyModeUserInput processes copy mode events in a typical fashion - a widget that wraps one with potentially copyable information could defer to this implementation of UserInput.

func Draw

func Draw(canvas IDrawCanvas, mode IColorMode, screen tcell.Screen)

Draw will render a Canvas to a tcell Screen.

func FindNextSelectableFrom

func FindNextSelectableFrom(w ICompositeMultipleDimensions, start int, dir Direction, wrap bool) (int, bool)

func FindNextSelectableWidget

func FindNextSelectableWidget(w []IWidget, pos int, dir Direction, wrap bool) (int, bool)

func FixCanvasHeight

func FixCanvasHeight(c ICanvas, size IRenderSize)

func Focus

func Focus(w IWidget) int

func FocusPath

func FocusPath(w IWidget) []interface{}

FocusPath returns a list of positions, each representing the focus position at that level in the widget hierarchy. The returned list may be shorter than the focus path through the hierarchy - only widgets that have more than one option for the focus will contribute.

func HandleQuitKeys

func HandleQuitKeys(app IApp, event interface{}) bool

HandleQuitKeys is provided as a simple way to terminate your application using typical "quit" keys - q/Q, ctrl-c, escape.

func KeysEqual

func KeysEqual(k1, k2 IKey) bool

func MakeCanvasRightSize

func MakeCanvasRightSize(c IRightSizeCanvas, size IRenderSize)

func MakeCellStyle

func MakeCellStyle(fg TCellColor, bg TCellColor, attr StyleAttrs) tcell.Style

MakeCellStyle constructs a tcell.Style from gowid colors and styles. The return value can be provided to tcell in order to style a particular region of the screen.

func PanicIfCanvasNotRightSize

func PanicIfCanvasNotRightSize(c IRenderBox, size IRenderSize)

PanicIfCanvasNotRightSize is for debugging - it panics if the size of the supplied canvas does not conform to the size specified by the size argument. For a box argument, columns and rows are checked; for a flow argument, columns are checked.

func PrefPosition

func PrefPosition(curw interface{}) gwutil.IntOption

PrefPosition repeatedly unpacks composite widgets until it has to stop. It looks for a type exports a prefered position API. The widget might be ContainerWidget/StyledWidget/...

func QuitFn

func QuitFn(app IApp, widget IWidget)

QuitFn can be used to construct a widget callback that terminates your application. It can be used as the second argument of the WidgetChangedCallback struct which implements IWidgetChangedCallback.

func RangeOverCanvas

func RangeOverCanvas(c IRangeOverCanvas, f ICellProcessor)

RangeOverCanvas applies the supplied function to each cell, modifying it in place.

func RemoveWidgetCallback

func RemoveWidgetCallback(c ICallbacks, name interface{}, id IIdentity)

func RenderRoot

func RenderRoot(w IWidget, t *App)

RenderRoot is called from the App application object when beginning the widget rendering process. It starts at the root of the widget hierarchy with an IRenderBox size argument equal to the size of the current terminal.

func RunWidgetCallbacks

func RunWidgetCallbacks(c ICallbacks, name interface{}, app IApp, data ...interface{})

func SelectableIfAnySubWidgetsAre

func SelectableIfAnySubWidgetsAre(w ICompositeMultipleDimensions) bool

SelectableIfAnySubWidgetsAre is useful for various container widgets.

func SetPrefPosition

func SetPrefPosition(curw interface{}, prefPos int, app IApp) bool

func TranslatedMouseEvent

func TranslatedMouseEvent(ev interface{}, x, y int) interface{}

TranslatedMouseEvent is supplied with a tcell event and an x and y offset - it returns a tcell mouse event that represents a horizontal and vertical translation.

func UserInputIfSelectable

func UserInputIfSelectable(w IWidget, ev interface{}, size IRenderSize, focus Selector, app IApp) bool

UserInputIfSelectable will return false if the widget is not selectable; otherwise it will try the widget's UserInput function.

func WriteToCanvas

func WriteToCanvas(c IRangeOverCanvas, p []byte) (n int, err error)

WriteToCanvas extracts the logic of implementing io.Writer into a free function that can be used by any canvas implementing ICanvas.

Types

type AddressProvidesID

type AddressProvidesID struct{}

AddressProvidesID is a convenience struct that can be embedded in widgets. It provides an ID() function by simply returning the pointer of its caller argument. The ID() function is for widgets that want to implement IIdentity, which is needed by containers that want to compare widgets. For example, if the user clicks on a button.Widget, the app can be used to save that widget. When the click is released, the button's UserInput function tries to determine whether the mouse was released over the same widget that was clicked. It can do this by comparing the widgets' ID() values. Note that this will not work if new button widgets are created each time Render/UserInput is called (because the caller will change).

func (*AddressProvidesID) ID

func (a *AddressProvidesID) ID() interface{}

type App

type App struct {
	IPalette // App holds an IPalette and provides it to each widget when rendering

	TCellEvents       chan tcell.Event       // Events from tcell e.g. resize
	AfterRenderEvents chan IAfterRenderEvent // Functions intended to run on the widget goroutine

	MouseState   // Track which mouse buttons are currently down
	ClickTargets // When mouse is clicked, track potential interaction here
	// contains filtered or unexported fields
}

App is an implementation of IApp. The App struct conforms to IApp and provides services to a running gowid application, such as access to the palette, the screen and the state of the mouse.

func NewApp

func NewApp(args AppArgs) (rapp *App, rerr error)

func (*App) ActivateScreen added in v1.1.0

func (a *App) ActivateScreen() error

Let screen be taken over by gowid/tcell. A new screen struct is created because I can't make tcell claim and release the same screen successfully. Clients of the app struct shouldn't cache the screen object returned via GetScreen().

Assumes we own the screen...

func (*App) Clips

func (a *App) Clips() []ICopyResult

func (*App) Close

func (a *App) Close()

Close should be called by a gowid application after the user terminates the application. It will cleanup tcell's screen object.

func (*App) CopyLevel

func (a *App) CopyLevel(lvl ...int) int

func (*App) CopyModeClaimedAt

func (a *App) CopyModeClaimedAt(lvl ...int) int

func (*App) CopyModeClaimedBy

func (a *App) CopyModeClaimedBy(id ...IIdentity) IIdentity

func (*App) DeactivateScreen added in v1.1.0

func (a *App) DeactivateScreen()

Assumes we own the screen

func (*App) GetColorMode

func (a *App) GetColorMode() ColorMode

func (*App) GetLastMouseState

func (a *App) GetLastMouseState() MouseState

func (*App) GetMouseState

func (a *App) GetMouseState() MouseState

func (*App) GetPalette

func (a *App) GetPalette() IPalette

func (*App) GetScreen

func (a *App) GetScreen() tcell.Screen

func (*App) HandleTCellEvent

func (a *App) HandleTCellEvent(ev interface{}, unhandled IUnhandledInput)

HandleTCellEvent handles an event from the underlying TCell library, based on its type (key-press, error, etc.) User input events are sent to onInputEvent, which will check the widget hierarchy to see if the input can be processed; other events might result in gowid updating its internal state, like the size of the underlying terminal.

func (*App) InCopyMode

func (a *App) InCopyMode(on ...bool) bool

func (*App) MainLoop

func (a *App) MainLoop(unhandled IUnhandledInput)

MainLoop is the intended gowid entry point for typical applications. After the App is instantiated and the widget hierarchy set up, the application should call MainLoop with a handler for processing input that is not consumed by any widget.

func (*App) Quit

func (a *App) Quit()

Quit will terminate the gowid main loop.

func (*App) Redraw

func (a *App) Redraw()

Redraw will re-render the widget hierarchy.

func (*App) RedrawTerminal

func (a *App) RedrawTerminal()

RedrawTerminal updates the gui, re-drawing frames and buffers. Call this from the widget-handling goroutine only. Intended for use by apps that construct their own main loops and handle gowid events themselves.

func (*App) RefreshCopyMode

func (a *App) RefreshCopyMode()

func (*App) RegisterMenu

func (a *App) RegisterMenu(menu IMenuCompatible)

RegisterMenu should be called by any widget that wants to display a menu. The call could be made after initializing the App object. This call adds the menu above the current root of the widget hierarchy - when the App renders from the root down, any open menus will be rendered on top of the original root (using the overlay widget).

func (*App) Run

func (a *App) Run(f IAfterRenderEvent) error

Run executes this function on the goroutine that renders widgets and processes their callbacks. Any function that manipulates widget state outside of the Render/UserInput chain should be run this way for thread-safety e.g. a function that changes the UI from a timer event.

func (*App) RunThenRenderEvent

func (a *App) RunThenRenderEvent(ev IAfterRenderEvent)

RunThenRenderEvent dispatches the event by calling it with the app as an argument - then it will force the application to re-render itself.

func (*App) Runner

func (a *App) Runner() *AppRunner

func (*App) SetColorMode

func (a *App) SetColorMode(mode ColorMode)

func (*App) SetPalette

func (a *App) SetPalette(palette IPalette)

func (*App) SetSubWidget

func (a *App) SetSubWidget(widget IWidget, app IApp)

func (*App) SimpleMainLoop

func (a *App) SimpleMainLoop()

SimpleMainLoop will run your application using a default unhandled input function that will terminate your application on q/Q, ctrl-c and escape.

func (*App) StartTCellEvents

func (a *App) StartTCellEvents(quit <-chan Unit, wg *sync.WaitGroup)

StartTCellEvents starts a goroutine that listens for events from TCell. The PollEvent function will block until TCell has something to report - when something arrives, it is written to the tcellEvents channel. The function is provided with a quit channel which is consulted for an event that will terminate this goroutine.

func (*App) StopTCellEvents

func (a *App) StopTCellEvents(quit chan<- Unit, wg *sync.WaitGroup)

StopTCellEvents will cause TCell to generate an interrupt event; an event is posted to the quit channel first to stop the TCell event goroutine.

func (*App) SubWidget

func (a *App) SubWidget() IWidget

func (*App) Sync

func (a *App) Sync()

Sync defers immediately to tcell's Screen's Sync() function - it is for updating every screen cell in the event something corrupts the screen (e.g. ssh -v logging)

func (*App) TerminalSize

func (a *App) TerminalSize() (x, y int)

TerminalSize returns the terminal's size.

func (*App) UnregisterMenu

func (a *App) UnregisterMenu(menu IMenuCompatible) bool

UnregisterMenu will remove a menu from the widget hierarchy. If it's not found, false is returned.

type AppArgs

type AppArgs struct {
	Screen               tcell.Screen
	View                 IWidget
	Palette              IPalette
	EnableMouseMotion    bool
	EnableBracketedPaste bool
	Log                  log.StdLogger
	DontActivate         bool
	Tty                  string
}

AppArgs is a helper struct, providing arguments for the initialization of App.

type AppRunner

type AppRunner struct {
	// contains filtered or unexported fields
}

func (*AppRunner) Start

func (st *AppRunner) Start()

func (*AppRunner) Stop

func (st *AppRunner) Stop()

type BackgroundColor

type BackgroundColor struct {
	IColor
}

BackgroundColor is an ICellStyler that expresses a specific background color and no preference for foreground color or style.

func MakeBackground

func MakeBackground(c IColor) BackgroundColor

func (BackgroundColor) GetStyle

func (a BackgroundColor) GetStyle(prov IRenderContext) (x IColor, y IColor, z StyleAttrs)

GetStyle implements ICellStyler.

type Callback

type Callback struct {
	Name interface{}
	CallbackFunction
}

Callback is a simple implementation of ICallback.

func (Callback) ID

func (f Callback) ID() interface{}

type CallbackFunction

type CallbackFunction func(args ...interface{})

func (CallbackFunction) Call

func (f CallbackFunction) Call(args ...interface{})

type CallbackID

type CallbackID struct {
	Name interface{}
}

func (CallbackID) ID

func (f CallbackID) ID() interface{}

type Callbacks

type Callbacks struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewCallbacks

func NewCallbacks() *Callbacks

func (*Callbacks) AddCallback

func (c *Callbacks) AddCallback(name interface{}, cb ICallback)

func (*Callbacks) CopyOfCallbacks

func (c *Callbacks) CopyOfCallbacks(name interface{}) ([]ICallback, bool)

CopyOfCallbacks is used when callbacks are run - they are copied so that any callers modifying the callbacks themselves can do so safely with the modifications taking effect after all callbacks are run. Can be called with a nil receiver if the widget's callback object has not been initialized and e.g. RunWidgetCallbacks is called.

func (*Callbacks) RemoveCallback

func (c *Callbacks) RemoveCallback(name interface{}, cb IIdentity) bool

func (*Callbacks) RunCallbacks

func (c *Callbacks) RunCallbacks(name interface{}, args ...interface{})

type Canvas

type Canvas struct {
	Lines [][]Cell // inner array is a line
	Marks *map[string]CanvasPos
	// contains filtered or unexported fields
}

Canvas is a simple implementation of ICanvas, and is returned by the Render() function of all the current widgets. It represents the canvas by a 2-dimensional array of Cells - no tricks or attempts to optimize this yet! The canvas also stores a map of string identifiers to positions - for example, the cursor position is tracked this way, and the menu widget keeps track of where it should render a "dropdown" using canvas marks. Most Canvas APIs expect that each line has the same length.

func NewCanvas

func NewCanvas() *Canvas

NewCanvas returns an initialized Canvas struct. Its size is 0 columns and 0 rows.

func NewCanvasOfSize

func NewCanvasOfSize(cols, rows int) *Canvas

NewCanvasOfSize returns a canvas struct of size cols x rows, where each Cell is default-initialized (i.e. empty).

func NewCanvasOfSizeExt

func NewCanvasOfSizeExt(cols, rows int, fill Cell) *Canvas

NewCanvasOfSize returns a canvas struct of size cols x rows, where each Cell is initialized by copying the fill argument.

func NewCanvasWithLines

func NewCanvasWithLines(lines [][]Cell) *Canvas

NewCanvasWithLines allocates a canvas struct and sets its contents to the 2-d array provided as an argument.

func (*Canvas) AlignRight

func (c *Canvas) AlignRight()

AlignRight will extend each row of Cells in the receiver Canvas with an empty Cell in order to ensure all rows are the same length. Note that the Canvas will not increase in width as a result.

func (*Canvas) AlignRightWith

func (c *Canvas) AlignRightWith(cell Cell)

AlignRightWith will extend each row of Cells in the receiver Canvas with the supplied Cell in order to ensure all rows are the same length. Note that the Canvas will not increase in width as a result.

func (*Canvas) AppendBelow

func (c *Canvas) AppendBelow(c2 IAppendCanvas, doCursor bool, makeCopy bool)

AppendBelow appends the supplied Canvas to the "bottom" of the receiver Canvas. If doCursor is true and the supplied Canvas has an enabled cursor, it is applied to the received Canvas, with a suitable Y offset. If makeCopy is true then the supplied Canvas is copied; if false, and the supplied Canvas is capable of giving up ownership of its data structures, then they are moved to the receiver Canvas.

func (*Canvas) AppendLine

func (c *Canvas) AppendLine(line []Cell, makeCopy bool)

AppendLine will append the array of Cells provided to the bottom of the receiver Canvas. If the makeCopy argument is true, a copy is made of the provided Cell array; otherwise, a slice is taken and used directly, meaning the Canvas will hold a reference to the underlying array.

func (*Canvas) AppendRight

func (c *Canvas) AppendRight(c2 IMergeCanvas, useCursor bool)

AppendRight appends the supplied Canvas to the right of the receiver Canvas. It assumes both Canvases have the same number of rows. If useCursor is true and the supplied Canvas has an enabled cursor, then it is applied with a suitable X offset applied.

func (*Canvas) BoxColumns

func (c *Canvas) BoxColumns() int

BoxColumns helps Canvas conform to IRenderBox.

func (*Canvas) BoxRows

func (c *Canvas) BoxRows() int

BoxRows helps Canvas conform to IRenderBox.

func (*Canvas) CellAt

func (c *Canvas) CellAt(col, row int) Cell

CellAt returns the Cell at the Canvas position provided. Note that the function assumes the caller has ensured the position is not out of bounds.

func (*Canvas) ComputeCurrentMaxColumn

func (c *Canvas) ComputeCurrentMaxColumn() int

ComputeCurrentMaxColumn walks the 2-d array of Cells to determine the length of the longest line. This is used by certain APIs that manipulate the canvas.

func (*Canvas) CursorCoords

func (c *Canvas) CursorCoords() CanvasPos

CursorCoords returns a pair of ints representing the current cursor coordinates. Note that the caller must be sure the Canvas's cursor is enabled.

func (*Canvas) CursorEnabled

func (c *Canvas) CursorEnabled() bool

CursorEnabled returns true if the cursor is enabled in this canvas, false otherwise.

func (*Canvas) Duplicate

func (c *Canvas) Duplicate() ICanvas

Duplicate returns a deep copy of the receiver canvas.

func (*Canvas) ExtendLeft

func (c *Canvas) ExtendLeft(cells []Cell)

ExtendLeft prepends to each line of the receiver Canvas the array of Cells provided as an argument.

func (*Canvas) ExtendRight

func (c *Canvas) ExtendRight(cells []Cell)

ExtendRight appends to each line of the receiver Canvas the array of Cells provided as an argument.

func (*Canvas) GetMark

func (c *Canvas) GetMark(name string) (CanvasPos, bool)

GetMark returns the position and presence/absence of the specified string identifier in the Canvas.

func (*Canvas) ImplementsWidgetDimension

func (c *Canvas) ImplementsWidgetDimension()

BoxRows helps Canvas conform to IWidgetDimension.

func (*Canvas) Line

func (c *Canvas) Line(y int, cp LineCopy) LineResult

Line provides access to the lines of the canvas. LineCopy determines what the Line() function should allocate if it needs to make a copy of the Line. Return true if line was copied.

func (*Canvas) MergeUnder

func (c *Canvas) MergeUnder(c2 IMergeCanvas, leftOffset, topOffset int, bottomGetsCursor bool)

MergeUnder merges the supplied Canvas "under" the receiver Canvas, meaning the receiver Canvas's Cells' settings are given priority.

func (*Canvas) MergeWithFunc

func (c *Canvas) MergeWithFunc(c2 IMergeCanvas, leftOffset, topOffset int, fn CellMergeFunc, bottomGetsCursor bool)

MergeWithFunc merges the supplied Canvas with the receiver canvas, where the receiver canvas is considered to start at column leftOffset and at row topOffset, therefore translated some distance from the top-left, and the receiver Canvas is the one modified. A function argument is supplied which specifies how Cells are merged, one by one e.g. which style takes effect, which rune, and so on.

func (*Canvas) RangeOverMarks

func (c *Canvas) RangeOverMarks(f func(key string, value CanvasPos) bool)

RangeOverMarks applies the supplied function to each mark and position in the received Canvas. If the function returns false, the loop is terminated.

func (*Canvas) RemoveMark

func (c *Canvas) RemoveMark(name string)

RemoveMark removes a mark from the Canvas.

func (*Canvas) SetCellAt

func (c *Canvas) SetCellAt(col, row int, cell Cell)

SetCellAt sets the Canvas Cell at the position provided. Note that the function assumes the caller has ensured the position is not out of bounds.

func (*Canvas) SetCursorCoords

func (c *Canvas) SetCursorCoords(x, y int)

SetCursorCoords will set the Canvas's cursor coordinates. The special input of (-1,-1) will disable the cursor.

func (*Canvas) SetLineAt

func (c *Canvas) SetLineAt(row int, line []Cell)

SetLineAt sets a line of the Canvas at the given y position. The function assumes a line of the correct width has been provided.

func (*Canvas) SetMark

func (c *Canvas) SetMark(name string, x, y int)

SetMark allows the caller to store a string identifier at a particular position in the Canvas. The menu widget uses this feature to keep track of where it should "open", acting as an overlay over the widgets below.

func (*Canvas) String

func (c *Canvas) String() string

String lets Canvas conform to fmt.Stringer.

func (*Canvas) TrimLeft

func (c *Canvas) TrimLeft(colsToHave int)

TrimLeft removes columns from the left of the receiver Canvas until there is the specified number left.

func (*Canvas) TrimRight

func (c *Canvas) TrimRight(colsToHave int)

TrimRight removes columns from the right of the receiver Canvas until there is the specified number left.

func (*Canvas) Truncate

func (c *Canvas) Truncate(above, below int)

Truncate removes "above" lines from above the receiver Canvas, and "below" lines from below.

func (*Canvas) Write

func (c *Canvas) Write(p []byte) (n int, err error)

Write lets Canvas conform to io.Writer. Since each Canvas Cell holds a rune, the byte array argument is interpreted as the UTF-8 encoding of a sequence of runes.

type CanvasPos

type CanvasPos struct {
	X, Y int
}

CanvasPos is a convenience struct to represent the coordinates of a position on a canvas.

func (CanvasPos) PlusX

func (c CanvasPos) PlusX(n int) CanvasPos

func (CanvasPos) PlusY

func (c CanvasPos) PlusY(n int) CanvasPos

type CanvasSizeWrong

type CanvasSizeWrong struct {
	Requested IRenderSize
	Actual    IRenderBox
}

func (CanvasSizeWrong) Error

func (e CanvasSizeWrong) Error() string

type Cell

type Cell struct {
	// contains filtered or unexported fields
}

Cell represents a single element of terminal output. The empty value is a blank cell with default colors, style, and a 'blank' rune. It is closely tied to TCell's underlying cell representation - colors are TCell-specific, so are translated from anything more general before a Cell is instantiated.

func CellFromRune

func CellFromRune(r rune) Cell

CellFromRune returns a Cell with the supplied rune and with default coloring and styling.

func CellsFromString

func CellsFromString(s string) []Cell

CellsFromString is a utility function to turn a string into an array of Cells. Note that each Cell has no color or style set.

func EmptyLine

func EmptyLine(length int) []Cell

EmptyLine provides a ready-allocated source of empty cells. Of course this is to be treated as read-only.

func MakeCell

func MakeCell(codePoint rune, fg TCellColor, bg TCellColor, Attr StyleAttrs) Cell

MakeCell returns a Cell initialized with the supplied run (char to display), foreground color, background color and style attributes. Each color can specify "default" meaning whatever the terminal default foreground/background is, or "none" meaning no preference, allowing it to be overridden when laid on top of another Cell during the render process.

func (Cell) BackgroundColor

func (c Cell) BackgroundColor() TCellColor

BackgroundColor returns the background color of the receiver Cell.

func (Cell) ForegroundColor

func (c Cell) ForegroundColor() TCellColor

ForegroundColor returns the foreground color of the receiver Cell.

func (Cell) GetDisplayAttrs

func (c Cell) GetDisplayAttrs() (x TCellColor, y TCellColor, z StyleAttrs)

GetDisplayAttrs returns the receiver Cell's foreground and background color and styling.

func (Cell) HasRune

func (c Cell) HasRune() bool

HasRune returns true if the Cell actively specifies a rune to display; otherwise false, meaning there it is "empty", and a Cell layered underneath it will have its rune displayed.

func (Cell) MergeDisplayAttrsUnder

func (c Cell) MergeDisplayAttrsUnder(upper Cell) Cell

MergeDisplayAttrsUnder returns a Cell representing the receiver Cell with the argument Cell's color and styling applied, if they are explicitly set.

func (Cell) MergeUnder

func (c Cell) MergeUnder(upper Cell) Cell

MergeUnder returns a Cell representing the receiver merged "underneath" the Cell argument provided. This means the argument's rune value will be used unless it is "empty", and the cell's color and styling come from the argument's value in a similar fashion.

func (Cell) Rune

func (c Cell) Rune() rune

Rune will return a rune that can be displayed, if this Cell is being rendered in some fashion. If the Cell is empty, then a space rune is returned.

func (Cell) Style

func (c Cell) Style() StyleAttrs

Style returns the style of the receiver Cell.

func (Cell) WithBackgroundColor

func (c Cell) WithBackgroundColor(a TCellColor) Cell

WithBackgroundColor returns a Cell equal to the receiver Cell but that will render with the supplied background color instead. Note that this color can be set to "none" by passing the value gowid.ColorNone, meaning allow Cells layered underneath to determine the background color.

func (Cell) WithForegroundColor

func (c Cell) WithForegroundColor(a TCellColor) Cell

WithForegroundColor returns a Cell equal to the receiver Cell but that will render with the supplied foreground color instead. Note that this color can be set to "none" by passing the value gowid.ColorNone, meaning allow Cells layered underneath to determine the background color.

func (Cell) WithNoRune

func (c Cell) WithNoRune() Cell

WithRune returns a Cell equal to the receiver Cell but that will render no rune instead i.e. it is "empty".

func (Cell) WithRune

func (c Cell) WithRune(r rune) Cell

WithRune returns a Cell equal to the receiver Cell but that will render the supplied rune instead.

func (Cell) WithStyle

func (c Cell) WithStyle(attr StyleAttrs) Cell

WithStyle returns a Cell equal to the receiver Cell but that will render with the supplied style (e.g. underline) instead. Note that this style can be set to "none" by passing the value gowid.AttrNone, meaning allow Cells layered underneath to determine the style.

type CellMergeFunc

type CellMergeFunc func(lower, upper Cell) Cell

type CellRangeFunc

type CellRangeFunc func(cell Cell) Cell

CellRangeFunc is an adaptor for a simple function to implement ICellProcessor.

func (CellRangeFunc) ProcessCell

func (f CellRangeFunc) ProcessCell(cell Cell) Cell

ProcessCell hands over processing to the adapted function.

type ClickCB

type ClickCB struct{}

type ClickCallbacks

type ClickCallbacks struct {
	CB **Callbacks
}

ClickCallbacks is a convenience struct for embedding in a widget, providing methods to add and remove callbacks that are executed when the widget is "clicked".

func (*ClickCallbacks) OnClick

func (w *ClickCallbacks) OnClick(f IWidgetChangedCallback)

func (*ClickCallbacks) RemoveOnClick

func (w *ClickCallbacks) RemoveOnClick(f IIdentity)

type ClickTargets

type ClickTargets struct {
	// contains filtered or unexported fields
}

ClickTargets is used by the App to keep track of which widgets have been clicked. This allows the application to determine if a widget has been "selected" which may be best determined across two calls to UserInput - click and release.

func MakeClickTargets

func MakeClickTargets() ClickTargets

func (ClickTargets) ClickTarget

func (t ClickTargets) ClickTarget(f func(tcell.ButtonMask, IIdentityWidget))

func (ClickTargets) DeleteClickTargets

func (t ClickTargets) DeleteClickTargets(k tcell.ButtonMask)

func (ClickTargets) SetClickTarget

func (t ClickTargets) SetClickTarget(k tcell.ButtonMask, w IIdentityWidget) bool

SetClickTarget expects a Widget that provides an ID() function. Most widgets that can be clicked on can just use the default (&w). But if a widget might be recreated between the click down and release, and the widget under focus at the time of the release provides the same ID() (even if not the same object), then it can be given the click.

type Color

type Color struct {
	IColor
	Id string
}

Color satisfies IColor, embeds an IColor, and allows a gowid Color to be constructed from a string alone. Each of the more specific color types is tried in turn with the string until one succeeds.

func MakeColor

func MakeColor(s string) Color

func MakeColorSafe

func MakeColorSafe(s string) (Color, error)

MakeColorSafe returns a Color struct specified by the string argument, in a do-what-I-mean fashion - it tries the Color struct maker functions in a pre-determined order until one successfully initialized a Color, or until all fail - in which case an error is returned. The order tried is TCellColor, RGBColor, GrayColor, UrwidColor.

func (Color) String

func (c Color) String() string

type ColorByMode

type ColorByMode struct {
	Colors map[ColorMode]IColor // Indexed by ColorMode
}

func MakeColorByMode

func MakeColorByMode(cols map[ColorMode]IColor) ColorByMode

func MakeColorByModeSafe

func MakeColorByModeSafe(cols map[ColorMode]IColor) (ColorByMode, error)

func (ColorByMode) ToTCellColor

func (c ColorByMode) ToTCellColor(mode ColorMode) (TCellColor, bool)

type ColorInverter

type ColorInverter struct {
	ICellStyler
}

ColorInverter implements ICellStyler, and simply swaps foreground and background colors.

func (ColorInverter) GetStyle

func (c ColorInverter) GetStyle(prov IRenderContext) (x IColor, y IColor, z StyleAttrs)

type ColorMode

type ColorMode int

ColorMode represents the color capability of a terminal.

func (ColorMode) String

func (c ColorMode) String() string

type ColorModeMismatch

type ColorModeMismatch struct {
	Color IColor
	Mode  ColorMode
}

func (ColorModeMismatch) Error

func (e ColorModeMismatch) Error() string

type ContainerWidget

type ContainerWidget struct {
	IWidget
	D IWidgetDimension
}

ContainerWidget is a simple implementation that conforms to IContainerWidget. It can be used to pass widgets to containers like pile.Widget and columns.Widget.

func (ContainerWidget) Dimension

func (ww ContainerWidget) Dimension() IWidgetDimension

func (*ContainerWidget) SetDimension

func (ww *ContainerWidget) SetDimension(d IWidgetDimension)

func (*ContainerWidget) SetSubWidget

func (w *ContainerWidget) SetSubWidget(wi IWidget, app IApp)

func (*ContainerWidget) String

func (w *ContainerWidget) String() string

func (*ContainerWidget) SubWidget

func (w *ContainerWidget) SubWidget() IWidget

type CopyModeClipsEvent

type CopyModeClipsEvent struct {
	Action ICopyModeClips
}

func (CopyModeClipsEvent) When

func (c CopyModeClipsEvent) When() time.Time

type CopyModeClipsFn

type CopyModeClipsFn func([]ICopyResult)

func (CopyModeClipsFn) Collect

func (f CopyModeClipsFn) Collect(clips []ICopyResult)

type CopyModeEvent

type CopyModeEvent struct{}

func (CopyModeEvent) When

func (c CopyModeEvent) When() time.Time

type CopyResult

type CopyResult struct {
	Name string
	Val  string
}

func (CopyResult) ClipName

func (c CopyResult) ClipName() string

func (CopyResult) ClipValue

func (c CopyResult) ClipValue() string

type DefaultColor

type DefaultColor struct{}

DefaultColor implements IColor and means use whatever the default terminal color is. This is different to NoColor, which expresses no preference.

func (DefaultColor) String

func (r DefaultColor) String() string

func (DefaultColor) ToTCellColor

func (r DefaultColor) ToTCellColor(mode ColorMode) (TCellColor, bool)

ToTCellColor converts DefaultColor to TCellColor. This lets DefaultColor conform to the IColor interface.

type DimensionError

type DimensionError struct {
	Size IRenderSize
	Dim  IWidgetDimension
	Row  int
}

func (DimensionError) Error

func (e DimensionError) Error() string

type DimensionsCB

type DimensionsCB struct{}

type Direction

type Direction int

type EmptyLineTooLong

type EmptyLineTooLong struct {
	Requested int
}

func (EmptyLineTooLong) Error

func (e EmptyLineTooLong) Error() string

type EmptyPalette

type EmptyPalette struct{}

EmptyPalette implements ICellStyler and returns no preference for any colors or styling.

func MakeEmptyPalette

func MakeEmptyPalette() EmptyPalette

func (EmptyPalette) GetStyle

func (a EmptyPalette) GetStyle(prov IRenderContext) (x IColor, y IColor, z StyleAttrs)

GetStyle implements ICellStyler.

type FocusCB

type FocusCB struct{}

type FocusCallbacks

type FocusCallbacks struct {
	CB **Callbacks
}

FocusCallbacks is a convenience struct for embedding in a widget, providing methods to add and remove callbacks that are executed when the widget's focus widget changes.

func (*FocusCallbacks) OnFocusChanged

func (w *FocusCallbacks) OnFocusChanged(f IWidgetChangedCallback)

func (*FocusCallbacks) RemoveOnFocusChanged

func (w *FocusCallbacks) RemoveOnFocusChanged(f IIdentity)

type FocusPathResult

type FocusPathResult struct {
	Succeeded   bool
	FailedLevel int
}

func SetFocusPath

func SetFocusPath(w IWidget, path []interface{}, app IApp) FocusPathResult

SetFocusPath takes an array of focus positions, and applies them down the widget hierarchy starting at the supplied widget, w. If not all positions can be applied, the result's Succeeded field is set to false, and the FailedLevel field provides the index in the array of paths that could not be applied.

func (FocusPathResult) Error

func (f FocusPathResult) Error() string

type ForegroundColor

type ForegroundColor struct {
	IColor
}

ForegroundColor is an ICellStyler that expresses a specific foreground color and no preference for background color or style.

func MakeForeground

func MakeForeground(c IColor) ForegroundColor

func (ForegroundColor) GetStyle

func (a ForegroundColor) GetStyle(prov IRenderContext) (x IColor, y IColor, z StyleAttrs)

GetStyle implements ICellStyler.

type GrayColor

type GrayColor struct {
	Val int
}

GrayColor is an IColor that represents a greyscale specified by the same syntax as urwid - http://urwid.org/manual/displayattributes.html and search for "gray scale entries". Strings may be of the form "g3", "g100" or "g#a1", "g#ff" if hexadecimal is preferred. These index the grayscale color cube.

func MakeGrayColor

func MakeGrayColor(val string) GrayColor

MakeGrayColor returns an initialized GrayColor provided with a string input like "g50" or "g#ab". If the input is invalid, the function panics.

func MakeGrayColorSafe

func MakeGrayColorSafe(val string) (GrayColor, error)

MakeGrayColorSafe returns an initialized GrayColor provided with a string input like "g50" or "g#ab". If the input is invalid, an error is returned.

func (GrayColor) String

func (g GrayColor) String() string

func (GrayColor) ToTCellColor

func (s GrayColor) ToTCellColor(mode ColorMode) (TCellColor, bool)

ToTCellColor converts the receiver GrayColor to a TCellColor, ready for rendering to a tcell screen. This lets GrayColor conform to IColor.

type HAlignCB

type HAlignCB struct{}

type HAlignLeft

type HAlignLeft struct {
	Margin      int
	MarginRight int
}

func (HAlignLeft) ImplementsHAlignment

func (h HAlignLeft) ImplementsHAlignment()

type HAlignMiddle

type HAlignMiddle struct{}

func (HAlignMiddle) ImplementsHAlignment

func (h HAlignMiddle) ImplementsHAlignment()

type HAlignRight

type HAlignRight struct{}

func (HAlignRight) ImplementsHAlignment

func (h HAlignRight) ImplementsHAlignment()

type HeightCB

type HeightCB struct{}

type IAfterRenderEvent

type IAfterRenderEvent interface {
	RunThenRenderEvent(IApp)
}

IAfterRenderEvent is implemented by clients that wish to run a function on the gowid rendering goroutine, directly after the widget hierarchy is rendered. This allows the client to be sure that there is no race condition with the widget rendering code.

type IApp

type IApp interface {
	IRenderContext
	IGetScreen
	ISettableComposite
	Quit()                                                     // Terminate the running gowid app + main loop soon
	Redraw()                                                   // Issue a redraw of the terminal soon
	Sync()                                                     // From tcell's screen - refresh every screen cell e.g. if screen becomes corrupted
	SetColorMode(mode ColorMode)                               // Change the terminal's color mode - 256, 16, mono, etc
	Run(f IAfterRenderEvent) error                             // Send a function to run on the widget rendering goroutine
	SetClickTarget(k tcell.ButtonMask, w IIdentityWidget) bool // When a mouse is clicked on a widget, track that widget. So...
	ClickTarget(func(tcell.ButtonMask, IIdentityWidget))       // when the button is released, we can activate the widget if we are still "over" it
	GetMouseState() MouseState                                 // Which buttons are currently clicked
	GetLastMouseState() MouseState                             // Which buttons were clicked before current event
	RegisterMenu(menu IMenuCompatible)                         // Required for an app to display an overlaying menu
	UnregisterMenu(menu IMenuCompatible) bool                  // Returns false if the menu is not found in the hierarchy
	InCopyMode(...bool) bool                                   // A getter/setter - to set the app into copy mode. Widgets might render differently as a result
	CopyModeClaimedAt(...int) int                              // the level that claims copy, 0 means deepest should claim
	CopyModeClaimedBy(...IIdentity) IIdentity                  // the level that claims copy, 0 means deepest should claim
	RefreshCopyMode()                                          // Give widgets another chance to display copy options (after the user perhaps adjusted the scope of a copy selection)
	Clips() []ICopyResult                                      // If in copy-mode, the app will descend the widget hierarchy with a special user input, gathering options for copying data
	CopyLevel(...int) int                                      // level we're at as we descend
}

IApp is the interface of the application passed to every widget during Render or UserInput. It provides several features: - a function to terminate the application - access to the state of the mouse - access to the underlying tcell screen - access to an application-specific logger - functions to get and set the root widget of the widget hierarchy - a method to keep track of which widgets were last "clicked"

type IAppendBlankLines

type IAppendBlankLines interface {
	BoxColumns() int
	AppendBelow(c IAppendCanvas, doCursor bool, makeCopy bool)
}

type IAppendCanvas

type IAppendCanvas interface {
	IRenderBox
	ICanvasLineReader
	ICanvasMarkIterator
}

type IBox

type IBox interface {
	BoxColumns() int
	BoxRows() int
}

type ICallback

type ICallback interface {
	IIdentity
	Call(args ...interface{})
}

ICallback represents any object that can provide a way to be compared to others, and that can be called with an arbitrary number of arguments returning no result. The comparison is expected to be used by having the callback object provide a name to identify the callback operation e.g. "buttonclicked", so that it can later be removed.

type ICallbackRunner

type ICallbackRunner interface {
	RunWidgetCallbacks(name interface{}, app IApp, w IWidget)
}

type ICallbacks

type ICallbacks interface {
	RunCallbacks(name interface{}, args ...interface{})
	AddCallback(name interface{}, cb ICallback)
	RemoveCallback(name interface{}, cb IIdentity) bool
}

type ICanvas

type ICanvas interface {
	Duplicate() ICanvas
	MergeUnder(c IMergeCanvas, leftOffset, topOffset int, bottomGetsCursor bool)
	AppendBelow(c IAppendCanvas, doCursor bool, makeCopy bool)
	AppendRight(c IMergeCanvas, useCursor bool)
	SetCellAt(col, row int, c Cell)
	SetLineAt(row int, line []Cell)
	Truncate(above, below int)
	ExtendRight(cells []Cell)
	ExtendLeft(cells []Cell)
	TrimRight(cols int)
	TrimLeft(cols int)
	SetCursorCoords(col, row int)
	SetMark(name string, col, row int)
	GetMark(name string) (CanvasPos, bool)
	RemoveMark(name string)
	ICanvasMarkIterator
	ICanvasCellReader
	IDrawCanvas
	fmt.Stringer
}

ICanvas is the interface of any object which can generate a 2-dimensional array of Cells that are intended to be rendered on a terminal. This interface is pretty awful - cluttered and inconsistent and subject to cleanup... Note though that this interface is not here as the minimum requirement for providing arguments to a function or module - instead it's supposed to be an API surface for widgets so includes features that I am trying to guess will be needed, or that widgets already need.

type ICanvasCellReader

type ICanvasCellReader interface {
	CellAt(col, row int) Cell
}

ICanvasCellReader can provide a Cell given a row and a column.

type ICanvasLineReader

type ICanvasLineReader interface {
	Line(int, LineCopy) LineResult
}

ICanvasLineReader can provide a particular line of Cells, at the specified y offset. The result may or may not be a copy of the actual Cells, and is determined by whether the user requested a copy and/or the capability of the ICanvasLineReader (maybe it has to provide a copy).

type ICanvasMarkIterator

type ICanvasMarkIterator interface {
	RangeOverMarks(f func(key string, value CanvasPos) bool)
}

ICanvasMarkIterator will call the supplied function argument with the name and position of every mark set on the canvas. If the function returns true, the loop is terminated early.

type ICellProcessor

type ICellProcessor interface {
	ProcessCell(cell Cell) Cell
}

ICellProcessor is a general interface used by several gowid types for processing a range of Cell types. For example, a canvas provides a function to range over its contents, each cell being handed to an ICellProcessor.

type ICellStyler

type ICellStyler interface {
	GetStyle(IRenderContext) (IColor, IColor, StyleAttrs)
}

ICellStyler is an analog to urwid's AttrSpec (http://urwid.org/reference/attrspec.html). When provided a RenderContext (specifically the color mode in which to be rendered), the GetStyle() function will return foreground, background and style values with which a cell should be rendered. The IRenderContext argument provides access to the global palette, so an ICellStyle implementation can look up palette entries by name.

type IChangeFocus

type IChangeFocus interface {
	ChangeFocus(dir Direction, wrap bool, app IApp) bool
}

type IClickTracker

type IClickTracker interface {
	SetClickPending(bool)
}

IClickTracker is implemented by any type that can track the state of whether it was clicked. This is trivial, and may just be a boolean flag. It's intended for widgets that want to change their look when a mouse button is clicked when they are in focus, but before the button is released - to indicate that the widget is about to be activated. Of course if the user moves the cursor off the widget then releases the mouse button, the widget will not be activated.

type IClickable

type IClickable interface {
	Click(app IApp)
}

IClickable is implemented by any type that implements a Click() method, intended to be run in response to a user interaction with the type such as left mouse click or hitting enter.

type IClickableWidget

type IClickableWidget interface {
	IWidget
	IClickable
}

IClickableWidget is implemented by any widget that implements a Click() method, intended to be run in response to a user interaction with the widget such as left mouse click or hitting enter. A widget implementing Click() and ID() may be able to run UserInputCheckedWidget() for its UserInput() implementation.

type IClipboard

type IClipboard interface {
	Clips(app IApp) []ICopyResult
}

type IClipboardSelected

type IClipboardSelected interface {
	AlterWidget(w IWidget, app IApp) IWidget
}

IClipboardSelected is implemented by widgets that support changing their look when they have been "selected" in some application-level copy-mode, the idea being to provide the user with the information that this widget's contents will be copied.

type IColor

type IColor interface {
	ToTCellColor(mode ColorMode) (TCellColor, bool)
}

IColor is implemented by any object that can turn itself into a TCellColor, meaning a color with which a cell can be rendered. The display mode (e.g. 256 colors) is provided. If no TCellColor is available, the second argument should be set to false e.g. no color can be found given a particular string name.

type IColorMode

type IColorMode interface {
	GetColorMode() ColorMode
}

IColorMode provides access to a ColorMode value which represents the current mode of the terminal e.g. 24-bit color, 256-color, monochrome.

type IColumns

type IColumns interface {
	Columns() int
}

type IComposite

type IComposite interface {
	SubWidget() IWidget
}

IComposite is an interface for anything that has a concept of a single "inner" widget. This applies to certain widgets themselves (e.g. ButtonWidget) and also to the App object which holds the top-level view.

type ICompositeMultiple

type ICompositeMultiple interface {
	SubWidgets() []IWidget
}

ICompositeMultiple is an interface for widget containers that have multiple children and that support specifying how the children are laid out relative to each other.

type ICompositeMultipleDimensions

type ICompositeMultipleDimensions interface {
	ICompositeMultiple
	Dimensions() []IWidgetDimension
}

ICompositeMultipleDimensions is an interface for collections of widget dimensions, used in laying out some container widgets.

type ICompositeMultipleFocus

type ICompositeMultipleFocus interface {
	IFocus
	ICompositeMultiple
}

type ICompositeMultipleWidget

type ICompositeMultipleWidget interface {
	IWidget
	ICompositeMultipleDimensions
	IFocus
	// SubWidgetSize should return the IRenderSize value that will be used to render
	// an inner widget given the size used to render the outer widget and an
	// IWidgetDimension (such as units, weight, etc)
	SubWidgetSize(size IRenderSize, val int, sub IWidget, dim IWidgetDimension) IRenderSize
	// RenderSubWidgets should return an array of canvases representing each inner
	// widget, rendered in the context of the containing widget with the supplied
	// size argument.
	RenderSubWidgets(size IRenderSize, focus Selector, focusIdx int, app IApp) []ICanvas
	// RenderedSubWidgetsSizes should return a bounding box for each inner widget
	// when the containing widget is rendered with the provided size. Note that this
	// is not the same as rendering each inner widget separately, because the
	// container context might result in size adjustments e.g. adjusting the
	// height of inner widgets to make sure they're aligned vertically.
	RenderedSubWidgetsSizes(size IRenderSize, focus Selector, focusIdx int, app IApp) []IRenderBox
}

ICompositeMultipleWidget is a widget that implements ICompositeMultiple. The widget must support computing the render-time size of any of its children and setting focus.

type ICompositeWidget

type ICompositeWidget interface {
	IWidget
	IComposite
	ISubWidgetSize
}

ICompositeWidget is an interface implemented by widgets that contain one subwidget. Further implented methods could make it an IButtonWidget for example, which then means the RenderButton() function can be exploited to implement Render(). If you make a new Button by embedding ButtonWidget, you may be able to implement Render() by simply calling RenderButton().

type IContainerWidget

type IContainerWidget interface {
	IWidget
	IComposite
	Dimension() IWidgetDimension
	SetDimension(IWidgetDimension)
}

IContainerWidget is the type of an object that contains a widget and a render object that determines how it is rendered within a container of widgets. Note that it itself is an IWidget.

type ICopyModeClips

type ICopyModeClips interface {
	Collect([]ICopyResult)
}

type ICopyModeWidget

type ICopyModeWidget interface {
	IComposite
	IIdentity
	IClipboard
	CopyModeLevels() int
}

type ICopyResult

type ICopyResult interface {
	ClipName() string
	ClipValue() string
}

type IDrawCanvas

type IDrawCanvas interface {
	IRenderBox
	ICanvasLineReader
	CursorEnabled() bool
	CursorCoords() CanvasPos
}

type IFindNextSelectable

type IFindNextSelectable interface {
	FindNextSelectable(dir Direction, wrap bool) (int, bool)
}

IFindNextSelectable is for any object that can iterate to its next or previous object

type IFocus

type IFocus interface {
	Focus() int
	SetFocus(app IApp, i int)
}

IFocus is a container widget concept that describes which widget will be the target of keyboard input.

type IFocusSelectable

type IFocusSelectable interface {
	IFocus
	IFindNextSelectable
}

type IGetFocus

type IGetFocus interface {
	Focus() int
}

type IGetScreen

type IGetScreen interface {
	GetScreen() tcell.Screen
}

IGetScreen provides access to a tcell.Screen object e.g. for rendering a canvas to the terminal.

type IHAlignment

type IHAlignment interface {
	ImplementsHAlignment()
}

type IIdentity

type IIdentity interface {
	ID() interface{}
}

IIdentity is used for widgets that support being a click target - so it is possible to link the widget that is the target of MouseReleased with the one that was the target of MouseLeft/Right/Middle when they might not necessarily be the same object (i.e. rebuilt widget hierarchy in between). Also used to name callbacks so they can be removed (since function objects can't be compared)

type IIdentityWidget

type IIdentityWidget interface {
	IWidget
	IIdentity
}

IIdentityWidget is implemented by any widget that provides an ID() function that identifies itself and allows itself to be compared against other IIdentity implementers. This is intended be to used to check whether or not the widget that was in focus when a mouse click was issued is the same widget in focus when the mouse is released. If so then the widget was "clicked". This allows gowid to run the action on release rather than on click, which is more forgiving of mistaken clicks. The widget in focus on release may be logically the same widget as the one clicked, but possibly a different object, if the widget hierarchy was somehow rebuilt in response to the first click - so to receive the click event, make sure the newly built widget has the same ID() as the original (e.g. a serialized representation of a position in a ListWalker)

type IKey

type IKey interface {
	Rune() rune
	Key() tcell.Key
	Modifiers() tcell.ModMask
}

IKey represents a keypress. It's a subset of tcell.EventKey because it doesn't capture the time of the keypress. It can be used by widgets to customize what keypresses they respond to.

type IKeyPress

type IKeyPress interface {
	KeyPress(key IKey, app IApp)
}

IKeyPress is implemented by any type that implements a KeyPress() method, intended to be run in response to a user interaction with the type such as hitting the escape key.

type IMenuCompatible

type IMenuCompatible interface {
	IWidget
	ISettableComposite
}

IMenuCompatible is implemented by any widget that can set a subwidget. It's used by widgets like menus that need to inject themselves into the widget hierarchy close to the root (to be rendered over the main "view") i.e. the current root is made a child of the new menu widget, whuch becomes the new root.

type IMergeCanvas

type IMergeCanvas interface {
	IRenderBox
	ICanvasCellReader
	ICanvasMarkIterator
}

type IPalette

type IPalette interface {
	CellStyler(name string) (ICellStyler, bool)
	RangeOverPalette(f func(key string, value ICellStyler) bool)
}

IPalette provides application "palette" information - it can look up a Cell styling interface by name (e.g. "main text" -> (black, white, underline)) and it can let clients apply a function to each member of the palette (e.g. in order to construct a new modified palette).

type IPreferedPosition

type IPreferedPosition interface {
	GetPreferedPosition() gwutil.IntOption
	SetPreferedPosition(col int, app IApp)
}

IPreferedPosition is implemented by any widget that supports a prefered column or row (position in a dimension), meaning it understands what subwidget is at the current dimensional coordinate, and can move its focus widget to a new position. This is modeled on Urwid's get_pref_col() feature, which tries to provide a sensible switch of focus widget when moving the cursor vertically around the screen - instead of having it hop left and right depending on which widget happens to be in focus at the current y coordinate.

type IRangeOverCanvas

type IRangeOverCanvas interface {
	IRenderBox
	ICanvasCellReader
	SetCellAt(col, row int, c Cell)
}

type IRenderBox

type IRenderBox interface {
	IWidgetDimension
	IBox
}

func RenderSize

func RenderSize(w IWidget, size IRenderSize, focus Selector, app IApp) IRenderBox

RenderSize currently passes control through to the widget's RenderSize method. Having this function allows for easier instrumentation of the RenderSize path. RenderSize is intended to compute the size of the canvas that will be generated when the widget is rendered. Some parent widgets need this value from their children, and it might be possible to compute it much more cheaply than rendering the widget in order to determine the canvas size only.

type IRenderContext

type IRenderContext interface {
	IPalette
	IColorMode
}

IRenderContext proviees palette and color mode information.

type IRenderFixed

type IRenderFixed interface {
	IWidgetDimension
	Fixed() // dummy
}

type IRenderFlow

type IRenderFlow interface {
	IWidgetDimension
	Flow() // dummy
}

type IRenderFlowWith

type IRenderFlowWith interface {
	IWidgetDimension
	FlowColumns() int
}

type IRenderMax

type IRenderMax interface {
	MaxHeight() // dummy
}

Used in widgets laid out side-by-side - intended to have the effect that these widgets are rendered last and provided a height that corresponds to the max of the height of those widgets already rendered.

type IRenderMaxUnits

type IRenderMaxUnits interface {
	MaxUnits() int
}

Used in widgets laid out side-by-side - intended to limit the width of a widget which may otherwise be specified to be dimensioned in relation to the width available. This can let the layout algorithm give more space (e.g. maximized terminal) to widgets that can use it by constraining those that don't need it.

type IRenderRelative

type IRenderRelative interface {
	IWidgetDimension
	Relative() float64
}

type IRenderSize

type IRenderSize interface{}

IRenderSize is the type of objects that can specify how a widget is to be rendered. This is the empty interface, and only serves as a placeholder at the moment. In practise, actual rendering sizes will be determined by an IFlowDimension, IBoxDimension or an IFixedDimension

func ComputeHorizontalSubSize

func ComputeHorizontalSubSize(size IRenderSize, d IWidgetDimension) (IRenderSize, error)

ComputeHorizontalSubSize is used to determine the size with which a child widget should be rendered given the parent's render size, and an IWidgetDimension. The function will make adjustments to the size's number of columns i.e. in the horizontal dimension, and as such is used by hpadding and columns. For example the function can transform a RenderBox to a narrower RenderBox if the IWidgetDimension specifies a RenderWithUnits{} - so it allows widgets like columns and hpadding to force widgets to be of a certain width, or to have their width be in a certain ratio to other widgets.

func ComputeHorizontalSubSizeUnsafe

func ComputeHorizontalSubSizeUnsafe(size IRenderSize, d IWidgetDimension) IRenderSize

ComputeHorizontalSubSizeUnsafe calls ComputeHorizontalSubSize but returns only a single value - the IRenderSize. If there is an error the function will panic.

func ComputeSubSize

func ComputeSubSize(size IRenderSize, w IWidgetDimension, h IWidgetDimension) (IRenderSize, error)

TODO - doc

func ComputeVerticalSubSize

func ComputeVerticalSubSize(size IRenderSize, d IWidgetDimension, maxCol int, advRow int) (IRenderSize, error)

ComputeVerticalSubSize is used to determine the size with which a child widget should be rendered given the parent's render size, and an IWidgetDimension. The function will make adjustments to the size's number of rows i.e. in the vertical dimension, and as such is used by vpadding and pile. For example, if the parent render size is RenderBox{C: 20, R: 5} and the IWidgetDimension argument is RenderFlow{}, the function will return RenderFlowWith{C: 20}, i.e. it will transform a RenderBox to a RenderFlow of the same width. Another example is to transform a RenderBox to a shorter RenderBox if the IWidgetDimension specifies a RenderWithUnits{} - so it allows widgets like pile and vpadding to force widgets to be of a certain height, or to have their height be in a certain ratio to other widgets.

func ComputeVerticalSubSizeUnsafe

func ComputeVerticalSubSizeUnsafe(size IRenderSize, d IWidgetDimension, maxCol int, advRow int) IRenderSize

ComputeVerticalSubSizeUnsafe calls ComputeVerticalSubSize but returns only a single value - the IRenderSize. If there is an error the function will panic.

func SubWidgetSize

func SubWidgetSize(w ICompositeWidget, size IRenderSize, focus Selector, app IApp) IRenderSize

SubWidgetSize currently passes control through to the widget's SubWidgetSize method. Having this function allows for easier instrumentation of the SubWidgetSize path. The function should compute the size that it will itself use to render its child widget; for example, a framing widget rendered with IRenderBox might return a RenderBox value that is 2 units smaller in both height and width.

type IRenderWithUnits

type IRenderWithUnits interface {
	IWidgetDimension
	Units() int
}

type IRenderWithWeight

type IRenderWithWeight interface {
	IWidgetDimension
	Weight() int
}

type IRightSizeCanvas

type IRightSizeCanvas interface {
	IRenderBox
	ExtendRight(cells []Cell)
	TrimRight(cols int)
	Truncate(above, below int)
	AppendBelow(c IAppendCanvas, doCursor bool, makeCopy bool)
}

type IRows

type IRows interface {
	Rows() int
}

type ISelectChild

type ISelectChild interface {
	SelectChild(Selector) bool // Whether or not this widget will set focus.Selected for its selected child
}

ISelectChild is implemented by any type that controls whether or not it will set focus.Selected on its currently "selected" child. For example, a columns widget will have a notion of a child widget that will take focus. The user may want to render that widget in a way that highlights the selected child, even when the columns widget itself does not have focus. The columns widget will set focus.Selected on Render() and UserInput() calls depending on the result of SelectChild() - if focus.Selected is set, then a styling widget can change the look of the widget appropriately.

type ISettableComposite

type ISettableComposite interface {
	IComposite
	SetSubWidget(IWidget, IApp)
}

IComposite is an interface for anything that has a concept of a single settable "inner" widget. This applies to certain widgets themselves (e.g. ButtonWidget) and also to the App object which holds the top-level view.

type ISettableDimensions

type ISettableDimensions interface {
	SetDimensions([]IWidgetDimension, IApp)
}

ISettableDimensions is implemented by types that maintain a collection of dimensions - to be used by containers that use these dimensions to layout their children widgets.

type ISettableSubWidgets

type ISettableSubWidgets interface {
	SetSubWidgets([]IWidget, IApp)
}

ISettableSubWidgetsis implemented by a type that maintains a collection of child widgets (like pile, columns) and that allows them to be changed.

type ISubWidgetSize

type ISubWidgetSize interface {
	SubWidgetSize(size IRenderSize, focus Selector, app IApp) IRenderSize
}

ISubWidgetSize returns the size argument that should be provided to render the inner widget based on the size argument provided to the containing widget.

type IUnhandledInput

type IUnhandledInput interface {
	UnhandledInput(app IApp, ev interface{}) bool
}

IUnhandledInput is used as a handler for application user input that is not handled by any widget in the widget hierarchy.

type IVAlignment

type IVAlignment interface {
	ImplementsVAlignment()
}

type IWidget

type IWidget interface {
	Render(size IRenderSize, focus Selector, app IApp) ICanvas
	RenderSize(size IRenderSize, focus Selector, app IApp) IRenderBox
	UserInput(ev interface{}, size IRenderSize, focus Selector, app IApp) bool
	Selectable() bool
}

IWidget is the interface of any object acting as a gowid widget.

Render() is provided a size (cols, maybe rows), whether or not the widget is in focus, and a context (palette, etc). It must return an object conforming to gowid's ICanvas, which is a representation of what can be displayed in the terminal.

RenderSize() is used by clients that need to know only how big the widget will be when rendered. It is expected to be cheaper to compute in some cases than Render(), but a fallback is to run Render() then return the size of the canvas.

Selectable() should return true if this widget is designed for interaction e.g. a Button would return true, but a Text widget would return false. Note that, like urwid, returning false does not guarantee the widget will never have focus - it might be given focus if there is no other option (no other selectable widgets in the container, for example).

UserInput() is provided the TCell event (mouse or keyboard action), the size spec that would be given to Render(), whether or not the widget has focus, and access to the application, useful for effecting changes like changing colors, running a function, or quitting. The render size is needed because the widget might have to pass the event down to children widgets, and the correct one may depend on the coordinates of a mouse click relative to the dimensions of the widget itself.

func CopyWidgets

func CopyWidgets(w []IWidget) []IWidget

CopyWidgets is a trivial utility to return a copy of the array of widgets supplied. Note that this is not a deep copy! The array is different, but the IWidgets are not.

func FindInHierarchy

func FindInHierarchy(w IWidget, includeMe bool, pred WidgetPredicate) IWidget

FindInHierarchy starts at w, and applies the supplied predicate function; if it returns true, w is returned. If not, then the hierarchy is descended. If w has a child widget, then the predicate is applied to that child. If w has a set of children with a concept of one with focus, the predicate is applied to the child in focus. This repeats until a suitable widget is found, or the hierarchy terminates.

type IWidgetChangedCallback

type IWidgetChangedCallback interface {
	IIdentity
	Changed(app IApp, widget IWidget, data ...interface{})
}

IWidgetChangedCallback defines the types that can be used as callbacks that are issued when widget properties change. It expects a function Changed() that is called with the current app and the widget that is issuing the callback. It also expects to conform to IIdentity, so that one callback instance can be compared to another - this is to allow callbacks to be removed correctly, if that is required.

type IWidgetDimension

type IWidgetDimension interface {
	ImplementsWidgetDimension() // This exists as a marker so that IWidgetDimension is not empty, meaning satisfied by any struct.
}

Widgets that are used in containers such as Pile or Columns must implement this interface. It specifies how each subwidget of the container should be rendered.

type InvalidColor

type InvalidColor struct {
	Color interface{}
}

func (InvalidColor) Error

func (e InvalidColor) Error() string

type InvalidTypeToCompare

type InvalidTypeToCompare struct {
	LHS interface{}
	RHS interface{}
}

func (InvalidTypeToCompare) Error

func (e InvalidTypeToCompare) Error() string

type IsSelectable

type IsSelectable struct{}

IsSelectable is a convenience struct that can be embedded in widgets. It provides a function that simply return true to the call to Selectable()

func (*IsSelectable) Selectable

func (r *IsSelectable) Selectable() bool

type Key

type Key struct {
	// contains filtered or unexported fields
}

Key is a trivial representation of a keypress, a subset of tcell.Key. Key implements IKey. This exists as a convenience to widgets looking to customize keypress responses.

func MakeKey

func MakeKey(ch rune) Key

func MakeKeyExt

func MakeKeyExt(key tcell.Key) Key

func MakeKeyExt2

func MakeKeyExt2(mod tcell.ModMask, key tcell.Key, ch rune) Key

func (Key) Key

func (k Key) Key() tcell.Key

func (Key) Modifiers

func (k Key) Modifiers() tcell.ModMask

func (Key) Rune

func (k Key) Rune() rune

func (Key) String

func (k Key) String() string

Stolen from tcell, but omit the Rune[...]

type KeyPressCB

type KeyPressCB struct{}

type KeyPressCallbacks

type KeyPressCallbacks struct {
	CB **Callbacks
}

KeyPressCallbacks is a convenience struct for embedding in a widget, providing methods to add and remove callbacks that are executed when the widget is "clicked".

func (*KeyPressCallbacks) OnKeyPress

func (w *KeyPressCallbacks) OnKeyPress(f IWidgetChangedCallback)

func (*KeyPressCallbacks) RemoveOnKeyPress

func (w *KeyPressCallbacks) RemoveOnKeyPress(f IIdentity)

type KeyValueError

type KeyValueError struct {
	Base    error
	KeyVals map[string]interface{}
}

func WithKVs

func WithKVs(err error, kvs map[string]interface{}) KeyValueError

func (KeyValueError) Cause

func (e KeyValueError) Cause() error

func (KeyValueError) Error

func (e KeyValueError) Error() string

func (KeyValueError) Unwrap added in v1.2.0

func (e KeyValueError) Unwrap() error

type LineCanvas

type LineCanvas []Cell

LineCanvas exists to make an array of Cells conform to some interfaces, specifically IRenderBox (it has a width of len(.) and a height of 1), IAppendCanvas, to allow an array of Cells to be passed to the canvas function AppendLine(), and ICanvasLineReader so that an array of Cells can act as a line returned from a canvas.

func (LineCanvas) BoxColumns

func (c LineCanvas) BoxColumns() int

BoxColumns lets LineCanvas conform to IRenderBox

func (LineCanvas) BoxRows

func (c LineCanvas) BoxRows() int

BoxRows lets LineCanvas conform to IRenderBox

func (LineCanvas) ImplementsWidgetDimension

func (c LineCanvas) ImplementsWidgetDimension()

BoxRows lets LineCanvas conform to IWidgetDimension

func (LineCanvas) Line

func (c LineCanvas) Line(y int, cp LineCopy) LineResult

Line lets LineCanvas conform to ICanvasLineReader

func (LineCanvas) RangeOverMarks

func (c LineCanvas) RangeOverMarks(f func(key string, value CanvasPos) bool)

RangeOverMarks lets LineCanvas conform to ICanvasMarkIterator

type LineCopy

type LineCopy struct {
	Len int
	Cap int
}

LineCopy is an argument provided to some Canvas APIs, like Line(). It tells the function how to allocate the backing array for a line if the line it returns must be a copy. Typically the API will return a type that indicates whether the result is a copy or not. Since the caller may receive a copy, it can help to indicate the allocation details like length and capacity in case the caller intends to extend the line returned for some other use.

type LineResult

type LineResult struct {
	Line   []Cell
	Copied bool
}

LineResult is returned by some Canvas Line-accessing APIs. If the Canvas can return a line without copying it, the Copied field will be false, and the caller is expected to make a copy if necessary (or risk modifying the original).

type LogField

type LogField struct {
	Name string
	Val  interface{}
}

type MouseState

type MouseState struct {
	MouseLeftClicked   bool
	MouseMiddleClicked bool
	MouseRightClicked  bool
}

func (MouseState) LeftIsClicked

func (m MouseState) LeftIsClicked() bool

func (MouseState) MiddleIsClicked

func (m MouseState) MiddleIsClicked() bool

func (MouseState) NoButtonClicked

func (m MouseState) NoButtonClicked() bool

func (MouseState) RightIsClicked

func (m MouseState) RightIsClicked() bool

func (MouseState) String

func (m MouseState) String() string

type NoColor

type NoColor struct{}

NoColor implements IColor, and represents "no color preference", distinct from the default terminal color, white, black, etc. This means that if a NoColor is rendered over another color, the color underneath will be displayed.

func (NoColor) String

func (r NoColor) String() string

func (NoColor) ToTCellColor

func (r NoColor) ToTCellColor(mode ColorMode) (TCellColor, bool)

ToTCellColor converts NoColor to TCellColor. This lets NoColor conform to the IColor interface.

type NotSelectable

type NotSelectable struct{}

NotSelectable is a convenience struct that can be embedded in widgets. It provides a function that simply return false to the call to Selectable()

func (*NotSelectable) Selectable

func (r *NotSelectable) Selectable() bool

type Palette

type Palette map[string]ICellStyler

Palette implements IPalette and is a trivial implementation of a type that can store cell stylers and provide access to them via iteration.

func (Palette) CellStyler

func (m Palette) CellStyler(name string) (ICellStyler, bool)

CellStyler will return an ICellStyler by name, if it exists.

func (Palette) RangeOverPalette

func (m Palette) RangeOverPalette(f func(k string, v ICellStyler) bool)

RangeOverPalette applies the supplied function to each member of the palette. If the function returns false, the loop terminates early.

type PaletteEntry

type PaletteEntry struct {
	FG    IColor
	BG    IColor
	Style StyleAttrs
}

PaletteEntry is typically used by a gowid application to represent a set of color and style preferences for use by different application widgets e.g. black text on a white background with text underlined. PaletteEntry implements the ICellStyler interface meaning it can provide a triple of foreground and background IColor, and a StyleAttrs struct.

func MakePaletteEntry

func MakePaletteEntry(fg, bg IColor) PaletteEntry

MakePaletteEntry stores the two IColor parameters provided, and has no style preference.

func MakeStyledPaletteEntry

func MakeStyledPaletteEntry(fg, bg IColor, style StyleAttrs) PaletteEntry

MakeStyledPaletteEntry simply stores the three parameters provided - a foreground and background IColor, and a StyleAttrs struct.

func (PaletteEntry) GetStyle

func (a PaletteEntry) GetStyle(prov IRenderContext) (x IColor, y IColor, z StyleAttrs)

GetStyle returns the individual colors and style attributes.

type PaletteRef

type PaletteRef struct {
	Name string
}

PaletteRef is intended to represent a PaletteEntry, looked up by name. The ICellStyler API GetStyle() provides an IRenderContext and should return two colors and style attributes. PaletteRef provides these by looking up the IRenderContext with the name (string) provided to it at initialization.

func MakePaletteRef

func MakePaletteRef(name string) PaletteRef

MakePaletteRef returns a PaletteRef struct storing the (string) name of the PaletteEntry which will be looked up in the IRenderContext.

func (PaletteRef) GetStyle

func (a PaletteRef) GetStyle(prov IRenderContext) (x IColor, y IColor, z StyleAttrs)

GetStyle returns the two colors and a style, looked up in the IRenderContext by name.

type PrettyModMask added in v1.2.0

type PrettyModMask tcell.ModMask

func (PrettyModMask) String added in v1.2.0

func (p PrettyModMask) String() string

type PrettyTcellKey added in v1.2.0

type PrettyTcellKey tcell.EventKey

func (*PrettyTcellKey) String added in v1.2.0

func (p *PrettyTcellKey) String() string

type RGBColor

type RGBColor struct {
	Red, Green, Blue int
}

RGBColor allows for use of colors specified as three components, each with values from 0x0 to 0xf. Note that an RGBColor should render as close to the components specify regardless of the color mode of the terminal - 24-bit color, 256-color, 88-color. Gowid constructs a color cube, just like urwid, and for each color mode, has a lookup table that maps the rgb values to a color cube value which is closest to the intended color. Note that RGBColor is not supported in 16-color, 8-color or monochrome.

func MakeRGBColor

func MakeRGBColor(s string) RGBColor

MakeRGBColor constructs an RGBColor from a string e.g. "#f00" is red. Note that MakeRGBColorSafe should be used unless you are sure the string provided is valid (otherwise there will be a panic).

func MakeRGBColorExt

func MakeRGBColorExt(r, g, b int) RGBColor

MakeRGBColorExt builds an RGBColor from the red, green and blue components provided as integers. If the values are out of range, the function will panic.

func MakeRGBColorExtSafe

func MakeRGBColorExtSafe(r, g, b int) (RGBColor, error)

MakeRGBColorExtSafe builds an RGBColor from the red, green and blue components provided as integers. If the values are out of range, an error is returned.

func MakeRGBColorSafe

func MakeRGBColorSafe(s string) (RGBColor, error)

MakeRGBColorSafe does the same as MakeRGBColor except will return an error if provided with invalid input.

func (RGBColor) RGBA added in v1.1.0

func (rgb RGBColor) RGBA() (r, g, b, a uint32)

Implements golang standard library's color.Color

func (RGBColor) String

func (r RGBColor) String() string

func (RGBColor) ToTCellColor

func (r RGBColor) ToTCellColor(mode ColorMode) (TCellColor, bool)

ToTCellColor converts an RGBColor to a TCellColor, suitable for rendering to the screen with tcell. It lets RGBColor conform to IColor.

type RejectUserInput

type RejectUserInput struct{}

RejectUserInput is a convenience struct that can be embedded in widgets that don't accept any user input.

func (RejectUserInput) UserInput

func (r RejectUserInput) UserInput(ev interface{}, size IRenderSize, focus Selector, app IApp) bool

type RenderBox

type RenderBox struct {
	C int
	R int
}

RenderBox is an object passed to a widget's Render function that specifies that it should be rendered with a set number of columns and rows.

func CalculateRenderSizeFallback

func CalculateRenderSizeFallback(w IWidget, size IRenderSize, focus Selector, app IApp) RenderBox

CalculateRenderSizeFallback can be used by widgets that cannot easily compute a value for RenderSize without actually rendering the widget and measuring the bounding box. It assumes that if IRenderBox size is provided, then the widget's canvas when rendered will be that large, and simply returns the box. If an IRenderFlow is provided, then the widget is rendered, and the bounding box is returned.

func MakeRenderBox

func MakeRenderBox(columns, rows int) RenderBox

func (RenderBox) BoxColumns

func (r RenderBox) BoxColumns() int

func (RenderBox) BoxRows

func (r RenderBox) BoxRows() int

func (RenderBox) Columns

func (r RenderBox) Columns() int

For IColumns

func (RenderBox) ImplementsWidgetDimension

func (r RenderBox) ImplementsWidgetDimension()

func (RenderBox) Rows

func (r RenderBox) Rows() int

For IRows

func (RenderBox) String

func (r RenderBox) String() string

type RenderFixed

type RenderFixed struct{}

RenderFixed is an object passed to a widget's Render function that specifies that the widget itself will determine its own size.

func MakeRenderFixed

func MakeRenderFixed() RenderFixed

func (RenderFixed) Fixed

func (f RenderFixed) Fixed()

func (RenderFixed) ImplementsWidgetDimension

func (r RenderFixed) ImplementsWidgetDimension()

func (RenderFixed) String

func (f RenderFixed) String() string

type RenderFlow

type RenderFlow struct{}

RenderFlow is used by widgets that embed an inner widget, like hpadding.Widget. It directs the outer widget how it should render the inner widget. If the outer widget is rendered in box mode, the inner widget should be rendered in flow mode, using the box's number of columns. If the outer widget is rendered in flow mode, the inner widget should be rendered in flow mode with the same number of columns.

func (RenderFlow) Flow

func (s RenderFlow) Flow()

func (RenderFlow) ImplementsWidgetDimension

func (r RenderFlow) ImplementsWidgetDimension()

func (RenderFlow) String

func (f RenderFlow) String() string

type RenderFlowWith

type RenderFlowWith struct {
	C int
}

RenderFlowWith is an object passed to a widget's Render function that specifies that it should be rendered with a set number of columns, but using as many rows as the widget itself determines it needs.

func MakeRenderFlow

func MakeRenderFlow(columns int) RenderFlowWith

func (RenderFlowWith) Columns

func (r RenderFlowWith) Columns() int

For IColumns

func (RenderFlowWith) FlowColumns

func (r RenderFlowWith) FlowColumns() int

func (RenderFlowWith) ImplementsWidgetDimension

func (r RenderFlowWith) ImplementsWidgetDimension()

func (RenderFlowWith) String

func (r RenderFlowWith) String() string

type RenderMax

type RenderMax struct{}

RenderMax is used in widgets laid out side-by-side - it's intended to have the effect that these widgets are rendered last and provided a height/width that corresponds to the max of the height/width of those widgets already rendered.

func (RenderMax) MaxHeight

func (s RenderMax) MaxHeight()

func (RenderMax) String

func (f RenderMax) String() string

type RenderWithRatio

type RenderWithRatio struct {
	R float64
}

RenderWithRatio is used by widgets within a container

func (RenderWithRatio) ImplementsWidgetDimension

func (r RenderWithRatio) ImplementsWidgetDimension()

func (RenderWithRatio) Relative

func (f RenderWithRatio) Relative() float64

func (RenderWithRatio) String

func (f RenderWithRatio) String() string

type RenderWithUnits

type RenderWithUnits struct {
	U int
}

RenderWithUnits is used by widgets within a container. It specifies the number of columns or rows to use when rendering.

func (RenderWithUnits) ImplementsWidgetDimension

func (r RenderWithUnits) ImplementsWidgetDimension()

func (RenderWithUnits) String

func (f RenderWithUnits) String() string

func (RenderWithUnits) Units

func (f RenderWithUnits) Units() int

type RenderWithWeight

type RenderWithWeight struct {
	W int
}

func (RenderWithWeight) ImplementsWidgetDimension

func (r RenderWithWeight) ImplementsWidgetDimension()

func (RenderWithWeight) String

func (f RenderWithWeight) String() string

func (RenderWithWeight) Weight

func (f RenderWithWeight) Weight() int

type RunFunction

type RunFunction func(IApp)

func (RunFunction) RunThenRenderEvent

func (f RunFunction) RunThenRenderEvent(app IApp)

RunThenRenderEvent lets the receiver RunOnRenderFunction implement IOnRenderEvent. This lets a regular function be executed on the same goroutine as the rendering code.

type Selector

type Selector struct {
	Focus    bool
	Selected bool
}

Three states - false+false, false+true, true+true

func (Selector) And

func (s Selector) And(cond bool) Selector

And returns a Selector with both Selected and Focus set dependent on the supplied condition AND the receiver. Used to propagate Selected and Focus state to sub widgets for input and rendering.

func (Selector) SelectIf

func (s Selector) SelectIf(cond bool) Selector

SelectIf returns a Selector with the Selected field set dependent on the supplied condition only. The Focus field is set based on the supplied condition AND the receiver's Focus field. Used by composite widgets with multiple children to allow children to change their state dependent on whether they are selected but independent of whether the widget is currently in focus.

func (Selector) String

func (s Selector) String() string

type StyleAttrs

type StyleAttrs struct {
	OnOff tcell.AttrMask // If the specific bit in Set is 1, then the specific bit on OnOff says whether the style is on or off
	Set   tcell.AttrMask // If the specific bit in Set is 0, then no style preference is declared (e.g. for underline)
}

StyleAttrs allows the user to represent a set of styles, either affirmatively set (on) or unset (off) with the rest of the styles being unspecified, meaning they can be determined by styles layered "underneath".

func (StyleAttrs) MergeUnder

func (a StyleAttrs) MergeUnder(upper StyleAttrs) StyleAttrs

MergeUnder merges cell styles. E.g. if a is {underline, underline}, and upper is {!bold, bold}, that means a declares that it should be rendered with underline and doesn't care about other styles; and upper declares it should NOT be rendered bold, and doesn't declare about other styles. When merged, the result is {underline|!bold, underline|bold}.

type StyleMod

type StyleMod struct {
	Cur ICellStyler
	Mod ICellStyler
}

StyleMod implements ICellStyler. It returns colors and styles from its Cur field unless they are overridden by settings in its Mod field. This provides a way for a layering of ICellStylers.

func MakeStyleMod

func MakeStyleMod(cur, mod ICellStyler) StyleMod

MakeStyleMod implements ICellStyler and stores two ICellStylers, one to layer on top of the other.

func (StyleMod) GetStyle

func (a StyleMod) GetStyle(prov IRenderContext) (x IColor, y IColor, z StyleAttrs)

GetStyle returns the IColors and StyleAttrs from the Mod ICellStyler if they express an affirmative preference, otherwise defers to the values from the Cur ICellStyler.

type StyledAs

type StyledAs struct {
	StyleAttrs
}

StyledAs is an ICellStyler that expresses a specific text style and no preference for foreground and background color.

func MakeStyledAs

func MakeStyledAs(s StyleAttrs) StyledAs

func (StyledAs) GetStyle

func (a StyledAs) GetStyle(prov IRenderContext) (x IColor, y IColor, z StyleAttrs)

GetStyle implements ICellStyler.

type SubWidgetCB

type SubWidgetCB struct{}

type SubWidgetCallbacks

type SubWidgetCallbacks struct {
	CB **Callbacks
}

SubWidgetCallbacks is a convenience struct for embedding in a widget, providing methods to add and remove callbacks that are executed when the widget's child is modified.

func (*SubWidgetCallbacks) OnSetSubWidget

func (w *SubWidgetCallbacks) OnSetSubWidget(f IWidgetChangedCallback)

func (*SubWidgetCallbacks) RemoveOnSetSubWidget

func (w *SubWidgetCallbacks) RemoveOnSetSubWidget(f IIdentity)

type SubWidgetsCB

type SubWidgetsCB struct{}

type SubWidgetsCallbacks

type SubWidgetsCallbacks struct {
	CB **Callbacks
}

SubWidgetsCallbacks is a convenience struct for embedding in a widget, providing methods to add and remove callbacks that are executed when the widget's children are modified.

func (*SubWidgetsCallbacks) OnSetSubWidgets

func (w *SubWidgetsCallbacks) OnSetSubWidgets(f IWidgetChangedCallback)

func (*SubWidgetsCallbacks) RemoveOnSetSubWidgets

func (w *SubWidgetsCallbacks) RemoveOnSetSubWidgets(f IIdentity)

type TCellColor

type TCellColor struct {
	// contains filtered or unexported fields
}

TCellColor is an IColor using tcell's color primitives. If you are not porting from urwid or translating from urwid, this is the simplest approach to using color. Gowid's layering approach means that the empty value for a color should mean "no color preference" - so we want the zero value to mean that. A tcell.Color of 0 means "default color". So gowid coopts nil to mean "no color preference".

func IColorToTCell

func IColorToTCell(color IColor, def TCellColor, mode ColorMode) TCellColor

IColorToTCell is a utility function that will convert an IColor to a TCellColor in preparation for passing to tcell to render; if the conversion fails, a default TCellColor is returned (provided to the function via a parameter)

func MakeTCellColor

func MakeTCellColor(val string) (TCellColor, error)

MakeTCellColor returns an initialized TCellColor given a string input like "yellow". The names that can be used are provided here: https://github.com/gdamore/tcell/blob/master/color.go#L821.

func MakeTCellColorExt

func MakeTCellColorExt(val tcell.Color) TCellColor

MakeTCellColor returns an initialized TCellColor given a tcell.Color input. The values that can be used are provided here: https://github.com/gdamore/tcell/blob/master/color.go#L41.

func MakeTCellNoColor

func MakeTCellNoColor() TCellColor

MakeTCellNoColor returns an initialized TCellColor that represents "no color" - meaning if another color is rendered "under" this one, then the color underneath will be displayed.

func (TCellColor) String

func (r TCellColor) String() string

String implements Stringer for '%v' support.

func (TCellColor) ToTCell

func (r TCellColor) ToTCell() tcell.Color

ToTCell converts a TCellColor back to a tcell.Color for passing to tcell APIs.

func (TCellColor) ToTCellColor

func (r TCellColor) ToTCellColor(mode ColorMode) (TCellColor, bool)

ToTCellColor is a no-op, and exists so that TCellColor conforms to the IColor interface.

type UnhandledInputFunc

type UnhandledInputFunc func(app IApp, ev interface{}) bool

UnhandledInputFunc satisfies IUnhandledInput, allowing use of a simple function for handling input not claimed by any widget.

var IgnoreUnhandledInput UnhandledInputFunc = func(app IApp, ev interface{}) bool {
	return false
}

IgnoreUnhandledInput is a helper function for main loops that don't need to deal with hanlding input that the widgets haven't claimed.

func (UnhandledInputFunc) UnhandledInput

func (f UnhandledInputFunc) UnhandledInput(app IApp, ev interface{}) bool

type Unit

type Unit struct{}

Unit is a one-valued type used to send a message over a channel.

type UrwidColor

type UrwidColor struct {
	Id string
	// contains filtered or unexported fields
}

UrwidColor is a gowid Color implementing IColor and which allows urwid color names to be used (http://urwid.org/manual/displayattributes.html#foreground-and-background-settings) e.g. "dark blue", "light gray".

func NewUrwidColor

func NewUrwidColor(val string) *UrwidColor

NewUrwidColorSafe returns a pointer to an UrwidColor struct and builds the UrwidColor from a string argument e.g. "yellow"; this function will panic if the there is an error during initialization.

func NewUrwidColorSafe

func NewUrwidColorSafe(val string) (*UrwidColor, error)

NewUrwidColorSafe returns a pointer to an UrwidColor struct and builds the UrwidColor from a string argument e.g. "yellow". Note that in urwid proper (python), a color can also specify a style, like "yellow, underline". UrwidColor does not support specifying styles in that manner.

func (UrwidColor) String

func (r UrwidColor) String() string

func (*UrwidColor) ToTCellColor

func (s *UrwidColor) ToTCellColor(mode ColorMode) (TCellColor, bool)

ToTCellColor converts the receiver UrwidColor to a TCellColor, ready for rendering to a tcell screen. This lets UrwidColor conform to IColor.

type VAlignBottom

type VAlignBottom struct {
	Margin int
}

func (VAlignBottom) ImplementsVAlignment

func (v VAlignBottom) ImplementsVAlignment()

type VAlignCB

type VAlignCB struct{}

type VAlignMiddle

type VAlignMiddle struct{}

func (VAlignMiddle) ImplementsVAlignment

func (v VAlignMiddle) ImplementsVAlignment()

type VAlignTop

type VAlignTop struct {
	Margin int
}

func (VAlignTop) ImplementsVAlignment

func (v VAlignTop) ImplementsVAlignment()

type WidgetCallback

type WidgetCallback struct {
	Name interface{}
	WidgetChangedFunction
}

WidgetCallback is a simple struct with a name field for IIdentity and that embeds a WidgetChangedFunction to be issued as a callback when a widget property changes.

func MakeWidgetCallback

func MakeWidgetCallback(name interface{}, fn WidgetChangedFunction) WidgetCallback

func (WidgetCallback) ID

func (f WidgetCallback) ID() interface{}

type WidgetCallbackExt added in v1.2.0

type WidgetCallbackExt struct {
	Name interface{}
	WidgetChangedFunctionExt
}

WidgetCallbackExt is a simple struct with a name field for IIdentity and that embeds a WidgetChangedFunction to be issued as a callback when a widget property changes.

func MakeWidgetCallbackExt added in v1.2.0

func MakeWidgetCallbackExt(name interface{}, fn WidgetChangedFunctionExt) WidgetCallbackExt

func (WidgetCallbackExt) ID added in v1.2.0

func (f WidgetCallbackExt) ID() interface{}

type WidgetChangedFunction

type WidgetChangedFunction func(app IApp, widget IWidget)

WidgetChangedFunction meets the IWidgetChangedCallback interface, for simpler usage.

func (WidgetChangedFunction) Changed

func (f WidgetChangedFunction) Changed(app IApp, widget IWidget, data ...interface{})

type WidgetChangedFunctionExt added in v1.2.0

type WidgetChangedFunctionExt func(app IApp, widget IWidget, data ...interface{})

func (WidgetChangedFunctionExt) Changed added in v1.2.0

func (f WidgetChangedFunctionExt) Changed(app IApp, widget IWidget, data ...interface{})

type WidgetPredicate

type WidgetPredicate func(w IWidget) bool

type WidgetSizeError

type WidgetSizeError struct {
	Widget   interface{}
	Size     IRenderSize
	Required string // in case I only need an interface - not sure how to capture it and not concrete type
}

func (WidgetSizeError) Error

func (e WidgetSizeError) Error() string

type WidthCB

type WidthCB struct{}

Directories

Path Synopsis
gowid-asciigraph
An example of the gowid asciigraph widget which relies upon the asciigraph package at github.com/guptarohit/asciigraph.
An example of the gowid asciigraph widget which relies upon the asciigraph package at github.com/guptarohit/asciigraph.
gowid-dir
A simple gowid directory browser.
A simple gowid directory browser.
gowid-editor
A poor-man's editor using gowid widgets - shows dialog, edit and vscroll.
A poor-man's editor using gowid widgets - shows dialog, edit and vscroll.
gowid-fib
A port of urwid's fib.py example using gowid widgets.
A port of urwid's fib.py example using gowid widgets.
gowid-graph
A port of urwid's graph.py example using gowid widgets.
A port of urwid's graph.py example using gowid widgets.
gowid-helloworld
A port of urwid's "Hello World" example from the tutorial, using gowid widgets.
A port of urwid's "Hello World" example from the tutorial, using gowid widgets.
gowid-menu
A demonstration of gowid's menu, list and overlay widgets.
A demonstration of gowid's menu, list and overlay widgets.
gowid-overlay1
A demonstration of gowid's overlay and fill widgets.
A demonstration of gowid's overlay and fill widgets.
gowid-overlay2
A demonstration of gowid's overlay, fill, asciigraph and radio widgets.
A demonstration of gowid's overlay, fill, asciigraph and radio widgets.
gowid-overlay3
A demonstration of gowid's overlay and fill widgets.
A demonstration of gowid's overlay and fill widgets.
gowid-palette
A port of urwid's palette_test.py example using gowid widgets.
A port of urwid's palette_test.py example using gowid widgets.
gowid-table
A demonstration of gowid's table widget.
A demonstration of gowid's table widget.
gowid-table/statik
Package statik contains static assets.
Package statik contains static assets.
gowid-terminal
A very poor-man's tmux written using gowid's terminal widget.
A very poor-man's tmux written using gowid's terminal widget.
gowid-tree
A demonstration of gowid's tree widget.
A demonstration of gowid's tree widget.
gowid-tutorial1
The first example from the gowid tutorial.
The first example from the gowid tutorial.
gowid-tutorial2
The second example from the gowid tutorial.
The second example from the gowid tutorial.
gowid-tutorial3
The third example from the gowid tutorial.
The third example from the gowid tutorial.
gowid-tutorial4
The fourth example from the gowid tutorial.
The fourth example from the gowid tutorial.
gowid-tutorial5
The fifth example from the gowid tutorial.
The fifth example from the gowid tutorial.
gowid-tutorial6
The sixth example from the gowid tutorial.
The sixth example from the gowid tutorial.
gowid-widgets1
A gowid test app which exercises the pile, button, edit and progress widgets.
A gowid test app which exercises the pile, button, edit and progress widgets.
gowid-widgets2
A gowid test app which exercises the columns, checkbox, edit and styled widgets.
A gowid test app which exercises the columns, checkbox, edit and styled widgets.
gowid-widgets3
A gowid test app which exercises the button, grid, progress and radio widgets.
A gowid test app which exercises the button, grid, progress and radio widgets.
gowid-widgets4
A gowid test app which exercises the columns, list and framed widgets.
A gowid test app which exercises the columns, list and framed widgets.
gowid-widgets5
A gowid test app which exercises the edit and vpadding widgets.
A gowid test app which exercises the edit and vpadding widgets.
gowid-widgets6
A gowid test app which exercises the list, edit, columns and styled widgets.
A gowid test app which exercises the list, edit, columns and styled widgets.
gowid-widgets7
A gowid test app which exercises the list, edit and framed widgets.
A gowid test app which exercises the list, edit and framed widgets.
gowid-widgets8
A gowid test app which exercises the checkbox, columns and hpadding widgets.
A gowid test app which exercises the checkbox, columns and hpadding widgets.
Package gwtest provides utilities for testing gowid widgets.
Package gwtest provides utilities for testing gowid widgets.
Package gwutil provides general-purpose utilities that are not used by the core of gowid but that have proved useful for several pre-canned widgets.
Package gwutil provides general-purpose utilities that are not used by the core of gowid but that have proved useful for several pre-canned widgets.
Package vim provides utilities for parsing and generating vim-like keystrokes.
Package vim provides utilities for parsing and generating vim-like keystrokes.
widgets
asciigraph
Package asciigraph provides a simple plotting widget.
Package asciigraph provides a simple plotting widget.
bargraph
Package bargraph provides a simple plotting widget.
Package bargraph provides a simple plotting widget.
boxadapter
Package boxadapter provides a widget that will allow a box widget to be used in a flow context.
Package boxadapter provides a widget that will allow a box widget to be used in a flow context.
button
Package button provides a clickable widget which can be decorated.
Package button provides a clickable widget which can be decorated.
cellmod
Package cellmod provides a widget that can change the cell data of an inner widget.
Package cellmod provides a widget that can change the cell data of an inner widget.
checkbox
Package checkbox provides a widget which can be checked or unchecked.
Package checkbox provides a widget which can be checked or unchecked.
clicktracker
Package clicktracker provides a widget that inverts when the mouse is clicked but not yet released.
Package clicktracker provides a widget that inverts when the mouse is clicked but not yet released.
columns
Package columns provides a widget for organizing other widgets in columns.
Package columns provides a widget for organizing other widgets in columns.
dialog
Package dialog provides a modal dialog widget with support for ok/cancel.
Package dialog provides a modal dialog widget with support for ok/cancel.
disable
Package disable provides a widget that forces its inner widget to be disable (or enabled).
Package disable provides a widget that forces its inner widget to be disable (or enabled).
divider
Package divider provides a widget that draws a dividing line between other widgets.
Package divider provides a widget that draws a dividing line between other widgets.
edit
Package edit provides an editable text field widget with support for password hiding.
Package edit provides an editable text field widget with support for password hiding.
fill
Package fill provides a widget that can be filled with a styled rune.
Package fill provides a widget that can be filled with a styled rune.
fixedadapter
Package fixedadaptor provides a widget that will render a fixed widget when supplied with a box context.
Package fixedadaptor provides a widget that will render a fixed widget when supplied with a box context.
framed
Package framed provides a widget that draws a frame around an inner widget.
Package framed provides a widget that draws a frame around an inner widget.
grid
Package grid allows widgets to be arranged in rows and columns.
Package grid allows widgets to be arranged in rows and columns.
holder
Package holder provides a widget that wraps an inner widget, and allows it to be easily swapped for another.
Package holder provides a widget that wraps an inner widget, and allows it to be easily swapped for another.
hpadding
Package hpadding provides a widget that pads an inner widget on the left and right.
Package hpadding provides a widget that pads an inner widget on the left and right.
isselected
Package isselected provides a widget that acts differently if selected (or focused)
Package isselected provides a widget that acts differently if selected (or focused)
keypress
Package keypress provides a widget which responds to keyboard input.
Package keypress provides a widget which responds to keyboard input.
list
Package list provides a widget displaying a vertical list of widgets with one in focus and support for previous and next.
Package list provides a widget displaying a vertical list of widgets with one in focus and support for previous and next.
menu
Package menu is a widget that presents a drop-down menu.
Package menu is a widget that presents a drop-down menu.
null
Package null provides a widget which does nothing and renders nothing.
Package null provides a widget which does nothing and renders nothing.
overlay
Package overlay is a widget that allows one widget to be overlaid on another.
Package overlay is a widget that allows one widget to be overlaid on another.
padding
Package padding provides a widget that pads an inner widget on the sides, above and below
Package padding provides a widget that pads an inner widget on the sides, above and below
palettemap
Package palettemap provides a widget that can change the color and style of an inner widget.
Package palettemap provides a widget that can change the color and style of an inner widget.
paragraph
Package paragraph provides a simple text widget that neatly splits over multiple lines.
Package paragraph provides a simple text widget that neatly splits over multiple lines.
pile
Package pile provides a widget for organizing other widgets in a vertical stack.
Package pile provides a widget for organizing other widgets in a vertical stack.
progress
Package progress provides a simple progress bar.
Package progress provides a simple progress bar.
radio
Package radio provides radio button widgets where one can be selected among many.
Package radio provides radio button widgets where one can be selected among many.
selectable
Package selectable provides a widget that forces its inner widget to be selectable.
Package selectable provides a widget that forces its inner widget to be selectable.
shadow
Package shadow adds a drop shadow effect to a widget.
Package shadow adds a drop shadow effect to a widget.
spinner
Package spinner provides a simple themable spinner.
Package spinner provides a simple themable spinner.
styled
Package styled provides a colored styled widget.
Package styled provides a colored styled widget.
table
A simple implementation of a CSV table widget.
A simple implementation of a CSV table widget.
terminal
Package terminal provides a widget that functions as a unix terminal.
Package terminal provides a widget that functions as a unix terminal.
text
Package text provides a text field widget.
Package text provides a text field widget.
tree
Package tree is a widget that displays a collection of widgets organized in a tree structure.
Package tree is a widget that displays a collection of widgets organized in a tree structure.
vpadding
Package vpadding provides a widget that pads an inner widget on the top and bottom.
Package vpadding provides a widget that pads an inner widget on the top and bottom.
vscroll
Package vscroll provides a vertical scrollbar widget with mouse support.
Package vscroll provides a vertical scrollbar widget with mouse support.

Jump to

Keyboard shortcuts

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