api

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultStyle = Style{/* contains filtered or unexported fields */}

DefaultStyle has no attributes and "default" colors. The semantics of the later is decided by the backend implementation. Use the With* methods to create new styles from the default style.

Functions

This section is empty.

Types

type ButtonMask

type ButtonMask int32

ButtonMask mask is used to report/post user mouse input events.

const (
	Button1 ButtonMask = 1 << iota // Usually the left (primary) mouse button.
	Button2                        // Usually the right (secondary) mouse button.
	Button3                        // Usually the middle mouse button.
	Button4                        // Often a side button (thumb/next).
	Button5                        // Often a side button (thumb/prev).
	Button6
	Button7
	Button8
	WheelUp                   // Wheel motion up/away from user.
	WheelDown                 // Wheel motion down/towards user.
	WheelLeft                 // Wheel motion to left.
	WheelRight                // Wheel motion to right.
	ZeroButton ButtonMask = 0 // No button or wheel events.

	Primary   = Button1
	Secondary = Button2
	Middle    = Button3
)

type CellScreenDiff added in v0.10.0

type CellScreenDiff struct {
	LinesCount int
	CellsCount int
	Line, Cell int
}

type CellsLine

type CellsLine []TestCell

CellsLine represents a line of a CellsScreen providing of each cell in the line its displayed rune and style information for test-evaluations.

func (CellsLine) HasAA

func (l CellsLine) HasAA(x int, aa StyleAttributeMask) bool

HasAA returns true if line cell at given position x in given line cells l has given foreground color.

func (CellsLine) HasBG

func (l CellsLine) HasBG(x int, c Color) bool

HasBG returns true if line cell at given position x in given line cells l has given background color.

func (CellsLine) HasFG

func (l CellsLine) HasFG(x int, c Color) bool

HasFG returns true if line cell at given position x in given line cells l has given foreground color.

func (CellsLine) String

func (l CellsLine) String() string

String returns a string representation of given line cells l.

type CellsScreen

type CellsScreen []CellsLine

CellsScreen is a screen representation at a specific point in time of CellsLine instances. NOTE use CellsScreen.Trimmed to minimize the reported screen area.

func (CellsScreen) Column added in v0.10.0

func (cs CellsScreen) Column(i int) []TestCell

Column returns a column of test-cells from the test screen or nil iff the cells-screen cs is zero or given column i doesnt exist.

func (CellsScreen) Equals added in v0.10.0

func (cs CellsScreen) Equals(other CellsScreen) bool

func (CellsScreen) FirstDiff added in v0.10.0

func (cs CellsScreen) FirstDiff(other CellsScreen) CellScreenDiff

func (CellsScreen) HasAA

func (cs CellsScreen) HasAA(x, y int, aa StyleAttributeMask) bool

HasAA returns true if the screen cell at given coordinates x and y in given screen cells cs have given style attributes aa.

func (CellsScreen) HasBG

func (cs CellsScreen) HasBG(x, y int, c Color) bool

HasBG returns true if the screen cell at given coordinates x and y in given screen cells cs have given background color c.

func (CellsScreen) HasFG

func (cs CellsScreen) HasFG(x, y int, c Color) bool

HasFG returns true if the screen cell at given coordinates x and y in given screen cells cs have given foreground color c.

func (CellsScreen) String

func (cs CellsScreen) String() string

String returns a string representation of given screen cells cs.

func (CellsScreen) Trimmed

func (cs CellsScreen) Trimmed() CellsScreen

Trimmed reduces given screen-cells matrix to its minimum number of non-empty cells whereas the cells-lines are trimmed to contain all non white space cells:

+--------------------+
|                    |       +------------+
|   upper left       |       |upper left  |
|                    |  =>   |            |
|          right     |       |       right|
|      bottom        |       |   bottom   |
|                    |       +------------+
+--------------------+

type Color

type Color int32

Color represents an rgb color. Predefined colors are expressed in the typical hex-format 0xRRGGBB whereas R, G and B are hex-digits, i.e. red is 0xFF0000.

