MCPcopy
hub / github.com/xtermjs/xterm.js / extractActiveBg

Function extractActiveBg

addons/addon-image/src/SixelHandler.ts:118–145  ·  view source on GitHub ↗
(attr: AttributeData, colors: ReadonlyColorSet | undefined)

Source from the content-addressed store, hash-verified

116// get currently active background color from terminal
117// also respect INVERSE setting
118function extractActiveBg(attr: AttributeData, colors: ReadonlyColorSet | undefined): RGBA8888 {
119 let bg = 0;
120 if (!colors) {
121 // FIXME: theme service is prolly not available yet,
122 // happens if .open() was not called yet (bug in core?)
123 return bg;
124 }
125 if (attr.isInverse()) {
126 if (attr.isFgDefault()) {
127 bg = convertLe(colors.foreground.rgba);
128 } else if (attr.isFgRGB()) {
129 const t = (attr.constructor as typeof AttributeData).toColorRGB(attr.getFgColor());
130 bg = toRGBA8888(...t);
131 } else {
132 bg = convertLe(colors.ansi[attr.getFgColor()].rgba);
133 }
134 } else {
135 if (attr.isBgDefault()) {
136 bg = convertLe(colors.background.rgba);
137 } else if (attr.isBgRGB()) {
138 const t = (attr.constructor as typeof AttributeData).toColorRGB(attr.getBgColor());
139 bg = toRGBA8888(...t);
140 } else {
141 bg = convertLe(colors.ansi[attr.getBgColor()].rgba);
142 }
143 }
144 return bg;
145}
146
147// rgba values on the color managers are always in BE, thus convert to LE
148function convertLe(color: number): RGBA8888 {

Callers 1

hookMethod · 0.85

Calls 9

convertLeFunction · 0.85
toColorRGBMethod · 0.80
isInverseMethod · 0.65
isFgDefaultMethod · 0.65
isFgRGBMethod · 0.65
getFgColorMethod · 0.65
isBgDefaultMethod · 0.65
isBgRGBMethod · 0.65
getBgColorMethod · 0.65

Tested by

no test coverage detected