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

Better color config standardization. It's not just random anymore

This commit is contained in:
Chris Cummer
2018-04-23 09:17:54 -07:00
parent d7bc26684a
commit 3de253bd0d
5 changed files with 36 additions and 9 deletions

View File

@@ -2,8 +2,12 @@ package todo
import (
"fmt"
"strings"
//"github.com/gdamore/tcell"
)
const checkWidth = 4
func (widget *Widget) display() {
widget.View.Clear()
@@ -12,21 +16,36 @@ func (widget *Widget) display() {
foreColor, backColor := "white", "black"
if item.Checked {
foreColor = "gray"
foreColor = Config.UString("wtf.mods.todo.colors.checked", "white")
}
if widget.View.HasFocus() && idx == widget.list.selected {
foreColor, backColor = "black", "olive"
foreColor = Config.UString("wtf.mods.todo.colors.highlight.fore", "black")
backColor = Config.UString("wtf.mods.todo.colors.highlight.back", "white")
}
str = str + fmt.Sprintf(
"[%s:%s]|%s| %s[white]\n",
"[%s:%s]|%s| %s[white]",
foreColor,
backColor,
item.CheckMark(),
item.Text,
)
str = widget.padLine(str, item) + "\n"
}
fmt.Fprintf(widget.View, "%s", str)
}
// Pad with spaces to get full-line highlighting
func (widget *Widget) padLine(str string, item *Item) string {
_, _, w, _ := widget.View.GetInnerRect()
padSize := w - checkWidth - len(item.Text)
if padSize < 0 {
padSize = 0
}
return str + strings.Repeat(" ", padSize)
}