aboutsummaryrefslogtreecommitdiffstats
path: root/app/aerc.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2024-10-12 00:21:44 +0200
committerRobin Jarry <robin@jarry.cc>2024-10-23 10:22:51 +0200
commit3c9ad93801ce9bb71d76fa398d7d94f1afd2c2cb (patch)
treedcc715e090fedf65e2b0f800d4d969b4606f7a5c /app/aerc.go
parent63db443949b92eed5f5d2ded5f430bda96312b43 (diff)
downloadaerc-3c9ad93801ce9bb71d76fa398d7d94f1afd2c2cb.tar.gz
completion: display descriptions next to choices
Use go-opt v2 new completion API which returns items descriptions along with their text values. Display the descriptions after the items separated by two spaces. Wrap the descriptions in parentheses to better indicate that they are not part of the completion choices. Limit the description length to 80 characters to avoid display issues. Add a new style object completion_description in stylesets. By default, the object will be rendered with a dimmed terminal attribute. Update all stylesets and documentation accordingly. Implements: https://todo.sr.ht/~rjarry/aerc/271 Link: https://git.sr.ht/~rjarry/go-opt/commit/ebeb82538395a Changelog-added: Command completion now displays descriptions next to completion items. Changelog-added: New `completion_description` style object in style sets used for rendering completion item descriptions. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Bojan Gabric <bojan@bojangabric.com> Tested-by: Jason Cox <me@jasoncarloscox.com> Acked-by: Tim Culverhouse <tim@timculverhouse.com>
Diffstat (limited to 'app/aerc.go')
-rw-r--r--app/aerc.go18
1 files changed, 8 insertions, 10 deletions
diff --git a/app/aerc.go b/app/aerc.go
index 107fc1f3..72a60562 100644
--- a/app/aerc.go
+++ b/app/aerc.go
@@ -11,7 +11,7 @@ import (
"time"
"unicode"
- "git.sr.ht/~rjarry/go-opt"
+ "git.sr.ht/~rjarry/go-opt/v2"
"git.sr.ht/~rockorager/vaxis"
"github.com/ProtonMail/go-crypto/openpgp"
"github.com/emersion/go-message/mail"
@@ -29,7 +29,7 @@ type Aerc struct {
accounts map[string]*AccountView
cmd func(string, *config.AccountConfig, *models.MessageInfo) error
cmdHistory lib.History
- complete func(cmd string) ([]string, string)
+ complete func(cmd string) ([]opt.Completion, string)
focused ui.Interactive
grid *ui.Grid
simulating int
@@ -54,7 +54,7 @@ type Choice struct {
func (aerc *Aerc) Init(
crypto crypto.Provider,
cmd func(string, *config.AccountConfig, *models.MessageInfo) error,
- complete func(cmd string) ([]string, string), cmdHistory lib.History,
+ complete func(cmd string) ([]opt.Completion, string), cmdHistory lib.History,
deferLoop chan struct{},
) {
tabs := ui.NewTabs(func(d ui.Drawable) *config.UIConfig {
@@ -317,7 +317,7 @@ func (aerc *Aerc) simulate(strokes []config.KeyStroke) {
aerc.simulating -= 1
if exline, ok := aerc.focused.(*ExLine); ok {
// we are still focused on the exline, turn on tab complete
- exline.TabComplete(func(cmd string) ([]string, string) {
+ exline.TabComplete(func(cmd string) ([]opt.Completion, string) {
return aerc.complete(cmd)
})
if complete {
@@ -633,14 +633,12 @@ func (aerc *Aerc) focus(item ui.Interactive) {
func (aerc *Aerc) BeginExCommand(cmd string) {
previous := aerc.focused
- var tabComplete func(string) ([]string, string)
+ var tabComplete func(string) ([]opt.Completion, string)
if aerc.simulating != 0 {
// Don't try to draw completions for simulated events
tabComplete = nil
} else {
- tabComplete = func(cmd string) ([]string, string) {
- return aerc.complete(cmd)
- }
+ tabComplete = aerc.complete
}
exline := NewExLine(cmd, func(cmd string) {
err := aerc.cmd(cmd, nil, nil)
@@ -673,7 +671,7 @@ func (aerc *Aerc) RegisterPrompt(prompt string, cmd string) {
if err != nil {
aerc.PushError(err.Error())
}
- }, func(cmd string) ([]string, string) {
+ }, func(cmd string) ([]opt.Completion, string) {
return nil, "" // TODO: completions
})
aerc.prompts.Push(p)
@@ -700,7 +698,7 @@ func (aerc *Aerc) RegisterChoices(choices []Choice) {
if err != nil {
aerc.PushError(err.Error())
}
- }, func(cmd string) ([]string, string) {
+ }, func(cmd string) ([]opt.Completion, string) {
return nil, "" // TODO: completions
})
aerc.prompts.Push(p)