(fields: TabStatusAction)
| 474 | * `;` and `\` in status text are escaped per the spec. |
| 475 | */ |
| 476 | export function tabStatus(fields: TabStatusAction): string { |
| 477 | const parts: string[] = [] |
| 478 | const rgb = (c: Color) => |
| 479 | c.type === 'rgb' |
| 480 | ? `#${[c.r, c.g, c.b].map(n => n.toString(16).padStart(2, '0')).join('')}` |
| 481 | : '' |
| 482 | if ('indicator' in fields) |
| 483 | parts.push(`indicator=${fields.indicator ? rgb(fields.indicator) : ''}`) |
| 484 | if ('status' in fields) |
| 485 | parts.push( |
| 486 | `status=${fields.status?.replaceAll('\\', '\\\\').replaceAll(';', '\\;') ?? ''}`, |
| 487 | ) |
| 488 | if ('statusColor' in fields) |
| 489 | parts.push( |
| 490 | `status-color=${fields.statusColor ? rgb(fields.statusColor) : ''}`, |
| 491 | ) |
| 492 | return osc(OSC.TAB_STATUS, parts.join(';')) |
| 493 | } |
| 494 |
no test coverage detected