Open raccoonback opened 3 years ago
You can test it with the code below.
package main
import (
"fmt"
"github.com/c-bata/go-prompt"
)
func completer(d prompt.Document) []prompt.Suggest {
s := []prompt.Suggest{
{Text: "šØ", Description: "Store the username and age"},
{Text: "ā”ļø", Description: "Store the article text posted by user"},
{Text: "š„", Description: "Store the text commented to articles"},
{Text: "š", Description: "Store the text commented to articles"},
{Text: "āØ", Description: "Store the text commented to articles"},
{Text: "š", Description: "Store the text commented to articles"},
{Text: "š", Description: "Store the text commented to articles"},
{Text: "š", Description: "Store the text commented to articles"},
{Text: "š", Description: "Store the text commented to articles"},
{Text: "ā
", Description: "Store the text commented to articles"},
{Text: "š", Description: "Store the text commented to articles"},
{Text: "š", Description: "Store the text commented to articles"},
{Text: "šØ", Description: "Store the text commented to articles"},
{Text: "š§", Description: "Store the text commented to articles"},
{Text: "š", Description: "Store the text commented to articles"},
{Text: "ā¬", Description: "Store the text commented to articles"},
{Text: "ā¬", Description: "Store the text commented to articles"},
{Text: "š", Description: "Store the text commented to articles"},
{Text: "š·", Description: "Store the text commented to articles"},
{Text: "š", Description: "Store the text commented to articles"},
{Text: "ā»", Description: "Store the text commented to articles"},
{Text: "ā", Description: "Store the text commented to articles"},
{Text: "ā", Description: "Store the text commented to articles"},
{Text: "š§", Description: "Store the text commented to articles"},
{Text: "š", Description: "Store the text commented to articles"},
//
{Text: "āļø", Description: "Store the text commented to articles"},
{Text: "š©", Description: "Store the text commented to articles"},
{Text: "āŖ", Description: "Store the text commented to articles"},
{Text: "š¦", Description: "Store the text commented to articles"},
{Text: "š½", Description: "Store the text commented to articles"},
{Text: "š", Description: "Store the text commented to articles"},
{Text: "š„", Description: "Store the text commented to articles"},
{Text: "āæ", Description: "Store the text commented to articles"},
{Text: "š±", Description: "Store the text commented to articles"},
{Text: "š”", Description: "Store the text commented to articles"},
{Text: "š¬", Description: "Store the text commented to articles"},
{Text: "šļø", Description: "Store the text commented to articles"},
{Text: "š«", Description: "Store the text commented to articles"},
{Text: "š„
", Description: "Store the text commented to articles"},
{Text: "š©", Description: "Store the text commented to articles"},
{Text: "š±", Description: "Store the text commented to articles"},
{Text: "š·", Description: "Store the text commented to articles"},
{Text: "š", Description: "Store the text commented to articles"},
{Text: "ā", Description: "Store the text commented to articles"},
{Text: "šø", Description: "Store the text commented to articles"},
{Text: "š", Description: "Store the text commented to articles"},
{Text: "š„", Description: "Store the text commented to articles"},
{Text: "š¤”", Description: "Store the text commented to articles"},
{Text: "š±", Description: "Store the text commented to articles"},
{Text: "š", Description: "Store the text commented to articles"},
{Text: "šø", Description: "Store the text commented to articles"},
{Text: "š„", Description: "Store the text commented to articles"},
{Text: "š", Description: "Store the text commented to articles"},
{Text: "š", Description: "Store the text commented to articles"},
{Text: "š", Description: "Store the text commented to articles"},
{Text: "š¬", Description: "Store the text commented to articles"},
{Text: "š»", Description: "Store the text commented to articles"},
{Text: "š”", Description: "Store the text commented to articles"},
{Text: "āæ", Description: "Store the text commented to articles"},
{Text: "š", Description: "Store the text commented to articles"},
}
return prompt.FilterHasPrefix(s, d.GetWordBeforeCursor(), true)
}
func main() {
fmt.Println("Please select table.")
t := prompt.Input("abcdefgi > ", completer, prompt.OptionShowCompletionAtStart(),
prompt.OptionCompletionOnDown(),)
fmt.Println("You selected " + t)
}
We tried to use
Emoji
, but we found that each row in the completion area was pushed back as shown in the following issue.Related issue: https://github.com/c-bata/go-prompt/issues/209
Therefore, I applied
carriage return
to specify the initial cursor of all rows at thecolumn interval of the initial cursor
.In addition, we applied
carriage return
before movingthe prefix
tothe current cursor column
, so thatthe prefix
does not look redundant.