(style: TextStyle | undefined, linkRefs: LinkRefs | null)
| 129 | } |
| 130 | |
| 131 | function encodeStyle(style: TextStyle | undefined, linkRefs: LinkRefs | null): EncodedStyle { |
| 132 | if (!style) { |
| 133 | return { |
| 134 | fg: 0, |
| 135 | bg: 0, |
| 136 | attrs: 0, |
| 137 | reserved: 0, |
| 138 | underlineRgb: 0, |
| 139 | linkUriRef: linkRefs?.uriRef ?? 0, |
| 140 | linkIdRef: linkRefs?.idRef ?? 0, |
| 141 | }; |
| 142 | } |
| 143 | |
| 144 | const fg = asPackedRgb24(style.fg); |
| 145 | const bg = asPackedRgb24(style.bg); |
| 146 | const underlineColor = asPackedRgb24(style.underlineColor); |
| 147 | const underlineStyle = encodeUnderlineStyle(style.underlineStyle); |
| 148 | |
| 149 | const prepackedAttrs = (style as { attrs?: unknown }).attrs; |
| 150 | let attrs = |
| 151 | typeof prepackedAttrs === "number" && Number.isFinite(prepackedAttrs) |
| 152 | ? (prepackedAttrs >>> 0) & 0xff |
| 153 | : 0; |
| 154 | if (attrs === 0) { |
| 155 | if (style.bold) attrs |= 1 << 0; |
| 156 | if (style.italic) attrs |= 1 << 1; |
| 157 | if (style.underline || underlineStyle !== 0) attrs |= 1 << 2; |
| 158 | if (style.inverse) attrs |= 1 << 3; |
| 159 | if (style.dim) attrs |= 1 << 4; |
| 160 | if (style.strikethrough) attrs |= 1 << 5; |
| 161 | if (style.overline) attrs |= 1 << 6; |
| 162 | if (style.blink) attrs |= 1 << 7; |
| 163 | } |
| 164 | |
| 165 | return { |
| 166 | fg, |
| 167 | bg, |
| 168 | attrs, |
| 169 | reserved: underlineStyle & 0x7, |
| 170 | underlineRgb: underlineColor, |
| 171 | linkUriRef: linkRefs?.uriRef ?? 0, |
| 172 | linkIdRef: linkRefs?.idRef ?? 0, |
| 173 | }; |
| 174 | } |
| 175 | |
| 176 | function deriveCanvasPxFromBlitter( |
| 177 | cols: number, |
no test coverage detected