summary refs log tree commit diff stats
path: root/config/config.go
diff options
context:
space:
mode:
authorDaniel Bridges <bridges2@gmail.com>2019-07-15 11:56:44 -0700
committerDrew DeVault <sir@cmpwn.com>2019-07-17 17:26:43 -0400
commitdfc048fe285939d9de3b5753f723c935d042cc2b (patch)
treeea037462fb702d0f503a34bfc8edd310d4dbfaeb /config/config.go
parentd7975132b62942530da6c4907bed3eb3ab99e4a3 (diff)
downloadaerc-dfc048fe285939d9de3b5753f723c935d042cc2b.tar.gz
Display user specified headers in viewer if present
Diffstat (limited to 'config/config.go')
-rw-r--r--config/config.go26
1 files changed, 25 insertions, 1 deletions
diff --git a/config/config.go b/config/config.go
index aab3905..9e081fd 100644
--- a/config/config.go
+++ b/config/config.go
@@ -79,7 +79,8 @@ type FilterConfig struct {
 type ViewerConfig struct {
 	Pager        string
 	Alternatives []string
-	ShowHeaders  bool `ini:"show-headers"`
+	ShowHeaders  bool       `ini:"show-headers"`
+	HeaderLayout [][]string `ini:"-"`
 }
 
 type AercConfig struct {
@@ -261,6 +262,8 @@ func (config *AercConfig) LoadConfig(file *ini.File) error {
 			switch key {
 			case "alternatives":
 				config.Viewer.Alternatives = strings.Split(val, ",")
+			case "header-layout":
+				config.Viewer.HeaderLayout = parseLayout(val)
 			}
 		}
 	}
@@ -323,6 +326,18 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) {
 			EmptyDirlist:      "(no folders)",
 			MouseEnabled:      false,
 		},
+
+		Viewer: ViewerConfig{
+			Pager:        "less -R",
+			Alternatives: []string{"text/plain", "text/html"},
+			ShowHeaders:  false,
+			HeaderLayout: [][]string{
+				{"From", "To"},
+				{"Cc", "Bcc"},
+				{"Date"},
+				{"Subject"},
+			},
+		},
 	}
 	// These bindings are not configurable
 	config.Bindings.AccountWizard.ExKey = KeyStroke{
@@ -431,3 +446,12 @@ func checkConfigPerms(filename string) error {
 	}
 	return nil
 }
+
+func parseLayout(layout string) [][]string {
+	rows := strings.Split(layout, ",")
+	l := make([][]string, len(rows))
+	for i, r := range rows {
+		l[i] = strings.Split(r, "|")
+	}
+	return l
+}