Skip to content

Commit c09539a

Browse files
committed
color coded prioriry prefix
1 parent 90a419d commit c09539a

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

tui/view.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,28 @@ func (t tui) renderTuido(item tuido.Item, width int) string {
291291
ret = strings.ReplaceAll(ret, "#"+tag.String(), t.tagColors[tag.Name()].Render("#"+tag.String()))
292292
}
293293

294+
if imp := item.Importance(); imp > 0 {
295+
var exclamStyle lg.Style
296+
switch {
297+
case imp >= 5:
298+
exclamStyle = lg.NewStyle().Bold(true).Foreground(lg.Color("#ffffff")).Background(lg.Color("#ff2222")).Blink(true)
299+
case imp == 4:
300+
exclamStyle = lg.NewStyle().Bold(true).Foreground(lg.Color("#ffffff")).Background(lg.Color("#ff2222"))
301+
case imp == 3:
302+
exclamStyle = lg.NewStyle().Bold(true).Foreground(lg.Color("#ff2222"))
303+
case imp == 2:
304+
exclamStyle = lg.NewStyle().Bold(true).Foreground(lg.Color("#ff4444"))
305+
default:
306+
exclamStyle = lg.NewStyle().Bold(true).Foreground(lg.Color("#ff8866"))
307+
}
308+
text := ret[4:]
309+
prefixLen := 0
310+
for prefixLen < len(text) && (text[prefixLen] == '.' || text[prefixLen] == '!') {
311+
prefixLen++
312+
}
313+
ret = ret[:4] + exclamStyle.Render(text[:prefixLen]) + text[prefixLen:]
314+
}
315+
294316
// +2 here because of the leading 'cursor' space
295317
if len(ret)+2 > width {
296318
rowsRequired := (len(ret) - 4) / (width - 6) // -6 here instead of 4 because of the cursor spaces

0 commit comments

Comments
 (0)