termbox

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: MIT Imports: 2 Imported by: 30

Documentation

Overview

Package termbox is a compatibility layer to allow tcell to emulate the github.com/nsf/termbox package.

Index

Constants

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)
	KeyArrowUp    = Key(tcell.KeyUp)
	KeyArrowDown  = Key(tcell.KeyDown)
	KeyArrowRight = Key(tcell.KeyRight)
	KeyArrowLeft  = Key(tcell.KeyLeft)
	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)
	KeyCtrlH      = Key(tcell.KeyCtrlH)
	KeyCtrlI      = Key(tcell.KeyCtrlI)
	KeyCtrlJ      = Key(tcell.KeyCtrlJ)
	KeyCtrlK      = Key(tcell.KeyCtrlK)
	KeyCtrlL      = Key(tcell.KeyCtrlL)
	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)
	KeyBackspace  = Key(tcell.KeyBackspace)
	KeyBackspace2 = Key(tcell.KeyBackspace2)
	KeyTab        = Key(tcell.KeyTab)
	KeyEnter      = Key(tcell.KeyEnter)
	KeyEsc        = Key(tcell.KeyEscape)
	KeyPgdn       = Key(tcell.KeyPgDn)
	KeyPgup       = Key(tcell.KeyPgUp)
	MouseLeft     = Key(tcell.KeyF63) // arbitrary assignments
	MouseRight    = Key(tcell.KeyF62)
	MouseMiddle   = Key(tcell.KeyF61)
	MouseRelease  = Key(tcell.KeyF64)
	KeySpace      = Key(tcell.Key(' '))
)

Keys codes.

View Source
const (
	ModAlt = Modifier(tcell.ModAlt)
)

Modifiers.

Variables

This section is empty.

Functions

func Clear

func Clear(fg, bg Attribute)

Clear clears the screen with the given attributes.

func Close

func Close()

Close cleans up the terminal, restoring terminal modes, etc.

func Flush

func Flush() error

Flush updates the screen.

func GetCell

func GetCell(x, y int) (rune, Attribute, Attribute)

GetCell

func HideCursor

func HideCursor()

HideCursor hides the terminal cursor.

func Init

func Init() error

Init initializes the screen for use.

func Interrupt

func Interrupt()

Interrupt posts an interrupt event.

func SetCell

func SetCell(x, y int, ch rune, fg, bg Attribute)

SetCell sets the character cell at a given location to the given content (rune) and attributes.

func SetCursor

func SetCursor(x, y int)

SetCursor displays the terminal cursor at the given location.

func Size

func Size() (int, int)

Size returns the screen size as width, height in character cells.

func Sync

func Sync() error

Sync forces a resync of the screen.

Types

type Attribute

type Attribute uint16

Attribute affects the presentation of characters, such as color, boldness, and so forth.

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

Colors first. The order here is significant.

const (
	AttrBold Attribute = 1 << (9 + iota)
	AttrUnderline
	AttrReverse
)

Other attributes.

type Cell

type Cell struct {
	Ch rune
	Fg Attribute
	Bg Attribute
}

Cell represents a single character cell on screen.

type Event

type Event struct {
	Type   EventType
	Mod    Modifier
	Key    Key
	Ch     rune
	Width  int
	Height int
	Err    error
	MouseX int
	MouseY int
	N      int
}

Event represents an event like a key press, mouse action, or window resize.

func ParseEvent

func ParseEvent(data []byte) Event

ParseEvent is not supported.

func PollEvent

func PollEvent() Event

PollEvent blocks until an event is ready, and then returns it.

func PollRawEvent

func PollRawEvent(data []byte) Event

PollRawEvent is not supported.

type EventType

type EventType uint8

EventType represents the type of event.

const (
	EventNone EventType = iota
	EventKey
	EventResize
	EventMouse
	EventInterrupt
	EventError
	EventRaw
)

Event types.

type InputMode

type InputMode int

InputMode is not used.

const (
	InputEsc InputMode = 1 << iota
	InputAlt
	InputMouse
	InputCurrent InputMode = 0
)

Unused input modes; here for compatibility.

func SetInputMode

func SetInputMode(mode InputMode) InputMode

SetInputMode does not do much in this version.

type Key

type Key tcell.Key

Key is a key press.

type Modifier

type Modifier tcell.ModMask

Modifier represents the possible modifier keys.

type OutputMode

type OutputMode int

OutputMode represents an output mode, which determines how colors are used. See the termbox documentation for an explanation.

const (
	OutputCurrent OutputMode = iota
	OutputNormal
	Output256
	Output216
	OutputGrayscale
)

OutputMode values.

func SetOutputMode

func SetOutputMode(mode OutputMode) OutputMode

SetOutputMode is used to set the color palette used.

Jump to

Keyboard shortcuts

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