mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Merge branch 'master' into zendesk_module
This commit is contained in:
commit
cc74845d6c
@ -89,9 +89,9 @@ func (widget *BarGraph) UpdateRefreshedAt() {
|
||||
func (widget *BarGraph) addView() {
|
||||
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.SetBorderColor(ColorFor(widget.BorderColor()))
|
||||
view.SetBorderColor(colorFor(widget.BorderColor()))
|
||||
view.SetDynamicColors(true)
|
||||
view.SetTitle(widget.Name)
|
||||
view.SetWrap(false)
|
||||
|
@ -420,7 +420,9 @@ func ASCIItoTviewColors(text string) string {
|
||||
text, replaceWithHexColorString), `[::b]`), `[-]`)
|
||||
}
|
||||
|
||||
func ColorFor(label string) tcell.Color {
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func colorFor(label string) tcell.Color {
|
||||
if _, ok := colors[label]; ok {
|
||||
return colors[label]
|
||||
} else {
|
||||
@ -428,8 +430,6 @@ func ColorFor(label string) tcell.Color {
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------- Unexported Functions -------------------- */
|
||||
|
||||
func replaceWithHexColorString(substring string) string {
|
||||
colorID, err := strconv.Atoi(substring[7 : len(substring)-1])
|
||||
if err != nil {
|
||||
|
@ -14,11 +14,7 @@ func NewDisplay(widgets []Wtfable) *Display {
|
||||
}
|
||||
|
||||
display.build(widgets)
|
||||
display.Grid.SetBackgroundColor(
|
||||
ColorFor(
|
||||
Config.UString("wtf.colors.background", "black"),
|
||||
),
|
||||
)
|
||||
display.Grid.SetBackgroundColor(colorFor(Config.UString("wtf.colors.background", "black")))
|
||||
|
||||
return &display
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ func (tracker *FocusTracker) blur(idx int) {
|
||||
view := widget.TextView()
|
||||
view.Blur()
|
||||
|
||||
view.SetBorderColor(ColorFor(widget.BorderColor()))
|
||||
view.SetBorderColor(colorFor(widget.BorderColor()))
|
||||
}
|
||||
|
||||
func (tracker *FocusTracker) decrement() {
|
||||
@ -90,7 +90,7 @@ func (tracker *FocusTracker) focus(idx int) {
|
||||
view := widget.TextView()
|
||||
|
||||
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 {
|
||||
|
@ -82,9 +82,9 @@ func (widget *TextWidget) TextView() *tview.TextView {
|
||||
func (widget *TextWidget) addView() {
|
||||
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.SetBorderColor(ColorFor(widget.BorderColor()))
|
||||
view.SetBorderColor(colorFor(widget.BorderColor()))
|
||||
view.SetDynamicColors(true)
|
||||
view.SetTitle(widget.Name)
|
||||
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