|
|
|
@@ -15,6 +15,8 @@ import { css } from 'common/Color';
|
|
|
|
|
import { MockCharacterJoinerService, MockCoreBrowserService, MockThemeService } from 'browser/TestUtils.test';
|
|
|
|
|
|
|
|
|
|
const EMPTY_ELEM_MAPPING = new Int16Array(1000);
|
|
|
|
|
const EMPTY_METRICS = new Uint8Array(1024);
|
|
|
|
|
EMPTY_METRICS.fill(0xFF);
|
|
|
|
|
|
|
|
|
|
describe('DomRendererRowFactory', () => {
|
|
|
|
|
let dom: jsdom.JSDOM;
|
|
|
|
@@ -37,7 +39,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
|
|
|
|
|
describe('createRow', () => {
|
|
|
|
|
it('should not create anything for an empty row', () => {
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
''
|
|
|
|
|
);
|
|
|
|
@@ -47,7 +49,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
lineData.setCell(0, CellData.fromCharData([DEFAULT_ATTR, '語', 2, '語'.charCodeAt(0)]));
|
|
|
|
|
// There should be no element for the following "empty" cell
|
|
|
|
|
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, '', 0, 0]));
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
'<span style="width: 10px;">語</span>'
|
|
|
|
|
);
|
|
|
|
@@ -55,7 +57,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
|
|
|
|
|
it('should add class for cursor and cursor style', () => {
|
|
|
|
|
for (const style of ['block', 'bar', 'underline']) {
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, true, style, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, true, style, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
`<span class="xterm-cursor xterm-cursor-${style}"> </span>`
|
|
|
|
|
);
|
|
|
|
@@ -63,7 +65,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should add class for cursor blink', () => {
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, true, 'block', 0, true, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, true, 'block', 0, true, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
`<span class="xterm-cursor xterm-cursor-blink xterm-cursor-block"> </span>`
|
|
|
|
|
);
|
|
|
|
@@ -72,7 +74,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
it('should not render cells that go beyond the terminal\'s columns', () => {
|
|
|
|
|
lineData.setCell(0, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)]));
|
|
|
|
|
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, 'b', 1, 'b'.charCodeAt(0)]));
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 1, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 1, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
'<span>a</span>'
|
|
|
|
|
);
|
|
|
|
@@ -83,7 +85,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
|
|
|
|
cell.fg = DEFAULT_ATTR_DATA.fg | FgFlags.BOLD;
|
|
|
|
|
lineData.setCell(0, cell);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
'<span class="xterm-bold">a</span>'
|
|
|
|
|
);
|
|
|
|
@@ -93,7 +95,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
|
|
|
|
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.ITALIC;
|
|
|
|
|
lineData.setCell(0, cell);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
'<span class="xterm-italic">a</span>'
|
|
|
|
|
);
|
|
|
|
@@ -103,7 +105,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
|
|
|
|
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.DIM;
|
|
|
|
|
lineData.setCell(0, cell);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
'<span class="xterm-dim">a</span>'
|
|
|
|
|
);
|
|
|
|
@@ -116,7 +118,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.HAS_EXTENDED;
|
|
|
|
|
cell.extended.underlineStyle = UnderlineStyle.SINGLE;
|
|
|
|
|
lineData.setCell(0, cell);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
'<span class="xterm-underline-1">a</span>'
|
|
|
|
|
);
|
|
|
|
@@ -127,7 +129,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.HAS_EXTENDED;
|
|
|
|
|
cell.extended.underlineStyle = UnderlineStyle.DOUBLE;
|
|
|
|
|
lineData.setCell(0, cell);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
'<span class="xterm-underline-2">a</span>'
|
|
|
|
|
);
|
|
|
|
@@ -138,7 +140,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.HAS_EXTENDED;
|
|
|
|
|
cell.extended.underlineStyle = UnderlineStyle.CURLY;
|
|
|
|
|
lineData.setCell(0, cell);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
'<span class="xterm-underline-3">a</span>'
|
|
|
|
|
);
|
|
|
|
@@ -149,7 +151,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.HAS_EXTENDED;
|
|
|
|
|
cell.extended.underlineStyle = UnderlineStyle.DOTTED;
|
|
|
|
|
lineData.setCell(0, cell);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
'<span class="xterm-underline-4">a</span>'
|
|
|
|
|
);
|
|
|
|
@@ -160,7 +162,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.HAS_EXTENDED;
|
|
|
|
|
cell.extended.underlineStyle = UnderlineStyle.DASHED;
|
|
|
|
|
lineData.setCell(0, cell);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
'<span class="xterm-underline-5">a</span>'
|
|
|
|
|
);
|
|
|
|
@@ -171,7 +173,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
|
|
|
|
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.OVERLINE;
|
|
|
|
|
lineData.setCell(0, cell);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
'<span class="xterm-overline">a</span>'
|
|
|
|
|
);
|
|
|
|
@@ -181,7 +183,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
|
|
|
|
cell.fg = DEFAULT_ATTR_DATA.fg | FgFlags.STRIKETHROUGH;
|
|
|
|
|
lineData.setCell(0, cell);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
'<span class="xterm-strikethrough">a</span>'
|
|
|
|
|
);
|
|
|
|
@@ -194,7 +196,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
cell.fg &= ~Attributes.PCOLOR_MASK;
|
|
|
|
|
cell.fg |= i;
|
|
|
|
|
lineData.setCell(0, cell);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
`<span class="xterm-fg-${i}">a</span>`
|
|
|
|
|
);
|
|
|
|
@@ -208,7 +210,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
cell.bg &= ~Attributes.PCOLOR_MASK;
|
|
|
|
|
cell.bg |= i;
|
|
|
|
|
lineData.setCell(0, cell);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
`<span class="xterm-bg-${i}">a</span>`
|
|
|
|
|
);
|
|
|
|
@@ -220,7 +222,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
cell.fg |= Attributes.CM_P16 | 2 | FgFlags.INVERSE;
|
|
|
|
|
cell.bg |= Attributes.CM_P16 | 1;
|
|
|
|
|
lineData.setCell(0, cell);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
'<span class="xterm-bg-2 xterm-fg-1">a</span>'
|
|
|
|
|
);
|
|
|
|
@@ -231,7 +233,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
cell.fg |= FgFlags.INVERSE;
|
|
|
|
|
cell.bg |= Attributes.CM_P16 | 1;
|
|
|
|
|
lineData.setCell(0, cell);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
'<span class="xterm-bg-257 xterm-fg-1">a</span>'
|
|
|
|
|
);
|
|
|
|
@@ -241,7 +243,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
|
|
|
|
cell.fg |= Attributes.CM_P16 | 1 | FgFlags.INVERSE;
|
|
|
|
|
lineData.setCell(0, cell);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
'<span class="xterm-bg-1 xterm-fg-257">a</span>'
|
|
|
|
|
);
|
|
|
|
@@ -254,7 +256,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
cell.fg &= ~Attributes.PCOLOR_MASK;
|
|
|
|
|
cell.fg |= i;
|
|
|
|
|
lineData.setCell(0, cell);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
`<span class="xterm-bold xterm-fg-${i + 8}">a</span>`
|
|
|
|
|
);
|
|
|
|
@@ -266,7 +268,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
cell.fg |= Attributes.CM_RGB | 1 << 16 | 2 << 8 | 3;
|
|
|
|
|
cell.bg |= Attributes.CM_RGB | 4 << 16 | 5 << 8 | 6;
|
|
|
|
|
lineData.setCell(0, cell);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
'<span style="background-color:#040506;color:#010203;">a</span>'
|
|
|
|
|
);
|
|
|
|
@@ -277,7 +279,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
cell.fg |= Attributes.CM_RGB | 1 << 16 | 2 << 8 | 3 | FgFlags.INVERSE;
|
|
|
|
|
cell.bg |= Attributes.CM_RGB | 4 << 16 | 5 << 8 | 6;
|
|
|
|
|
lineData.setCell(0, cell);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
'<span style="background-color:#010203;color:#040506;">a</span>'
|
|
|
|
|
);
|
|
|
|
@@ -289,7 +291,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
lineData.setCell(0, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)]));
|
|
|
|
|
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, 'b', 1, 'b'.charCodeAt(0)]));
|
|
|
|
|
rowFactory.handleSelectionChanged([1, 0], [2, 0], false);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
'<span>a</span><span class="xterm-decoration-top">b</span>'
|
|
|
|
|
);
|
|
|
|
@@ -297,7 +299,7 @@ describe('DomRendererRowFactory', () => {
|
|
|
|
|
it('should force whitespace cells to be rendered above the background', () => {
|
|
|
|
|
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)]));
|
|
|
|
|
rowFactory.handleSelectionChanged([0, 0], [2, 0], false);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING);
|
|
|
|
|
const fragment = rowFactory.createRow(lineData, 0, false, undefined, 0, false, 5, 20, EMPTY_ELEM_MAPPING, EMPTY_METRICS);
|
|
|
|
|
assert.equal(getFragmentHtml(fragment),
|
|
|
|
|
'<span class="xterm-decoration-top"> </span><span class="xterm-decoration-top">a</span>'
|
|
|
|
|
);
|
|
|
|
|