Skip to content

Commit 518b87f

Browse files
authored
Merge pull request #4532 from Tyriar/4529
Finish overline support
2 parents ada5bfe + 6188c07 commit 518b87f

File tree

5 files changed

+25
-1
lines changed

5 files changed

+25
-1
lines changed

addons/xterm-addon-serialize/src/SerializeAddon.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ function equalFlags(cell1: IBufferCell | IAttributeData, cell2: IBufferCell): bo
7777
return cell1.isInverse() === cell2.isInverse()
7878
&& cell1.isBold() === cell2.isBold()
7979
&& cell1.isUnderline() === cell2.isUnderline()
80+
&& cell1.isOverline() === cell2.isOverline()
8081
&& cell1.isBlink() === cell2.isBlink()
8182
&& cell1.isInvisible() === cell2.isInvisible()
8283
&& cell1.isItalic() === cell2.isItalic()
@@ -264,6 +265,7 @@ class StringSerializeHandler extends BaseSerializeHandler {
264265
if (cell.isInverse() !== oldCell.isInverse()) { sgrSeq.push(cell.isInverse() ? 7 : 27); }
265266
if (cell.isBold() !== oldCell.isBold()) { sgrSeq.push(cell.isBold() ? 1 : 22); }
266267
if (cell.isUnderline() !== oldCell.isUnderline()) { sgrSeq.push(cell.isUnderline() ? 4 : 24); }
268+
if (cell.isOverline() !== oldCell.isOverline()) { sgrSeq.push(cell.isOverline() ? 53 : 55); }
267269
if (cell.isBlink() !== oldCell.isBlink()) { sgrSeq.push(cell.isBlink() ? 5 : 25); }
268270
if (cell.isInvisible() !== oldCell.isInvisible()) { sgrSeq.push(cell.isInvisible() ? 8 : 28); }
269271
if (cell.isItalic() !== oldCell.isItalic()) { sgrSeq.push(cell.isItalic() ? 3 : 23); }
@@ -625,7 +627,9 @@ export class HTMLSerializeHandler extends BaseSerializeHandler {
625627

626628
if (cell.isInverse()) { content.push('color: #000000; background-color: #BFBFBF;'); }
627629
if (cell.isBold()) { content.push('font-weight: bold;'); }
628-
if (cell.isUnderline()) { content.push('text-decoration: underline;'); }
630+
if (cell.isUnderline() && cell.isOverline()) { content.push('text-decoration: overline underline;'); }
631+
else if (cell.isUnderline()) { content.push('text-decoration: underline;'); }
632+
else if (cell.isOverline()) { content.push('text-decoration: overline;'); }
629633
if (cell.isBlink()) { content.push('text-decoration: blink;'); }
630634
if (cell.isInvisible()) { content.push('visibility: hidden;'); }
631635
if (cell.isItalic()) { content.push('font-style: italic;'); }

addons/xterm-addon-serialize/test/SerializeAddon.api.ts

+14
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,18 @@ describe('SerializeAddon', () => {
220220
assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n'));
221221
});
222222

223+
it('serialize all rows of content with overline', async () => {
224+
const cols = 10;
225+
const line = '+'.repeat(cols);
226+
const lines: string[] = [
227+
sgr(OVERLINED) + line, // Overlined
228+
sgr(UNDERLINED) + line, // Overlined, Underlined
229+
sgr(NORMAL) + line // Normal
230+
];
231+
await writeSync(page, lines.join('\\r\\n'));
232+
assert.equal(await page.evaluate(`serializeAddon.serialize();`), lines.join('\r\n'));
233+
});
234+
223235
it('serialize all rows of content with color16 and style separately', async function(): Promise<any> {
224236
const cols = 10;
225237
const line = '+'.repeat(cols);
@@ -601,6 +613,7 @@ const BLINK = '5';
601613
const INVERSE = '7';
602614
const INVISIBLE = '8';
603615
const STRIKETHROUGH = '9';
616+
const OVERLINED = '53';
604617

605618
const NO_BOLD = '22';
606619
const NO_DIM = '22';
@@ -610,3 +623,4 @@ const NO_BLINK = '25';
610623
const NO_INVERSE = '27';
611624
const NO_INVISIBLE = '28';
612625
const NO_STRIKETHROUGH = '29';
626+
const NO_OVERLINED = '55';

src/common/InputHandler.ts

+2
Original file line numberDiff line numberDiff line change
@@ -2425,6 +2425,8 @@ export class InputHandler extends Disposable implements IInputHandler {
24252425
* | 47 | Background color: White. | #Y |
24262426
* | 48 | Background color: Extended color. | #P[Support for RGB and indexed colors, see below.] |
24272427
* | 49 | Background color: Default (original). | #Y |
2428+
* | 53 | Overlined. | #Y |
2429+
* | 55 | Not Overlined. | #Y |
24282430
* | 58 | Underline color: Extended color. | #P[Support for RGB and indexed colors, see below.] |
24292431
* | 90 - 97 | Bright foreground color (analogous to 30 - 37). | #Y |
24302432
* | 100 - 107 | Bright background color (analogous to 40 - 47). | #Y |

typings/xterm-headless.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,8 @@ declare module 'xterm-headless' {
999999
isInvisible(): number;
10001000
/** Whether the cell has the strikethrough attribute (CSI 9 m). */
10011001
isStrikethrough(): number;
1002+
/** Whether the cell has the overline attribute (CSI 53 m). */
1003+
isOverline(): number;
10021004

10031005
/** Whether the cell is using the RGB foreground color mode. */
10041006
isFgRGB(): boolean;

typings/xterm.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1516,6 +1516,8 @@ declare module 'xterm' {
15161516
isInvisible(): number;
15171517
/** Whether the cell has the strikethrough attribute (CSI 9 m). */
15181518
isStrikethrough(): number;
1519+
/** Whether the cell has the overline attribute (CSI 53 m). */
1520+
isOverline(): number;
15191521

15201522
/** Whether the cell is using the RGB foreground color mode. */
15211523
isFgRGB(): boolean;

0 commit comments

Comments
 (0)