fix: clear to EOL after prompt

relates to #65
This commit is contained in:
Jan De Dobbeleer 2020-10-27 16:19:30 +01:00 committed by Jan De Dobbeleer
parent 96a2af1405
commit 82c8efe0ed
2 changed files with 9 additions and 0 deletions

View file

@ -146,6 +146,7 @@ func (e *engine) render() {
if e.settings.FinalSpace {
e.renderer.print(" ")
}
e.renderer.clearEOL()
}
func (e *engine) reset() {

View file

@ -20,6 +20,7 @@ type formats struct {
rANSI string
title string
creset string
clearOEL string
}
//Renderer writes colorized strings
@ -49,6 +50,7 @@ func (r *Renderer) init(shell string) {
r.formats.right = "%%{\x1b[%dD%%}"
r.formats.title = "%%{\033]0;%s\007%%}"
r.formats.creset = "%{\x1b[0m%}"
r.formats.clearOEL = "%{\x1b[K%}"
case "bash":
r.formats.single = "\\[\x1b[%sm\\]%s\\[\x1b[0m\\]"
r.formats.full = "\\[\x1b[%sm\x1b[%sm\\]%s\\[\x1b[0m\\]"
@ -58,6 +60,7 @@ func (r *Renderer) init(shell string) {
r.formats.right = "\\[\x1b[%dD\\]"
r.formats.title = "\\[\033]0;%s\007\\]"
r.formats.creset = "\\[\x1b[0m\\]"
r.formats.clearOEL = "\\[\x1b[K\\]"
default:
r.formats.single = "\x1b[%sm%s\x1b[0m"
r.formats.full = "\x1b[%sm\x1b[%sm%s\x1b[0m"
@ -67,6 +70,7 @@ func (r *Renderer) init(shell string) {
r.formats.right = "\x1b[%dD"
r.formats.title = "\033]0;%s\007"
r.formats.creset = "\x1b[0m"
r.formats.clearOEL = "\x1b[K"
}
}
@ -167,3 +171,7 @@ func (r *Renderer) creset() {
func (r *Renderer) print(text string) {
fmt.Print(text)
}
func (r *Renderer) clearEOL() {
fmt.Print(r.formats.clearOEL)
}