diff options
author | Robin Jarry <robin@jarry.cc> | 2022-02-22 20:10:54 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-02-23 11:27:19 +0100 |
commit | 8935c452939cd707d7bd060292da502157625fa4 (patch) | |
tree | 508896a9cc225a0df55bd2a9b0631f6cf5d4eca2 /widgets | |
parent | df8c129235d9f26892caf89f056adc0e16b3d6b6 (diff) | |
download | aerc-8935c452939cd707d7bd060292da502157625fa4.tar.gz |
search/filter: display in extra status
Add an extra attribute to the status line. When non-empty, display it
after the current status.
Set that extra status after a successful :search or :filter. Remove it
after :clear.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/aerc.go | 8 | ||||
-rw-r--r-- | widgets/status.go | 16 |
2 files changed, 23 insertions, 1 deletions
diff --git a/widgets/aerc.go b/widgets/aerc.go index e644f827..10e9924c 100644 --- a/widgets/aerc.go +++ b/widgets/aerc.go @@ -392,6 +392,14 @@ func (aerc *Aerc) SetStatus(status string) *StatusMessage { return aerc.statusline.Set(status) } +func (aerc *Aerc) SetExtraStatus(status string) { + aerc.statusline.SetExtra(status) +} + +func (aerc *Aerc) ClearExtraStatus() { + aerc.statusline.ClearExtra() +} + func (aerc *Aerc) SetError(status string) *StatusMessage { return aerc.statusline.SetError(status) } diff --git a/widgets/status.go b/widgets/status.go index c70d215f..960f2445 100644 --- a/widgets/status.go +++ b/widgets/status.go @@ -14,6 +14,7 @@ type StatusLine struct { ui.Invalidatable stack []*StatusMessage fallback StatusMessage + extra string aerc *Aerc uiConfig config.UIConfig } @@ -29,6 +30,7 @@ func NewStatusLine(uiConfig config.UIConfig) *StatusLine { style: uiConfig.GetStyle(config.STYLE_STATUSLINE_DEFAULT), message: "Idle", }, + extra: "", uiConfig: uiConfig, } } @@ -49,7 +51,11 @@ func (status *StatusLine) Draw(ctx *ui.Context) { pendingKeys += string(pendingKey.Rune) } } - message := runewidth.FillRight(line.message, ctx.Width()-len(pendingKeys)-5) + text := line.message + if status.extra != "" { + text += " " + status.extra + } + message := runewidth.FillRight(text, ctx.Width()-len(pendingKeys)-5) ctx.Printf(0, 0, line.style, "%s%s", message, pendingKeys) } @@ -103,6 +109,14 @@ func (status *StatusLine) PushSuccess(text string) *StatusMessage { return msg } +func (status *StatusLine) SetExtra(text string) { + status.extra = text +} + +func (status *StatusLine) ClearExtra() { + status.extra = "" +} + func (status *StatusLine) Expire() { status.stack = nil } |