1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Close #84. Add wtf.colors.background config option

This commit is contained in:
Chris Cummer 2018-05-31 08:48:10 -07:00
parent 43d937992c
commit 9e49c18c44
9 changed files with 29 additions and 3 deletions

View File

@ -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

View File

@ -1,5 +1,6 @@
wtf:
colors:
background: gray
border:
focusable: darkslateblue
focused: orange

View File

@ -10,6 +10,7 @@ See this <a href="https://github.com/senorprogrammer/wtf/blob/master/_sample_con
```yaml
wtf:
colors:
background: "red"
border:
Focusable: "darkslateblue"
focused: "orange"
@ -28,6 +29,13 @@ wtf:
### Attributes
`colors.background` <br />
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. <br />
Values: Any <a href="https://en.wikipedia.org/wiki/X11_color_names">X11
color name</a>.
`colors.border.focusable` <br />
The color in which to draw the border of widgets that can accept
keyboard focus. <br />

View File

@ -82,7 +82,7 @@ cmd The terminal command to be run, withouth the arguments. Ie: ping, whoami, cu
<guid>https://wtfutil.com/posts/configuration/attributes/</guid>
<description>The following top-level attributes are configurable in config.yml. See this example config file for more details.
wtf:colors:border:Focusable:&amp;#34;darkslateblue&amp;#34;focused:&amp;#34;orange&amp;#34;normal:&amp;#34;gray&amp;#34;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.</description>
wtf:colors:background:&amp;#34;red&amp;#34;border:Focusable:&amp;#34;darkslateblue&amp;#34;focused:&amp;#34;orange&amp;#34;normal:&amp;#34;gray&amp;#34;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.</description>
</item>
<item>

View File

@ -113,6 +113,7 @@
See this <a href="https://github.com/senorprogrammer/wtf/blob/master/_sample_configs/simple_config.yml">example config file</a> for more details.</p>
<div class="highlight"><pre class="chroma"><code class="language-yaml" data-lang="yaml">wtf<span class="p">:</span><span class="w">
</span><span class="w"> </span>colors<span class="p">:</span><span class="w">
</span><span class="w"> </span>background<span class="p">:</span><span class="w"> </span><span class="s2">&#34;red&#34;</span><span class="w">
</span><span class="w"> </span>border<span class="p">:</span><span class="w">
</span><span class="w"> </span>Focusable<span class="p">:</span><span class="w"> </span><span class="s2">&#34;darkslateblue&#34;</span><span class="w">
</span><span class="w"> </span>focused<span class="p">:</span><span class="w"> </span><span class="s2">&#34;orange&#34;</span><span class="w">
@ -129,6 +130,13 @@ See this <a href="https://github.com/senorprogrammer/wtf/blob/master/_sample_con
</span><span class="w"> </span>refreshInterval<span class="p">:</span><span class="w"> </span><span class="m">1</span></code></pre></div>
<h3 id="attributes">Attributes</h3>
<p><code>colors.background</code> <br />
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. <br />
Values: Any <a href="https://en.wikipedia.org/wiki/X11_color_names">X11
color name</a>.</p>
<p><code>colors.border.focusable</code> <br />
The color in which to draw the border of widgets that can accept
keyboard focus. <br />

View File

@ -82,7 +82,7 @@ cmd The terminal command to be run, withouth the arguments. Ie: ping, whoami, cu
<guid>https://wtfutil.com/posts/configuration/attributes/</guid>
<description>The following top-level attributes are configurable in config.yml. See this example config file for more details.
wtf:colors:border:Focusable:&amp;#34;darkslateblue&amp;#34;focused:&amp;#34;orange&amp;#34;normal:&amp;#34;gray&amp;#34;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.</description>
wtf:colors:background:&amp;#34;red&amp;#34;border:Focusable:&amp;#34;darkslateblue&amp;#34;focused:&amp;#34;orange&amp;#34;normal:&amp;#34;gray&amp;#34;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.</description>
</item>
<item>

View File

@ -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")

2
wtf.go
View File

@ -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)

View File

@ -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)