1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/modules/todoist/display.go
Sean Smith 264f49fd2c Fix race with HighlightableHelper
GetRect can lead to a race condition
Add a RenderFunc method so that we can call try to
wrap even more of our rendering in the thread safe
`QueueUpdateDraw` method
2019-08-24 22:15:35 -04:00

37 lines
694 B
Go

package todoist
import (
"fmt"
"github.com/rivo/tview"
"github.com/wtfutil/wtf/utils"
)
func (widget *Widget) content() (string, string, bool) {
proj := widget.CurrentProject()
if proj == nil {
return widget.CommonSettings().Title, "", false
}
title := fmt.Sprintf("[green]%s[white]", proj.Project.Name)
str := ""
for idx, item := range proj.tasks {
row := fmt.Sprintf(
`[%s]| | %s[%s]`,
widget.RowColor(idx),
tview.Escape(item.Content),
widget.RowColor(idx),
)
str += utils.HighlightableHelper(widget.View, row, idx, len(item.Content))
}
return title, str, false
}
func (widget *Widget) display() {
widget.ScrollableWidget.RedrawFunc(widget.content)
}