const (
	Black             Color = 0x000000
	Maroon            Color = 0x800000
	Green             Color = 0x008000
	Olive             Color = 0x808000
	Navy              Color = 0x000080
	Purple            Color = 0x800080
	Teal              Color = 0x008080
	Silver            Color = 0xc0c0c0
	Grey              Color = 0x808080
	Red               Color = 0xff0000
	Lime              Color = 0x00ff00
	Yellow            Color = 0xffff00
	Blue              Color = 0x0000ff
	Fuchsia           Color = 0xff00ff
	Aqua              Color = 0x00ffff
	White             Color = 0xffffff
	Grey0             Color = 0x000000
	NavyBlue          Color = 0x00005f
	DarkBlue          Color = 0x000087
	Blue3             Color = 0x0000af
	Blue3_2           Color = 0x0000d7
	Blue1             Color = 0x0000ff
	DarkGreen         Color = 0x005f00
	DeepSkyBlue4      Color = 0x005f5f
	DeepSkyBlue4_2    Color = 0x005f87
	DeepSkyBlue4_3    Color = 0x005faf
	DodgerBlue3       Color = 0x005fd7
	DodgerBlue2       Color = 0x005fff
	Green4            Color = 0x008700
	SpringGreen4      Color = 0x00875f
	Turquoise4        Color = 0x008787
	DeepSkyBlue3      Color = 0x0087af
	DeepSkyBlue3_2    Color = 0x0087d7
	DodgerBlue1       Color = 0x0087ff
	Green3            Color = 0x00af00
	SpringGreen3      Color = 0x00af5f
	DarkCyan          Color = 0x00af87
	LightSeaGreen     Color = 0x00afaf
	DeepSkyBlue2      Color = 0x00afd7
	DeepSkyBlue1      Color = 0x00afff
	Green3_2          Color = 0x00d700
	SpringGreen3_2    Color = 0x00d75f
	SpringGreen2      Color = 0x00d787
	Cyan3             Color = 0x00d7af
	DarkTurquoise     Color = 0x00d7d7
	Turquoise2        Color = 0x00d7ff
	Green1            Color = 0x00ff00
	SpringGreen2_2    Color = 0x00ff5f
	SpringGreen1      Color = 0x00ff87
	MediumSpringGreen Color = 0x00ffaf
	Cyan2             Color = 0x00ffd7
	Cyan1             Color = 0x00ffff
	DarkRed           Color = 0x5f0000
	DeepPink4_3       Color = 0x5f005f
	Purple4           Color = 0x5f0087
	Purple4_2         Color = 0x5f00af
	Purple3           Color = 0x5f00d7
	BlueViolet        Color = 0x5f00ff
	Orange4           Color = 0x5f5f00
	Grey37            Color = 0x5f5f5f
	MediumPurple4     Color = 0x5f5f87
	SlateBlue3        Color = 0x5f5faf
	SlateBlue3_2      Color = 0x5f5fd7
	RoyalBlue1        Color = 0x5f5fff
	Chartreuse4       Color = 0x5f8700
	DarkSeaGreen4     Color = 0x5f875f
	PaleTurquoise4    Color = 0x5f8787
	SteelBlue         Color = 0x5f87af
	SteelBlue3        Color = 0x5f87d7
	CornflowerBlue    Color = 0x5f87ff
	Chartreuse3       Color = 0x5faf00
	DarkSeaGreen4_2   Color = 0x5faf5f
	CadetBlue         Color = 0x5faf87
	CadetBlue_2       Color = 0x5fafaf
	SkyBlue3          Color = 0x5fafd7
	SteelBlue1        Color = 0x5fafff
	Chartreuse3_2     Color = 0x5fd700
	PaleGreen3        Color = 0x5fd75f
	SeaGreen3         Color = 0x5fd787
	Aquamarine3       Color = 0x5fd7af
	MediumTurquoise   Color = 0x5fd7d7
	SteelBlue1_2      Color = 0x5fd7ff
	Chartreuse2       Color = 0x5fff00
	SeaGreen2         Color = 0x5fff5f
	SeaGreen1         Color = 0x5fff87
	SeaGreen1_2       Color = 0x5fffaf
	Aquamarine1       Color = 0x5fffd7
	DarkSlateGray2    Color = 0x5fffff
	DarkRed_2         Color = 0x870000
	DeepPink4_2       Color = 0x87005f
	DarkMagenta       Color = 0x870087
	DarkMagenta_2     Color = 0x8700af
	DarkViolet        Color = 0x8700d7
	Purple_1          Color = 0x8700ff
	Orange4_2         Color = 0x875f00
	LightPink4        Color = 0x875f5f
	Plum4             Color = 0x875f87
	MediumPurple3     Color = 0x875faf
	MediumPurple3_2   Color = 0x875fd7
	SlateBlue1        Color = 0x875fff
	Yellow4           Color = 0x878700
	Wheat4            Color = 0x87875f
	Grey53            Color = 0x878787
	LightSlateGrey    Color = 0x8787af
	MediumPurple      Color = 0x8787d7
	LightSlateBlue    Color = 0x8787ff
	Yellow4_2         Color = 0x87af00
	DarkOliveGreen3   Color = 0x87af5f
	DarkSeaGreen      Color = 0x87af87
	LightSkyBlue3     Color = 0x87afaf
	LightSkyBlue3_2   Color = 0x87afd7
	SkyBlue2          Color = 0x87afff
	Chartreuse2_2     Color = 0x87d700
	DarkOliveGreen3_2 Color = 0x87d75f
	PaleGreen3_2      Color = 0x87d787
	DarkSeaGreen3     Color = 0x87d7af
	DarkSlateGray3    Color = 0x87d7d7
	SkyBlue1          Color = 0x87d7ff
	Chartreuse1       Color = 0x87ff00
	LightGreen        Color = 0x87ff5f
	LightGreen_2      Color = 0x87ff87
	PaleGreen1        Color = 0x87ffaf
	Aquamarine1_2     Color = 0x87ffd7
	DarkSlateGray1    Color = 0x87ffff
	Red3              Color = 0xaf0000
	DeepPink4         Color = 0xaf005f
	MediumVioletRed   Color = 0xaf0087
	Magenta3          Color = 0xaf00af
	DarkViolet_2      Color = 0xaf00d7
	Purple_2          Color = 0xaf00ff
	DarkOrange3       Color = 0xaf5f00
	IndianRed         Color = 0xaf5f5f
	HotPink3          Color = 0xaf5f87
	MediumOrchid3     Color = 0xaf5faf
	MediumOrchid      Color = 0xaf5fd7
	MediumPurple2     Color = 0xaf5fff
	DarkGoldenrod     Color = 0xaf8700
	LightSalmon3      Color = 0xaf875f
	RosyBrown         Color = 0xaf8787
	Grey63            Color = 0xaf87af
	MediumPurple2_2   Color = 0xaf87d7
	MediumPurple1     Color = 0xaf87ff
	Gold3             Color = 0xafaf00
	DarkKhaki         Color = 0xafaf5f
	NavajoWhite3      Color = 0xafaf87
	Grey69            Color = 0xafafaf
	LightSteelBlue3   Color = 0xafafd7
	LightSteelBlue    Color = 0xafafff
	Yellow3           Color = 0xafd700
	DarkOliveGreen3_3 Color = 0xafd75f
	DarkSeaGreen3_2   Color = 0xafd787
	DarkSeaGreen2     Color = 0xafd7af
	LightCyan3        Color = 0xafd7d7
	LightSkyBlue1     Color = 0xafd7ff
	GreenYellow       Color = 0xafff00
	DarkOliveGreen2   Color = 0xafff5f
	PaleGreen1_2      Color = 0xafff87
	DarkSeaGreen2_2   Color = 0xafffaf
	DarkSeaGreen1     Color = 0xafffd7
	PaleTurquoise1    Color = 0xafffff
	Red3_2            Color = 0xd70000
	DeepPink3         Color = 0xd7005f
	DeepPink3_2       Color = 0xd70087
	Magenta3_2        Color = 0xd700af
	Magenta3_3        Color = 0xd700d7
	Magenta2          Color = 0xd700ff
	DarkOrange3_2     Color = 0xd75f00
	IndianRed_2       Color = 0xd75f5f
	HotPink3_2        Color = 0xd75f87
	HotPink2          Color = 0xd75faf
	Orchid            Color = 0xd75fd7
	MediumOrchid1     Color = 0xd75fff
	Orange3           Color = 0xd78700
	LightSalmon3_2    Color = 0xd7875f
	LightPink3        Color = 0xd78787
	Pink3             Color = 0xd787af
	Plum3             Color = 0xd787d7
	Violet            Color = 0xd787ff
	Gold3_2           Color = 0xd7af00
	LightGoldenrod3   Color = 0xd7af5f
	Tan               Color = 0xd7af87
	MistyRose3        Color = 0xd7afaf
	Thistle3          Color = 0xd7afd7
	Plum2             Color = 0xd7afff
	Yellow3_2         Color = 0xd7d700
	Khaki3            Color = 0xd7d75f
	LightGoldenrod2   Color = 0xd7d787
	LightYellow3      Color = 0xd7d7af
	Grey84            Color = 0xd7d7d7
	LightSteelBlue1   Color = 0xd7d7ff
	Yellow2           Color = 0xd7ff00
	DarkOliveGreen1   Color = 0xd7ff5f
	DarkOliveGreen1_2 Color = 0xd7ff87
	DarkSeaGreen1_2   Color = 0xd7ffaf
	Honeydew2         Color = 0xd7ffd7
	LightCyan1        Color = 0xd7ffff
	Red1              Color = 0xff0000
	DeepPink2         Color = 0xff005f
	DeepPink1         Color = 0xff0087
	DeepPink1_2       Color = 0xff00af
	Magenta2_2        Color = 0xff00d7
	Magenta1          Color = 0xff00ff
	OrangeRed1        Color = 0xff5f00
	IndianRed1        Color = 0xff5f5f
	IndianRed1_2      Color = 0xff5f87
	HotPink           Color = 0xff5faf
	HotPink_2         Color = 0xff5fd7
	MediumOrchid1_2   Color = 0xff5fff
	DarkOrange        Color = 0xff8700
	Salmon1           Color = 0xff875f
	LightCoral        Color = 0xff8787
	PaleVioletRed1    Color = 0xff87af
	Orchid2           Color = 0xff87d7
	Orchid1           Color = 0xff87ff
	Orange1           Color = 0xffaf00
	SandyBrown        Color = 0xffaf5f
	LightSalmon1      Color = 0xffaf87
	LightPink1        Color = 0xffafaf
	Pink1             Color = 0xffafd7
	Plum1             Color = 0xffafff
	Gold1             Color = 0xffd700
	LightGoldenrod2_2 Color = 0xffd75f
	LightGoldenrod2_3 Color = 0xffd787
	NavajoWhite1      Color = 0xffd7af
	MistyRose1        Color = 0xffd7d7
	Thistle1          Color = 0xffd7ff
	Yellow1           Color = 0xffff00
	LightGoldenrod1   Color = 0xffff5f
	Khaki1            Color = 0xffff87
	Wheat1            Color = 0xffffaf
	Cornsilk1         Color = 0xffffd7
	Grey100           Color = 0xffffff
	Grey3             Color = 0x080808
	Grey7             Color = 0x121212
	Grey11            Color = 0x1c1c1c
	Grey15            Color = 0x262626
	Grey19            Color = 0x303030
	Grey23            Color = 0x3a3a3a
	Grey27            Color = 0x444444
	Grey30            Color = 0x4e4e4e
	Grey35            Color = 0x585858
	Grey39            Color = 0x626262
	Grey42            Color = 0x6c6c6c
	Grey46            Color = 0x767676
	Grey50            Color = 0x808080
	Grey54            Color = 0x8a8a8a
	Grey58            Color = 0x949494
	Grey62            Color = 0x9e9e9e
	Grey66            Color = 0xa8a8a8
	Grey70            Color = 0xb2b2b2
	Grey74            Color = 0xbcbcbc
	Grey78            Color = 0xc6c6c6
	Grey82            Color = 0xd0d0d0
	Grey85            Color = 0xdadada
	Grey89            Color = 0xe4e4e4
	Grey93            Color = 0xeeeeee

	DefaultColor Color = -1
)

