mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Unexport colorFor() function
This commit is contained in:
parent
8db4dc3f87
commit
66868a3f49
@ -89,9 +89,9 @@ func (widget *BarGraph) UpdateRefreshedAt() {
|
|||||||
func (widget *BarGraph) addView() {
|
func (widget *BarGraph) addView() {
|
||||||
view := tview.NewTextView()
|
view := tview.NewTextView()
|
||||||
|
|
||||||
view.SetBackgroundColor(ColorFor(Config.UString("wtf.colors.background", "black")))
|
view.SetBackgroundColor(colorFor(Config.UString("wtf.colors.background", "black")))
|
||||||
view.SetBorder(true)
|
view.SetBorder(true)
|
||||||
view.SetBorderColor(ColorFor(widget.BorderColor()))
|
view.SetBorderColor(colorFor(widget.BorderColor()))
|
||||||
view.SetDynamicColors(true)
|
view.SetDynamicColors(true)
|
||||||
view.SetTitle(widget.Name)
|
view.SetTitle(widget.Name)
|
||||||
view.SetWrap(false)
|
view.SetWrap(false)
|
||||||
|
@ -420,7 +420,9 @@ func ASCIItoTviewColors(text string) string {
|
|||||||
text, replaceWithHexColorString), `[::b]`), `[-]`)
|
text, replaceWithHexColorString), `[::b]`), `[-]`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func ColorFor(label string) tcell.Color {
|
/* -------------------- Unexported Functions -------------------- */
|
||||||
|
|
||||||
|
func colorFor(label string) tcell.Color {
|
||||||
if _, ok := colors[label]; ok {
|
if _, ok := colors[label]; ok {
|
||||||
return colors[label]
|
return colors[label]
|
||||||
} else {
|
} else {
|
||||||
@ -428,8 +430,6 @@ func ColorFor(label string) tcell.Color {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------- Unexported Functions -------------------- */
|
|
||||||
|
|
||||||
func replaceWithHexColorString(substring string) string {
|
func replaceWithHexColorString(substring string) string {
|
||||||
colorID, err := strconv.Atoi(substring[7 : len(substring)-1])
|
colorID, err := strconv.Atoi(substring[7 : len(substring)-1])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -14,11 +14,7 @@ func NewDisplay(widgets []Wtfable) *Display {
|
|||||||
}
|
}
|
||||||
|
|
||||||
display.build(widgets)
|
display.build(widgets)
|
||||||
display.Grid.SetBackgroundColor(
|
display.Grid.SetBackgroundColor(colorFor(Config.UString("wtf.colors.background", "black")))
|
||||||
ColorFor(
|
|
||||||
Config.UString("wtf.colors.background", "black"),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
return &display
|
return &display
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ func (tracker *FocusTracker) blur(idx int) {
|
|||||||
view := widget.TextView()
|
view := widget.TextView()
|
||||||
view.Blur()
|
view.Blur()
|
||||||
|
|
||||||
view.SetBorderColor(ColorFor(widget.BorderColor()))
|
view.SetBorderColor(colorFor(widget.BorderColor()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tracker *FocusTracker) decrement() {
|
func (tracker *FocusTracker) decrement() {
|
||||||
@ -90,7 +90,7 @@ func (tracker *FocusTracker) focus(idx int) {
|
|||||||
view := widget.TextView()
|
view := widget.TextView()
|
||||||
|
|
||||||
tracker.App.SetFocus(view)
|
tracker.App.SetFocus(view)
|
||||||
view.SetBorderColor(ColorFor(Config.UString("wtf.colors.border.focused", "gray")))
|
view.SetBorderColor(colorFor(Config.UString("wtf.colors.border.focused", "gray")))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tracker *FocusTracker) focusables() []Wtfable {
|
func (tracker *FocusTracker) focusables() []Wtfable {
|
||||||
|
@ -82,9 +82,9 @@ func (widget *TextWidget) TextView() *tview.TextView {
|
|||||||
func (widget *TextWidget) addView() {
|
func (widget *TextWidget) addView() {
|
||||||
view := tview.NewTextView()
|
view := tview.NewTextView()
|
||||||
|
|
||||||
view.SetBackgroundColor(ColorFor(Config.UString("wtf.colors.background", "black")))
|
view.SetBackgroundColor(colorFor(Config.UString("wtf.colors.background", "black")))
|
||||||
view.SetBorder(true)
|
view.SetBorder(true)
|
||||||
view.SetBorderColor(ColorFor(widget.BorderColor()))
|
view.SetBorderColor(colorFor(widget.BorderColor()))
|
||||||
view.SetDynamicColors(true)
|
view.SetDynamicColors(true)
|
||||||
view.SetTitle(widget.Name)
|
view.SetTitle(widget.Name)
|
||||||
view.SetWrap(false)
|
view.SetWrap(false)
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
package wtftests
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
|
||||||
. "github.com/senorprogrammer/wtf/wtf"
|
|
||||||
. "github.com/stretchr/testify/assert"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestColorFor(t *testing.T) {
|
|
||||||
Equal(t, tcell.ColorRed, ColorFor("red"))
|
|
||||||
Equal(t, tcell.ColorGreen, ColorFor("cat"))
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user