fix: prompt handling

windows-fixes
TorchedSammy 2022-03-04 21:16:45 -04:00
parent 63e33af34d
commit 237bc19f68
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 3 additions and 4 deletions

7
rl.go
View File

@ -217,13 +217,12 @@ func (lr *lineReader) Read() (string, error) {
func (lr *lineReader) SetPrompt(prompt string) { func (lr *lineReader) SetPrompt(prompt string) {
halfPrompt := strings.Split(prompt, "\n") halfPrompt := strings.Split(prompt, "\n")
if len(halfPrompt) > 1 { if len(halfPrompt) > 1 {
lr.rl.Multiline = true
lr.rl.SetPrompt(strings.Join(halfPrompt[:len(halfPrompt) - 1], "\n")) lr.rl.SetPrompt(strings.Join(halfPrompt[:len(halfPrompt) - 1], "\n"))
lr.rl.MultilinePrompt = halfPrompt[len(halfPrompt) - 1:][0] lr.rl.MultilinePrompt = halfPrompt[len(halfPrompt) - 1:][0]
} else { } else {
// print cursor up ansi code lr.rl.Multiline = false
//fmt.Printf("\033[1A") lr.rl.SetPrompt(prompt)
lr.rl.SetPrompt("")
lr.rl.MultilinePrompt = halfPrompt[len(halfPrompt) - 1:][0]
} }
if !running { if !running {
lr.rl.RefreshPromptInPlace("") lr.rl.RefreshPromptInPlace("")