type CursorStyle added in v0.9.1

type CursorStyle int

CursorStyle represents a given cursor style, which can include the shape and whether the cursor blinks or is solid. Backends need to map their provided cursor styles to these cursor styles and set a requested cursor style to default if not supported.

const (
	ZeroCursor CursorStyle = iota
	DefaultCursor
	BlockCursorBlinking
	BlockCursorSteady
	UnderlineCursorBlinking
	UnderlineCursorSteady
	BarCursorBlinking
	BarCursorSteady
)

type Displayer

type Displayer interface {

	// NewStyle must be used to obtain a new style with backend specific
	// defaults.
	NewStyle() Style

	// Display "writes" given run with given style at given coordinates
	// to the screen.
	Display(int, int, rune, Style)

	// Update updates the screen.
	Update()

	// Redraw redraws the screen.
	Redraw()

	// Size reports the available screen/window size whereas the width
	// is the number of single width runes fitting in a line and the
	// height is the number of lines fitting on the screen.
	Size() (int, int)

	// SetCursor positions the screen/window cursor at given coordinates
	// x and y having optionally given cursor style cs and returns the
	// actually set cursor position with actually set cursor style:
	//  - if x and y are outside the screen or they are inside and given
	//    cursor style is the ZeroCursor the -1, -1, ZeroCursor is
	//    returned.
	//  - if x and y are inside the screen and no cursor style is given
	//    x and y and ZeroCursor is return indicating that the cursor
	//    style has not changed.
	//  - if x and y are inside the screen and a non-zero cursor style
	//    is given the arguments are returned as received.
	SetCursor(x, y int, cs ...CursorStyle) (int, int, CursorStyle)

	// Colors provide the number of available (ANSI) colors.  In case of
	// a monochrome screen 0 is returned.
	Colors() int
}

