Added new public (exported) getter for Theme. Fixes #6
Added new public setter for Theme (which uses a bare theme). Made ColorScheme public.
This commit is contained in:
parent
4a60506c99
commit
080cb3c6f0
19
theme.go
19
theme.go
@ -1,6 +1,7 @@
|
||||
package termui
|
||||
|
||||
type colorScheme struct {
|
||||
// A ColorScheme represents the current look-and-feel of the dashboard.
|
||||
type ColorScheme struct {
|
||||
BodyBg Attribute
|
||||
BlockBg Attribute
|
||||
HasBorder bool
|
||||
@ -24,9 +25,9 @@ type colorScheme struct {
|
||||
}
|
||||
|
||||
// default color scheme depends on the user's terminal setting.
|
||||
var themeDefault = colorScheme{HasBorder: true}
|
||||
var themeDefault = ColorScheme{HasBorder: true}
|
||||
|
||||
var themeHelloWorld = colorScheme{
|
||||
var themeHelloWorld = ColorScheme{
|
||||
BodyBg: ColorBlack,
|
||||
BlockBg: ColorBlack,
|
||||
HasBorder: true,
|
||||
@ -51,6 +52,18 @@ var themeHelloWorld = colorScheme{
|
||||
|
||||
var theme = themeDefault // global dep
|
||||
|
||||
// Theme returns the currently used theme.
|
||||
func Theme() ColorScheme {
|
||||
return theme
|
||||
}
|
||||
|
||||
// SetTheme sets a new, custom theme.
|
||||
func SetTheme(newTheme ColorScheme) {
|
||||
theme = newTheme
|
||||
}
|
||||
|
||||
// UseTheme sets a predefined scheme. Currently available: "hello-world" and
|
||||
// "black-and-white".
|
||||
func UseTheme(th string) {
|
||||
switch th {
|
||||
case "helloworld":
|
||||
|
Loading…
Reference in New Issue
Block a user