Add IMAP folder tab completion
Credit for this fix goes to Reto; I guess if we're not gonna be mutt we should probabaly do things correctly.
This commit is contained in:
parent
8d9d94f0ee
commit
f9d26eef58
|
@ -3,6 +3,7 @@ package account
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
|
"git.sr.ht/~sircmpwn/aerc/commands"
|
||||||
"git.sr.ht/~sircmpwn/aerc/widgets"
|
"git.sr.ht/~sircmpwn/aerc/widgets"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ func (_ ChangeFolder) Aliases() []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ ChangeFolder) Complete(aerc *widgets.Aerc, args []string) []string {
|
func (_ ChangeFolder) Complete(aerc *widgets.Aerc, args []string) []string {
|
||||||
return nil
|
return commands.GetFolders(aerc, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ ChangeFolder) Execute(aerc *widgets.Aerc, args []string) error {
|
func (_ ChangeFolder) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package commands
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
|
"unicode"
|
||||||
|
|
||||||
"github.com/google/shlex"
|
"github.com/google/shlex"
|
||||||
|
|
||||||
|
@ -108,3 +109,25 @@ func (cmds *Commands) GetCompletions(aerc *widgets.Aerc, cmd string) []string {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const caps string = "ABCDEFGHIJKLMNOPQRSTUVXYZ"
|
||||||
|
|
||||||
|
func GetFolders(aerc *widgets.Aerc, args []string) []string {
|
||||||
|
out := make([]string, 0)
|
||||||
|
lower_only := false
|
||||||
|
for _, rune := range args[0] {
|
||||||
|
lower_only = lower_only || unicode.IsLower(rune)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, dir := range aerc.SelectedAccount().Directories().List() {
|
||||||
|
test := dir
|
||||||
|
if lower_only {
|
||||||
|
test = strings.ToLower(dir)
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.HasPrefix(test, args[0]) {
|
||||||
|
out = append(out, dir)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"git.sr.ht/~sircmpwn/getopt"
|
"git.sr.ht/~sircmpwn/getopt"
|
||||||
"github.com/gdamore/tcell"
|
"github.com/gdamore/tcell"
|
||||||
|
|
||||||
|
"git.sr.ht/~sircmpwn/aerc/commands"
|
||||||
"git.sr.ht/~sircmpwn/aerc/widgets"
|
"git.sr.ht/~sircmpwn/aerc/widgets"
|
||||||
"git.sr.ht/~sircmpwn/aerc/worker/types"
|
"git.sr.ht/~sircmpwn/aerc/worker/types"
|
||||||
)
|
)
|
||||||
|
@ -22,7 +23,7 @@ func (_ Move) Aliases() []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ Move) Complete(aerc *widgets.Aerc, args []string) []string {
|
func (_ Move) Complete(aerc *widgets.Aerc, args []string) []string {
|
||||||
return nil
|
return commands.GetFolders(aerc, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ Move) Execute(aerc *widgets.Aerc, args []string) error {
|
func (_ Move) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
|
|
|
@ -43,10 +43,14 @@ func NewDirectoryList(acctConf *config.AccountConfig, uiConf *config.UIConfig,
|
||||||
return dirlist
|
return dirlist
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dirlist *DirectoryList) List() []string {
|
func (dirlist *DirectoryList) FilteredList() []string {
|
||||||
return dirlist.dirs
|
return dirlist.dirs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dirlist *DirectoryList) List() []string {
|
||||||
|
return dirlist.store.List()
|
||||||
|
}
|
||||||
|
|
||||||
func (dirlist *DirectoryList) UpdateList(done func(dirs []string)) {
|
func (dirlist *DirectoryList) UpdateList(done func(dirs []string)) {
|
||||||
var dirs []string
|
var dirs []string
|
||||||
dirlist.worker.PostAction(
|
dirlist.worker.PostAction(
|
||||||
|
|
Loading…
Reference in New Issue