Displayer implementation provides the screen/a window as a set of lines and cells to which a rune at a given position with a given style can be written.

type EventProcessor

type EventProcessor interface {

	// Post posts given event to the event loop.
	Post(Eventer) error

	// Quit event polling.
	Quit()

	// WaitForQuit blocks until the backend was quit.
	WaitForQuit()

	// OnQuit registers given function to be called on quitting.
	OnQuit(listener func())
}

EventProcessor provides user input events and programmatically posted events.

type Eventer

type Eventer interface {
	// When returns the creation time of an event.
	When() time.Time
	// Source returns the wrapped event of the backend.
	Source() interface{}
}

Eventer is the abstract interface which must be implemented by all reported/posted events.

type Gaps

type Gaps struct {
	Top, Right, Bottom, Left int
}

Gaps is internally used for layout calculations of nested components of either stacking or chaining gaped components. The layout wrapper of stacking/chaining components created during a component's initialization process provides a Gaps instance to the layout manager.

type Key

type Key int32
const (
	NUL Key = iota
	SOH
	STX
	ETX
	EOT
	ENQ
	ACK
	BEL
	BS
	TAB
	LF
	VT
	FF
	CR
	SO
	SI
	DLE
	DC1
	DC2
	DC3
	DC4
	NAK
	SYN
	ETB
	CAN
	EM
	SUB
	ESC
	FS
	GS
	RS
	US
	DEL
	Up
	Down
	Right
	Left
	UpLeft
	UpRight
	DownLeft
	DownRight
	Center
	PgUp
	PgDn
	Home
	End
	Insert
	Delete
	Help
	Exit
	Clear
	Cancel
	Print
	Pause
	Backtab
	F1
	F2
	F3
	F4
	F5
	F6
	F7
	F8
	F9
	F10
	F11
	F12
	F13
	F14
	F15
	F16
	F17
	F18
	F19
	F20
	F21
	F22
	F23
	F24
	F25
	F26
	F27
	F28
	F29
	F30
	F31
	F32
	F33
	F34
	F35
	F36
	F37
	F38
	F39
	F40
	F41
	F42
	F43
	F44
	F45
	F46
	F47
	F48
	F49
	F50
	F51
	F52
	F53
	F54
	F55
	F56
	F57
	F58
	F59
	F60
	F61
	F62
	F63
	F64

	CtrlSpace      = NUL
	CtrlA          = SOH
	CtrlB          = STX
	CtrlC          = ETX
	CtrlD          = EOT
	CtrlE          = ENQ
	CtrlF          = ACK
	CtrlG          = BEL
	CtrlH          = BS
	CtrlI          = TAB
	CtrlJ          = LF
	CtrlK          = VT
	CtrlL          = FF
	CtrlM          = CR
	CtrlN          = SO
	CtrlO          = SI
	CtrlP          = DLE
	CtrlQ          = DC1
	CtrlR          = DC2
	CtrlS          = DC3
	CtrlT          = DC4
	CtrlU          = NAK
	CtrlV          = SYN
	CtrlW          = ETB
	CtrlX          = CAN
	CtrlY          = EM
	CtrlZ          = SUB
	CtrlLeftSq     = ESC
	CtrlBackslash  = FS
	CtrlRightSq    = GS
	CtrlCarat      = RS
	CtrlUnderscore = US
	Enter          = CR
	Tab            = TAB
	Backspace      = BS
	Esc            = ESC
)

