mirror of
https://github.com/wez/wezterm.git
synced 2024-12-25 14:22:37 +03:00
refactor: extract resolve_fg_color_attr to module scope
This commit is contained in:
parent
33c87611dc
commit
d32c6fca23
@ -673,38 +673,6 @@ impl super::TermWindow {
|
|||||||
let bg_is_default = attrs.background == ColorAttribute::Default;
|
let bg_is_default = attrs.background == ColorAttribute::Default;
|
||||||
let bg_color = params.palette.resolve_bg(attrs.background);
|
let bg_color = params.palette.resolve_bg(attrs.background);
|
||||||
|
|
||||||
fn resolve_fg_color_attr(
|
|
||||||
attrs: &CellAttributes,
|
|
||||||
fg: &ColorAttribute,
|
|
||||||
params: &RenderScreenLineOpenGLParams,
|
|
||||||
style: &config::TextStyle,
|
|
||||||
) -> RgbColor {
|
|
||||||
match fg {
|
|
||||||
wezterm_term::color::ColorAttribute::Default => {
|
|
||||||
if let Some(fg) = style.foreground {
|
|
||||||
fg
|
|
||||||
} else {
|
|
||||||
params.palette.resolve_fg(attrs.foreground)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wezterm_term::color::ColorAttribute::PaletteIndex(idx)
|
|
||||||
if *idx < 8 && params.config.bold_brightens_ansi_colors =>
|
|
||||||
{
|
|
||||||
// For compatibility purposes, switch to a brighter version
|
|
||||||
// of one of the standard ANSI colors when Bold is enabled.
|
|
||||||
// This lifts black to dark grey.
|
|
||||||
let idx = if attrs.intensity() == wezterm_term::Intensity::Bold {
|
|
||||||
*idx + 8
|
|
||||||
} else {
|
|
||||||
*idx
|
|
||||||
};
|
|
||||||
params
|
|
||||||
.palette
|
|
||||||
.resolve_fg(wezterm_term::color::ColorAttribute::PaletteIndex(idx))
|
|
||||||
}
|
|
||||||
_ => params.palette.resolve_fg(*fg),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let fg_color = resolve_fg_color_attr(&attrs, &attrs.foreground, ¶ms, &style);
|
let fg_color = resolve_fg_color_attr(&attrs, &attrs.foreground, ¶ms, &style);
|
||||||
|
|
||||||
let (fg_color, bg_color, bg_is_default) = {
|
let (fg_color, bg_color, bg_is_default) = {
|
||||||
@ -1295,3 +1263,36 @@ fn rgbcolor_alpha_to_window_color(color: RgbColor, alpha: u8) -> LinearRgba {
|
|||||||
// with_srgba.
|
// with_srgba.
|
||||||
LinearRgba::with_rgba(color.red, color.green, color.blue, alpha)
|
LinearRgba::with_rgba(color.red, color.green, color.blue, alpha)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn resolve_fg_color_attr(
|
||||||
|
attrs: &CellAttributes,
|
||||||
|
fg: &ColorAttribute,
|
||||||
|
params: &RenderScreenLineOpenGLParams,
|
||||||
|
style: &config::TextStyle,
|
||||||
|
) -> RgbColor {
|
||||||
|
match fg {
|
||||||
|
wezterm_term::color::ColorAttribute::Default => {
|
||||||
|
if let Some(fg) = style.foreground {
|
||||||
|
fg
|
||||||
|
} else {
|
||||||
|
params.palette.resolve_fg(attrs.foreground)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
wezterm_term::color::ColorAttribute::PaletteIndex(idx)
|
||||||
|
if *idx < 8 && params.config.bold_brightens_ansi_colors =>
|
||||||
|
{
|
||||||
|
// For compatibility purposes, switch to a brighter version
|
||||||
|
// of one of the standard ANSI colors when Bold is enabled.
|
||||||
|
// This lifts black to dark grey.
|
||||||
|
let idx = if attrs.intensity() == wezterm_term::Intensity::Bold {
|
||||||
|
*idx + 8
|
||||||
|
} else {
|
||||||
|
*idx
|
||||||
|
};
|
||||||
|
params
|
||||||
|
.palette
|
||||||
|
.resolve_fg(wezterm_term::color::ColorAttribute::PaletteIndex(idx))
|
||||||
|
}
|
||||||
|
_ => params.palette.resolve_fg(*fg),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user