1
0
mirror of https://github.com/gizak/termui.git synced 2025-04-24 13:48:50 +08:00
termui/theme.go
Caleb Bassi 08e68490f3 Add TextBox widget
- TextBox is a superset of Paragraph, so Paragraph is deprecated
- adds support for a cursor, which can be moved
- the `Text` field is now private, replaced with `SetText`, `InsertText`, and `ClearText` methods

TODO:

- adding focusable widgets support to termui might clean up the API since we could potentially move the event handling from client side to library side
- add support for scrolling the TextBox view
- fix the cursor position on linewrap
- fix linewrapping
- add line number support
2019-03-15 22:40:01 -07:00

166 lines
2.7 KiB
Go

// Copyright 2017 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
// Use of this source code is governed by a MIT license that can
// be found in the LICENSE file.
package termui
var StandardColors = []Color{
ColorRed,
ColorGreen,
ColorYellow,
ColorBlue,
ColorMagenta,
ColorCyan,
ColorWhite,
}
var StandardStyles = []Style{
NewStyle(ColorRed),
NewStyle(ColorGreen),
NewStyle(ColorYellow),
NewStyle(ColorBlue),
NewStyle(ColorMagenta),
NewStyle(ColorCyan),
NewStyle(ColorWhite),
}
type RootTheme struct {
Default Style
Block BlockTheme
BarChart BarChartTheme
Gauge GaugeTheme
List ListTheme
Paragraph ParagraphTheme
PieChart PieChartTheme
Plot PlotTheme
Sparkline SparklineTheme
StackedBarChart StackedBarChartTheme
Tab TabTheme
Table TableTheme
TextBox TextBoxTheme
}
type BlockTheme struct {
Title Style
Border Style
}
type BarChartTheme struct {
Bars []Color
Nums []Style
Labels []Style
}
type GaugeTheme struct {
Bar Color
Label Style
}
type ListTheme struct {
Text Style
}
type ParagraphTheme struct {
Text Style
}
type PieChartTheme struct {
Slices []Color
}
type PlotTheme struct {
Lines []Color
Axes Color
}
type SparklineTheme struct {
Title Style
Line Color
}
type StackedBarChartTheme struct {
Bars []Color
Nums []Style
Labels []Style
}
type TabTheme struct { // TODO v4: rename to TabPaneTheme
Active Style
Inactive Style
}
type TableTheme struct {
Text Style
}
type TextBoxTheme struct {
Text Style
Cursor Style
}
// Theme holds the default Styles and Colors for all widgets.
// You can set default widget Styles by modifying the Theme before creating the widgets.
var Theme = RootTheme{
Default: NewStyle(ColorWhite),
Block: BlockTheme{
Title: NewStyle(ColorWhite),
Border: NewStyle(ColorWhite),
},
BarChart: BarChartTheme{
Bars: StandardColors,
Nums: StandardStyles,
Labels: StandardStyles,
},
Gauge: GaugeTheme{
Bar: ColorWhite,
Label: NewStyle(ColorWhite),
},
List: ListTheme{
Text: NewStyle(ColorWhite),
},
Paragraph: ParagraphTheme{
Text: NewStyle(ColorWhite),
},
PieChart: PieChartTheme{
Slices: StandardColors,
},
Plot: PlotTheme{
Lines: StandardColors,
Axes: ColorWhite,
},
Sparkline: SparklineTheme{
Title: NewStyle(ColorWhite),
Line: ColorWhite,
},
StackedBarChart: StackedBarChartTheme{
Bars: StandardColors,
Nums: StandardStyles,
Labels: StandardStyles,
},
Tab: TabTheme{
Active: NewStyle(ColorRed),
Inactive: NewStyle(ColorWhite),
},
Table: TableTheme{
Text: NewStyle(ColorWhite),
},
TextBox: TextBoxTheme{
Text: NewStyle(ColorWhite),
Cursor: NewStyle(ColorWhite, ColorClear, ModifierReverse),
},
}