Skip to content

Commit

Permalink
Implemented @ autocomplete feature
Browse files Browse the repository at this point in the history
  • Loading branch information
mrusme committed Apr 3, 2021
1 parent 695e2ff commit 7607c1d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions mast/timeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type Timeline struct {
Account mastodon.Account
Toots []Toot
TootIndexStatusIDMappings map[string]int
KnownUsers []string
}

func NewTimeline(mastodonClient *mastodon.Client) Timeline {
Expand Down Expand Up @@ -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
}
}
Expand Down
4 changes: 3 additions & 1 deletion tui/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 7607c1d

Please sign in to comment.