From afe35839eddfaf43be0f791e97a926a15d91fc02 Mon Sep 17 00:00:00 2001 From: Tim Culverhouse Date: Sun, 24 Apr 2022 09:50:08 -0500 Subject: style: add style config options for dirlist_unread and dirlist_recent Adds two style options: dirlist_unread and dirlist_recent. These options apply in layers, in the same way as msglist_* styles do. Signed-off-by: Tim Culverhouse Acked-by: Robin Jarry --- widgets/dirtree.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'widgets/dirtree.go') diff --git a/widgets/dirtree.go b/widgets/dirtree.go index cf4575f..24094e5 100644 --- a/widgets/dirtree.go +++ b/widgets/dirtree.go @@ -90,15 +90,26 @@ func (dt *DirectoryTree) Draw(ctx *ui.Context) { name := dt.displayText(node) rowNr++ - style := dt.UiConfig().GetStyle(config.STYLE_DIRLIST_DEFAULT) + dirStyle := []config.StyleObject{} + path := dt.getDirectory(node) + s := dt.getRUEString(path) + switch strings.Count(s, "/") { + case 1: + dirStyle = append(dirStyle, config.STYLE_DIRLIST_UNREAD) + case 2: + dirStyle = append(dirStyle, config.STYLE_DIRLIST_RECENT) + } + style := dt.UiConfig().GetComposedStyle( + config.STYLE_DIRLIST_DEFAULT, dirStyle) if i == dt.listIdx { - style = dt.UiConfig().GetStyleSelected(config.STYLE_DIRLIST_DEFAULT) + style = dt.UiConfig().GetComposedStyleSelected( + config.STYLE_DIRLIST_DEFAULT, dirStyle) } ctx.Fill(0, row, textWidth, 1, ' ', style) dirString := dt.getDirString(name, textWidth, func() string { - if path := dt.getDirectory(node); path != "" { - return dt.getRUEString(path) + if path != "" { + return s } return "" }) -- cgit v1.2.3