aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/status.go
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-04-17 01:03:50 +0200
committerRobin Jarry <robin@jarry.cc>2022-04-17 12:18:29 +0200
commita34be9eb36d26afdd723146673694db70662429c (patch)
tree75e536cb4404c4ba95dc76c9ad9ab66edab39d1d /widgets/status.go
parent6edfbfa8ce3760b7d0ee91bb6be768b296a50574 (diff)
downloadaerc-a34be9eb36d26afdd723146673694db70662429c.tar.gz
status: use contextual ui styleset for statusline
Use contextual ui styleset for statusline widget. Signed-off-by: Koni Marti <koni.marti@gmail.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets/status.go')
-rw-r--r--widgets/status.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/widgets/status.go b/widgets/status.go
index 6c501b24..9944e0d1 100644
--- a/widgets/status.go
+++ b/widgets/status.go
@@ -16,7 +16,6 @@ type StatusLine struct {
stack []*StatusMessage
fallback StatusMessage
aerc *Aerc
- uiConfig config.UIConfig
}
type StatusMessage struct {
@@ -30,7 +29,6 @@ func NewStatusLine(uiConfig config.UIConfig) *StatusLine {
style: uiConfig.GetStyle(config.STYLE_STATUSLINE_DEFAULT),
message: "Idle",
},
- uiConfig: uiConfig,
}
}
@@ -56,7 +54,7 @@ func (status *StatusLine) Draw(ctx *ui.Context) {
func (status *StatusLine) Set(text string) *StatusMessage {
status.fallback = StatusMessage{
- style: status.uiConfig.GetStyle(config.STYLE_STATUSLINE_DEFAULT),
+ style: status.uiConfig().GetStyle(config.STYLE_STATUSLINE_DEFAULT),
message: text,
}
status.Invalidate()
@@ -65,7 +63,7 @@ func (status *StatusLine) Set(text string) *StatusMessage {
func (status *StatusLine) SetError(text string) *StatusMessage {
status.fallback = StatusMessage{
- style: status.uiConfig.GetStyle(config.STYLE_STATUSLINE_ERROR),
+ style: status.uiConfig().GetStyle(config.STYLE_STATUSLINE_ERROR),
message: text,
}
status.Invalidate()
@@ -74,7 +72,7 @@ func (status *StatusLine) SetError(text string) *StatusMessage {
func (status *StatusLine) Push(text string, expiry time.Duration) *StatusMessage {
msg := &StatusMessage{
- style: status.uiConfig.GetStyle(config.STYLE_STATUSLINE_DEFAULT),
+ style: status.uiConfig().GetStyle(config.STYLE_STATUSLINE_DEFAULT),
message: text,
}
status.stack = append(status.stack, msg)
@@ -96,13 +94,13 @@ func (status *StatusLine) Push(text string, expiry time.Duration) *StatusMessage
func (status *StatusLine) PushError(text string) *StatusMessage {
msg := status.Push(text, 10*time.Second)
- msg.Color(status.uiConfig.GetStyle(config.STYLE_STATUSLINE_ERROR))
+ msg.Color(status.uiConfig().GetStyle(config.STYLE_STATUSLINE_ERROR))
return msg
}
func (status *StatusLine) PushSuccess(text string) *StatusMessage {
msg := status.Push(text, 10*time.Second)
- msg.Color(status.uiConfig.GetStyle(config.STYLE_STATUSLINE_SUCCESS))
+ msg.Color(status.uiConfig().GetStyle(config.STYLE_STATUSLINE_SUCCESS))
return msg
}
@@ -110,6 +108,10 @@ func (status *StatusLine) Expire() {
status.stack = nil
}
+func (status *StatusLine) uiConfig() config.UIConfig {
+ return status.aerc.SelectedAccountUiConfig()
+}
+
func (status *StatusLine) SetAerc(aerc *Aerc) {
status.aerc = aerc
}