type KeyEventer

type KeyEventer interface {
	Eventer

	// Key reports the pressed key.
	Key() Key

	// Mod reports the pressed modifier key like shift, alt, ...
	Mod() ModifierMask
}

KeyEventer implementation is reported on a user special-key input event like "enter" or "backspace".

type ModifierMask

type ModifierMask int32

ModifierMask mask is used to provide pressed modifiers of a reported/posted key/rune user input event.

const (
	Shift ModifierMask = 1 << iota
	Ctrl
	Alt
	Meta
	ZeroModifier ModifierMask = 0
)

type MouseClick added in v0.9.0

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

MouseClick is an MouseEventer implementation reporting the aggregation of mouse events as a mouse click of arbitrary button.

func NewMouseClick added in v0.9.0

func NewMouseClick(to MouseEventer) *MouseClick

func (*MouseClick) Button added in v0.9.0

func (e *MouseClick) Button() ButtonMask

func (*MouseClick) Mod added in v0.9.0

func (e *MouseClick) Mod() ModifierMask

func (*MouseClick) Pos added in v0.9.0

func (e *MouseClick) Pos() (int, int)

func (*MouseClick) Source added in v0.9.0

func (e *MouseClick) Source() interface{}

func (*MouseClick) When added in v0.9.0

func (e *MouseClick) When() time.Time

type MouseDrag added in v0.9.0

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

func NewMouseDrag added in v0.9.0

func NewMouseDrag(ox, oy int, to MouseEventer) *MouseDrag

func (*MouseDrag) Button added in v0.9.0

func (e *MouseDrag) Button() ButtonMask

func (*MouseDrag) Mod added in v0.9.0

func (e *MouseDrag) Mod() ModifierMask

func (*MouseDrag) Origin added in v0.9.0

func (d *MouseDrag) Origin() (x, y int)

Origin returns the absolute coordinates where the drag started.

func (*MouseDrag) Pos added in v0.9.0

func (e *MouseDrag) Pos() (int, int)

func (*MouseDrag) Source added in v0.9.0

func (e *MouseDrag) Source() interface{}

func (*MouseDrag) When added in v0.9.0

func (e *MouseDrag) When() time.Time

type MouseDrop added in v0.9.0

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

func NewMouseDrop added in v0.9.0

func NewMouseDrop(to MouseEventer) *MouseDrop

func (*MouseDrop) Button added in v0.9.0

func (e *MouseDrop) Button() ButtonMask

func (*MouseDrop) Mod added in v0.9.0

func (e *MouseDrop) Mod() ModifierMask

func (*MouseDrop) Pos added in v0.9.0

func (e *MouseDrop) Pos() (int, int)

func (*MouseDrop) Source added in v0.9.0

func (e *MouseDrop) Source() interface{}

func (*MouseDrop) When added in v0.9.0

func (e *MouseDrop) When() time.Time

type MouseEventer

type MouseEventer interface {
	Eventer

	// Button returns the buttons mask of the mouse event.
	Button() ButtonMask

	// Mod reports the pressed modifier key like shift, alt, ...
	Mod() ModifierMask

	// Pos returns the x- and y-screen-coordinates of a mouse event.
	Pos() (int, int)
}

MouseEventer implementation is reported on a user-input mouse event.

type MouseMove added in v0.9.0

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

func NewMouseMove added in v0.9.0

func NewMouseMove(ox, oy int, to MouseEventer) *MouseMove

func (*MouseMove) Button added in v0.9.0

func (e *MouseMove) Button() ButtonMask

func (*MouseMove) Mod added in v0.9.0

func (e *MouseMove) Mod() ModifierMask

func (*MouseMove) Origin added in v0.9.0

func (d *MouseMove) Origin() (x, y int)

Origin reports coordinates from where the mouse move started. NOTE these coordinates are absolute coordinates since the movement might started outside the component.

func (*MouseMove) Pos added in v0.9.0

func (e *MouseMove) Pos() (int, int)

func (*MouseMove) Source added in v0.9.0

func (e *MouseMove) Source() interface{}

func (*MouseMove) When added in v0.9.0

func (e *MouseMove) When() time.Time

type ResizeEventer

type ResizeEventer interface {
	Eventer

	// Size reports the width, i.e. the number of runes fitting in a
	// screen/window line, and the height, i.e. the number of lines fitting on
	// the screen/window, of the resize event.
	Size() (int, int)
}

ResizeEventer implementation is reported on a screen/window-size change.

type RuneEventer

type RuneEventer interface {
	Eventer

	// Rune reports the pressed rune.
	Rune() rune

	// Mod reports the pressed modifier key like shift, alt, ...
	Mod() ModifierMask
}

RuneEventer implementation is reported on a user rune input event.

type StringLine

type StringLine string

StringLine is a line of a StringScreen providing the sequence of runes displayed in a particular screen line.

type StringScreen

type StringScreen []string

StringScreen is the string representation of the screen lines at a particular point in time. Note use StringScreen.Trimmed to minimize reported screen content.

func (StringScreen) Column

func (ss StringScreen) Column(idx int) string

Column returns the content of the column with given index as string.

func (StringScreen) String

func (ss StringScreen) String() string

String joins the lines of given screen string representation with line breaks and returns resulting string.

func (StringScreen) Trimmed

func (ss StringScreen) Trimmed() StringScreen

Trimmed reduces given string to its minimum number of non-empty lines whereas the lines are trimmed to contain all non white space runes:

+--------------------+
|                    |       +------------+
|   upper left       |       |upper left  |
|                    |  =>   |            |
|          right     |       |       right|
|      bottom        |       |   bottom   |
|                    |       +------------+
+--------------------+

type Style

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

Style represents what a print to the screen should look like. A zero Style instance has fore- and background color set to black. Use its With* methods to create a style with desired properties:

myStyle := (lines.Style{}).WithFG(lines.White)

func NewStyle

func NewStyle(aa StyleAttributeMask, fg, bg Color) Style

NewStyle creates a new style with given style attributes and given fore- and background color.

func (Style) AA

