Documentation
¶
Index ¶
- Constants
- Variables
- func Display(ctx context.Context, ui *UI) error
- func DummyBackend() settings.Setting
- func GraphicalBackend() settings.Setting
- func HintColorMode(m ColorMode) settings.Setting
- func SetBackend(bui backends.UIer) settings.Setting
- func SetColors(fg, bg lyt.Color, ml ModeListener) settings.Setting
- func SetContent(p Content) settings.Setting
- func SetPanicking(p Panicking) settings.Setting
- func SetQuitting(q Quitting) settings.Setting
- func SetReceiver(r Receiver) settings.Setting
- func TerminalBackend() settings.Setting
- type ColorMode
- type Content
- type Info
- type ModeListener
- type Panicking
- type Quitting
- type ReConfig
- type Receiver
- type UI
Constants ¶
const ( ModeUnknown = backends.ModeUnknown ModeDark = backends.ModeDark ModeLight = backends.ModeLight )
Variables ¶
var ErrNoBackendSet = errors.New(
"vw: display: ui needs a backend set")
var ErrTimeout = errors.New("vw: ui: wait for cleanup: timeout")
var ErrUINotConsumed = errors.New(
"vw: display: ui needs at least vw.Receiver or vw.Quitter")
var NoReConfig = ReConfig{}
NoReConfig is used by an receiver to signal no configuration changes.
Functions ¶
func Display ¶
Display sets up the ui for reporting events to set callbacks and for receiving content to be displayed. Display will fail if it is not consumed -- i.e. neither vw.Quitting nor vw.Receiver was set -- and if it has no backend set.
func DummyBackend ¶
func GraphicalBackend ¶
func HintColorMode ¶ added in v0.9.12
HintColorMode hints the color mode for when the backend can't auto-detect it. Has no effect on the color mode while non-default colors are set; takes effect once SetColors(DefaultColor, DefaultColor) restores backend defaults.
func SetBackend ¶
SetBackend sets the used backend.
func SetColors ¶ added in v0.9.7
func SetColors(fg, bg lyt.Color, ml ModeListener) settings.Setting
SetColors overrides the backend's default fg/bg colors. ml is called when the derived color mode changes; pass nil if not needed.
func SetContent ¶
SetContent from which are the runes retrieved to display.
func SetPanicking ¶
SetPanicking sets the listener for panic events.
func SetQuitting ¶
SetQuitting sets the listener for quit events.
func SetReceiver ¶
SetReceiver sets the listener for keyboard events.
func TerminalBackend ¶
Types ¶
type ColorMode ¶ added in v0.9.7
ColorMode classifies a fg/bg color pair as dark, light, or unknown.
type Content ¶
type Content interface {
// Init is the first call initiating a new painting of the display
// content having given columns and rows available.
Init(columns, rows int) lyt.Settings
// Next is asked for the next rune to display until either both
// return values are zero or the display is filled.
Next() (rune, lyt.Settings)
// Done is called when either no more runes provided or the display
// is full or a combination of lyt.Settings can't be applied
// typically because the position would leave the available space.
// In the later case an error is reported.
Done(error)
}
Content provides the content for the display and is set using SetContent. Setting a content indicates also the redrawing of the display (except for the first time).
type Info ¶
type Info struct {
IsConsumed bool
IsPolling bool
IsTerminal bool
Backend string
Columns int
Rows int
FgColor lyt.Color
BgColor lyt.Color
ColorMode ColorMode
}
Info holds information about an UI's current state.
type ModeListener ¶ added in v0.9.12
type ModeListener func(ColorMode)
ModeListener is called by SetColors when the derived color mode changes as a result of the new colors.
type Panicking ¶
type Panicking func(any)
Panicking -- if set by SetPanicking -- is called if the receiver of events from the respective ui-backend has panicked.
type Quitting ¶
type Quitting func(error)
A Quitting -- if set by SetQuitter -- is called if the user uses ui controls to indicate that the application should be closed.
type ReConfig ¶
ReConfig allows the Receiver to reconfigure view behavior in response to key events. Returning view.NoReConfig means no reconfiguration.
type Receiver ¶
A Receiver -- if set by SetReceiver -- is called if a key event is reported from the backend.
type UI ¶
type UI struct {
// contains filtered or unexported fields
}
UI instance is used to set up the ui and retrieve its current state. An UI instance must not be copied after its first use. An UI is typically created by vw.Apply e.g.:
ui, err := vw.Apply(nil, SetQuitting(...), SetReceiver(...), // .... )
and then displayed with vw.Display.
func Apply ¶
Apply given settings ss to given ui instance g and return ui or fail if one of ss fails. Note ui is created if nil.
func Register ¶
Register given ui at given settings context scc. Register panics if scc already contains an ui.
func (*UI) CanDetermineColorMode ¶ added in v0.9.11
CanDetermineColorMode reports whether the backend can detect color-mode changes mid-session. TUI: true iff COLORFGBG is set. GUI/mock: always true. No backend: false.
func (*UI) DetectColorMode ¶ added in v0.9.13
DetectColorMode returns the backend's current detected color mode, bypassing any consumer override. Consumers use this to watch for OS/terminal theme changes. No backend: ModeUnknown.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
lyt
package lyt is an indirection that translates consumer space layout settings (see vw/lyt-package) into backend layout aspects (see internal/backends.)
|
package lyt is an indirection that translates consumer space layout settings (see vw/lyt-package) into backend layout aspects (see internal/backends.) |
|
Package key provides key constants in their own name space.
|
Package key provides key constants in their own name space. |
|
Package lyt makes internal constants and types for the layout available to a consumer of the vw package without filling its name space.
|
Package lyt makes internal constants and types for the layout available to a consumer of the vw package without filling its name space. |
|
pkg
|
|