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>
This commit is contained in:
Koni Marti 2022-04-17 01:03:50 +02:00 committed by Robin Jarry
parent 6edfbfa8ce
commit a34be9eb36
1 changed files with 9 additions and 7 deletions

View File

@ -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
}