diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2022-10-28 12:20:19 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-11-06 23:17:02 +0100 |
commit | c894ee2d7ae9442a04ca2af2dca5b576a850482a (patch) | |
tree | 31a4d9bd714c90892e67c7eb3faf17773352bc3d | |
parent | 4cf96270f135fb31411d933ab4b686fe4e4900cf (diff) | |
download | aerc-c894ee2d7ae9442a04ca2af2dca5b576a850482a.tar.gz |
status: add warning style and methods
Add a warning style to default statusline. Add methods to status, aerc,
and account to push a warning message.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r-- | config/default_styleset | 2 | ||||
-rw-r--r-- | config/style.go | 2 | ||||
-rw-r--r-- | widgets/account.go | 4 | ||||
-rw-r--r-- | widgets/aerc.go | 4 | ||||
-rw-r--r-- | widgets/status.go | 6 |
5 files changed, 18 insertions, 0 deletions
diff --git a/config/default_styleset b/config/default_styleset index 30baf970..da57e936 100644 --- a/config/default_styleset +++ b/config/default_styleset @@ -21,6 +21,8 @@ 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 diff --git a/config/style.go b/config/style.go index d1fd5573..3a0f7a4f 100644 --- a/config/style.go +++ b/config/style.go @@ -27,6 +27,7 @@ const ( STYLE_STATUSLINE_DEFAULT STYLE_STATUSLINE_ERROR + STYLE_STATUSLINE_WARNING STYLE_STATUSLINE_SUCCESS STYLE_MSGLIST_DEFAULT @@ -65,6 +66,7 @@ var StyleNames = map[string]StyleObject{ "statusline_default": STYLE_STATUSLINE_DEFAULT, "statusline_error": STYLE_STATUSLINE_ERROR, + "statusline_warning": STYLE_STATUSLINE_WARNING, "statusline_success": STYLE_STATUSLINE_SUCCESS, "msglist_default": STYLE_MSGLIST_DEFAULT, diff --git a/widgets/account.go b/widgets/account.go index cdb43cbf..f1360b8f 100644 --- a/widgets/account.go +++ b/widgets/account.go @@ -137,6 +137,10 @@ func (acct *AccountView) PushError(err error) { acct.aerc.PushError(fmt.Sprintf("%s: %v", acct.acct.Name, err)) } +func (acct *AccountView) PushWarning(warning string) { + acct.aerc.PushWarning(fmt.Sprintf("%s: %s", acct.acct.Name, warning)) +} + func (acct *AccountView) AccountConfig() *config.AccountConfig { return acct.acct } diff --git a/widgets/aerc.go b/widgets/aerc.go index 81d07474..aef874b3 100644 --- a/widgets/aerc.go +++ b/widgets/aerc.go @@ -542,6 +542,10 @@ func (aerc *Aerc) PushError(text string) *StatusMessage { return aerc.statusline.PushError(text) } +func (aerc *Aerc) PushWarning(text string) *StatusMessage { + return aerc.statusline.PushWarning(text) +} + func (aerc *Aerc) PushSuccess(text string) *StatusMessage { return aerc.statusline.PushSuccess(text) } diff --git a/widgets/status.go b/widgets/status.go index d8d0328a..a6fd5c8f 100644 --- a/widgets/status.go +++ b/widgets/status.go @@ -97,6 +97,12 @@ func (status *StatusLine) PushError(text string) *StatusMessage { return msg } +func (status *StatusLine) PushWarning(text string) *StatusMessage { + msg := status.Push(text, 10*time.Second) + msg.Color(status.uiConfig().GetStyle(config.STYLE_STATUSLINE_WARNING)) + 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)) |