diff options
author | Ben Burwell <ben@benburwell.com> | 2019-12-20 13:21:33 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2019-12-21 09:23:21 -0500 |
commit | 7160f98a9081bcab05904484eae790ec0a006b87 (patch) | |
tree | e35712afd3dcec12efd47a89d8e4f652fab9cca1 /widgets/exline.go | |
parent | bcd03c4c4a94e73b2545bf5dfc404082a674c76e (diff) | |
download | aerc-7160f98a9081bcab05904484eae790ec0a006b87.tar.gz |
Show textinput completions in popovers
Rather than showing completions inline in the text input, show them in a
popover which can be scrolled by repeatedly pressing the tab key. The
selected completion can be executed by pressing enter.
Diffstat (limited to 'widgets/exline.go')
-rw-r--r-- | widgets/exline.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/widgets/exline.go b/widgets/exline.go index f2c7249f..6def938e 100644 --- a/widgets/exline.go +++ b/widgets/exline.go @@ -3,6 +3,7 @@ package widgets import ( "github.com/gdamore/tcell" + "git.sr.ht/~sircmpwn/aerc/config" "git.sr.ht/~sircmpwn/aerc/lib" "git.sr.ht/~sircmpwn/aerc/lib/ui" ) @@ -16,11 +17,14 @@ type ExLine struct { input *ui.TextInput } -func NewExLine(cmd string, commit func(cmd string), finish func(), +func NewExLine(conf *config.AercConfig, cmd string, commit func(cmd string), finish func(), tabcomplete func(cmd string) []string, cmdHistory lib.History) *ExLine { - input := ui.NewTextInput("").Prompt(":").TabComplete(tabcomplete).Set(cmd) + input := ui.NewTextInput("").Prompt(":").Set(cmd) + if conf.Ui.CompletionPopovers { + input.TabComplete(tabcomplete, conf.Ui.CompletionDelay) + } exline := &ExLine{ commit: commit, finish: finish, @@ -34,10 +38,13 @@ func NewExLine(cmd string, commit func(cmd string), finish func(), return exline } -func NewPrompt(prompt string, commit func(text string), +func NewPrompt(conf *config.AercConfig, prompt string, commit func(text string), tabcomplete func(cmd string) []string) *ExLine { - input := ui.NewTextInput("").Prompt(prompt).TabComplete(tabcomplete) + input := ui.NewTextInput("").Prompt(prompt) + if conf.Ui.CompletionPopovers { + input.TabComplete(tabcomplete, conf.Ui.CompletionDelay) + } exline := &ExLine{ commit: commit, tabcomplete: tabcomplete, |