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

Minor code cleanup

This commit is contained in:
Chris Cummer
2018-09-24 08:52:57 -07:00
parent fb69547fc8
commit 9bd2430063
4 changed files with 44 additions and 16 deletions

View File

@@ -6,6 +6,7 @@ import (
"os/exec"
"regexp"
"strings"
//"sync"
"github.com/rivo/tview"
)
@@ -26,6 +27,20 @@ func CenterText(str string, width int) string {
return fmt.Sprintf("%[1]*s", -width, fmt.Sprintf("%[1]*s", (width+len(str))/2, str))
}
func DefaultFocussedRowColor() string {
foreColor := Config.UString("wtf.colors.highlight.fore", "black")
backColor := Config.UString("wtf.colors.highlight.back", "orange")
return fmt.Sprintf("%s:%s", foreColor, backColor)
}
func DefaultRowColor() string {
foreColor := Config.UString("wtf.colors.foreground", "white")
backColor := Config.UString("wtf.colors.background", "black")
return fmt.Sprintf("%s:%s", foreColor, backColor)
}
func ExecuteCommand(cmd *exec.Cmd) string {
stdout, err := cmd.StdoutPipe()
if err != nil {
@@ -109,24 +124,14 @@ func ReadFileBytes(filePath string) ([]byte, error) {
}
func RightAlignFormat(view *tview.TextView) string {
//mutex := &sync.Mutex{}
//mutex.Lock()
_, _, w, _ := view.GetInnerRect()
//mutex.Unlock()
return fmt.Sprintf("%%%ds", w-1)
}
func DefaultRowColor() string {
foreColor := Config.UString("wtf.colors.foreground", "white")
backColor := Config.UString("wtf.colors.background", "black")
return fmt.Sprintf("%s:%s", foreColor, backColor)
}
func DefaultFocussedRowColor() string {
foreColor := Config.UString("wtf.colors.highlight.fore", "black")
backColor := Config.UString("wtf.colors.highlight.back", "orange")
return fmt.Sprintf("%s:%s", foreColor, backColor)
}
func RowColor(module string, idx int) string {
evenKey := fmt.Sprintf("wtf.mods.%s.colors.rows.even", module)
oddKey := fmt.Sprintf("wtf.mods.%s.colors.rows.odd", module)