mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Add a helper function to do highlighting in a uniform way
This commit is contained in:
@@ -7,8 +7,6 @@ import (
|
||||
"github.com/wtfutil/wtf/wtf"
|
||||
)
|
||||
|
||||
const checkWidth = 4
|
||||
|
||||
func (widget *Widget) display() {
|
||||
proj := widget.CurrentProject()
|
||||
|
||||
@@ -17,27 +15,17 @@ func (widget *Widget) display() {
|
||||
}
|
||||
|
||||
title := fmt.Sprintf("[green]%s[white]", proj.Project.Name)
|
||||
|
||||
_, _, width, _ := widget.View.GetRect()
|
||||
str := widget.settings.common.SigilStr(len(widget.projects), widget.Idx, width) + "\n"
|
||||
|
||||
maxLen := proj.LongestLine()
|
||||
str := ""
|
||||
|
||||
for index, item := range proj.tasks {
|
||||
row := fmt.Sprintf(
|
||||
`["%d"][""][%s]| | %s[%s]`,
|
||||
index,
|
||||
`[%s]| | %s[%s]`,
|
||||
widget.RowColor(index),
|
||||
tview.Escape(item.Content),
|
||||
widget.RowColor(index),
|
||||
)
|
||||
|
||||
_, _, w, _ := widget.View.GetInnerRect()
|
||||
if w > maxLen {
|
||||
maxLen = w
|
||||
}
|
||||
|
||||
str = str + row + wtf.PadRow((checkWidth+len(item.Content)), (checkWidth+maxLen+1)) + `[""]` + "\n"
|
||||
str += wtf.HighlightableHelper(widget.View, row, index, len(item.Content))
|
||||
}
|
||||
|
||||
widget.ScrollableWidget.Redraw(title, str, false)
|
||||
|
||||
Reference in New Issue
Block a user