Documentation
¶
Index ¶
- Constants
- Variables
- func AbsInt(x int) int
- func Capture(width, height int, items ...Drawable) *image.RGBA
- func CellsToString(cells []Cell) string
- func Clear()
- func ClearBackground(c Color)
- func Close()
- func FloorFloat64(x float64) float64
- func GetMaxFloat64From2dSlice(slices [][]float64) (float64, error)
- func GetMaxFloat64FromSlice(slice []float64) (float64, error)
- func GetMaxIntFromSlice(slice []int) (int, error)
- func Init() error
- func InitWithConfig(cfg *InitConfig) error
- func InterfaceSlice(slice any) []any
- func MaxFloat64(x, y float64) float64
- func MaxInt(x, y int) int
- func MinFloat64(x, y float64) float64
- func MinInt(x, y int) int
- func PollEvents() <-chan Event
- func PollEventsWithContext(ctx context.Context) <-chan Event
- func Render(items ...Drawable)
- func RenderBufferToImage(buf *Buffer) *image.RGBA
- func ResolveBorderRune(existing, newRune rune) rune
- func RoundFloat64(x float64) float64
- func SaveImage(path string, width, height int, items ...Drawable) error
- func SplitCells(cells []Cell, r rune) [][]Cell
- func SumFloat64Slice(data []float64) float64
- func SumIntSlice(slice []int) int
- func TerminalDimensions() (int, int)
- func TrimString(s string, w int) string
- type Alignment
- type Application
- type Backend
- func (b *Backend) Clear()
- func (b *Backend) ClearBackground(c Color)
- func (b *Backend) Close()
- func (b *Backend) Init() error
- func (b *Backend) InitWithConfig(cfg *InitConfig) error
- func (b *Backend) PollEvents() <-chan Event
- func (b *Backend) PollEventsWithContext(ctx context.Context) <-chan Event
- func (b *Backend) Render(items ...Drawable)
- func (b *Backend) TerminalDimensions() (int, int)
- type BarChartTheme
- type Block
- type BlockTheme
- type BorderSet
- type BorderType
- type Borders
- type Buffer
- type Canvas
- type Cell
- func ApplyGradientToText(text string, start, end Color) []Cell
- func NewCell(rune rune, args ...any) Cell
- func ParseStyles(s string, defaultStyle Style) []Cell
- func RunesToStyledCells(runes []rune, style Style) []Cell
- func TrimCells(cells []Cell, w int) []Cell
- func WrapCells(cells []Cell, width uint) []Cell
- type CellWithX
- type Color
- func GenerateGradient(start, end Color, length int) []Color
- func GenerateMultiGradient(length int, colors ...Color) []Color
- func HexToColor(hex string) (Color, error)
- func InterpolateColor(c1, c2 Color, step, steps int) Color
- func NewColorRGB(r, g, b int32) Color
- func NewRGBColor(r, g, b int32) Color
- func SelectColor(colors []Color, index int) Color
- type Drawable
- type Event
- type EventHandler
- type EventType
- type GaugeTheme
- type Gradient
- type Grid
- type GridItem
- type InitConfig
- type ListTheme
- type Modifier
- type Mouse
- type ParagraphTheme
- type PieChartTheme
- type PlotTheme
- type Resize
- type RootTheme
- type SparklineTheme
- type StackedBarChartTheme
- type Style
- type TTYHandle
- type TabTheme
- type TableTheme
- type TreeTheme
- type VerticalAlignment
- type Widget
Constants ¶
const ( BorderTop = 1 BorderRight = 2 BorderBottom = 4 BorderLeft = 8 )
const ( BoxDrawingsLightHorizontal = '─' BoxDrawingsLightVertical = '│' BoxDrawingsLightDownAndRight = '┌' BoxDrawingsLightDownAndLeft = '┐' BoxDrawingsLightUpAndRight = '└' BoxDrawingsLightUpAndLeft = '┘' BoxDrawingsLightDownAndHorizontal = '┬' BoxDrawingsLightUpAndHorizontal = '┴' BoxDrawingsLightVerticalAndRight = '├' BoxDrawingsLightVerticalAndLeft = '┤' BoxDrawingsLightVerticalAndHorizontal = '┼' BoxDrawingsLightArcDownAndRight = '╭' BoxDrawingsLightArcDownAndLeft = '╮' BoxDrawingsLightArcUpAndRight = '╰' BoxDrawingsLightArcUpAndLeft = '╯' BoxDrawingsHeavyHorizontal = '━' BoxDrawingsHeavyVertical = '┃' BoxDrawingsHeavyDownAndRight = '┏' BoxDrawingsHeavyDownAndLeft = '┓' BoxDrawingsHeavyUpAndRight = '┗' BoxDrawingsHeavyUpAndLeft = '┛' BoxDrawingsHeavyDownAndHorizontal = '┳' BoxDrawingsHeavyUpAndHorizontal = '┻' BoxDrawingsHeavyVerticalAndRight = '┣' BoxDrawingsHeavyVerticalAndLeft = '┫' BoxDrawingsDoubleHorizontal = '═' BoxDrawingsDoubleVertical = '║' BoxDrawingsDoubleDownAndRight = '╔' BoxDrawingsDoubleDownAndLeft = '╗' BoxDrawingsDoubleUpAndRight = '╚' BoxDrawingsDoubleUpAndLeft = '╝' BoxDrawingsDoubleDownAndHorizontal = '╦' BoxDrawingsDoubleUpAndHorizontal = '╩' BoxDrawingsDoubleVerticalAndRight = '╠' BoxDrawingsDoubleVerticalAndLeft = '╣' )
const ( GradientHorizontal int = 0 GradientVertical int = 1 )
const ( TOP_LEFT = '┌' TOP_RIGHT = '┐' BOTTOM_LEFT = '└' BOTTOM_RIGHT = '┘' ROUNDED_TOP_LEFT = '╭' ROUNDED_TOP_RIGHT = '╮' ROUNDED_BOTTOM_LEFT = '╰' ROUNDED_BOTTOM_RIGHT = '╯' VERTICAL_LINE = '│' HORIZONTAL_LINE = '─' VERTICAL_LEFT = '┤' VERTICAL_RIGHT = '├' HORIZONTAL_UP = '┴' HORIZONTAL_DOWN = '┬' QUOTA_LEFT = '«' QUOTA_RIGHT = '»' VERTICAL_DASH = '┊' HORIZONTAL_DASH = '┈' COLLAPSED = '+' EXPANDED = '−' ELLIPSES = '…' UP_ARROW = '▲' DOWN_ARROW = '▼' DOT = '•' )
const (
CROSS = '┼'
)
Variables ¶
var ( BARS = [...]rune{' ', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'} SHADED_BLOCKS = [...]rune{' ', '░', '▒', '▓', '█'} IRREGULAR_BLOCKS = [...]rune{ ' ', '▘', '▝', '▀', '▖', '▌', '▞', '▛', '▗', '▚', '▐', '▜', '▄', '▙', '▟', '█', } BRAILLE_OFFSET = '\u2800' BRAILLE = [4][2]rune{ {'\u0001', '\u0008'}, {'\u0002', '\u0010'}, {'\u0004', '\u0020'}, {'\u0040', '\u0080'}, } DOUBLE_BRAILLE = map[[2]int]rune{ {0, 0}: '⣀', {0, 1}: '⡠', {0, 2}: '⡐', {0, 3}: '⡈', {1, 0}: '⢄', {1, 1}: '⠤', {1, 2}: '⠔', {1, 3}: '⠌', {2, 0}: '⢂', {2, 1}: '⠢', {2, 2}: '⠒', {2, 3}: '⠊', {3, 0}: '⢁', {3, 1}: '⠡', {3, 2}: '⠑', {3, 3}: '⠉', } SINGLE_BRAILLE_LEFT = [4]rune{'\u2840', '⠄', '⠂', '⠁'} SINGLE_BRAILLE_RIGHT = [4]rune{'\u2880', '⠠', '⠐', '⠈'} )
var CellClear = Cell{ Rune: ' ', Style: StyleClear, }
var DefaultBackend = &Backend{}
DefaultBackend is the default backend.
var Screen tcell.Screen
Screen is the default screen. Deprecated: Use DefaultBackend.Screen instead.
var ScreenshotMode bool
ScreenshotMode is the default screenshot mode. Deprecated: Use DefaultBackend.ScreenshotMode instead.
var StandardColors = []Color{ ColorRed, ColorGreen, ColorYellow, ColorBlue, ColorMagenta, ColorLightCyan, ColorWhite, }
var StandardStyles = []Style{ NewStyle(ColorRed), NewStyle(ColorGreen), NewStyle(ColorYellow), NewStyle(ColorBlue), NewStyle(ColorMagenta), NewStyle(ColorLightCyan), NewStyle(ColorWhite), }
var StyleClear = Style{ Fg: ColorClear, Bg: ColorClear, Modifier: ModifierClear, }
var StyleParserColorMap = map[string]Color{ "red": ColorRed, "blue": ColorBlue, "black": ColorBlack, "cyan": ColorLightCyan, "yellow": ColorYellow, "white": ColorWhite, "clear": ColorClear, "green": ColorGreen, "magenta": ColorMagenta, "grey": ColorGrey, "darkgrey": ColorDarkGrey, "lightgrey": ColorLightGrey, "silver": ColorSilver, "orange": ColorOrange, "purple": ColorPurple, "pink": ColorPink, "coral": ColorCoral, "crimson": ColorCrimson, "gold": ColorGold, "teal": ColorTeal, "turquoise": ColorTurquoise, "indigo": ColorIndigo, "violet": ColorViolet, "olive": ColorOlive, "navy": ColorNavy, "aliceblue": ColorAliceBlue, "beige": ColorBeige, "brown": ColorBrown, "darkblue": ColorDarkBlue, "darkcyan": ColorDarkCyan, "darkgreen": ColorDarkGreen, "darkred": ColorDarkRed, "hotpink": ColorHotPink, "lightblue": ColorLightBlue, "lightgreen": ColorLightGreen, "lime": ColorLime, "maroon": ColorMaroon, "mintcream": ColorMintCream, "mistyrose": ColorMistyRose, "orchid": ColorOrchid, "plum": ColorPlum, "salmon": ColorSalmon, "seagreen": ColorSeaGreen, "skyblue": ColorSkyBlue, "slateblue": ColorSlateBlue, "tan": ColorTan, "tomato": ColorTomato, "wheat": ColorWheat, }
var Theme = RootTheme{ Default: NewStyle(ColorWhite), Block: BlockTheme{ Title: NewStyle(ColorWhite), Border: NewStyle(ColorWhite), }, BarChart: BarChartTheme{ Bars: StandardColors, Nums: StandardStyles, Labels: StandardStyles, }, Paragraph: ParagraphTheme{ Text: NewStyle(ColorWhite), }, PieChart: PieChartTheme{ Slices: StandardColors, }, List: ListTheme{ Text: NewStyle(ColorWhite), }, Tree: TreeTheme{ Text: NewStyle(ColorWhite), Collapsed: COLLAPSED, Expanded: EXPANDED, }, StackedBarChart: StackedBarChartTheme{ Bars: StandardColors, Nums: StandardStyles, Labels: StandardStyles, }, Gauge: GaugeTheme{ Bar: ColorWhite, Label: NewStyle(ColorWhite), }, Sparkline: SparklineTheme{ Title: NewStyle(ColorWhite), Line: ColorWhite, }, Plot: PlotTheme{ Lines: StandardColors, Axes: ColorWhite, }, Table: TableTheme{ Text: NewStyle(ColorWhite), }, Tab: TabTheme{ Active: NewStyle(ColorRed), Inactive: NewStyle(ColorWhite), }, }
Functions ¶
func CellsToString ¶
CellsToString converts a slice of cells to a string.
func ClearBackground ¶
func ClearBackground(c Color)
func GetMaxFloat64From2dSlice ¶
GetMaxFloat64From2dSlice returns the maximum value from a 2D slice of float64s.
func GetMaxFloat64FromSlice ¶
GetMaxFloat64FromSlice returns the maximum value from a slice of float64s.
func GetMaxIntFromSlice ¶
GetMaxIntFromSlice returns the maximum value from a slice of ints.
func InitWithConfig ¶
func InitWithConfig(cfg *InitConfig) error
func InterfaceSlice ¶
InterfaceSlice converts a slice of any type to a slice of interface{}.
func MaxFloat64 ¶
MaxFloat64 returns the maximum of two float64s.
func MinFloat64 ¶
MinFloat64 returns the minimum of two float64s.
func PollEventsWithContext ¶
PollEventsWithContext polls for events with a context.
func RenderBufferToImage ¶
func ResolveBorderRune ¶
func RoundFloat64 ¶
RoundFloat64 rounds a float64 to the nearest integer.
func SplitCells ¶
SplitCells splits a slice of cells by a rune.
func SumFloat64Slice ¶
SumFloat64Slice sums a slice of float64s.
func TerminalDimensions ¶
func TrimString ¶
TrimString trims a string to a given width.
Types ¶
type Application ¶
Application represents the application.
func (*Application) SetFocus ¶
func (a *Application) SetFocus(p Widget)
SetFocus sets the focus to the given widget.
func (*Application) SetRoot ¶
func (a *Application) SetRoot(root Widget, focus bool)
SetRoot sets the root widget of the application. If focus is true, the root widget is also focused.
type Backend ¶
Backend represents the backend.
func NewBackend ¶
func NewBackend(cfg *InitConfig) (*Backend, error)
func (*Backend) ClearBackground ¶
func (*Backend) InitWithConfig ¶
func (b *Backend) InitWithConfig(cfg *InitConfig) error
func (*Backend) PollEvents ¶
PollEvents polls for events.
func (*Backend) PollEventsWithContext ¶
PollEventsWithContext polls for events with a context.
func (*Backend) TerminalDimensions ¶
type BarChartTheme ¶
type Block ¶
type Block struct {
Border bool
BorderStyle Style
BackgroundColor Color
FillBorder bool
BorderLeft, BorderRight, BorderTop, BorderBottom bool
BorderCollapse bool
BorderRounded bool
BorderType BorderType
PaddingLeft, PaddingRight, PaddingTop, PaddingBottom int
image.Rectangle
Inner image.Rectangle
Title string
TitleLeft string
TitleRight string
TitleStyle Style
TitleAlignment Alignment
TitleBottom string
TitleBottomLeft string
TitleBottomRight string
TitleBottomStyle Style
TitleBottomAlignment Alignment
BorderGradient Gradient
BorderSet *BorderSet
sync.Mutex
}
Block is the base struct for all widgets.
func (*Block) HandleEvent ¶
HandleEvent handles events. This is a default implementation for Block that returns false, meaning the event was not handled. Embedders should override this method to handle specific events.
type BlockTheme ¶
type BorderSet ¶
type BorderSet struct {
Top rune
Bottom rune
Left rune
Right rune
TopLeft rune
TopRight rune
BottomLeft rune
BottomRight rune
TopT rune
BottomT rune
LeftT rune
RightT rune
}
BorderSet defines various borders used when primitives are drawn.
func BorderSetDouble ¶
func BorderSetDouble() BorderSet
func BorderSetHidden ¶
func BorderSetHidden() BorderSet
func BorderSetPlain ¶
func BorderSetPlain() BorderSet
func BorderSetRound ¶
func BorderSetRound() BorderSet
func BorderSetThick ¶
func BorderSetThick() BorderSet
type BorderType ¶
type BorderType int
const ( BorderLine BorderType = iota BorderBlock BorderDouble BorderThick )
type Borders ¶
type Borders uint
const ( BordersTop Borders = 1 << iota BordersBottom BordersLeft BordersRight BordersNone Borders = 0 BordersAll Borders = BordersTop | BordersBottom | BordersLeft | BordersRight )
type Buffer ¶
Buffer represents a buffer of cells.
type Canvas ¶
Canvas is a widget that allows drawing points and lines using braille characters.
type Cell ¶
Cell represents a single cell in the terminal.
func ApplyGradientToText ¶
ApplyGradientToText applies a gradient to a string of text.
func ParseStyles ¶
func RunesToStyledCells ¶
RunesToStyledCells converts a slice of runes to a slice of cells with a given style.
type CellWithX ¶
func BuildCellWithXArray ¶
BuildCellWithXArray builds an array of CellWithX from a slice of Cells.
type Color ¶
const ( ColorBlack Color = tcell.ColorBlack ColorRed Color = tcell.ColorRed ColorGreen Color = tcell.ColorGreen ColorYellow Color = tcell.ColorYellow ColorBlue Color = tcell.ColorBlue ColorMagenta Color = tcell.ColorDarkMagenta ColorLightCyan Color = tcell.ColorLightCyan ColorWhite Color = tcell.ColorWhite ColorGrey Color = tcell.ColorGrey ColorDarkGrey Color = tcell.ColorDarkGrey ColorLightGrey Color = tcell.ColorLightGrey ColorSilver Color = tcell.ColorSilver ColorOrange Color = tcell.ColorOrange ColorPurple Color = tcell.ColorPurple ColorPink Color = tcell.ColorPink ColorCoral Color = tcell.ColorCoral ColorCrimson Color = tcell.ColorCrimson ColorGold Color = tcell.ColorGold ColorTeal Color = tcell.ColorTeal ColorTurquoise Color = tcell.ColorTurquoise ColorIndigo Color = tcell.ColorIndigo ColorViolet Color = tcell.ColorViolet ColorOlive Color = tcell.ColorOlive ColorAliceBlue Color = tcell.ColorAliceBlue ColorBeige Color = tcell.ColorBeige ColorBrown Color = tcell.ColorBrown ColorDarkBlue Color = tcell.ColorDarkBlue ColorCyan Color = tcell.ColorTeal ColorDarkCyan Color = tcell.ColorDarkCyan ColorDarkGreen Color = tcell.ColorDarkGreen ColorDarkRed Color = tcell.ColorDarkRed ColorHotPink Color = tcell.ColorHotPink ColorLightBlue Color = tcell.ColorLightBlue ColorLightGreen Color = tcell.ColorLightGreen ColorLime Color = tcell.ColorLime ColorMaroon Color = tcell.ColorMaroon ColorMintCream Color = tcell.ColorMintCream ColorMistyRose Color = tcell.ColorMistyRose ColorOrchid Color = tcell.ColorOrchid ColorPlum Color = tcell.ColorPlum ColorSalmon Color = tcell.ColorSalmon ColorSeaGreen Color = tcell.ColorSeaGreen ColorSkyBlue Color = tcell.ColorSkyblue ColorSlateBlue Color = tcell.ColorSlateBlue ColorTan Color = tcell.ColorTan ColorTomato Color = tcell.ColorTomato ColorWheat Color = tcell.ColorWheat )
const ColorClear Color = tcell.ColorDefault
func GenerateGradient ¶
GenerateGradient generates a gradient from start to end color.
func GenerateMultiGradient ¶
GenerateMultiGradient generates a gradient that transitions through multiple colors.
func HexToColor ¶
HexToColor converts a hex color string to a Color.
func InterpolateColor ¶
func NewColorRGB ¶
func NewRGBColor ¶
func SelectColor ¶
SelectColor selects a color from a slice of colors based on an index.
type Drawable ¶
type Drawable interface {
GetRect() image.Rectangle
SetRect(int, int, int, int)
Draw(*Buffer)
sync.Locker
}
Drawable represents a widget that can be drawn to the buffer.
type EventHandler ¶
EventHandler represents a widget that can handle events.
type GaugeTheme ¶
type GridItem ¶
type GridItem struct {
Type gridItemType
XRatio float64
YRatio float64
WidthRatio float64
HeightRatio float64
Entry any
IsLeaf bool
// contains filtered or unexported fields
}
GridItem represents an item in the grid.
type InitConfig ¶
type InitConfig struct {
CustomTTY TTYHandle
Width, Height int
SimulationMode bool
SimulationSize image.Point
}
InitConfig represents the configuration for initializing the library.
type ParagraphTheme ¶
type ParagraphTheme struct {
Text Style
}
type PieChartTheme ¶
type PieChartTheme struct {
Slices []Color
}
type RootTheme ¶
type RootTheme struct {
Default Style
Block BlockTheme
BarChart BarChartTheme
Gauge GaugeTheme
Plot PlotTheme
List ListTheme
Tree TreeTheme
Paragraph ParagraphTheme
PieChart PieChartTheme
Sparkline SparklineTheme
StackedBarChart StackedBarChartTheme
Tab TabTheme
Table TableTheme
}
type SparklineTheme ¶
type StackedBarChartTheme ¶
type Style ¶
Style represents the style of a cell.
func SelectStyle ¶
SelectStyle selects a style from a slice of styles based on an index.
type TableTheme ¶
type TableTheme struct {
Text Style
}
TableTheme represents the theme for a table.
type VerticalAlignment ¶
type VerticalAlignment int
const ( AlignTop VerticalAlignment = iota AlignMiddle AlignBottom )
type Widget ¶
type Widget interface {
Drawable
EventHandler
}
Widget represents a Drawable that also handles events.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
_examples
|
|
|
alignment
command
|
|
|
application
command
|
|
|
background
command
|
|
|
barchart
command
|
|
|
block
command
|
|
|
block_multi_title
command
|
|
|
borders
command
|
|
|
calendar
command
|
|
|
canvas
command
|
|
|
collapsed_borders
command
|
|
|
colors
command
|
|
|
dashboard
command
|
|
|
demo
command
|
|
|
donutchart
command
|
|
|
events
command
|
|
|
flex
command
|
|
|
funnelchart
command
|
|
|
gauge
command
|
|
|
gradient
command
|
|
|
grid
command
|
|
|
heatmap
command
|
|
|
hello_world
command
|
|
|
image
command
|
|
|
input
command
|
|
|
interaction
command
|
|
|
linechart
command
|
|
|
linegauge
command
|
|
|
list
command
|
|
|
logo
command
|
|
|
modal
command
|
|
|
modern_demo
command
|
|
|
modern_table
command
|
|
|
paragraph
command
|
|
|
piechart
command
|
|
|
plot
command
|
|
|
radarchart
command
|
|
|
scrollbar
command
|
|
|
sparkline
command
|
|
|
spinner
command
|
|
|
ssh-dashboard
command
|
|
|
stacked_barchart
command
|
|
|
stepchart
command
|
|
|
table
command
|
|
|
tabs
command
|
|
|
textarea
command
|
|
|
tree
command
|
|
|
treemap
command
|
|










































