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>
This commit is contained in:
parent
df8c129235
commit
8935c45293
|
@ -2,8 +2,8 @@ package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"git.sr.ht/~rjarry/aerc/widgets"
|
"git.sr.ht/~rjarry/aerc/widgets"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Clear struct{}
|
type Clear struct{}
|
||||||
|
@ -30,6 +30,6 @@ func (Clear) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
return errors.New("Cannot perform action. Messages still loading")
|
return errors.New("Cannot perform action. Messages still loading")
|
||||||
}
|
}
|
||||||
store.ApplyClear()
|
store.ApplyClear()
|
||||||
aerc.PushStatus("Clear complete.", 10*time.Second)
|
aerc.ClearExtraStatus()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package account
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.sr.ht/~rjarry/aerc/widgets"
|
"git.sr.ht/~rjarry/aerc/widgets"
|
||||||
)
|
)
|
||||||
|
@ -34,16 +33,16 @@ func (SearchFilter) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
|
|
||||||
var cb func([]uint32)
|
var cb func([]uint32)
|
||||||
if args[0] == "filter" {
|
if args[0] == "filter" {
|
||||||
aerc.PushStatus("Filtering...", 10*time.Second)
|
aerc.SetExtraStatus("Filtering...")
|
||||||
cb = func(uids []uint32) {
|
cb = func(uids []uint32) {
|
||||||
aerc.PushStatus(fmt.Sprintf("Filter complete %s", args), 20*time.Second)
|
aerc.SetExtraStatus(fmt.Sprintf("%s", args))
|
||||||
acct.Logger().Printf("Filter results: %v", uids)
|
acct.Logger().Printf("Filter results: %v", uids)
|
||||||
store.ApplyFilter(uids)
|
store.ApplyFilter(uids)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
aerc.PushStatus("Searching...", 10*time.Second)
|
aerc.SetExtraStatus("Searching...")
|
||||||
cb = func(uids []uint32) {
|
cb = func(uids []uint32) {
|
||||||
aerc.PushStatus(fmt.Sprintf("Search complete %s", args), 20*time.Second)
|
aerc.SetExtraStatus(fmt.Sprintf("%s", args))
|
||||||
acct.Logger().Printf("Search results: %v", uids)
|
acct.Logger().Printf("Search results: %v", uids)
|
||||||
store.ApplySearch(uids)
|
store.ApplySearch(uids)
|
||||||
// TODO: Remove when stores have multiple OnUpdate handlers
|
// TODO: Remove when stores have multiple OnUpdate handlers
|
||||||
|
|
|
@ -392,6 +392,14 @@ func (aerc *Aerc) SetStatus(status string) *StatusMessage {
|
||||||
return aerc.statusline.Set(status)
|
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 {
|
func (aerc *Aerc) SetError(status string) *StatusMessage {
|
||||||
return aerc.statusline.SetError(status)
|
return aerc.statusline.SetError(status)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ type StatusLine struct {
|
||||||
ui.Invalidatable
|
ui.Invalidatable
|
||||||
stack []*StatusMessage
|
stack []*StatusMessage
|
||||||
fallback StatusMessage
|
fallback StatusMessage
|
||||||
|
extra string
|
||||||
aerc *Aerc
|
aerc *Aerc
|
||||||
uiConfig config.UIConfig
|
uiConfig config.UIConfig
|
||||||
}
|
}
|
||||||
|
@ -29,6 +30,7 @@ func NewStatusLine(uiConfig config.UIConfig) *StatusLine {
|
||||||
style: uiConfig.GetStyle(config.STYLE_STATUSLINE_DEFAULT),
|
style: uiConfig.GetStyle(config.STYLE_STATUSLINE_DEFAULT),
|
||||||
message: "Idle",
|
message: "Idle",
|
||||||
},
|
},
|
||||||
|
extra: "",
|
||||||
uiConfig: uiConfig,
|
uiConfig: uiConfig,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +51,11 @@ func (status *StatusLine) Draw(ctx *ui.Context) {
|
||||||
pendingKeys += string(pendingKey.Rune)
|
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)
|
ctx.Printf(0, 0, line.style, "%s%s", message, pendingKeys)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,6 +109,14 @@ func (status *StatusLine) PushSuccess(text string) *StatusMessage {
|
||||||
return msg
|
return msg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (status *StatusLine) SetExtra(text string) {
|
||||||
|
status.extra = text
|
||||||
|
}
|
||||||
|
|
||||||
|
func (status *StatusLine) ClearExtra() {
|
||||||
|
status.extra = ""
|
||||||
|
}
|
||||||
|
|
||||||
func (status *StatusLine) Expire() {
|
func (status *StatusLine) Expire() {
|
||||||
status.stack = nil
|
status.stack = nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue