summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--config/aerc.conf.in5
-rw-r--r--config/config.go2
-rw-r--r--doc/aerc-config.5.scd5
-rw-r--r--widgets/account.go6
-rw-r--r--widgets/dirlist.go40
5 files changed, 40 insertions, 18 deletions
diff --git a/config/aerc.conf.in b/config/aerc.conf.in
index b07317f..7758eba 100644
--- a/config/aerc.conf.in
+++ b/config/aerc.conf.in
@@ -27,6 +27,11 @@ sidebar-width=20
 # Default: (no messages)
 empty-message=(no messages)
 
+# Message to display when no folders exists or are all filtered
+#
+# Default: (no folders)
+empty-dirlist=(no folders)
+
 [viewer]
 #
 # Specifies the pager to use when displaying emails. Note that some filters
diff --git a/config/config.go b/config/config.go
index 8e669f7..9295a1d 100644
--- a/config/config.go
+++ b/config/config.go
@@ -26,6 +26,7 @@ type UIConfig struct {
 	SidebarWidth      int      `ini:"sidebar-width"`
 	PreviewHeight     int      `ini:"preview-height"`
 	EmptyMessage      string   `ini:"empty-message"`
+	EmptyDirlist      string   `ini:"empty-dirlist"`
 }
 
 const (
@@ -259,6 +260,7 @@ func LoadConfig(root *string, sharedir string) (*AercConfig, error) {
 			SidebarWidth:      20,
 			PreviewHeight:     12,
 			EmptyMessage:      "(no messages)",
+			EmptyDirlist:      "(no folders)",
 		},
 	}
 	// These bindings are not configurable
diff --git a/doc/aerc-config.5.scd b/doc/aerc-config.5.scd
index caf971d..31e8806 100644
--- a/doc/aerc-config.5.scd
+++ b/doc/aerc-config.5.scd
@@ -49,6 +49,11 @@ These options are configured in the *[ui]* section of aerc.conf.
 
 	Default: (no messages)
 
+*empty-dirlist*
+	Message to display when no folders exists or are all filtered.
+
+	Default: (no folders)
+
 ## VIEWER
 
 These options are configured in the *[viewer]* section of aerc.conf.
diff --git a/widgets/account.go b/widgets/account.go
index 397cccd..824f958 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -47,7 +47,7 @@ func NewAccountView(conf *config.AercConfig, acct *config.AccountConfig,
 		}
 	}
 
-	dirlist := NewDirectoryList(acct, logger, worker)
+	dirlist := NewDirectoryList(acct, &conf.Ui, logger, worker)
 	if conf.Ui.SidebarWidth > 0 {
 		grid.AddChild(ui.NewBordered(dirlist, ui.BORDER_RIGHT))
 	}
@@ -144,7 +144,9 @@ func (acct *AccountView) connected(msg types.WorkerMessage) {
 			if dir == "" && len(dirs) > 0 {
 				dir = dirs[0]
 			}
-			acct.dirlist.Select(dir)
+			if dir != "" {
+				acct.dirlist.Select(dir)
+			}
 			acct.logger.Println("Connected.")
 			acct.host.SetStatus("Connected.")
 		})
diff --git a/widgets/dirlist.go b/widgets/dirlist.go
index d7c4874..2b4773a 100644
--- a/widgets/dirlist.go
+++ b/widgets/dirlist.go
@@ -13,7 +13,8 @@ import (
 
 type DirectoryList struct {
 	ui.Invalidatable
-	conf      *config.AccountConfig
+	acctConf  *config.AccountConfig
+	uiConf    *config.UIConfig
 	dirs      []string
 	logger    *log.Logger
 	selecting string
@@ -22,14 +23,15 @@ type DirectoryList struct {
 	worker    *types.Worker
 }
 
-func NewDirectoryList(conf *config.AccountConfig,
+func NewDirectoryList(acctConf *config.AccountConfig, uiConf *config.UIConfig,
 	logger *log.Logger, worker *types.Worker) *DirectoryList {
 
 	dirlist := &DirectoryList{
-		conf:    conf,
-		logger:  logger,
-		spinner: NewSpinner(),
-		worker:  worker,
+		acctConf: acctConf,
+		uiConf:   uiConf,
+		logger:   logger,
+		spinner:  NewSpinner(),
+		worker:   worker,
 	}
 	dirlist.spinner.OnInvalidate(func(_ ui.Drawable) {
 		dirlist.Invalidate()
@@ -101,15 +103,21 @@ func (dirlist *DirectoryList) Draw(ctx *ui.Context) {
 		return
 	}
 
+	if len(dirlist.dirs) == 0 {
+		style := tcell.StyleDefault
+		ctx.Printf(0, 0, style, dirlist.uiConf.EmptyDirlist)
+		return
+	}
+
 	row := 0
 	for _, name := range dirlist.dirs {
 		if row >= ctx.Height() {
 			break
 		}
-		if len(dirlist.conf.Folders) > 1 && name != dirlist.selected {
-			idx := sort.SearchStrings(dirlist.conf.Folders, name)
-			if idx == len(dirlist.conf.Folders) ||
-				dirlist.conf.Folders[idx] != name {
+		if len(dirlist.acctConf.Folders) > 1 && name != dirlist.selected {
+			idx := sort.SearchStrings(dirlist.acctConf.Folders, name)
+			if idx == len(dirlist.acctConf.Folders) ||
+				dirlist.acctConf.Folders[idx] != name {
 				continue
 			}
 		}
@@ -136,10 +144,10 @@ func (dirlist *DirectoryList) nextPrev(delta int) {
 					j = 0
 				}
 				name := dirlist.dirs[j]
-				if len(dirlist.conf.Folders) > 1 && name != dirlist.selected {
-					idx := sort.SearchStrings(dirlist.conf.Folders, name)
-					if idx == len(dirlist.conf.Folders) ||
-						dirlist.conf.Folders[idx] != name {
+				if len(dirlist.acctConf.Folders) > 1 && name != dirlist.selected {
+					idx := sort.SearchStrings(dirlist.acctConf.Folders, name)
+					if idx == len(dirlist.acctConf.Folders) ||
+						dirlist.acctConf.Folders[idx] != name {
 
 						continue
 					}
@@ -164,12 +172,12 @@ func (dirlist *DirectoryList) Prev() {
 // present in the account.folders config option
 func (dirlist *DirectoryList) filterDirsByFoldersConfig() {
 	// config option defaults to show all if unset
-	if len(dirlist.conf.Folders) == 0 {
+	if len(dirlist.acctConf.Folders) == 0 {
 		return
 	}
 	var filtered []string
 	for _, folder := range dirlist.dirs {
-		for _, cfgfolder := range dirlist.conf.Folders {
+		for _, cfgfolder := range dirlist.acctConf.Folders {
 			if folder == cfgfolder {
 				filtered = append(filtered, folder)
 				break
Agaram <vc@akkartik.com> 2016-09-10 11:47:28 -0700 3318' href='/akkartik/mu/commit/html/mutable.mu.html?h=main&id=f8a4a457cdf2d2ccd69260ce19f2cda0490e73fb'>f8a4a457 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74