gobless

package module
v0.0.0-...-ce7a36a Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2018 License: MIT Imports: 7 Imported by: 0

README

gobless

Build beautiful terminal dashboards and GUIs in Golang.

example

The name was intended to be pronounced go-bless due to the inspiration from blessed-contrib, but gob-less is kind of funnier, so we'll go with that instead.

Thanks to tcell, full cross-platform terminal support is expected.

Requirements

  • Go 1.10+
  • Terminal with:
    • Unicode support
    • 256 color support

Get Started

go get github.com/liamg/gobless

You can get started by experimenting with the various examples.

Components

Text Box

example

textbox := gobless.NewTextBox()
textbox.SetWidth(64)
textbox.SetHeight(10)
helloTextbox.SetTextWrap(true)
helloTextbox.SetText(`Lorem ipsum...`)

Full example code is here.

Bar Chart

example

chart := gobless.NewBarChart()
chart.SetTitle("Traffic")
chart.SetWidth(40)
chart.SetHeight(15)
chart.SetYScale(100)
chart.SetBar("Europe", 60)
chart.SetBar("US", 72)
chart.SetBar("Asia", 37)

Full example code is here.

Progress Bar
Sparklines
Line Chart
Block Chart

(kind of like blessed-contrib's stacked gauge)

Donut
Log
Table
Tree
Dot Matrix

The dot matrix component allows you set blocks of colour at double the resolution of the terminal characters, using the various partial quadrant unicode characters.

It includes utility methods for drawing lines, circles etc.

example

Example code is here.

Layout System

Gobless includes a built-in CSS style 12 column nestable grid layout system. This uses Rows and Columns (which are themselves components) to quickly build a UI with minimal effort.

example

rows := []gobless.Component{
	gobless.NewRow(
		gobless.GridSizeHalf,
		gobless.NewColumn(
			gobless.GridSizeTwoThirds,
			helloTextbox,
		),
		gobless.NewColumn(
			gobless.GridSizeOneThird,
			gobless.NewRow(
				gobless.GridSizeFull,
				gobless.NewColumn(
					gobless.GridSizeFull,
					chart,
					chart2,
				),
			),
		),
	), 
	gobless.NewRow(
		gobless.GridSizeHalf,
		gobless.NewColumn(
			gobless.GridSizeFull,
			quitTextbox,
		),
	),
}

gui.Render(rows...)

You can also detect resize events and automatically resize the layout of your components if you wish.

gui.HandleResize(func(event gobless.ResizeEvent) {
	gui.Render(rows...)
})

A full example is also available.

Alternatively, if you need to, you can position components absolutely using the .SetX(), .SetY(), .SetWidth() and .SetHeight() methods, omitting the presence of rows/columns entirely.

Events

Gobless can currently detect two types of events:

Key Press Events

You can add your own handlers for key presses, utilising the gobless.Key* constants.

For example, to stop rendering the GUI when the user presses CTRL + Q, you could do:

gui.HandleKeyPress(gobless.KeyCtrlQ, func(event gobless.KeyPressEvent){
		gui.Close()
})

Terminology

  • A Cell refers to an individual terminal cell, in which a single character can be drawn.
  • A Tile refers to a rectangular grouping of cells.
  • A Component is an entity which provides a tile - or tiles - to the GUI to render. A bar chart, for example.

Documentation

Index

Constants

View Source
const (
	ColorBlack                = Color(tcell.ColorBlack)
	ColorMaroon               = Color(tcell.ColorMaroon)
	ColorGreen                = Color(tcell.ColorGreen)
	ColorOlive                = Color(tcell.ColorOlive)
	ColorNavy                 = Color(tcell.ColorNavy)
	ColorPurple               = Color(tcell.ColorPurple)
	ColorTeal                 = Color(tcell.ColorTeal)
	ColorSilver               = Color(tcell.ColorSilver)
	ColorGray                 = Color(tcell.ColorGray)
	ColorRed                  = Color(tcell.ColorRed)
	ColorLime                 = Color(tcell.ColorLime)
	ColorYellow               = Color(tcell.ColorYellow)
	ColorBlue                 = Color(tcell.ColorBlue)
	ColorFuchsia              = Color(tcell.ColorFuchsia)
	ColorAqua                 = Color(tcell.ColorAqua)
	ColorWhite                = Color(tcell.ColorWhite)
	Color16                   = Color(tcell.Color16)
	Color17                   = Color(tcell.Color17)
	Color18                   = Color(tcell.Color18)
	Color19                   = Color(tcell.Color19)
	Color20                   = Color(tcell.Color20)
	Color21                   = Color(tcell.Color21)
	Color22                   = Color(tcell.Color22)
	Color23                   = Color(tcell.Color23)
	Color24                   = Color(tcell.Color24)
	Color25                   = Color(tcell.Color25)
	Color26                   = Color(tcell.Color26)
	Color27                   = Color(tcell.Color27)
	Color28                   = Color(tcell.Color28)
	Color29                   = Color(tcell.Color29)
	Color30                   = Color(tcell.Color30)
	Color31                   = Color(tcell.Color31)
	Color32                   = Color(tcell.Color32)
	Color33                   = Color(tcell.Color33)
	Color34                   = Color(tcell.Color34)
	Color35                   = Color(tcell.Color35)
	Color36                   = Color(tcell.Color36)
	Color37                   = Color(tcell.Color37)
	Color38                   = Color(tcell.Color38)
	Color39                   = Color(tcell.Color39)
	Color40                   = Color(tcell.Color40)
	Color41                   = Color(tcell.Color41)
	Color42                   = Color(tcell.Color42)
	Color43                   = Color(tcell.Color43)
	Color44                   = Color(tcell.Color44)
	Color45                   = Color(tcell.Color45)
	Color46                   = Color(tcell.Color46)
	Color47                   = Color(tcell.Color47)
	Color48                   = Color(tcell.Color48)
	Color49                   = Color(tcell.Color49)
	Color50                   = Color(tcell.Color50)
	Color51                   = Color(tcell.Color51)
	Color52                   = Color(tcell.Color52)
	Color53                   = Color(tcell.Color53)
	Color54                   = Color(tcell.Color54)
	Color55                   = Color(tcell.Color55)
	Color56                   = Color(tcell.Color56)
	Color57                   = Color(tcell.Color57)
	Color58                   = Color(tcell.Color58)
	Color59                   = Color(tcell.Color59)
	Color60                   = Color(tcell.Color60)
	Color61                   = Color(tcell.Color61)
	Color62                   = Color(tcell.Color62)
	Color63                   = Color(tcell.Color63)
	Color64                   = Color(tcell.Color64)
	Color65                   = Color(tcell.Color65)
	Color66                   = Color(tcell.Color66)
	Color67                   = Color(tcell.Color67)
	Color68                   = Color(tcell.Color68)
	Color69                   = Color(tcell.Color69)
	Color70                   = Color(tcell.Color70)
	Color71                   = Color(tcell.Color71)
	Color72                   = Color(tcell.Color72)
	Color73                   = Color(tcell.Color73)
	Color74                   = Color(tcell.Color74)
	Color75                   = Color(tcell.Color75)
	Color76                   = Color(tcell.Color76)
	Color77                   = Color(tcell.Color77)
	Color78                   = Color(tcell.Color78)
	Color79                   = Color(tcell.Color79)
	Color80                   = Color(tcell.Color80)
	Color81                   = Color(tcell.Color81)
	Color82                   = Color(tcell.Color82)
	Color83                   = Color(tcell.Color83)
	Color84                   = Color(tcell.Color84)
	Color85                   = Color(tcell.Color85)
	Color86                   = Color(tcell.Color86)
	Color87                   = Color(tcell.Color87)
	Color88                   = Color(tcell.Color88)
	Color89                   = Color(tcell.Color89)
	Color90                   = Color(tcell.Color90)
	Color91                   = Color(tcell.Color91)
	Color92                   = Color(tcell.Color92)
	Color93                   = Color(tcell.Color93)
	Color94                   = Color(tcell.Color94)
	Color95                   = Color(tcell.Color95)
	Color96                   = Color(tcell.Color96)
	Color97                   = Color(tcell.Color97)
	Color98                   = Color(tcell.Color98)
	Color99                   = Color(tcell.Color99)
	Color100                  = Color(tcell.Color100)
	Color101                  = Color(tcell.Color101)
	Color102                  = Color(tcell.Color102)
	Color103                  = Color(tcell.Color103)
	Color104                  = Color(tcell.Color104)
	Color105                  = Color(tcell.Color105)
	Color106                  = Color(tcell.Color106)
	Color107                  = Color(tcell.Color107)
	Color108                  = Color(tcell.Color108)
	Color109                  = Color(tcell.Color109)
	Color110                  = Color(tcell.Color110)
	Color111                  = Color(tcell.Color111)
	Color112                  = Color(tcell.Color112)
	Color113                  = Color(tcell.Color113)
	Color114                  = Color(tcell.Color114)
	Color115                  = Color(tcell.Color115)
	Color116                  = Color(tcell.Color116)
	Color117                  = Color(tcell.Color117)
	Color118                  = Color(tcell.Color118)
	Color119                  = Color(tcell.Color119)
	Color120                  = Color(tcell.Color120)
	Color121                  = Color(tcell.Color121)
	Color122                  = Color(tcell.Color122)
	Color123                  = Color(tcell.Color123)
	Color124                  = Color(tcell.Color124)
	Color125                  = Color(tcell.Color125)
	Color126                  = Color(tcell.Color126)
	Color127                  = Color(tcell.Color127)
	Color128                  = Color(tcell.Color128)
	Color129                  = Color(tcell.Color129)
	Color130                  = Color(tcell.Color130)
	Color131                  = Color(tcell.Color131)
	Color132                  = Color(tcell.Color132)
	Color133                  = Color(tcell.Color133)
	Color134                  = Color(tcell.Color134)
	Color135                  = Color(tcell.Color135)
	Color136                  = Color(tcell.Color136)
	Color137                  = Color(tcell.Color137)
	Color138                  = Color(tcell.Color138)
	Color139                  = Color(tcell.Color139)
	Color140                  = Color(tcell.Color140)
	Color141                  = Color(tcell.Color141)
	Color142                  = Color(tcell.Color142)
	Color143                  = Color(tcell.Color143)
	Color144                  = Color(tcell.Color144)
	Color145                  = Color(tcell.Color145)
	Color146                  = Color(tcell.Color146)
	Color147                  = Color(tcell.Color147)
	Color148                  = Color(tcell.Color148)
	Color149                  = Color(tcell.Color149)
	Color150                  = Color(tcell.Color150)
	Color151                  = Color(tcell.Color151)
	Color152                  = Color(tcell.Color152)
	Color153                  = Color(tcell.Color153)
	Color154                  = Color(tcell.Color154)
	Color155                  = Color(tcell.Color155)
	Color156                  = Color(tcell.Color156)
	Color157                  = Color(tcell.Color157)
	Color158                  = Color(tcell.Color158)
	Color159                  = Color(tcell.Color159)
	Color160                  = Color(tcell.Color160)
	Color161                  = Color(tcell.Color161)
	Color162                  = Color(tcell.Color162)
	Color163                  = Color(tcell.Color163)
	Color164                  = Color(tcell.Color164)
	Color165                  = Color(tcell.Color165)
	Color166                  = Color(tcell.Color166)
	Color167                  = Color(tcell.Color167)
	Color168                  = Color(tcell.Color168)
	Color169                  = Color(tcell.Color169)
	Color170                  = Color(tcell.Color170)
	Color171                  = Color(tcell.Color171)
	Color172                  = Color(tcell.Color172)
	Color173                  = Color(tcell.Color173)
	Color174                  = Color(tcell.Color174)
	Color175                  = Color(tcell.Color175)
	Color176                  = Color(tcell.Color176)
	Color177                  = Color(tcell.Color177)
	Color178                  = Color(tcell.Color178)
	Color179                  = Color(tcell.Color179)
	Color180                  = Color(tcell.Color180)
	Color181                  = Color(tcell.Color181)
	Color182                  = Color(tcell.Color182)
	Color183                  = Color(tcell.Color183)
	Color184                  = Color(tcell.Color184)
	Color185                  = Color(tcell.Color185)
	Color186                  = Color(tcell.Color186)
	Color187                  = Color(tcell.Color187)
	Color188                  = Color(tcell.Color188)
	Color189                  = Color(tcell.Color189)
	Color190                  = Color(tcell.Color190)
	Color191                  = Color(tcell.Color191)
	Color192                  = Color(tcell.Color192)
	Color193                  = Color(tcell.Color193)
	Color194                  = Color(tcell.Color194)
	Color195                  = Color(tcell.Color195)
	Color196                  = Color(tcell.Color196)
	Color197                  = Color(tcell.Color197)
	Color198                  = Color(tcell.Color198)
	Color199                  = Color(tcell.Color199)
	Color200                  = Color(tcell.Color200)
	Color201                  = Color(tcell.Color201)
	Color202                  = Color(tcell.Color202)
	Color203                  = Color(tcell.Color203)
	Color204                  = Color(tcell.Color204)
	Color205                  = Color(tcell.Color205)
	Color206                  = Color(tcell.Color206)
	Color207                  = Color(tcell.Color207)
	Color208                  = Color(tcell.Color208)
	Color209                  = Color(tcell.Color209)
	Color210                  = Color(tcell.Color210)
	Color211                  = Color(tcell.Color211)
	Color212                  = Color(tcell.Color212)
	Color213                  = Color(tcell.Color213)
	Color214                  = Color(tcell.Color214)
	Color215                  = Color(tcell.Color215)
	Color216                  = Color(tcell.Color216)
	Color217                  = Color(tcell.Color217)
	Color218                  = Color(tcell.Color218)
	Color219                  = Color(tcell.Color219)
	Color220                  = Color(tcell.Color220)
	Color221                  = Color(tcell.Color221)
	Color222                  = Color(tcell.Color222)
	Color223                  = Color(tcell.Color223)
	Color224                  = Color(tcell.Color224)
	Color225                  = Color(tcell.Color225)
	Color226                  = Color(tcell.Color226)
	Color227                  = Color(tcell.Color227)
	Color228                  = Color(tcell.Color228)
	Color229                  = Color(tcell.Color229)
	Color230                  = Color(tcell.Color230)
	Color231                  = Color(tcell.Color231)
	Color232                  = Color(tcell.Color232)
	Color233                  = Color(tcell.Color233)
	Color234                  = Color(tcell.Color234)
	Color235                  = Color(tcell.Color235)
	Color236                  = Color(tcell.Color236)
	Color237                  = Color(tcell.Color237)
	Color238                  = Color(tcell.Color238)
	Color239                  = Color(tcell.Color239)
	Color240                  = Color(tcell.Color240)
	Color241                  = Color(tcell.Color241)
	Color242                  = Color(tcell.Color242)
	Color243                  = Color(tcell.Color243)
	Color244                  = Color(tcell.Color244)
	Color245                  = Color(tcell.Color245)
	Color246                  = Color(tcell.Color246)
	Color247                  = Color(tcell.Color247)
	Color248                  = Color(tcell.Color248)
	Color249                  = Color(tcell.Color249)
	Color250                  = Color(tcell.Color250)
	Color251                  = Color(tcell.Color251)
	Color252                  = Color(tcell.Color252)
	Color253                  = Color(tcell.Color253)
	Color254                  = Color(tcell.Color254)
	Color255                  = Color(tcell.Color255)
	ColorAliceBlue            = Color(tcell.ColorAliceBlue)
	ColorAntiqueWhite         = Color(tcell.ColorAntiqueWhite)
	ColorAquaMarine           = Color(tcell.ColorAquaMarine)
	ColorAzure                = Color(tcell.ColorAzure)
	ColorBeige                = Color(tcell.ColorBeige)
	ColorBisque               = Color(tcell.ColorBisque)
	ColorBlanchedAlmond       = Color(tcell.ColorBlanchedAlmond)
	ColorBlueViolet           = Color(tcell.ColorBlueViolet)
	ColorBrown                = Color(tcell.ColorBrown)
	ColorBurlyWood            = Color(tcell.ColorBurlyWood)
	ColorCadetBlue            = Color(tcell.ColorCadetBlue)
	ColorChartreuse           = Color(tcell.ColorChartreuse)
	ColorChocolate            = Color(tcell.ColorChocolate)
	ColorCoral                = Color(tcell.ColorCoral)
	ColorCornflowerBlue       = Color(tcell.ColorCornflowerBlue)
	ColorCornsilk             = Color(tcell.ColorCornsilk)
	ColorCrimson              = Color(tcell.ColorCrimson)
	ColorDarkBlue             = Color(tcell.ColorDarkBlue)
	ColorDarkCyan             = Color(tcell.ColorDarkCyan)
	ColorDarkGoldenrod        = Color(tcell.ColorDarkGoldenrod)
	ColorDarkGray             = Color(tcell.ColorDarkGray)
	ColorDarkGreen            = Color(tcell.ColorDarkGreen)
	ColorDarkKhaki            = Color(tcell.ColorDarkKhaki)
	ColorDarkMagenta          = Color(tcell.ColorDarkMagenta)
	ColorDarkOliveGreen       = Color(tcell.ColorDarkOliveGreen)
	ColorDarkOrange           = Color(tcell.ColorDarkOrange)
	ColorDarkOrchid           = Color(tcell.ColorDarkOrchid)
	ColorDarkRed              = Color(tcell.ColorDarkRed)
	ColorDarkSalmon           = Color(tcell.ColorDarkSalmon)
	ColorDarkSeaGreen         = Color(tcell.ColorDarkSeaGreen)
	ColorDarkSlateBlue        = Color(tcell.ColorDarkSlateBlue)
	ColorDarkSlateGray        = Color(tcell.ColorDarkSlateGray)
	ColorDarkTurquoise        = Color(tcell.ColorDarkTurquoise)
	ColorDarkViolet           = Color(tcell.ColorDarkViolet)
	ColorDeepPink             = Color(tcell.ColorDeepPink)
	ColorDeepSkyBlue          = Color(tcell.ColorDeepSkyBlue)
	ColorDimGray              = Color(tcell.ColorDimGray)
	ColorDodgerBlue           = Color(tcell.ColorDodgerBlue)
	ColorFireBrick            = Color(tcell.ColorFireBrick)
	ColorFloralWhite          = Color(tcell.ColorFloralWhite)
	ColorForestGreen          = Color(tcell.ColorForestGreen)
	ColorGainsboro            = Color(tcell.ColorGainsboro)
	ColorGhostWhite           = Color(tcell.ColorGhostWhite)
	ColorGold                 = Color(tcell.ColorGold)
	ColorGoldenrod            = Color(tcell.ColorGoldenrod)
	ColorGreenYellow          = Color(tcell.ColorGreenYellow)
	ColorHoneydew             = Color(tcell.ColorHoneydew)
	ColorHotPink              = Color(tcell.ColorHotPink)
	ColorIndianRed            = Color(tcell.ColorIndianRed)
	ColorIndigo               = Color(tcell.ColorIndigo)
	ColorIvory                = Color(tcell.ColorIvory)
	ColorKhaki                = Color(tcell.ColorKhaki)
	ColorLavender             = Color(tcell.ColorLavender)
	ColorLavenderBlush        = Color(tcell.ColorLavenderBlush)
	ColorLawnGreen            = Color(tcell.ColorLawnGreen)
	ColorLemonChiffon         = Color(tcell.ColorLemonChiffon)
	ColorLightBlue            = Color(tcell.ColorLightBlue)
	ColorLightCoral           = Color(tcell.ColorLightCoral)
	ColorLightCyan            = Color(tcell.ColorLightCyan)
	ColorLightGoldenrodYellow = Color(tcell.ColorLightGoldenrodYellow)
	ColorLightGray            = Color(tcell.ColorLightGray)
	ColorLightGreen           = Color(tcell.ColorLightGreen)
	ColorLightPink            = Color(tcell.ColorLightPink)
	ColorLightSalmon          = Color(tcell.ColorLightSalmon)
	ColorLightSeaGreen        = Color(tcell.ColorLightSeaGreen)
	ColorLightSkyBlue         = Color(tcell.ColorLightSkyBlue)
	ColorLightSlateGray       = Color(tcell.ColorLightSlateGray)
	ColorLightSteelBlue       = Color(tcell.ColorLightSteelBlue)
	ColorLightYellow          = Color(tcell.ColorLightYellow)
	ColorLimeGreen            = Color(tcell.ColorLimeGreen)
	ColorLinen                = Color(tcell.ColorLinen)
	ColorMediumAquamarine     = Color(tcell.ColorMediumAquamarine)
	ColorMediumBlue           = Color(tcell.ColorMediumBlue)
	ColorMediumOrchid         = Color(tcell.ColorMediumOrchid)
	ColorMediumPurple         = Color(tcell.ColorMediumPurple)
	ColorMediumSeaGreen       = Color(tcell.ColorMediumSeaGreen)
	ColorMediumSlateBlue      = Color(tcell.ColorMediumSlateBlue)
	ColorMediumSpringGreen    = Color(tcell.ColorMediumSpringGreen)
	ColorMediumTurquoise      = Color(tcell.ColorMediumTurquoise)
	ColorMediumVioletRed      = Color(tcell.ColorMediumVioletRed)
	ColorMidnightBlue         = Color(tcell.ColorMidnightBlue)
	ColorMintCream            = Color(tcell.ColorMintCream)
	ColorMistyRose            = Color(tcell.ColorMistyRose)
	ColorMoccasin             = Color(tcell.ColorMoccasin)
	ColorNavajoWhite          = Color(tcell.ColorNavajoWhite)
	ColorOldLace              = Color(tcell.ColorOldLace)
	ColorOliveDrab            = Color(tcell.ColorOliveDrab)
	ColorOrange               = Color(tcell.ColorOrange)
	ColorOrangeRed            = Color(tcell.ColorOrangeRed)
	ColorOrchid               = Color(tcell.ColorOrchid)
	ColorPaleGoldenrod        = Color(tcell.ColorPaleGoldenrod)
	ColorPaleGreen            = Color(tcell.ColorPaleGreen)
	ColorPaleTurquoise        = Color(tcell.ColorPaleTurquoise)
	ColorPaleVioletRed        = Color(tcell.ColorPaleVioletRed)
	ColorPapayaWhip           = Color(tcell.ColorPapayaWhip)
	ColorPeachPuff            = Color(tcell.ColorPeachPuff)
	ColorPeru                 = Color(tcell.ColorPeru)
	ColorPink                 = Color(tcell.ColorPink)
	ColorPlum                 = Color(tcell.ColorPlum)
	ColorPowderBlue           = Color(tcell.ColorPowderBlue)
	ColorRebeccaPurple        = Color(tcell.ColorRebeccaPurple)
	ColorRosyBrown            = Color(tcell.ColorRosyBrown)
	ColorRoyalBlue            = Color(tcell.ColorRoyalBlue)
	ColorSaddleBrown          = Color(tcell.ColorSaddleBrown)
	ColorSalmon               = Color(tcell.ColorSalmon)
	ColorSandyBrown           = Color(tcell.ColorSandyBrown)
	ColorSeaGreen             = Color(tcell.ColorSeaGreen)
	ColorSeashell             = Color(tcell.ColorSeashell)
	ColorSienna               = Color(tcell.ColorSienna)
	ColorSkyblue              = Color(tcell.ColorSkyblue)
	ColorSlateBlue            = Color(tcell.ColorSlateBlue)
	ColorSlateGray            = Color(tcell.ColorSlateGray)
	ColorSnow                 = Color(tcell.ColorSnow)
	ColorSpringGreen          = Color(tcell.ColorSpringGreen)
	ColorSteelBlue            = Color(tcell.ColorSteelBlue)
	ColorTan                  = Color(tcell.ColorTan)
	ColorThistle              = Color(tcell.ColorThistle)
	ColorTomato               = Color(tcell.ColorTomato)
	ColorTurquoise            = Color(tcell.ColorTurquoise)
	ColorViolet               = Color(tcell.ColorViolet)
	ColorWheat                = Color(tcell.ColorWheat)
	ColorWhiteSmoke           = Color(tcell.ColorWhiteSmoke)
	ColorYellowGreen          = Color(tcell.ColorYellowGreen)
)
View Source
const (
	KeyF1     = Key(tcell.KeyF1)
	KeyF2     = Key(tcell.KeyF2)
	KeyF3     = Key(tcell.KeyF3)
	KeyF4     = Key(tcell.KeyF4)
	KeyF5     = Key(tcell.KeyF5)
	KeyF6     = Key(tcell.KeyF6)
	KeyF7     = Key(tcell.KeyF7)
	KeyF8     = Key(tcell.KeyF8)
	KeyF9     = Key(tcell.KeyF9)
	KeyF10    = Key(tcell.KeyF10)
	KeyF11    = Key(tcell.KeyF11)
	KeyF12    = Key(tcell.KeyF12)
	KeyInsert = Key(tcell.KeyInsert)
	KeyDelete = Key(tcell.KeyDelete)
	KeyHome   = Key(tcell.KeyHome)
	KeyEnd    = Key(tcell.KeyEnd)
	KeyPgUp   = Key(tcell.KeyPgUp)
	KeyPgDn   = Key(tcell.KeyPgDn)
	KeyUp     = Key(tcell.KeyUp)
	KeyDown   = Key(tcell.KeyDown)
	KeyLeft   = Key(tcell.KeyLeft)
	KeyRight  = Key(tcell.KeyRight)
)

Abstract from tcell

View Source
const (
	KeyCtrlSpace      = Key(tcell.KeyCtrlSpace)
	KeyCtrlA          = Key(tcell.KeyCtrlA)
	KeyCtrlB          = Key(tcell.KeyCtrlB)
	KeyCtrlC          = Key(tcell.KeyCtrlC)
	KeyCtrlD          = Key(tcell.KeyCtrlD)
	KeyCtrlE          = Key(tcell.KeyCtrlE)
	KeyCtrlF          = Key(tcell.KeyCtrlF)
	KeyCtrlG          = Key(tcell.KeyCtrlG)
	KeyBackspace      = Key(tcell.KeyBackspace)
	KeyCtrlH          = Key(tcell.KeyCtrlH)
	KeyTab            = Key(tcell.KeyTab)
	KeyCtrlI          = Key(tcell.KeyCtrlI)
	KeyCtrlJ          = Key(tcell.KeyCtrlJ)
	KeyCtrlK          = Key(tcell.KeyCtrlK)
	KeyCtrlL          = Key(tcell.KeyCtrlL)
	KeyEnter          = Key(tcell.KeyEnter)
	KeyCtrlM          = Key(tcell.KeyCtrlM)
	KeyCtrlN          = Key(tcell.KeyCtrlN)
	KeyCtrlO          = Key(tcell.KeyCtrlO)
	KeyCtrlP          = Key(tcell.KeyCtrlP)
	KeyCtrlQ          = Key(tcell.KeyCtrlQ)
	KeyCtrlR          = Key(tcell.KeyCtrlR)
	KeyCtrlS          = Key(tcell.KeyCtrlS)
	KeyCtrlT          = Key(tcell.KeyCtrlT)
	KeyCtrlU          = Key(tcell.KeyCtrlU)
	KeyCtrlV          = Key(tcell.KeyCtrlV)
	KeyCtrlW          = Key(tcell.KeyCtrlW)
	KeyCtrlX          = Key(tcell.KeyCtrlX)
	KeyCtrlY          = Key(tcell.KeyCtrlY)
	KeyCtrlZ          = Key(tcell.KeyCtrlZ)
	KeyEsc            = Key(tcell.KeyEsc)
	KeyCtrlBackslash  = Key(tcell.KeyCtrlBackslash)
	KeyCtrlUnderscore = Key(tcell.KeyCtrlUnderscore)
	KeyBackspace2     = Key(tcell.KeyBackspace2)
)

Variables

View Source
var DefaultStyle = Style{
	ForegroundColor: ColorWhite,
	BackgroundColor: ColorBlack,
}

Functions

This section is empty.

Types

type BarChart

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

func NewBarChart

func NewBarChart() *BarChart

func (*BarChart) GetTiles

func (barchart *BarChart) GetTiles(gui *GUI) []Tile

func (*BarChart) SetBar

func (barchart *BarChart) SetBar(name string, value int)

func (*BarChart) SetBarSpacing

func (barchart *BarChart) SetBarSpacing(space bool)

func (*BarChart) SetBarStyle

func (component *BarChart) SetBarStyle(style Style)

func (*BarChart) SetBorderColor

func (barchart *BarChart) SetBorderColor(color Color)

func (*BarChart) SetHeight

func (barchart *BarChart) SetHeight(h int)

func (*BarChart) SetStyle

func (component *BarChart) SetStyle(style Style)

func (*BarChart) SetTextWrap

func (component *BarChart) SetTextWrap(enabled bool)

func (*BarChart) SetTitle

func (barchart *BarChart) SetTitle(title string)

func (*BarChart) SetWidth

func (barchart *BarChart) SetWidth(w int)

func (*BarChart) SetX

func (barchart *BarChart) SetX(x int)

func (*BarChart) SetY

func (barchart *BarChart) SetY(y int)

func (*BarChart) SetYScale

func (barchart *BarChart) SetYScale(scale int)

type Border

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

func NewBorder

func NewBorder() *Border

func (*Border) GetTiles

func (component *Border) GetTiles(gui *GUI) []Tile

func (*Border) SetHeight

func (component *Border) SetHeight(h int)

func (*Border) SetStyle

func (component *Border) SetStyle(style Style)

func (*Border) SetText

func (component *Border) SetText(text string)

func (*Border) SetWidth

func (component *Border) SetWidth(w int)

func (*Border) SetX

func (component *Border) SetX(x int)

func (*Border) SetY

func (component *Border) SetY(y int)

type Cell

type Cell struct {
	Rune  rune
	Style Style
}

func NewCell

func NewCell(c rune, style Style) Cell

type Color

type Color int32

type Column

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

func NewColumn

func NewColumn(size GridSize, components ...Component) *Column

func (*Column) GetTiles

func (col *Column) GetTiles(gui *GUI) []Tile

func (*Column) SetHeight

func (col *Column) SetHeight(h int)

func (*Column) SetWidth

func (col *Column) SetWidth(w int)

func (*Column) SetX

func (col *Column) SetX(x int)

func (*Column) SetY

func (col *Column) SetY(y int)

type Component

type Component interface {
	GetTiles(gui *GUI) []Tile
	SetX(x int)
	SetY(y int)
	SetWidth(w int)
	SetHeight(h int)
}

type Donut

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

func NewDonut

func NewDonut() *Donut

func (*Donut) GetTiles

func (donut *Donut) GetTiles(gui *GUI) []Tile

func (*Donut) SetHeight

func (donut *Donut) SetHeight(h int)

func (*Donut) SetLabel

func (donut *Donut) SetLabel(label string)

func (*Donut) SetPercent

func (donut *Donut) SetPercent(pc int)

func (*Donut) SetStyle

func (donut *Donut) SetStyle(style Style)

func (*Donut) SetWidth

func (donut *Donut) SetWidth(w int)

func (*Donut) SetX

func (donut *Donut) SetX(x int)

func (*Donut) SetY

func (donut *Donut) SetY(y int)

type DotMatrix

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

func NewDotMatrix

func NewDotMatrix() *DotMatrix

func (*DotMatrix) Circle

func (dotMatrix *DotMatrix) Circle(x0 int, y0 int, radius int, color Color)

func (*DotMatrix) GetDotHeight

func (screen *DotMatrix) GetDotHeight() int

func (*DotMatrix) GetDotWidth

func (screen *DotMatrix) GetDotWidth() int

func (*DotMatrix) GetTiles

func (screen *DotMatrix) GetTiles(gui *GUI) []Tile

func (*DotMatrix) Line

func (dotMatrix *DotMatrix) Line(x0 int, y0 int, x1 int, y1 int, color Color)

func (*DotMatrix) Off

func (screen *DotMatrix) Off(dotX int, dotY int)

func (*DotMatrix) On

func (screen *DotMatrix) On(dotX int, dotY int, color Color)

func (*DotMatrix) SetHeight

func (screen *DotMatrix) SetHeight(h int)

func (*DotMatrix) SetWidth

func (screen *DotMatrix) SetWidth(w int)

func (*DotMatrix) SetX

func (screen *DotMatrix) SetX(x int)

func (*DotMatrix) SetY

func (screen *DotMatrix) SetY(y int)

type Event

type Event interface{}

type GUI

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

func NewGUI

func NewGUI() *GUI

func (*GUI) Clear

func (gui *GUI) Clear()

func (*GUI) Close

func (gui *GUI) Close()

func (*GUI) HandleKeyPress

func (gui *GUI) HandleKeyPress(key Key, handler func(event KeyPressEvent))

func (*GUI) HandleResize

func (gui *GUI) HandleResize(handler func(event ResizeEvent))

func (*GUI) Init

func (gui *GUI) Init() error

func (*GUI) Loop

func (gui *GUI) Loop()

func (*GUI) Render

func (gui *GUI) Render(components ...Component)

func (*GUI) Size

func (gui *GUI) Size() (int, int)

type GridSize

type GridSize int
const (
	GridSizeFull          GridSize = 12
	GridSizeFiveSixths    GridSize = 10
	GridSizeThreeQuarters GridSize = 9
	GridSizeTwoThirds     GridSize = 8
	GridSizeHalf          GridSize = 6
	GridSizeOneThird      GridSize = 4
	GridSizeOneQuarter    GridSize = 3
	GridSizeOneSixth      GridSize = 2
)

type Key

type Key uint16

type KeyPressEvent

type KeyPressEvent struct {
	Key Key
}

type ResizeEvent

type ResizeEvent struct {
	Width  int
	Height int
}

type Row

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

func NewRow

func NewRow(size GridSize, columns ...*Column) *Row

func (*Row) GetTiles

func (row *Row) GetTiles(gui *GUI) []Tile

func (*Row) SetHeight

func (row *Row) SetHeight(h int)

func (*Row) SetWidth

func (row *Row) SetWidth(w int)

func (*Row) SetX

func (row *Row) SetX(x int)

func (*Row) SetY

func (row *Row) SetY(y int)

type Style

type Style struct {
	ForegroundColor Color
	BackgroundColor Color
}

func NewStyle

func NewStyle(backgroundColor Color, foregroundColor Color) Style

type TextBox

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

func NewTextBox

func NewTextBox() *TextBox

func (*TextBox) GetTiles

func (textbox *TextBox) GetTiles(gui *GUI) []Tile

func (*TextBox) SetBorderColor

func (textbox *TextBox) SetBorderColor(color Color)

func (*TextBox) SetHeight

func (textbox *TextBox) SetHeight(h int)

func (*TextBox) SetStyle

func (component *TextBox) SetStyle(style Style)

func (*TextBox) SetText

func (component *TextBox) SetText(text string)

func (*TextBox) SetTextWrap

func (component *TextBox) SetTextWrap(enabled bool)

func (*TextBox) SetTitle

func (textbox *TextBox) SetTitle(title string)

func (*TextBox) SetWidth

func (textbox *TextBox) SetWidth(w int)

func (*TextBox) SetX

func (textbox *TextBox) SetX(x int)

func (*TextBox) SetY

func (textbox *TextBox) SetY(y int)

type Tile

type Tile struct {
	Rectangle image.Rectangle
	Cells     map[image.Point]Cell
}

func NewTile

func NewTile(x1 int, y1 int, x2 int, y2 int) Tile

func (*Tile) SetCell

func (tile *Tile) SetCell(point image.Point, cell Cell)

func (*Tile) SetCells

func (tile *Tile) SetCells(rectangle image.Rectangle, cell Cell)

Directories

Path Synopsis
_examples

Jump to

Keyboard shortcuts

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