aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-09-11 17:52:47 +0200
committerRobin Jarry <robin@jarry.cc>2023-09-19 16:49:59 +0200
commit320aa2257f5b5f4ef516eccc3ab2bd49b79d0fdb (patch)
tree75a12e13e29f2c793ff2768408c596897defe914
parentd4e49c79a69c399702c3c781920c8eae5b9e22ba (diff)
downloadaerc-320aa2257f5b5f4ef516eccc3ab2bd49b79d0fdb.tar.gz
config: add default values for empty stylesets
When adding new style objects it is impossible to give them a default color nor attributes without modifying each existing user styleset. Also, if the user has an incomplete styleset, some parts of aerc will have no style at all. These quirks are not nice from a user experience point of view. Before parsing the user styleset, initialize aerc style with basic defaults. Reuse the exact same content than the actual "default" styleset provided in /usr/share/aerc/stylesets. Comment all of the default styleset to make it obvious that these are default values. This has some implications: * To reset these defaults, the user styleset must now start with these two lines: *.default = true *.normal = true If these two lines are not present, the default style will be kept and only changed if the user styleset explicitly sets them. * Empty stylesets no longer produce weird results. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
-rw-r--r--CHANGELOG.md9
-rw-r--r--config/style.go89
-rw-r--r--doc/aerc-stylesets.7.scd39
-rw-r--r--stylesets/blue3
-rw-r--r--stylesets/default49
-rw-r--r--stylesets/dracula3
-rw-r--r--stylesets/nord1
-rw-r--r--stylesets/pink3
-rw-r--r--stylesets/solarized1
9 files changed, 156 insertions, 41 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 20a1697f..05019a08 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -53,6 +53,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
default. Legacy behaviour can be restored by setting `send-with-hostname
= true` in `accounts.conf`.
- The notmuch bindings were replaced with internal bindings
+- Aerc now has a default style for most UI elements. The `default` styleset is
+ now empty. Existing stylesets will only override the default attributes if
+ they are set explicitly. To reset the default style and preserve existing
+ stylesets appearance, these two lines must be inserted **at the beginning**:
+
+ ```
+ *.default=true
+ *.normal=true
+ ```
### Deprecated
diff --git a/config/style.go b/config/style.go
index 50c53de3..f50126bd 100644
--- a/config/style.go
+++ b/config/style.go
@@ -280,23 +280,80 @@ func NewStyleSet() StyleSet {
user: make(map[string]*Style),
}
for _, so := range StyleNames {
- ss.objects[so] = new(StyleConf)
- ss.selected[so] = new(StyleConf)
- }
- return ss
-}
-
-func (ss StyleSet) reset() {
- for _, so := range StyleNames {
- ss.objects[so].base.Reset()
- for _, d := range ss.objects[so].dynamic {
- d.Reset()
- }
- ss.selected[so].base.Reset()
- for _, d := range ss.selected[so].dynamic {
- d.Reset()
+ conf := new(StyleConf)
+
+ switch so {
+ case STYLE_ERROR:
+ // *error.bold=true
+ conf.base.Bold = true
+ // error.fg=red
+ conf.base.Fg = tcell.ColorRed
+ case STYLE_WARNING:
+ // warning.fg=yellow
+ conf.base.Fg = tcell.ColorYellow
+ case STYLE_SUCCESS:
+ // success.fg=green
+ conf.base.Fg = tcell.ColorGreen
+ case STYLE_TITLE:
+ // title.reverse=true
+ conf.base.Reverse = true
+ case STYLE_HEADER:
+ // header.bold=true
+ conf.base.Bold = true
+ case STYLE_STATUSLINE_DEFAULT:
+ // statusline_default.reverse=true
+ conf.base.Reverse = true
+ case STYLE_STATUSLINE_ERROR:
+ // *error.bold=true
+ conf.base.Fg = tcell.ColorRed
+ // statusline_error.fg=red
+ conf.base.Bold = true
+ // statusline_error.reverse=true
+ conf.base.Reverse = true
+ case STYLE_STATUSLINE_WARNING:
+ // statusline_warning.fg=yellow
+ conf.base.Fg = tcell.ColorYellow
+ // statusline_warning.reverse=true
+ conf.base.Reverse = true
+ case STYLE_STATUSLINE_SUCCESS:
+ conf.base.Fg = tcell.ColorGreen
+ conf.base.Reverse = true
+ case STYLE_MSGLIST_UNREAD:
+ // msglist_unread.bold=true
+ conf.base.Bold = true
+ case STYLE_MSGLIST_DELETED:
+ // msglist_deleted.fg=gray
+ conf.base.Fg = tcell.ColorGray
+ case STYLE_MSGLIST_RESULT:
+ // msglist_result.fg=green
+ conf.base.Fg = tcell.ColorGreen
+ case STYLE_MSGLIST_PILL:
+ // msglist_pill.reverse=true
+ conf.base.Reverse = true
+ case STYLE_COMPLETION_PILL:
+ // completion_pill.reverse=true
+ conf.base.Reverse = true
+ case STYLE_TAB:
+ // tab.reverse=true
+ conf.base.Reverse = true
+ case STYLE_BORDER:
+ // border.reverse = true
+ conf.base.Reverse = true
+ case STYLE_SELECTOR_FOCUSED:
+ // selector_focused.reverse=true
+ conf.base.Reverse = true
+ case STYLE_SELECTOR_CHOOSER:
+ // selector_chooser.bold=true
+ conf.base.Bold = true
}
+
+ ss.objects[so] = conf
+ selected := *conf
+ // *.selected.reverse=toggle
+ selected.base.Reverse = !conf.base.Reverse
+ ss.selected[so] = &selected
}
+ return ss
}
func (c *StyleConf) getStyle(h *mail.Header) *Style {
@@ -367,8 +424,6 @@ func findStyleSet(stylesetName string, stylesetsDir []string) (string, error) {
}
func (ss *StyleSet) ParseStyleSet(file *ini.File) error {
- ss.reset()
-
defaultSection, err := file.GetSection(ini.DefaultSection)
if err != nil {
return err
diff --git a/doc/aerc-stylesets.7.scd b/doc/aerc-stylesets.7.scd
index 9d54e0be..3050eab7 100644
--- a/doc/aerc-stylesets.7.scd
+++ b/doc/aerc-stylesets.7.scd
@@ -334,6 +334,45 @@ _<Dec number>_
Color based on the terminal palette index. Valid numbers are
between _0_ and _255_.
+# DEFAULTS
+
+Before parsing a styleset, it is first initialized with the following defaults:
+
+```
+*.selected.reverse=toggle
+title.reverse=true
+header.bold=true
+*error.bold=true
+error.fg=red
+warning.fg=yellow
+success.fg=green
+statusline*.default=true
+statusline_default.reverse=true
+statusline_error.fg=red
+statusline_error.reverse=true
+statusline_warning.fg=yellow
+statusline_warning.reverse=true
+msglist_unread.bold=true
+msglist_deleted.fg=gray
+msglist_result.fg=green
+msglist_pill.reverse=true
+completion_pill.reverse=true
+tab.reverse=true
+border.reverse = true
+selector_focused.reverse=true
+selector_chooser.bold=true
+```
+
+You can choose either to reset everything by starting your styleset with these
+two lines:
+
+```
+*.default=true
+*.normal=true
+```
+
+Or selectively override style object attributes.
+
# SEE ALSO
*aerc*(1) *aerc-config*(5)
diff --git a/stylesets/blue b/stylesets/blue
index c598ef92..46e04b46 100644
--- a/stylesets/blue
+++ b/stylesets/blue
@@ -1,5 +1,8 @@
# vim: ft=dosini
+*.default=true
+*.normal=true
+
border.bg=#005f87
title.bg=#005f87
diff --git a/stylesets/default b/stylesets/default
index f3ea2733..c0d6f909 100644
--- a/stylesets/default
+++ b/stylesets/default
@@ -6,36 +6,39 @@
# the aerc-stylesets(7) manpage. Please read the manual before
# modifying or creating a styleset.
-*.default=true
-*.selected.reverse=toggle
+# Uncomment these two lines to reset all attributes and start from scratch.
+#*.default=true
+#*.normal=true
-title.reverse=true
-header.bold=true
+#*.selected.reverse=toggle
+#
+#title.reverse=true
+#header.bold=true
-*error.bold=true
-error.fg=red
-warning.fg=yellow
-success.fg=green
+#*error.bold=true
+#error.fg=red
+#warning.fg=yellow
+#success.fg=green
-statusline*.default=true
-statusline_default.reverse=true
-statusline_error.fg=red
-statusline_error.reverse=true
-statusline_warning.fg=yellow
-statusline_warning.reverse=true
+#statusline*.default=true
+#statusline_default.reverse=true
+#statusline_error.fg=red
+#statusline_error.reverse=true
+#statusline_warning.fg=yellow
+#statusline_warning.reverse=true
-msglist_unread.bold=true
-msglist_deleted.fg=gray
-msglist_result.fg=green
-msglist_pill.reverse=true
+#msglist_unread.bold=true
+#msglist_deleted.fg=gray
+#msglist_result.fg=green
+#msglist_pill.reverse=true
-completion_pill.reverse=true
+#completion_pill.reverse=true
-tab.reverse=true
-border.reverse = true
+#tab.reverse=true
+#border.reverse = true
-selector_focused.reverse=true
-selector_chooser.bold=true
+#selector_focused.reverse=true
+#selector_chooser.bold=true
#[viewer]
#url.underline=true
diff --git a/stylesets/dracula b/stylesets/dracula
index 9e24f422..8b8788e9 100644
--- a/stylesets/dracula
+++ b/stylesets/dracula
@@ -1,3 +1,6 @@
+*.default=true
+*.normal=true
+
#border.bg=#BD93F9
title.bg=#BD93F9
diff --git a/stylesets/nord b/stylesets/nord
index f099a43f..e9c7e853 100644
--- a/stylesets/nord
+++ b/stylesets/nord
@@ -3,6 +3,7 @@
#
*.default=true
+*.normal=true
title.reverse=true
header.bold=true
diff --git a/stylesets/pink b/stylesets/pink
index 1f73d0f7..9fd8c213 100644
--- a/stylesets/pink
+++ b/stylesets/pink
@@ -1,6 +1,7 @@
# vim: ft=dosini
-#de4e85
+*.default=true
+*.normal=true
border.bg=#de4e85
title.bg=#de4e85
diff --git a/stylesets/solarized b/stylesets/solarized
index 026c3755..dcd8606f 100644
--- a/stylesets/solarized
+++ b/stylesets/solarized
@@ -3,6 +3,7 @@
#
*.default=true
+*.normal=true
*error.bold=true
border.reverse=true
completion_pill.reverse=true