1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/todoist/display.go
Chris Cummer beb0c43b07 Add character identifiers to focusable widgets
When no widget has focus, press the letter key to focus on the widget
assigned to that letter.

Example:

    GitHub (d)

    Press "d" to focus on the GitHub widget.
2018-07-30 15:51:19 -07:00

53 lines
1.1 KiB
Go

package todoist
import (
"fmt"
"github.com/rivo/tview"
"github.com/senorprogrammer/wtf/wtf"
)
const checkWidth = 4
func (widget *Widget) display() {
proj := widget.CurrentProject()
if proj == nil {
return
}
//widget.View.SetTitle(fmt.Sprintf(" [green]%s[white] ", proj.Project.Name))
widget.View.SetTitle(widget.ContextualTitle(proj.Project.Name))
str := wtf.SigilStr(len(widget.projects), widget.idx, widget.View) + "\n"
maxLen := proj.LongestLine()
for index, item := range proj.tasks {
foreColor, backColor := "white", wtf.Config.UString("wtf.colors.background", "black")
if index == proj.index {
foreColor = wtf.Config.UString("wtf.colors.highlight.fore", "black")
backColor = wtf.Config.UString("wtf.colors.highlight.back", "orange")
}
row := fmt.Sprintf(
"[%s:%s]| | %s[white]",
foreColor,
backColor,
tview.Escape(item.Content),
)
_, _, w, _ := widget.View.GetInnerRect()
if w > maxLen {
maxLen = w
}
str = str + row + wtf.PadRow((checkWidth+len(item.Content)), (checkWidth+maxLen+1)) + "\n"
}
//widget.View.Clear()
widget.View.SetText(str)
}