func (s Style) AA() StyleAttributeMask

func (Style) BG

func (s Style) BG() Color

func (Style) FG

func (s Style) FG() Color

func (Style) Invert added in v0.10.0

func (s Style) Invert() Style

Invert returns a style having given Style s foreground color as background color and its background color as foreground color.

func (Style) IsDefault added in v0.10.0

func (s Style) IsDefault() bool

IsDefault returns true if given Style s is the DefaultStyle.

func (Style) Reverse added in v0.10.0

func (s Style) Reverse() Style

Reverse returns given Style s reversed, i.e. with the Reverse-bit set if s has it not set or with the Reverse-bit unset otherwise.

func (Style) SMN added in v0.10.0

func (s Style) SMN() StyleSemantic

func (Style) Switch added in v0.10.0

func (s Style) Switch(a StyleAttributeMask) Style

Switch removes given attribute a if it is set or adds it otherwise.

func (Style) WithAA

func (s Style) WithAA(aa StyleAttributeMask) Style

WithAA returns given style with its attributes set to given attribute mask.

func (Style) WithAdded

func (s Style) WithAdded(aa StyleAttributeMask) Style

WithAdded returns given style with given attribute mask added.

func (Style) WithBG

func (s Style) WithBG(c Color) Style

WithBG returns given style with its background color set to given color.

func (Style) WithFG

func (s Style) WithFG(c Color) Style

WithFG returns given style with its foreground color set to given color.

func (Style) WithRemoved

func (s Style) WithRemoved(aa StyleAttributeMask) Style

WithRemoved returns given style without given attribute mask.

func (Style) WithSemantics added in v0.10.0

func (s Style) WithSemantics(sm StyleSemantic) Style

WithSemantics returns given style s with given semantics (ID) set. Note the lines package doesn't define any semantics (yet). The sole purpose of the semantics property is to give the user an option to discriminate two semantics which might accidentally have the same colors and attributes but have two different meanings.

type StyleAttributeMask

type StyleAttributeMask int32

StyleAttributeMask defines the looks of a style, i.e. the looks of a print to the screen/window.

const (
	Bold StyleAttributeMask = 1 << iota
	Blink
	Reverse
	Underline
	Dim
	Italic
	StrikeThrough
	Invalid
	ZeroStyle StyleAttributeMask = 0
)

type StyleSemantic added in v0.10.0

type StyleSemantic uint8

type TestCell

type TestCell struct {
	Rune  rune
	Style Style
}

type Tester

type Tester interface {

	// Size returns the number of available lines (height) and the number of
	// runes per line (width) as reported by an backend.
	Size() (width, height int)

	// String returns a string representation of the screen/window
	// content.
	Screen() StringScreen

	// StringArea returns a string representation of given screen/window
	// area.
	ScreenArea(x, y, width, height int) StringScreen

	// Cells returns the content of a test screen as lines of test
	// cells, i.e. in addition to a screens content also the style
	// information is provided.
	Cells() CellsScreen

	// CellsArea returns the content of a test screen area as lines of
	// test cells, i.e. in addition to the area's content also the style
	// information is provided.
	CellsArea(x, y, width, height int) CellsScreen

	// Display brings given string in given style to the screen.
	Display(string, Style)

	// PostKey emulates a user-key-input with underlying backend.
	PostKey(Key, ModifierMask) error

	// PostKey emulates a user-rune-input with underlying backend.
	PostRune(rune, ModifierMask) error

	// PostKey emulates a user-mouse-input with underlying backend.
	PostMouse(x, y int, _ ButtonMask, _ ModifierMask) error

	// PostKey emulates a resize event of the available display area
	// with underlying backend.
	PostResize(width, height int) error
}

Tester implementation augments an UIer implementation with additional functionality for testing.

type UIer

type UIer interface {
	Displayer
	EventProcessor

	// Lib provides access to the encapsulated backend library.
	Lib() interface{}
}

An UIer implementation provides the functionality lines needs to provide its features.

Jump to

Keyboard shortcuts

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