Filter dirlist according to user config
This commit is contained in:
parent
2349b7de86
commit
755aa9af73
|
@ -53,7 +53,7 @@ func NewAccountView(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dirlist := NewDirectoryList(logger, worker)
|
dirlist := NewDirectoryList(conf, logger, worker)
|
||||||
grid.AddChild(ui.NewBordered(dirlist, ui.BORDER_RIGHT)).Span(2, 1)
|
grid.AddChild(ui.NewBordered(dirlist, ui.BORDER_RIGHT)).Span(2, 1)
|
||||||
|
|
||||||
acct := &AccountView{
|
acct := &AccountView{
|
||||||
|
|
|
@ -6,19 +6,23 @@ import (
|
||||||
|
|
||||||
"github.com/gdamore/tcell"
|
"github.com/gdamore/tcell"
|
||||||
|
|
||||||
|
"git.sr.ht/~sircmpwn/aerc2/config"
|
||||||
"git.sr.ht/~sircmpwn/aerc2/lib/ui"
|
"git.sr.ht/~sircmpwn/aerc2/lib/ui"
|
||||||
"git.sr.ht/~sircmpwn/aerc2/worker/types"
|
"git.sr.ht/~sircmpwn/aerc2/worker/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DirectoryList struct {
|
type DirectoryList struct {
|
||||||
|
conf *config.AccountConfig
|
||||||
dirs []string
|
dirs []string
|
||||||
logger *log.Logger
|
logger *log.Logger
|
||||||
onInvalidate func(d ui.Drawable)
|
onInvalidate func(d ui.Drawable)
|
||||||
worker *types.Worker
|
worker *types.Worker
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDirectoryList(logger *log.Logger, worker *types.Worker) *DirectoryList {
|
func NewDirectoryList(conf *config.AccountConfig,
|
||||||
return &DirectoryList{logger: logger, worker: worker}
|
logger *log.Logger, worker *types.Worker) *DirectoryList {
|
||||||
|
|
||||||
|
return &DirectoryList{conf: conf, logger: logger, worker: worker}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dirlist *DirectoryList) UpdateList() {
|
func (dirlist *DirectoryList) UpdateList() {
|
||||||
|
@ -49,10 +53,19 @@ func (dirlist *DirectoryList) Invalidate() {
|
||||||
|
|
||||||
func (dirlist *DirectoryList) Draw(ctx *ui.Context) {
|
func (dirlist *DirectoryList) Draw(ctx *ui.Context) {
|
||||||
ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
|
ctx.Fill(0, 0, ctx.Width(), ctx.Height(), ' ', tcell.StyleDefault)
|
||||||
for i, name := range dirlist.dirs {
|
row := 0
|
||||||
if i >= ctx.Height() {
|
for _, name := range dirlist.dirs {
|
||||||
|
if row >= ctx.Height() {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
ctx.Printf(0, i, tcell.StyleDefault, "%s", name)
|
if len(dirlist.conf.Folders) > 1 {
|
||||||
|
idx := sort.SearchStrings(dirlist.conf.Folders, name)
|
||||||
|
if idx == len(dirlist.conf.Folders) ||
|
||||||
|
dirlist.conf.Folders[idx] != name {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx.Printf(0, row, tcell.StyleDefault, "%s", name)
|
||||||
|
row++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue