aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/crypto/crypto.go5
-rw-r--r--lib/open.go8
-rw-r--r--lib/statusline/renderer.go16
-rw-r--r--lib/statusline/state.go20
-rw-r--r--lib/ui/stack.go4
5 files changed, 27 insertions, 26 deletions
diff --git a/lib/crypto/crypto.go b/lib/crypto/crypto.go
index cb026696..e58e6075 100644
--- a/lib/crypto/crypto.go
+++ b/lib/crypto/crypto.go
@@ -4,6 +4,7 @@ import (
"bytes"
"io"
+ "git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/lib/crypto/gpg"
"git.sr.ht/~rjarry/aerc/lib/crypto/pgp"
"git.sr.ht/~rjarry/aerc/log"
@@ -24,8 +25,8 @@ type Provider interface {
ExportKey(string) (io.Reader, error)
}
-func New(s string) Provider {
- switch s {
+func New() Provider {
+ switch config.General.PgpProvider {
case "auto":
internal := &pgp.Mail{}
if internal.KeyringExists() {
diff --git a/lib/open.go b/lib/open.go
index 2a4bdbcf..8477b8f1 100644
--- a/lib/open.go
+++ b/lib/open.go
@@ -6,20 +6,20 @@ import (
"runtime"
"strings"
+ "git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/log"
)
func XDGOpen(uri string) error {
- return XDGOpenMime(uri, "", nil, nil)
+ return XDGOpenMime(uri, "", nil)
}
func XDGOpenMime(
- uri string, mimeType string,
- openers map[string][]string, args []string,
+ uri string, mimeType string, args []string,
) error {
if len(args) == 0 {
// no explicit command provided, lookup opener from mime type
- opener, ok := openers[mimeType]
+ opener, ok := config.Openers[mimeType]
if ok {
args = opener
} else {
diff --git a/lib/statusline/renderer.go b/lib/statusline/renderer.go
index f128e6a2..993cfcc5 100644
--- a/lib/statusline/renderer.go
+++ b/lib/statusline/renderer.go
@@ -7,6 +7,7 @@ import (
"strings"
"unicode"
+ "git.sr.ht/~rjarry/aerc/config"
"github.com/mattn/go-runewidth"
)
@@ -19,24 +20,25 @@ type renderParams struct {
type renderFunc func(r renderParams) string
-func newRenderer(renderFormat, textMode string) renderFunc {
+func newRenderer() renderFunc {
var texter Texter
- switch strings.ToLower(textMode) {
+ switch strings.ToLower(config.Statusline.DisplayMode) {
case "icon":
texter = &icon{}
default:
texter = &text{}
}
- return renderer(texter, renderFormat)
+ return renderer(texter)
}
-func renderer(texter Texter, renderFormat string) renderFunc {
+func renderer(texter Texter) renderFunc {
var leftFmt, rightFmt string
- if idx := strings.Index(renderFormat, "%>"); idx < 0 {
- leftFmt = renderFormat
+ if idx := strings.Index(config.Statusline.RenderFormat, "%>"); idx < 0 {
+ leftFmt = config.Statusline.RenderFormat
} else {
- leftFmt, rightFmt = renderFormat[:idx], strings.Replace(renderFormat[idx:], "%>", "", 1)
+ leftFmt = config.Statusline.RenderFormat[:idx]
+ rightFmt = strings.Replace(config.Statusline.RenderFormat[idx:], "%>", "", 1)
}
return func(r renderParams) string {
diff --git a/lib/statusline/state.go b/lib/statusline/state.go
index 8384f200..528400b1 100644
--- a/lib/statusline/state.go
+++ b/lib/statusline/state.go
@@ -7,11 +7,10 @@ import (
)
type State struct {
- separator string
- renderer renderFunc
- acct *accountState
- fldr map[string]*folderState
- width int
+ renderer renderFunc
+ acct *accountState
+ fldr map[string]*folderState
+ width int
}
type accountState struct {
@@ -31,19 +30,18 @@ type folderState struct {
Threading bool
}
-func NewState(name string, multipleAccts bool, conf config.StatuslineConfig) *State {
+func NewState(name string, multipleAccts bool) *State {
return &State{
- separator: conf.Separator,
- renderer: newRenderer(conf.RenderFormat, conf.DisplayMode),
- acct: &accountState{Name: name, Multiple: multipleAccts},
- fldr: make(map[string]*folderState),
+ renderer: newRenderer(),
+ acct: &accountState{Name: name, Multiple: multipleAccts},
+ fldr: make(map[string]*folderState),
}
}
func (s *State) StatusLine(folder string) string {
return s.renderer(renderParams{
width: s.width,
- sep: s.separator,
+ sep: config.Statusline.Separator,
acct: s.acct,
fldr: s.folderState(folder),
})
diff --git a/lib/ui/stack.go b/lib/ui/stack.go
index c0aca4e4..a4017007 100644
--- a/lib/ui/stack.go
+++ b/lib/ui/stack.go
@@ -10,10 +10,10 @@ import (
type Stack struct {
children []Drawable
- uiConfig config.UIConfig
+ uiConfig *config.UIConfig
}
-func NewStack(uiConfig config.UIConfig) *Stack {
+func NewStack(uiConfig *config.UIConfig) *Stack {
return &Stack{uiConfig: uiConfig}
}