convertStyle function
Converts a UvStyle to respect the given terminal color profile.
Implementation
UvStyle convertStyle(UvStyle style, cp.Profile profile) {
switch (profile) {
case cp.Profile.trueColor:
return style;
case cp.Profile.noTty:
return const UvStyle();
case cp.Profile.ascii:
case cp.Profile.unknown:
return style.copyWith(
clearFg: true,
clearBg: true,
clearUnderlineColor: true,
);
case cp.Profile.ansi:
case cp.Profile.ansi256:
break;
}
return style.copyWith(
fg: _convertColor(style.fg, profile),
clearFg: style.fg != null && _convertColor(style.fg, profile) == null,
bg: _convertColor(style.bg, profile),
clearBg: style.bg != null && _convertColor(style.bg, profile) == null,
underlineColor: _convertColor(style.underlineColor, profile),
clearUnderlineColor:
style.underlineColor != null &&
_convertColor(style.underlineColor, profile) == null,
);
}