aboutsummaryrefslogtreecommitdiffstats
path: root/commands/ct.go
diff options
context:
space:
mode:
authorJeffas <dev@jeffas.io>2019-07-26 14:29:40 +0100
committerDrew DeVault <sir@cmpwn.com>2019-07-26 14:39:42 -0400
commitcded067bc3919a77b17feedd877e4590e7c95f4a (patch)
treef359c28abd705167e3bf013faf8d4d1af4887f29 /commands/ct.go
parentaabe3d9b3a58efd9f0ad9b39917b85092d0955a1 (diff)
downloadaerc-cded067bc3919a77b17feedd877e4590e7c95f4a.tar.gz
Add tab completion to textinputs
This adds tab completion to textinput components. They can be configured with a completion function. This function is called when the user presses <tab>. The first completion is initially shown to the user inserted into the text. Repeated presses of <tab> or <backtab> cycle through the completions list. The completions list is invalidated when any other non-tab-like key is pressed. Also changed is some logic for current completion generation so that all available commands are returned when <tab> is pressed with no current text and similarly for arguments of commands.
Diffstat (limited to 'commands/ct.go')
-rw-r--r--commands/ct.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/commands/ct.go b/commands/ct.go
index ab2993d4..19fb63aa 100644
--- a/commands/ct.go
+++ b/commands/ct.go
@@ -19,6 +19,9 @@ func (_ ChangeTab) Aliases() []string {
}
func (_ ChangeTab) Complete(aerc *widgets.Aerc, args []string) []string {
+ if len(args) == 0 {
+ return aerc.TabNames()
+ }
out := make([]string, 0)
for _, tab := range aerc.TabNames() {
if strings.HasPrefix(tab, args[0]) {