Fixes an issue with seed content
This commit is contained in:
parent
0e5b1ba06b
commit
48bedb4e12
13
qline.go
13
qline.go
|
@ -71,7 +71,6 @@ func GetInput(prompt string, content string) string {
|
||||||
termios.SetCharMode()
|
termios.SetCharMode()
|
||||||
cols, _ := termios.GetWindowSize()
|
cols, _ := termios.GetWindowSize()
|
||||||
b := buffer{make([]rune, 0, (len(content)+1)*2), 0, cols-len(prompt), 0, 0, prompt}
|
b := buffer{make([]rune, 0, (len(content)+1)*2), 0, cols-len(prompt), 0, 0, prompt}
|
||||||
seeded := false
|
|
||||||
|
|
||||||
fmt.Print(prompt)
|
fmt.Print(prompt)
|
||||||
fmt.Print("\033[6n")
|
fmt.Print("\033[6n")
|
||||||
|
@ -85,6 +84,8 @@ func GetInput(prompt string, content string) string {
|
||||||
if err != nil && err.Error() == "response" {
|
if err != nil && err.Error() == "response" {
|
||||||
b.cursorStart = int(ch)
|
b.cursorStart = int(ch)
|
||||||
b.maxWidth = cols - b.cursorStart
|
b.maxWidth = cols - b.cursorStart
|
||||||
|
b.seedContent(content)
|
||||||
|
b.printBuf()
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -97,16 +98,6 @@ func GetInput(prompt string, content string) string {
|
||||||
} else {
|
} else {
|
||||||
b.addChar(ch, true)
|
b.addChar(ch, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Seeding the content needs to happen
|
|
||||||
// _after_ reading in the width from the [6n
|
|
||||||
// function call.
|
|
||||||
if !seeded {
|
|
||||||
b.seedContent(content)
|
|
||||||
b.printBuf()
|
|
||||||
seeded = true
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return b.string()
|
return b.string()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue