From 1dae2456cc668566e3705e786c1d16afaae1f1a6 Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Thu, 31 May 2018 08:48:10 -0700 Subject: [PATCH] Close #84. Add wtf.colors.background config option --- _sample_configs/complex_config.yml | 6 ++++++ _sample_configs/simple_config.yml | 1 + _site/content/posts/configuration/attributes.md | 8 ++++++++ docs/index.xml | 2 +- docs/posts/configuration/attributes/index.html | 8 ++++++++ docs/posts/index.xml | 2 +- todo/display.go | 2 +- wtf.go | 2 ++ wtf/text_widget.go | 1 + 9 files changed, 29 insertions(+), 3 deletions(-) diff --git a/_sample_configs/complex_config.yml b/_sample_configs/complex_config.yml index 8f443238..c21bdb72 100644 --- a/_sample_configs/complex_config.yml +++ b/_sample_configs/complex_config.yml @@ -1,4 +1,10 @@ wtf: + colors: + background: gray + border: + focusable: darkslateblue + focused: orange + normal: gray grid: # How _wide_ the columns are, in terminal characters. In this case we have # five columns, each of which are 37 characters wide diff --git a/_sample_configs/simple_config.yml b/_sample_configs/simple_config.yml index f0fe3be9..3d08666d 100644 --- a/_sample_configs/simple_config.yml +++ b/_sample_configs/simple_config.yml @@ -1,5 +1,6 @@ wtf: colors: + background: gray border: focusable: darkslateblue focused: orange diff --git a/_site/content/posts/configuration/attributes.md b/_site/content/posts/configuration/attributes.md index 1228a2a3..d709a8fb 100644 --- a/_site/content/posts/configuration/attributes.md +++ b/_site/content/posts/configuration/attributes.md @@ -10,6 +10,7 @@ See this +The color to draw the background of the app in. Use this to match your +terminal colors. May be over-written by individual module +configurations.
+Values: Any
X11 +color name. + `colors.border.focusable`
The color in which to draw the border of widgets that can accept keyboard focus.
diff --git a/docs/index.xml b/docs/index.xml index aa614d56..22a96bce 100644 --- a/docs/index.xml +++ b/docs/index.xml @@ -82,7 +82,7 @@ cmd The terminal command to be run, withouth the arguments. Ie: ping, whoami, cu https://wtfutil.com/posts/configuration/attributes/ The following top-level attributes are configurable in config.yml. See this example config file for more details. -wtf:colors:border:Focusable:"darkslateblue"focused:"orange"normal:"gray"grid:# How _wide_ the columns are, in terminal characters. In this case we have# six columns, each of which are 35 characters widecolumns:[35,35,35,35,35,35]# How _high_ the rows are, in terminal lines. In this case we have five rows# that support ten line of text, one of three lines, and one of fourrows:[10,10,10,10,10,3,4]# The app redraws itself once a secondrefreshInterval:1 Attributes colors. +wtf:colors:background:"red"border:Focusable:"darkslateblue"focused:"orange"normal:"gray"grid:# How _wide_ the columns are, in terminal characters. In this case we have# six columns, each of which are 35 characters widecolumns:[35,35,35,35,35,35]# How _high_ the rows are, in terminal lines. In this case we have five rows# that support ten line of text, one of three lines, and one of fourrows:[10,10,10,10,10,3,4]# The app redraws itself once a secondrefreshInterval:1 Attributes colors. diff --git a/docs/posts/configuration/attributes/index.html b/docs/posts/configuration/attributes/index.html index 33d24908..e06cedcc 100644 --- a/docs/posts/configuration/attributes/index.html +++ b/docs/posts/configuration/attributes/index.html @@ -113,6 +113,7 @@ See this example config file for more details.

wtf:
   colors:
+    background: "red"
     border:
       Focusable: "darkslateblue"
       focused: "orange"
@@ -129,6 +130,13 @@ See this   refreshInterval: 1

Attributes

+

colors.background
+The color to draw the background of the app in. Use this to match your +terminal colors. May be over-written by individual module +configurations.
+Values: Any
X11 +color name.

+

colors.border.focusable
The color in which to draw the border of widgets that can accept keyboard focus.
diff --git a/docs/posts/index.xml b/docs/posts/index.xml index 1be94e36..b867dd86 100644 --- a/docs/posts/index.xml +++ b/docs/posts/index.xml @@ -82,7 +82,7 @@ cmd The terminal command to be run, withouth the arguments. Ie: ping, whoami, cu https://wtfutil.com/posts/configuration/attributes/ The following top-level attributes are configurable in config.yml. See this example config file for more details. -wtf:colors:border:Focusable:"darkslateblue"focused:"orange"normal:"gray"grid:# How _wide_ the columns are, in terminal characters. In this case we have# six columns, each of which are 35 characters widecolumns:[35,35,35,35,35,35]# How _high_ the rows are, in terminal lines. In this case we have five rows# that support ten line of text, one of three lines, and one of fourrows:[10,10,10,10,10,3,4]# The app redraws itself once a secondrefreshInterval:1 Attributes colors. +wtf:colors:background:"red"border:Focusable:"darkslateblue"focused:"orange"normal:"gray"grid:# How _wide_ the columns are, in terminal characters. In this case we have# six columns, each of which are 35 characters widecolumns:[35,35,35,35,35,35]# How _high_ the rows are, in terminal lines. In this case we have five rows# that support ten line of text, one of three lines, and one of fourrows:[10,10,10,10,10,3,4]# The app redraws itself once a secondrefreshInterval:1 Attributes colors. diff --git a/todo/display.go b/todo/display.go index f66f578c..98f3eb72 100644 --- a/todo/display.go +++ b/todo/display.go @@ -33,7 +33,7 @@ func (widget *Widget) display() { } func (widget *Widget) formattedItemLine(item *Item, selectedItem *Item, maxLen int) string { - foreColor, backColor := "white", "black" + foreColor, backColor := "white", Config.UString("wtf.colors.background", "black") if item.Checked { foreColor = Config.UString("wtf.mods.todo.colors.checked", "white") diff --git a/wtf.go b/wtf.go index 63819b53..1cac8af9 100644 --- a/wtf.go +++ b/wtf.go @@ -225,6 +225,8 @@ func main() { pages.AddPage("grid", grid, true, true) app.SetInputCapture(keyboardIntercept) + grid.SetBackgroundColor(wtf.ColorFor(Config.UString("wtf.colors.background", "black"))) + // Loop in a routine to redraw the screen go redrawApp(app) go watchForConfigChanges(app, cmdFlags.Config, grid, pages) diff --git a/wtf/text_widget.go b/wtf/text_widget.go index 6acb1572..17342f0c 100644 --- a/wtf/text_widget.go +++ b/wtf/text_widget.go @@ -78,6 +78,7 @@ func (widget *TextWidget) TextView() *tview.TextView { func (widget *TextWidget) addView() { view := tview.NewTextView() + view.SetBackgroundColor(ColorFor(Config.UString("wtf.colors.background", "black"))) view.SetBorder(true) view.SetBorderColor(ColorFor(widget.BorderColor())) view.SetDynamicColors(true)