diff --git a/cli/tuiCmd.go b/cli/tuiCmd.go index 87179e9..8db1ed8 100644 --- a/cli/tuiCmd.go +++ b/cli/tuiCmd.go @@ -5,6 +5,8 @@ import ( "github.com/mrusme/gomphotherium/tui" ) +var flagAutocompletion bool + var tuiCmd = &cobra.Command{ Use: "tui", Short: "Launch TUI", @@ -14,6 +16,7 @@ var tuiCmd = &cobra.Command{ Client: MastodonClient, Options: tui.TUIOptions{ ShowImages: flagShowImages, + AutoCompletion: flagAutocompletion, }, Help: help, } @@ -23,4 +26,11 @@ var tuiCmd = &cobra.Command{ func init() { rootCmd.AddCommand(tuiCmd) + tuiCmd.Flags().BoolVarP( + &flagAutocompletion, + "auto-completion", + "a", + true, + "Auto-completion on command input", + ) } diff --git a/tui/tui.go b/tui/tui.go index e4beaa5..b0b3793 100644 --- a/tui/tui.go +++ b/tui/tui.go @@ -21,6 +21,7 @@ const ( type TUIOptions struct { ShowImages bool + AutoCompletion bool } type TUICore struct { @@ -67,9 +68,6 @@ func TUI(tuiCore TUICore) { tuiCore.CmdLine = tview.NewInputField(). SetLabelColor(tcell.ColorDefault). SetFieldBackgroundColor(tcell.ColorDefault). - 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() @@ -100,6 +98,12 @@ func TUI(tuiCore TUICore) { } }) + if tuiCore.Options.AutoCompletion == true { + tuiCore.CmdLine.SetAutocompleteFunc(func(input string) ([]string) { + return mast.CmdAutocompleter(input, tuiCore.Timeline.KnownUsers) + }) + } + tuiCore.Profile = tview.NewTextView(). SetDynamicColors(true). SetRegions(true).