mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-31 13:57:26 -08:00
refactor(ansi): do not print when invisible
This commit is contained in:
parent
850787cd6f
commit
c1bf3a16fe
|
@ -89,6 +89,7 @@ type Writer struct {
|
||||||
currentBackground Color
|
currentBackground Color
|
||||||
runes []rune
|
runes []rune
|
||||||
transparent bool
|
transparent bool
|
||||||
|
invisible bool
|
||||||
|
|
||||||
shell string
|
shell string
|
||||||
format string
|
format string
|
||||||
|
@ -365,8 +366,11 @@ func (w *Writer) writeSegmentColors() {
|
||||||
fg = w.currentForeground
|
fg = w.currentForeground
|
||||||
}
|
}
|
||||||
|
|
||||||
// always reset inverted
|
// ignore processing fully tranparent colors
|
||||||
// w.transparent = false
|
w.invisible = fg.IsTransparent() && bg.IsTransparent()
|
||||||
|
if w.invisible {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if fg.IsTransparent() && len(w.TerminalBackground) != 0 {
|
if fg.IsTransparent() && len(w.TerminalBackground) != 0 {
|
||||||
background := w.getAnsiFromColorString(w.TerminalBackground, false)
|
background := w.getAnsiFromColorString(w.TerminalBackground, false)
|
||||||
|
@ -430,6 +434,12 @@ func (w *Writer) writeColorOverrides(match map[string]string, background string,
|
||||||
}
|
}
|
||||||
w.currentBackground, w.currentForeground = w.asAnsiColors(match[BG], match[FG])
|
w.currentBackground, w.currentForeground = w.asAnsiColors(match[BG], match[FG])
|
||||||
|
|
||||||
|
// ignore processing fully tranparent colors
|
||||||
|
w.invisible = w.currentForeground.IsTransparent() && w.currentBackground.IsTransparent()
|
||||||
|
if w.invisible {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// make sure we have colors
|
// make sure we have colors
|
||||||
if w.currentForeground.IsEmpty() {
|
if w.currentForeground.IsEmpty() {
|
||||||
w.currentForeground = w.foreground
|
w.currentForeground = w.foreground
|
||||||
|
|
|
@ -10,7 +10,11 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (w *Writer) write(i int, s rune) {
|
func (w *Writer) write(i int, s rune) {
|
||||||
// ignore the logic when there is no hyperlink
|
// ignore processing when invisible (<transparent,transparent>)
|
||||||
|
if w.invisible {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// ignore the logic when there is no hyperlink or things arent't visible
|
||||||
if !w.hasHyperlink {
|
if !w.hasHyperlink {
|
||||||
w.length += runewidth.RuneWidth(s)
|
w.length += runewidth.RuneWidth(s)
|
||||||
w.builder.WriteRune(s)
|
w.builder.WriteRune(s)
|
||||||
|
|
Loading…
Reference in a new issue