diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-04-24 09:50:08 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-04-27 09:46:06 +0200 |
commit | afe35839eddfaf43be0f791e97a926a15d91fc02 (patch) | |
tree | ba9e5e07e8e86129f3567d982b172de1132ef233 /widgets | |
parent | 698c0957d7f7ad6a4461120853102b38a76d0780 (diff) | |
download | aerc-afe35839eddfaf43be0f791e97a926a15d91fc02.tar.gz |
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 <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/dirlist.go | 17 | ||||
-rw-r--r-- | widgets/dirtree.go | 19 |
2 files changed, 29 insertions, 7 deletions
diff --git a/widgets/dirlist.go b/widgets/dirlist.go index b6c09dda..5ddb1362 100644 --- a/widgets/dirlist.go +++ b/widgets/dirlist.go @@ -7,6 +7,7 @@ import ( "os" "regexp" "sort" + "strings" "time" "github.com/gdamore/tcell/v2" @@ -293,14 +294,24 @@ func (dirlist *DirectoryList) Draw(ctx *ui.Context) { break } - style := dirlist.UiConfig().GetStyle(config.STYLE_DIRLIST_DEFAULT) + dirStyle := []config.StyleObject{} + s := dirlist.getRUEString(name) + switch strings.Count(s, "/") { + case 1: + dirStyle = append(dirStyle, config.STYLE_DIRLIST_UNREAD) + case 2: + dirStyle = append(dirStyle, config.STYLE_DIRLIST_RECENT) + } + style := dirlist.UiConfig().GetComposedStyle( + config.STYLE_DIRLIST_DEFAULT, dirStyle) if name == dirlist.selecting { - style = dirlist.UiConfig().GetStyleSelected(config.STYLE_DIRLIST_DEFAULT) + style = dirlist.UiConfig().GetComposedStyleSelected( + config.STYLE_DIRLIST_DEFAULT, dirStyle) } ctx.Fill(0, row, textWidth, 1, ' ', style) dirString := dirlist.getDirString(name, textWidth, func() string { - return dirlist.getRUEString(name) + return s }) ctx.Printf(0, row, style, dirString) diff --git a/widgets/dirtree.go b/widgets/dirtree.go index cf4575f7..24094e57 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 "" }) |