From 7607c1d09f4f62795d4a7f908eb2029b973a35ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9E=E3=83=AA=E3=82=A6=E3=82=B9?= Date: Sat, 3 Apr 2021 16:57:41 -0500 Subject: [PATCH] Implemented @ autocomplete feature --- mast/timeline.go | 2 ++ tui/tui.go | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/mast/timeline.go b/mast/timeline.go index 3d62dab..e8c0291 100644 --- a/mast/timeline.go +++ b/mast/timeline.go @@ -24,6 +24,7 @@ type Timeline struct { Account mastodon.Account Toots []Toot TootIndexStatusIDMappings map[string]int + KnownUsers []string } func NewTimeline(mastodonClient *mastodon.Client) Timeline { @@ -79,6 +80,7 @@ func (timeline *Timeline) Load(timelineType TimelineType) (error) { if exists == false { tootIndex := len(timeline.Toots) timeline.Toots = append(timeline.Toots, NewToot(timeline.client, status, tootIndex)) + timeline.KnownUsers = append(timeline.KnownUsers, status.Account.Acct) // TODO: Deduplicate timeline.TootIndexStatusIDMappings[id] = tootIndex } } diff --git a/tui/tui.go b/tui/tui.go index ce49052..aa442fb 100644 --- a/tui/tui.go +++ b/tui/tui.go @@ -36,7 +36,9 @@ func TUI(tuiCore TUICore, mastodonClient *mastodon.Client) { tuiCore.CmdLine = tview.NewInputField(). SetLabelColor(tcell.ColorDefault). SetFieldBackgroundColor(tcell.ColorDefault). - SetAutocompleteFunc(mast.CmdAutocompleter). + SetAutocompleteFunc(func(input string) ([]string) { + return mast.CmdAutocompleter(input, tuiCore.Timeline.KnownUsers) + }). SetDoneFunc(func(key tcell.Key) { if key == tcell.KeyEnter { cmd := tuiCore.CmdLine.GetText()