github.com/wtfutil/wtf@v0.43.0/modules/todo_plus/display.go (about)

     1  package todo_plus
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/rivo/tview"
     7  	"github.com/wtfutil/wtf/utils"
     8  )
     9  
    10  func (widget *Widget) content() (string, string, bool) {
    11  	proj := widget.CurrentProject()
    12  
    13  	if proj == nil {
    14  		return widget.CommonSettings().Title, "", false
    15  	}
    16  
    17  	if proj.Err != nil {
    18  		return widget.CommonSettings().Title, proj.Err.Error(), true
    19  	}
    20  
    21  	title := fmt.Sprintf(
    22  		"[%s]%s[white]",
    23  		widget.settings.Colors.TextTheme.Title,
    24  		proj.Name)
    25  
    26  	str := ""
    27  
    28  	for idx, item := range proj.Tasks {
    29  		row := fmt.Sprintf(
    30  			`[%s]| | %s[%s]`,
    31  			widget.RowColor(idx),
    32  			tview.Escape(item.Name),
    33  			widget.RowColor(idx),
    34  		)
    35  
    36  		str += utils.HighlightableHelper(widget.View, row, idx, len(item.Name))
    37  	}
    38  	return title, str, false
    39  }
    40  
    41  func (widget *Widget) display() {
    42  	widget.ScrollableWidget.Redraw(widget.content)
    43  }