From 080cb3c6f0636c6c64ea2ee9f576511c9d3ddfd5 Mon Sep 17 00:00:00 2001 From: Matteo Kloiber Date: Fri, 20 Mar 2015 10:35:09 +0100 Subject: [PATCH] Added new public (exported) getter for Theme. Fixes #6 Added new public setter for Theme (which uses a bare theme). Made ColorScheme public. --- theme.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/theme.go b/theme.go index a2294e2..af51516 100644 --- a/theme.go +++ b/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":