peterh / liner

Pure Go line editor with history, inspired by linenoise
MIT License
1.05k stars 132 forks source link

Support colorful prompt #135

Closed jievince closed 4 years ago

jievince commented 4 years ago

liner doesn't support colorful prompt now:

func (s *State) PromptWithSuggestion(prompt string, text string, pos int) (string, error) {
    for _, r := range prompt {
        if unicode.Is(unicode.C, r) {
            return "", ErrInvalidPrompt
        }
    }

Why liner doesn't prompt like \033[31;1m\033[0m ?

jievince commented 4 years ago

@peterh

peterh commented 4 years ago

Liner doesn't support \033 because it's not portable. Specifically, Windows doesn't support VT102 escape sequences. It has a completely different API.

If you want colour, you want something more powerful (and less opinionated) than liner.