mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
WTF-400 Move settings-related functions from util.go into common_settings.go
This commit is contained in:
47
wtf/utils.go
47
wtf/utils.go
@@ -7,8 +7,6 @@ import (
|
||||
"regexp"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
const SimpleDateFormat = "Jan 2"
|
||||
@@ -27,20 +25,6 @@ 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 {
|
||||
@@ -134,37 +118,6 @@ func ReadFileBytes(filePath string) ([]byte, error) {
|
||||
return fileData, nil
|
||||
}
|
||||
|
||||
func RightAlignFormat(view *tview.TextView) string {
|
||||
_, _, w, _ := view.GetInnerRect()
|
||||
|
||||
return fmt.Sprintf("%%%ds", w-1)
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
if idx%2 == 0 {
|
||||
return Config.UString(evenKey, "white")
|
||||
}
|
||||
|
||||
return Config.UString(oddKey, "lightblue")
|
||||
}
|
||||
|
||||
func SigilStr(len, pos int, view *tview.TextView) string {
|
||||
sigils := ""
|
||||
|
||||
if len > 1 {
|
||||
sigils = strings.Repeat(Config.UString("wtf.paging.pageSigil", "*"), pos)
|
||||
sigils = sigils + Config.UString("wtf.paging.selectedSigil", "_")
|
||||
sigils = sigils + strings.Repeat(Config.UString("wtf.paging.pageSigil", "*"), len-1-pos)
|
||||
|
||||
sigils = "[lightblue]" + fmt.Sprintf(RightAlignFormat(view), sigils) + "[white]"
|
||||
}
|
||||
|
||||
return sigils
|
||||
}
|
||||
|
||||
/* -------------------- Map Conversion -------------------- */
|
||||
|
||||
func MapToStrs(aMap map[string]interface{}) map[string]string {
|
||||
|
||||
Reference in New Issue
Block a user