* CSI Pm m Character Attributes (SGR). * * @vt: #P[See below for supported attributes.] CSI SGR "Select Graphic Rendition" "CSI Pm m" "Set/Reset various text attributes." * SGR selects one or more character attributes at the same time. Multiple params (up to 32) * are applied in
(params: IParams)
| 2508 | * FIXME: remove dead branch for p=100 |
| 2509 | */ |
| 2510 | public charAttributes(params: IParams): boolean { |
| 2511 | // Optimize a single SGR0. |
| 2512 | if (params.length === 1 && params.params[0] === 0) { |
| 2513 | this._processSGR0(this._curAttrData); |
| 2514 | return true; |
| 2515 | } |
| 2516 | |
| 2517 | const l = params.length; |
| 2518 | let p; |
| 2519 | const attr = this._curAttrData; |
| 2520 | |
| 2521 | for (let i = 0; i < l; i++) { |
| 2522 | p = params.params[i]; |
| 2523 | if (p >= 30 && p <= 37) { |
| 2524 | // fg color 8 |
| 2525 | attr.fg &= ~(Attributes.CM_MASK | Attributes.PCOLOR_MASK); |
| 2526 | attr.fg |= Attributes.CM_P16 | (p - 30); |
| 2527 | } else if (p >= 40 && p <= 47) { |
| 2528 | // bg color 8 |
| 2529 | attr.bg &= ~(Attributes.CM_MASK | Attributes.PCOLOR_MASK); |
| 2530 | attr.bg |= Attributes.CM_P16 | (p - 40); |
| 2531 | } else if (p >= 90 && p <= 97) { |
| 2532 | // fg color 16 |
| 2533 | attr.fg &= ~(Attributes.CM_MASK | Attributes.PCOLOR_MASK); |
| 2534 | attr.fg |= Attributes.CM_P16 | (p - 90) | 8; |
| 2535 | } else if (p >= 100 && p <= 107) { |
| 2536 | // bg color 16 |
| 2537 | attr.bg &= ~(Attributes.CM_MASK | Attributes.PCOLOR_MASK); |
| 2538 | attr.bg |= Attributes.CM_P16 | (p - 100) | 8; |
| 2539 | } else if (p === 0) { |
| 2540 | // default |
| 2541 | this._processSGR0(attr); |
| 2542 | } else if (p === 1) { |
| 2543 | // bold text |
| 2544 | attr.fg |= FgFlags.BOLD; |
| 2545 | } else if (p === 3) { |
| 2546 | // italic text |
| 2547 | attr.bg |= BgFlags.ITALIC; |
| 2548 | } else if (p === 4) { |
| 2549 | // underlined text |
| 2550 | attr.fg |= FgFlags.UNDERLINE; |
| 2551 | this._processUnderline(params.hasSubParams(i) ? params.getSubParams(i)![0] : UnderlineStyle.SINGLE, attr); |
| 2552 | } else if (p === 5) { |
| 2553 | // blink |
| 2554 | attr.fg |= FgFlags.BLINK; |
| 2555 | } else if (p === 7) { |
| 2556 | // inverse and positive |
| 2557 | // test with: echo -e '\e[31m\e[42mhello\e[7mworld\e[27mhi\e[m' |
| 2558 | attr.fg |= FgFlags.INVERSE; |
| 2559 | } else if (p === 8) { |
| 2560 | // invisible |
| 2561 | attr.fg |= FgFlags.INVISIBLE; |
| 2562 | } else if (p === 9) { |
| 2563 | // strikethrough |
| 2564 | attr.fg |= FgFlags.STRIKETHROUGH; |
| 2565 | } else if (p === 2) { |
| 2566 | // dimmed text |
| 2567 | attr.bg |= BgFlags.DIM; |
no test coverage detected