fix: reset colors after rendering prompt

resolves #65
This commit is contained in:
Jan De Dobbeleer 2020-10-14 16:25:18 +02:00 committed by Jan De Dobbeleer
parent 4e8051d423
commit e5213551bd
2 changed files with 9 additions and 0 deletions

View file

@ -129,6 +129,7 @@ func (e *engine) render() {
if e.settings.ConsoleTitle {
e.renderer.setConsoleTitle(e.env.getcwd())
}
e.renderer.creset()
if e.settings.FinalSpace {
fmt.Print(" ")
}

View file

@ -20,6 +20,7 @@ type formats struct {
right string
rANSI string
title string
creset string
}
//Shell indicates the shell we're currently in
@ -54,6 +55,7 @@ func (r *Renderer) init(shell string) {
r.formats.left = "%%{\x1b[%dC%%}"
r.formats.right = "%%{\x1b[%dD%%}"
r.formats.title = "%%{\033]0;%s\007%%}"
r.formats.creset = "%{\x1b[0m%}"
r.shell = zsh
case "bash":
r.formats.single = "\\[\x1b[%sm\\]%s\\[\x1b[0m\\]"
@ -64,6 +66,7 @@ func (r *Renderer) init(shell string) {
r.formats.left = "\\[\x1b[%dC\\]"
r.formats.right = "\\[\x1b[%dD\\]"
r.formats.title = "\\[\033]0;%s\007\\]"
r.formats.creset = "\\[\x1b[0m\\]"
r.shell = bash
default:
r.formats.single = "\x1b[%sm%s\x1b[0m"
@ -74,6 +77,7 @@ func (r *Renderer) init(shell string) {
r.formats.left = "\x1b[%dC"
r.formats.right = "\x1b[%dD"
r.formats.title = "\033]0;%s\007"
r.formats.creset = "\x1b[0m"
r.shell = universal
}
}
@ -171,3 +175,7 @@ func (r *Renderer) string() string {
func (r *Renderer) reset() {
r.Buffer.Reset()
}
func (r *Renderer) creset() {
fmt.Print(r.formats.creset)
}