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>
This commit is contained in:
parent
698c0957d7
commit
afe35839ed
4 changed files with 46 additions and 10 deletions
|
@ -37,6 +37,8 @@ const (
|
|||
STYLE_MSGLIST_MARKED
|
||||
|
||||
STYLE_DIRLIST_DEFAULT
|
||||
STYLE_DIRLIST_UNREAD
|
||||
STYLE_DIRLIST_RECENT
|
||||
|
||||
STYLE_COMPLETION_DEFAULT
|
||||
STYLE_COMPLETION_GUTTER
|
||||
|
@ -73,6 +75,8 @@ var StyleNames = map[string]StyleObject{
|
|||
"msglist_marked": STYLE_MSGLIST_MARKED,
|
||||
|
||||
"dirlist_default": STYLE_DIRLIST_DEFAULT,
|
||||
"dirlist_unread": STYLE_DIRLIST_UNREAD,
|
||||
"dirlist_recent": STYLE_DIRLIST_RECENT,
|
||||
|
||||
"completion_default": STYLE_COMPLETION_DEFAULT,
|
||||
"completion_gutter": STYLE_COMPLETION_GUTTER,
|
||||
|
|
|
@ -115,6 +115,10 @@ styling.
|
|||
: The messages with the marked flag.
|
||||
| dirlist_default
|
||||
: The default style for directories in the directory list.
|
||||
| dirlist_unread
|
||||
: The style used for directories with unread messages
|
||||
| dirlist_recent
|
||||
: The style used for directories with recent messages
|
||||
| completion_default
|
||||
: The default style for the completion engine.
|
||||
| completion_gutter
|
||||
|
@ -176,8 +180,8 @@ If we specify the global style selected modifer using fnmatch as below:
|
|||
This toggles the reverse switch for selected version of all the style objects.
|
||||
|
||||
## Layered styles
|
||||
Some styles, (currently only the `msglist\*` ones) are applied in layers. If
|
||||
a style differs from the base (in this case `msglist_default`) then that style
|
||||
Some styles, (currently the `msglist\*` and `dirlist\*` ones) are applied in layers. If
|
||||
a style differs from the base (in this case `\{msglist|dirlist\}_default`) then that style
|
||||
applies, unless overridden by a higher layer. The order that `msglist` styles
|
||||
are applied in is, from first to last:
|
||||
|
||||
|
@ -190,7 +194,13 @@ msglist_deleted
|
|||
msglist_marked
|
||||
```
|
||||
|
||||
So, the marked style will override all other msglist styles.
|
||||
So, the marked style will override all other msglist styles. The order for `dirlist` styles is:
|
||||
|
||||
```
|
||||
dirlist_default
|
||||
dirlist_unread
|
||||
dirlist_recent
|
||||
```
|
||||
|
||||
## Colors
|
||||
The color values are set using the values accepted by the tcell library.
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 ""
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue