diff options
author | Dian M Fay <dian.m.fay@gmail.com> | 2021-11-29 17:48:35 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2021-11-30 15:05:33 +0100 |
commit | f776fb82469d0b9aefffd3f16b27024d53d922c8 (patch) | |
tree | 7f683ad0ae2f5e8c19d5fbef1a2e23a98d7279c5 /config | |
parent | ad5f65b92788d624a036af763a8243c19fc4c1a8 (diff) | |
download | aerc-f776fb82469d0b9aefffd3f16b27024d53d922c8.tar.gz |
style: customize vertical and horizontal border characters
New border-char-horizontal and border-char-vertical config settings in aerc.conf allow users to modify border appearance from the default 1-wide/tall blank space. In stylesets, border.fg now affects the foreground color when custom characters are defined. Signed-off-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'config')
-rw-r--r-- | config/aerc.conf.in | 6 | ||||
-rw-r--r-- | config/config.go | 32 |
2 files changed, 38 insertions, 0 deletions
diff --git a/config/aerc.conf.in b/config/aerc.conf.in index 08d1dbc..1f5c87d 100644 --- a/config/aerc.conf.in +++ b/config/aerc.conf.in @@ -94,6 +94,12 @@ next-message-on-delete=true # default: @SHAREDIR@/stylesets/ stylesets-dirs=@SHAREDIR@/stylesets/ +# Uncomment to use box-drawing characters for vertical and horizontal borders. +# +# Default: spaces +# border-char-vertical=│ +# border-char-horizontal=─ + # Sets the styleset to use for the aerc ui elements. # # Default: default diff --git a/config/config.go b/config/config.go index 9be55c6..cbd5860 100644 --- a/config/config.go +++ b/config/config.go @@ -53,6 +53,9 @@ type UIConfig struct { StyleSetDirs []string `ini:"stylesets-dirs" delim:":"` StyleSetName string `ini:"styleset-name"` style StyleSet + // customize border appearance + BorderCharVertical rune `ini:"-"` + BorderCharHorizontal rune `ini:"-"` } type ContextType int @@ -358,6 +361,9 @@ func (config *AercConfig) LoadConfig(file *ini.File) error { if err := ui.MapTo(&config.Ui); err != nil { return err } + if err := validateBorderChars(ui, &config.Ui); err != nil { + return err + } } for _, sectionName := range file.SectionStrings() { if !strings.Contains(sectionName, "ui:") { @@ -372,6 +378,9 @@ func (config *AercConfig) LoadConfig(file *ini.File) error { if err := uiSection.MapTo(&uiSubConfig); err != nil { return err } + if err := validateBorderChars(uiSection, &uiSubConfig); err != nil { + return err + } contextualUi := UIConfigContext{ UiConfig: uiSubConfig, @@ -461,6 +470,26 @@ func (config *AercConfig) LoadConfig(file *ini.File) error { return nil } +func validateBorderChars(section *ini.Section, config *UIConfig) error { + for key, val := range section.KeysHash() { + switch key { + case "border-char-vertical": + char := []rune(val) + if len(char) != 1 { + return fmt.Errorf("%v must be one and only one character", key) + } + config.BorderCharVertical = char[0] + case "border-char-horizontal": + char := []rune(val) + if len(char) != 1 { + return fmt.Errorf("%v must be one and only one character", key) + } + config.BorderCharHorizontal = char[0] + } + } + return nil +} + func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) { if root == nil { _root := path.Join(xdg.ConfigHome(), "aerc") @@ -524,6 +553,9 @@ func LoadConfigFromFile(root *string, sharedir string) (*AercConfig, error) { CompletionPopovers: true, StyleSetDirs: []string{path.Join(sharedir, "stylesets")}, StyleSetName: "default", + // border defaults + BorderCharVertical: ' ', + BorderCharHorizontal: ' ', }, ContextualUis: []UIConfigContext{}, |