@@ -13,7 +13,8 @@ import { ICharSizeService, ICharacterJoinerService, ICoreBrowserService, IThemeS
|
|||||||
import { CharData, IBufferLine, ICellData } from 'common/Types';
|
import { CharData, IBufferLine, ICellData } from 'common/Types';
|
||||||
import { AttributeData } from 'common/buffer/AttributeData';
|
import { AttributeData } from 'common/buffer/AttributeData';
|
||||||
import { CellData } from 'common/buffer/CellData';
|
import { CellData } from 'common/buffer/CellData';
|
||||||
import { Attributes, Content, NULL_CELL_CHAR, NULL_CELL_CODE } from 'common/buffer/Constants';
|
import { Attributes, Content, FgFlags, NULL_CELL_CHAR, NULL_CELL_CODE } from 'common/buffer/Constants';
|
||||||
|
import { TextBlinkStateManager } from 'browser/renderer/shared/TextBlinkStateManager';
|
||||||
import { ICoreService, IDecorationService, IOptionsService } from 'common/services/Services';
|
import { ICoreService, IDecorationService, IOptionsService } from 'common/services/Services';
|
||||||
import { Terminal } from '@xterm/xterm';
|
import { Terminal } from '@xterm/xterm';
|
||||||
import { GlyphRenderer } from './GlyphRenderer';
|
import { GlyphRenderer } from './GlyphRenderer';
|
||||||
@@ -30,6 +31,7 @@ import { createRenderDimensions } from 'browser/renderer/shared/RendererUtils';
|
|||||||
export class WebglRenderer extends Disposable implements IRenderer {
|
export class WebglRenderer extends Disposable implements IRenderer {
|
||||||
private _renderLayers: IRenderLayer[];
|
private _renderLayers: IRenderLayer[];
|
||||||
private _cursorBlinkStateManager: MutableDisposable<CursorBlinkStateManager> = new MutableDisposable();
|
private _cursorBlinkStateManager: MutableDisposable<CursorBlinkStateManager> = new MutableDisposable();
|
||||||
|
private _textBlinkStateManager: TextBlinkStateManager;
|
||||||
private _charAtlasDisposable = this._register(new MutableDisposable());
|
private _charAtlasDisposable = this._register(new MutableDisposable());
|
||||||
private _charAtlas: ITextureAtlas | undefined;
|
private _charAtlas: ITextureAtlas | undefined;
|
||||||
private _devicePixelRatio: number;
|
private _devicePixelRatio: number;
|
||||||
@@ -105,6 +107,12 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
this._updateDimensions();
|
this._updateDimensions();
|
||||||
this._updateCursorBlink();
|
this._updateCursorBlink();
|
||||||
this._register(_optionsService.onOptionChange(() => this._handleOptionsChanged()));
|
this._register(_optionsService.onOptionChange(() => this._handleOptionsChanged()));
|
||||||
|
this._textBlinkStateManager = new TextBlinkStateManager(
|
||||||
|
() => this._requestRedrawViewport(),
|
||||||
|
this._coreBrowserService
|
||||||
|
);
|
||||||
|
this._textBlinkStateManager.setIntervalDuration(this._optionsService.rawOptions.blinkIntervalDuration);
|
||||||
|
this._register(toDisposable(() => this._textBlinkStateManager.dispose()));
|
||||||
|
|
||||||
this._deviceMaxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
|
this._deviceMaxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
|
||||||
|
|
||||||
@@ -250,6 +258,7 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
this._updateDimensions();
|
this._updateDimensions();
|
||||||
this._refreshCharAtlas();
|
this._refreshCharAtlas();
|
||||||
this._updateCursorBlink();
|
this._updateCursorBlink();
|
||||||
|
this._textBlinkStateManager.setIntervalDuration(this._optionsService.rawOptions.blinkIntervalDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -506,6 +515,10 @@ export class WebglRenderer extends Disposable implements IRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this._textBlinkStateManager.isEnabled && !this._textBlinkStateManager.isBlinkOn && cell.isBlink()) {
|
||||||
|
this._cellColorResolver.result.fg |= FgFlags.INVISIBLE;
|
||||||
|
}
|
||||||
|
|
||||||
if (code !== NULL_CELL_CODE) {
|
if (code !== NULL_CELL_CODE) {
|
||||||
this._model.lineLengths[y] = x + 1;
|
this._model.lineLengths[y] = x + 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import { WidthCache } from 'browser/renderer/dom/WidthCache';
|
|||||||
import { INVERTED_DEFAULT_COLOR, RendererConstants } from 'browser/renderer/shared/Constants';
|
import { INVERTED_DEFAULT_COLOR, RendererConstants } from 'browser/renderer/shared/Constants';
|
||||||
import { createRenderDimensions } from 'browser/renderer/shared/RendererUtils';
|
import { createRenderDimensions } from 'browser/renderer/shared/RendererUtils';
|
||||||
import { createSelectionRenderModel } from 'browser/renderer/shared/SelectionRenderModel';
|
import { createSelectionRenderModel } from 'browser/renderer/shared/SelectionRenderModel';
|
||||||
|
import { TextBlinkStateManager } from 'browser/renderer/shared/TextBlinkStateManager';
|
||||||
import { IRenderDimensions, IRenderer, IRequestRedrawEvent, ISelectionRenderModel } from 'browser/renderer/shared/Types';
|
import { IRenderDimensions, IRenderer, IRequestRedrawEvent, ISelectionRenderModel } from 'browser/renderer/shared/Types';
|
||||||
import { ICharSizeService, ICoreBrowserService, IThemeService } from 'browser/services/Services';
|
import { ICharSizeService, ICoreBrowserService, IThemeService } from 'browser/services/Services';
|
||||||
import { ILinkifier2, ILinkifierEvent, ITerminal, ReadonlyColorSet } from 'browser/Types';
|
import { ILinkifier2, ILinkifierEvent, ITerminal, ReadonlyColorSet } from 'browser/Types';
|
||||||
@@ -45,10 +46,12 @@ export class DomRenderer extends Disposable implements IRenderer {
|
|||||||
private _widthCache: WidthCache;
|
private _widthCache: WidthCache;
|
||||||
private _selectionRenderModel: ISelectionRenderModel = createSelectionRenderModel();
|
private _selectionRenderModel: ISelectionRenderModel = createSelectionRenderModel();
|
||||||
private _cursorBlinkStateManager: CursorBlinkStateManager;
|
private _cursorBlinkStateManager: CursorBlinkStateManager;
|
||||||
|
private _textBlinkStateManager: TextBlinkStateManager;
|
||||||
|
|
||||||
public dimensions: IRenderDimensions;
|
public dimensions: IRenderDimensions;
|
||||||
|
|
||||||
public readonly onRequestRedraw = this._register(new Emitter<IRequestRedrawEvent>()).event;
|
private readonly _onRequestRedraw = this._register(new Emitter<IRequestRedrawEvent>());
|
||||||
|
public readonly onRequestRedraw = this._onRequestRedraw.event;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly _terminal: ITerminal,
|
private readonly _terminal: ITerminal,
|
||||||
@@ -95,6 +98,12 @@ export class DomRenderer extends Disposable implements IRenderer {
|
|||||||
this._cursorBlinkStateManager = new CursorBlinkStateManager(this._rowContainer, this._coreBrowserService);
|
this._cursorBlinkStateManager = new CursorBlinkStateManager(this._rowContainer, this._coreBrowserService);
|
||||||
this._register(addDisposableListener(this._document, 'mousedown', () => this._cursorBlinkStateManager.restartBlinkAnimation()));
|
this._register(addDisposableListener(this._document, 'mousedown', () => this._cursorBlinkStateManager.restartBlinkAnimation()));
|
||||||
this._register(toDisposable(() => this._cursorBlinkStateManager.dispose()));
|
this._register(toDisposable(() => this._cursorBlinkStateManager.dispose()));
|
||||||
|
this._textBlinkStateManager = new TextBlinkStateManager(
|
||||||
|
() => this._onRequestRedraw.fire({ start: 0, end: this._bufferService.rows - 1 }),
|
||||||
|
this._coreBrowserService
|
||||||
|
);
|
||||||
|
this._textBlinkStateManager.setIntervalDuration(this._optionsService.rawOptions.blinkIntervalDuration);
|
||||||
|
this._register(toDisposable(() => this._textBlinkStateManager.dispose()));
|
||||||
|
|
||||||
this._register(toDisposable(() => {
|
this._register(toDisposable(() => {
|
||||||
this._element.classList.remove(TERMINAL_CLASS_PREFIX + this._terminalClass);
|
this._element.classList.remove(TERMINAL_CLASS_PREFIX + this._terminalClass);
|
||||||
@@ -193,6 +202,9 @@ export class DomRenderer extends Disposable implements IRenderer {
|
|||||||
`}` +
|
`}` +
|
||||||
`${this._terminalSelector} span.${RowCss.ITALIC_CLASS} {` +
|
`${this._terminalSelector} span.${RowCss.ITALIC_CLASS} {` +
|
||||||
` font-style: italic;` +
|
` font-style: italic;` +
|
||||||
|
`}` +
|
||||||
|
`${this._terminalSelector} span.${RowCss.BLINK_HIDDEN_CLASS} {` +
|
||||||
|
` visibility: hidden;` +
|
||||||
`}`;
|
`}`;
|
||||||
// Blink animation
|
// Blink animation
|
||||||
const blinkAnimationUnderlineId = `blink_underline_${this._terminalClass}`;
|
const blinkAnimationUnderlineId = `blink_underline_${this._terminalClass}`;
|
||||||
@@ -436,6 +448,7 @@ export class DomRenderer extends Disposable implements IRenderer {
|
|||||||
this._optionsService.rawOptions.fontWeightBold
|
this._optionsService.rawOptions.fontWeightBold
|
||||||
);
|
);
|
||||||
this._setDefaultSpacing();
|
this._setDefaultSpacing();
|
||||||
|
this._textBlinkStateManager.setIntervalDuration(this._optionsService.rawOptions.blinkIntervalDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
public clear(): void {
|
public clear(): void {
|
||||||
@@ -476,6 +489,7 @@ export class DomRenderer extends Disposable implements IRenderer {
|
|||||||
cursorInactiveStyle,
|
cursorInactiveStyle,
|
||||||
cursorX,
|
cursorX,
|
||||||
cursorBlink,
|
cursorBlink,
|
||||||
|
this._textBlinkStateManager.isBlinkOn,
|
||||||
this.dimensions.css.cell.width,
|
this.dimensions.css.cell.width,
|
||||||
this._widthCache,
|
this._widthCache,
|
||||||
-1,
|
-1,
|
||||||
@@ -545,6 +559,7 @@ export class DomRenderer extends Disposable implements IRenderer {
|
|||||||
cursorInactiveStyle,
|
cursorInactiveStyle,
|
||||||
cursorX,
|
cursorX,
|
||||||
cursorBlink,
|
cursorBlink,
|
||||||
|
this._textBlinkStateManager.isBlinkOn,
|
||||||
this.dimensions.css.cell.width,
|
this.dimensions.css.cell.width,
|
||||||
this._widthCache,
|
this._widthCache,
|
||||||
enabled ? (i === y ? x : 0) : -1,
|
enabled ? (i === y ? x : 0) : -1,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
|
|
||||||
describe('createRow', () => {
|
describe('createRow', () => {
|
||||||
it('should not create anything for an empty row', () => {
|
it('should not create anything for an empty row', () => {
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
@@ -51,7 +51,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
lineData.setCell(0, CellData.fromCharData([DEFAULT_ATTR, '語', 2, '語'.charCodeAt(0)]));
|
lineData.setCell(0, CellData.fromCharData([DEFAULT_ATTR, '語', 2, '語'.charCodeAt(0)]));
|
||||||
// There should be no element for the following "empty" cell
|
// There should be no element for the following "empty" cell
|
||||||
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, '', 0, 0]));
|
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, '', 0, 0]));
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span>語</span>'
|
'<span>語</span>'
|
||||||
);
|
);
|
||||||
@@ -59,7 +59,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
|
|
||||||
it('should add class for cursor and cursor style', () => {
|
it('should add class for cursor and cursor style', () => {
|
||||||
for (const style of ['block', 'bar', 'underline']) {
|
for (const style of ['block', 'bar', 'underline']) {
|
||||||
const spans = rowFactory.createRow(lineData, 0, true, style, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, true, style, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
`<span class="xterm-cursor xterm-cursor-${style}"> </span>`
|
`<span class="xterm-cursor xterm-cursor-${style}"> </span>`
|
||||||
);
|
);
|
||||||
@@ -67,7 +67,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should add class for cursor blink', () => {
|
it('should add class for cursor blink', () => {
|
||||||
const spans = rowFactory.createRow(lineData, 0, true, 'block', undefined, 0, true, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, true, 'block', undefined, 0, true, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
`<span class="xterm-cursor xterm-cursor-blink xterm-cursor-block"> </span>`
|
`<span class="xterm-cursor xterm-cursor-blink xterm-cursor-block"> </span>`
|
||||||
);
|
);
|
||||||
@@ -86,7 +86,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
new MockThemeService()
|
new MockThemeService()
|
||||||
);
|
);
|
||||||
for (const inactiveStyle of ['outline', 'block', 'bar', 'underline', 'none']){
|
for (const inactiveStyle of ['outline', 'block', 'bar', 'underline', 'none']){
|
||||||
const spans = rowFactory.createRow(lineData, 0, true, 'block', inactiveStyle, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, true, 'block', inactiveStyle, 0, false, true, 5, widthCache, -1, -1);
|
||||||
if (inactiveStyle === 'none') {
|
if (inactiveStyle === 'none') {
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
`<span class="xterm-cursor"> </span>`);
|
`<span class="xterm-cursor"> </span>`);
|
||||||
@@ -109,7 +109,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
new MockDecorationService(),
|
new MockDecorationService(),
|
||||||
new MockThemeService()
|
new MockThemeService()
|
||||||
);
|
);
|
||||||
const spans = rowFactory.createRow(lineData, 0, true, 'block', undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, true, 'block', undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
`<span> </span>`
|
`<span> </span>`
|
||||||
);
|
);
|
||||||
@@ -120,7 +120,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
||||||
cell.fg = DEFAULT_ATTR_DATA.fg | FgFlags.BOLD;
|
cell.fg = DEFAULT_ATTR_DATA.fg | FgFlags.BOLD;
|
||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span class="xterm-bold">a</span>'
|
'<span class="xterm-bold">a</span>'
|
||||||
);
|
);
|
||||||
@@ -130,7 +130,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
||||||
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.ITALIC;
|
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.ITALIC;
|
||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span class="xterm-italic">a</span>'
|
'<span class="xterm-italic">a</span>'
|
||||||
);
|
);
|
||||||
@@ -140,7 +140,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
||||||
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.DIM;
|
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.DIM;
|
||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span class="xterm-dim">a</span>'
|
'<span class="xterm-dim">a</span>'
|
||||||
);
|
);
|
||||||
@@ -153,7 +153,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.HAS_EXTENDED;
|
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.HAS_EXTENDED;
|
||||||
cell.extended.underlineStyle = UnderlineStyle.SINGLE;
|
cell.extended.underlineStyle = UnderlineStyle.SINGLE;
|
||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span class="xterm-underline-1">a</span>'
|
'<span class="xterm-underline-1">a</span>'
|
||||||
);
|
);
|
||||||
@@ -164,7 +164,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.HAS_EXTENDED;
|
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.HAS_EXTENDED;
|
||||||
cell.extended.underlineStyle = UnderlineStyle.DOUBLE;
|
cell.extended.underlineStyle = UnderlineStyle.DOUBLE;
|
||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span class="xterm-underline-2">a</span>'
|
'<span class="xterm-underline-2">a</span>'
|
||||||
);
|
);
|
||||||
@@ -175,7 +175,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.HAS_EXTENDED;
|
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.HAS_EXTENDED;
|
||||||
cell.extended.underlineStyle = UnderlineStyle.CURLY;
|
cell.extended.underlineStyle = UnderlineStyle.CURLY;
|
||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span class="xterm-underline-3">a</span>'
|
'<span class="xterm-underline-3">a</span>'
|
||||||
);
|
);
|
||||||
@@ -186,7 +186,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.HAS_EXTENDED;
|
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.HAS_EXTENDED;
|
||||||
cell.extended.underlineStyle = UnderlineStyle.DOTTED;
|
cell.extended.underlineStyle = UnderlineStyle.DOTTED;
|
||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span class="xterm-underline-4">a</span>'
|
'<span class="xterm-underline-4">a</span>'
|
||||||
);
|
);
|
||||||
@@ -197,7 +197,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.HAS_EXTENDED;
|
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.HAS_EXTENDED;
|
||||||
cell.extended.underlineStyle = UnderlineStyle.DASHED;
|
cell.extended.underlineStyle = UnderlineStyle.DASHED;
|
||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span class="xterm-underline-5">a</span>'
|
'<span class="xterm-underline-5">a</span>'
|
||||||
);
|
);
|
||||||
@@ -208,7 +208,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
||||||
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.OVERLINE;
|
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.OVERLINE;
|
||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span class="xterm-overline">a</span>'
|
'<span class="xterm-overline">a</span>'
|
||||||
);
|
);
|
||||||
@@ -218,12 +218,28 @@ describe('DomRendererRowFactory', () => {
|
|||||||
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
||||||
cell.fg = DEFAULT_ATTR_DATA.fg | FgFlags.STRIKETHROUGH;
|
cell.fg = DEFAULT_ATTR_DATA.fg | FgFlags.STRIKETHROUGH;
|
||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span class="xterm-strikethrough">a</span>'
|
'<span class="xterm-strikethrough">a</span>'
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should hide blinking text when blink is off', () => {
|
||||||
|
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
||||||
|
cell.fg = DEFAULT_ATTR_DATA.fg | FgFlags.BLINK | FgFlags.UNDERLINE;
|
||||||
|
cell.bg = DEFAULT_ATTR_DATA.bg | BgFlags.HAS_EXTENDED;
|
||||||
|
cell.extended.underlineStyle = UnderlineStyle.SINGLE;
|
||||||
|
lineData.setCell(0, cell);
|
||||||
|
const onSpans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
|
assert.equal(extractHtml(onSpans),
|
||||||
|
'<span class="xterm-underline-1">a</span>'
|
||||||
|
);
|
||||||
|
const offSpans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, false, 5, widthCache, -1, -1);
|
||||||
|
assert.equal(extractHtml(offSpans),
|
||||||
|
'<span class="xterm-blink-hidden xterm-underline-1">a</span>'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it('should add classes for 256 foreground colors', () => {
|
it('should add classes for 256 foreground colors', () => {
|
||||||
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
||||||
cell.fg |= Attributes.CM_P256;
|
cell.fg |= Attributes.CM_P256;
|
||||||
@@ -231,7 +247,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
cell.fg &= ~Attributes.PCOLOR_MASK;
|
cell.fg &= ~Attributes.PCOLOR_MASK;
|
||||||
cell.fg |= i;
|
cell.fg |= i;
|
||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
`<span class="xterm-fg-${i}">a</span>`
|
`<span class="xterm-fg-${i}">a</span>`
|
||||||
);
|
);
|
||||||
@@ -245,7 +261,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
cell.bg &= ~Attributes.PCOLOR_MASK;
|
cell.bg &= ~Attributes.PCOLOR_MASK;
|
||||||
cell.bg |= i;
|
cell.bg |= i;
|
||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
`<span class="xterm-bg-${i}">a</span>`
|
`<span class="xterm-bg-${i}">a</span>`
|
||||||
);
|
);
|
||||||
@@ -257,7 +273,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
cell.fg |= Attributes.CM_P16 | 2 | FgFlags.INVERSE;
|
cell.fg |= Attributes.CM_P16 | 2 | FgFlags.INVERSE;
|
||||||
cell.bg |= Attributes.CM_P16 | 1;
|
cell.bg |= Attributes.CM_P16 | 1;
|
||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span class="xterm-bg-2 xterm-fg-1">a</span>'
|
'<span class="xterm-bg-2 xterm-fg-1">a</span>'
|
||||||
);
|
);
|
||||||
@@ -268,7 +284,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
cell.fg |= FgFlags.INVERSE;
|
cell.fg |= FgFlags.INVERSE;
|
||||||
cell.bg |= Attributes.CM_P16 | 1;
|
cell.bg |= Attributes.CM_P16 | 1;
|
||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span class="xterm-bg-257 xterm-fg-1">a</span>'
|
'<span class="xterm-bg-257 xterm-fg-1">a</span>'
|
||||||
);
|
);
|
||||||
@@ -278,7 +294,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
const cell = CellData.fromCharData([0, 'a', 1, 'a'.charCodeAt(0)]);
|
||||||
cell.fg |= Attributes.CM_P16 | 1 | FgFlags.INVERSE;
|
cell.fg |= Attributes.CM_P16 | 1 | FgFlags.INVERSE;
|
||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span class="xterm-bg-1 xterm-fg-257">a</span>'
|
'<span class="xterm-bg-1 xterm-fg-257">a</span>'
|
||||||
);
|
);
|
||||||
@@ -291,7 +307,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
cell.fg &= ~Attributes.PCOLOR_MASK;
|
cell.fg &= ~Attributes.PCOLOR_MASK;
|
||||||
cell.fg |= i;
|
cell.fg |= i;
|
||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
`<span class="xterm-bold xterm-fg-${i + 8}">a</span>`
|
`<span class="xterm-bold xterm-fg-${i + 8}">a</span>`
|
||||||
);
|
);
|
||||||
@@ -303,7 +319,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
cell.fg |= Attributes.CM_RGB | 1 << 16 | 2 << 8 | 3;
|
cell.fg |= Attributes.CM_RGB | 1 << 16 | 2 << 8 | 3;
|
||||||
cell.bg |= Attributes.CM_RGB | 4 << 16 | 5 << 8 | 6;
|
cell.bg |= Attributes.CM_RGB | 4 << 16 | 5 << 8 | 6;
|
||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span style="background-color:#040506;color:#010203;">a</span>'
|
'<span style="background-color:#040506;color:#010203;">a</span>'
|
||||||
);
|
);
|
||||||
@@ -314,7 +330,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
cell.fg |= Attributes.CM_RGB | 1 << 16 | 2 << 8 | 3 | FgFlags.INVERSE;
|
cell.fg |= Attributes.CM_RGB | 1 << 16 | 2 << 8 | 3 | FgFlags.INVERSE;
|
||||||
cell.bg |= Attributes.CM_RGB | 4 << 16 | 5 << 8 | 6;
|
cell.bg |= Attributes.CM_RGB | 4 << 16 | 5 << 8 | 6;
|
||||||
lineData.setCell(0, cell);
|
lineData.setCell(0, cell);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span style="background-color:#010203;color:#040506;">a</span>'
|
'<span style="background-color:#010203;color:#040506;">a</span>'
|
||||||
);
|
);
|
||||||
@@ -326,7 +342,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
lineData.setCell(0, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)]));
|
lineData.setCell(0, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)]));
|
||||||
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, 'b', 1, 'b'.charCodeAt(0)]));
|
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, 'b', 1, 'b'.charCodeAt(0)]));
|
||||||
rowFactory.handleSelectionChanged([1, 0], [2, 0], false);
|
rowFactory.handleSelectionChanged([1, 0], [2, 0], false);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span>a</span><span style="background-color:#ff0000;" class="xterm-decoration-top">b</span>'
|
'<span>a</span><span style="background-color:#ff0000;" class="xterm-decoration-top">b</span>'
|
||||||
);
|
);
|
||||||
@@ -334,7 +350,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
it('should force whitespace cells to be rendered above the background', () => {
|
it('should force whitespace cells to be rendered above the background', () => {
|
||||||
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)]));
|
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)]));
|
||||||
rowFactory.handleSelectionChanged([0, 0], [2, 0], false);
|
rowFactory.handleSelectionChanged([0, 0], [2, 0], false);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span style="background-color:#ff0000;" class="xterm-decoration-top"> a</span>'
|
'<span style="background-color:#ff0000;" class="xterm-decoration-top"> a</span>'
|
||||||
);
|
);
|
||||||
@@ -351,7 +367,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not create anything for an empty row', () => {
|
it('should not create anything for an empty row', () => {
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
@@ -361,7 +377,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
lineData.setCell(0, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)]));
|
lineData.setCell(0, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)]));
|
||||||
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, 'b', 1, 'b'.charCodeAt(0)]));
|
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, 'b', 1, 'b'.charCodeAt(0)]));
|
||||||
lineData.setCell(2, CellData.fromCharData([DEFAULT_ATTR, 'c', 1, 'c'.charCodeAt(0)]));
|
lineData.setCell(2, CellData.fromCharData([DEFAULT_ATTR, 'c', 1, 'c'.charCodeAt(0)]));
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span>abc</span>'
|
'<span>abc</span>'
|
||||||
);
|
);
|
||||||
@@ -372,7 +388,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
lineData.setCell(0, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)]));
|
lineData.setCell(0, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)]));
|
||||||
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, '€', 1, '€'.charCodeAt(0)]));
|
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, '€', 1, '€'.charCodeAt(0)]));
|
||||||
lineData.setCell(2, CellData.fromCharData([DEFAULT_ATTR, 'c', 1, 'c'.charCodeAt(0)]));
|
lineData.setCell(2, CellData.fromCharData([DEFAULT_ATTR, 'c', 1, 'c'.charCodeAt(0)]));
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span>a</span><span style="letter-spacing: 3px;">€</span><span>c</span>'
|
'<span>a</span><span style="letter-spacing: 3px;">€</span><span>c</span>'
|
||||||
);
|
);
|
||||||
@@ -387,7 +403,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
lineData.setCell(1, aColor1);
|
lineData.setCell(1, aColor1);
|
||||||
lineData.setCell(2, bColor2);
|
lineData.setCell(2, bColor2);
|
||||||
lineData.setCell(3, bColor2);
|
lineData.setCell(3, bColor2);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span class="xterm-fg-1">aa</span><span class="xterm-fg-2">bb</span>'
|
'<span class="xterm-fg-1">aa</span><span class="xterm-fg-2">bb</span>'
|
||||||
);
|
);
|
||||||
@@ -399,7 +415,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
lineData.setCell(2, CellData.fromCharData([DEFAULT_ATTR, 'X', 1, 'X'.charCodeAt(0)]));
|
lineData.setCell(2, CellData.fromCharData([DEFAULT_ATTR, 'X', 1, 'X'.charCodeAt(0)]));
|
||||||
lineData.setCell(3, CellData.fromCharData([DEFAULT_ATTR, 'b', 1, 'b'.charCodeAt(0)]));
|
lineData.setCell(3, CellData.fromCharData([DEFAULT_ATTR, 'b', 1, 'b'.charCodeAt(0)]));
|
||||||
lineData.setCell(4, CellData.fromCharData([DEFAULT_ATTR, 'b', 1, 'b'.charCodeAt(0)]));
|
lineData.setCell(4, CellData.fromCharData([DEFAULT_ATTR, 'b', 1, 'b'.charCodeAt(0)]));
|
||||||
const spans = rowFactory.createRow(lineData, 0, true, undefined, undefined, 2, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, true, undefined, undefined, 2, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span>aa</span><span class="xterm-cursor xterm-cursor-block">X</span><span>bb</span>'
|
'<span>aa</span><span class="xterm-cursor xterm-cursor-block">X</span><span>bb</span>'
|
||||||
);
|
);
|
||||||
@@ -412,7 +428,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
nullCell.bg = Attributes.CM_P16 | 2;
|
nullCell.bg = Attributes.CM_P16 | 2;
|
||||||
lineData.setCell(3, nullCell);
|
lineData.setCell(3, nullCell);
|
||||||
lineData.setCell(4, nullCell);
|
lineData.setCell(4, nullCell);
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span> </span><span class="xterm-bg-1"> </span><span class="xterm-bg-2"> </span>'
|
'<span> </span><span class="xterm-bg-1"> </span><span class="xterm-bg-2"> </span>'
|
||||||
);
|
);
|
||||||
@@ -422,23 +438,23 @@ describe('DomRendererRowFactory', () => {
|
|||||||
const nullCell = lineData.loadCell(0, new CellData());
|
const nullCell = lineData.loadCell(0, new CellData());
|
||||||
nullCell.bg = Attributes.CM_P16 | 1;
|
nullCell.bg = Attributes.CM_P16 | 1;
|
||||||
lineData.setCell(0, nullCell);
|
lineData.setCell(0, nullCell);
|
||||||
let spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
let spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span class="xterm-bg-1"> </span>'
|
'<span class="xterm-bg-1"> </span>'
|
||||||
);
|
);
|
||||||
lineData.setCell(1, nullCell);
|
lineData.setCell(1, nullCell);
|
||||||
spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span class="xterm-bg-1"> </span>'
|
'<span class="xterm-bg-1"> </span>'
|
||||||
);
|
);
|
||||||
lineData.setCell(2, nullCell);
|
lineData.setCell(2, nullCell);
|
||||||
lineData.setCell(3, nullCell);
|
lineData.setCell(3, nullCell);
|
||||||
spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span class="xterm-bg-1"> </span>'
|
'<span class="xterm-bg-1"> </span>'
|
||||||
);
|
);
|
||||||
lineData.setCell(4, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)]));
|
lineData.setCell(4, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)]));
|
||||||
spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span class="xterm-bg-1"> </span><span>a</span>'
|
'<span class="xterm-bg-1"> </span><span>a</span>'
|
||||||
);
|
);
|
||||||
@@ -451,7 +467,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
lineData.setCell(2, CellData.fromCharData([DEFAULT_ATTR, 'c', 1, 'c'.charCodeAt(0)]));
|
lineData.setCell(2, CellData.fromCharData([DEFAULT_ATTR, 'c', 1, 'c'.charCodeAt(0)]));
|
||||||
lineData.setCell(3, CellData.fromCharData([DEFAULT_ATTR, '語', 2, 'c'.charCodeAt(0)]));
|
lineData.setCell(3, CellData.fromCharData([DEFAULT_ATTR, '語', 2, 'c'.charCodeAt(0)]));
|
||||||
lineData.setCell(4, CellData.fromCharData([DEFAULT_ATTR, '𝄞', 1, 'c'.charCodeAt(0)]));
|
lineData.setCell(4, CellData.fromCharData([DEFAULT_ATTR, '𝄞', 1, 'c'.charCodeAt(0)]));
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -1, -1);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -1, -1);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span>a</span><span style="letter-spacing: 3px;">€</span><span>c語</span><span style="letter-spacing: -2px;">𝄞</span>'
|
'<span>a</span><span style="letter-spacing: 3px;">€</span><span>c語</span><span style="letter-spacing: -2px;">𝄞</span>'
|
||||||
);
|
);
|
||||||
@@ -465,7 +481,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
lineData.setCell(4, CellData.fromCharData([DEFAULT_ATTR, 'x', 1, 'x'.charCodeAt(0)]));
|
lineData.setCell(4, CellData.fromCharData([DEFAULT_ATTR, 'x', 1, 'x'.charCodeAt(0)]));
|
||||||
lineData.setCell(5, CellData.fromCharData([DEFAULT_ATTR, 'b', 1, 'b'.charCodeAt(0)]));
|
lineData.setCell(5, CellData.fromCharData([DEFAULT_ATTR, 'b', 1, 'b'.charCodeAt(0)]));
|
||||||
lineData.setCell(6, CellData.fromCharData([DEFAULT_ATTR, 'b', 1, 'b'.charCodeAt(0)]));
|
lineData.setCell(6, CellData.fromCharData([DEFAULT_ATTR, 'b', 1, 'b'.charCodeAt(0)]));
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, 2, 4);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, 2, 4);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span>aa</span><span style="text-decoration: underline;">xxx</span><span>bb</span>'
|
'<span>aa</span><span style="text-decoration: underline;">xxx</span><span>bb</span>'
|
||||||
);
|
);
|
||||||
@@ -476,7 +492,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)]));
|
lineData.setCell(1, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)]));
|
||||||
lineData.setCell(2, CellData.fromCharData([DEFAULT_ATTR, 'x', 1, 'x'.charCodeAt(0)]));
|
lineData.setCell(2, CellData.fromCharData([DEFAULT_ATTR, 'x', 1, 'x'.charCodeAt(0)]));
|
||||||
lineData.setCell(4, CellData.fromCharData([DEFAULT_ATTR, 'x', 1, 'x'.charCodeAt(0)]));
|
lineData.setCell(4, CellData.fromCharData([DEFAULT_ATTR, 'x', 1, 'x'.charCodeAt(0)]));
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, 2, 4);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, 2, 4);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span>aa</span><span style="text-decoration: underline;">x x</span>'
|
'<span>aa</span><span style="text-decoration: underline;">x x</span>'
|
||||||
);
|
);
|
||||||
@@ -486,7 +502,7 @@ describe('DomRendererRowFactory', () => {
|
|||||||
for (let i = 0; i < 10; ++i) {
|
for (let i = 0; i < 10; ++i) {
|
||||||
lineData.setCell(i, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)]));
|
lineData.setCell(i, CellData.fromCharData([DEFAULT_ATTR, 'a', 1, 'a'.charCodeAt(0)]));
|
||||||
}
|
}
|
||||||
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, 5, widthCache, -100, 100);
|
const spans = rowFactory.createRow(lineData, 0, false, undefined, undefined, 0, false, true, 5, widthCache, -100, 100);
|
||||||
assert.equal(extractHtml(spans),
|
assert.equal(extractHtml(spans),
|
||||||
'<span style="text-decoration: underline;">aaaaaaaaaa</span>'
|
'<span style="text-decoration: underline;">aaaaaaaaaa</span>'
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export const enum RowCss {
|
|||||||
UNDERLINE_CLASS = 'xterm-underline',
|
UNDERLINE_CLASS = 'xterm-underline',
|
||||||
OVERLINE_CLASS = 'xterm-overline',
|
OVERLINE_CLASS = 'xterm-overline',
|
||||||
STRIKETHROUGH_CLASS = 'xterm-strikethrough',
|
STRIKETHROUGH_CLASS = 'xterm-strikethrough',
|
||||||
|
BLINK_HIDDEN_CLASS = 'xterm-blink-hidden',
|
||||||
CURSOR_CLASS = 'xterm-cursor',
|
CURSOR_CLASS = 'xterm-cursor',
|
||||||
CURSOR_BLINK_CLASS = 'xterm-cursor-blink',
|
CURSOR_BLINK_CLASS = 'xterm-cursor-blink',
|
||||||
CURSOR_STYLE_BLOCK_CLASS = 'xterm-cursor-block',
|
CURSOR_STYLE_BLOCK_CLASS = 'xterm-cursor-block',
|
||||||
@@ -66,6 +67,7 @@ export class DomRendererRowFactory {
|
|||||||
cursorInactiveStyle: string | undefined,
|
cursorInactiveStyle: string | undefined,
|
||||||
cursorX: number,
|
cursorX: number,
|
||||||
cursorBlink: boolean,
|
cursorBlink: boolean,
|
||||||
|
blinkOn: boolean,
|
||||||
cellWidth: number,
|
cellWidth: number,
|
||||||
widthCache: WidthCache,
|
widthCache: WidthCache,
|
||||||
linkStart: number,
|
linkStart: number,
|
||||||
@@ -153,6 +155,10 @@ export class DomRendererRowFactory {
|
|||||||
const isInSelection = this._isCellInSelection(x, row);
|
const isInSelection = this._isCellInSelection(x, row);
|
||||||
const isCursorCell = isCursorRow && x === cursorX;
|
const isCursorCell = isCursorRow && x === cursorX;
|
||||||
const isLinkHover = hasHover && x >= linkStart && x <= linkEnd;
|
const isLinkHover = hasHover && x >= linkStart && x <= linkEnd;
|
||||||
|
const isBlinkHidden = !blinkOn && cell.isBlink();
|
||||||
|
if (isBlinkHidden) {
|
||||||
|
classes.push(RowCss.BLINK_HIDDEN_CLASS);
|
||||||
|
}
|
||||||
|
|
||||||
let isDecorated = false;
|
let isDecorated = false;
|
||||||
this._decorationService.forEachDecorationAtCell(x, row, undefined, d => {
|
this._decorationService.forEachDecorationAtCell(x, row, undefined, d => {
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 The xterm.js authors. All rights reserved.
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { ICoreBrowserService } from 'browser/services/Services';
|
||||||
|
import { Disposable, toDisposable } from 'common/Lifecycle';
|
||||||
|
|
||||||
|
export class TextBlinkStateManager extends Disposable {
|
||||||
|
private _intervalDuration: number = 0;
|
||||||
|
private _interval: number | undefined;
|
||||||
|
private _blinkOn: boolean = true;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private readonly _renderCallback: () => void,
|
||||||
|
private readonly _coreBrowserService: ICoreBrowserService
|
||||||
|
) {
|
||||||
|
super();
|
||||||
|
this._register(toDisposable(() => this._clearInterval()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public get isBlinkOn(): boolean {
|
||||||
|
return this._blinkOn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public get isEnabled(): boolean {
|
||||||
|
return this._intervalDuration > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public setIntervalDuration(duration: number): void {
|
||||||
|
if (duration === this._intervalDuration) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this._intervalDuration = duration;
|
||||||
|
this._clearInterval();
|
||||||
|
|
||||||
|
const wasBlinkOn = this._blinkOn;
|
||||||
|
if (duration > 0) {
|
||||||
|
this._blinkOn = true;
|
||||||
|
this._interval = this._coreBrowserService.window.setInterval(() => {
|
||||||
|
this._blinkOn = !this._blinkOn;
|
||||||
|
this._renderCallback();
|
||||||
|
}, duration);
|
||||||
|
if (!wasBlinkOn) {
|
||||||
|
this._renderCallback();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this._blinkOn = true;
|
||||||
|
if (!wasBlinkOn) {
|
||||||
|
this._renderCallback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private _clearInterval(): void {
|
||||||
|
if (this._interval !== undefined) {
|
||||||
|
this._coreBrowserService.window.clearInterval(this._interval);
|
||||||
|
this._interval = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ export const DEFAULT_OPTIONS: Readonly<Required<ITerminalOptions>> = {
|
|||||||
rows: 24,
|
rows: 24,
|
||||||
showCursorImmediately: false,
|
showCursorImmediately: false,
|
||||||
cursorBlink: false,
|
cursorBlink: false,
|
||||||
|
blinkIntervalDuration: 0,
|
||||||
cursorStyle: 'block',
|
cursorStyle: 'block',
|
||||||
cursorWidth: 1,
|
cursorWidth: 1,
|
||||||
cursorInactiveStyle: 'outline',
|
cursorInactiveStyle: 'outline',
|
||||||
@@ -168,6 +169,12 @@ export class OptionsService extends Disposable implements IOptionsService {
|
|||||||
}
|
}
|
||||||
value = FONT_WEIGHT_OPTIONS.includes(value) ? value : DEFAULT_OPTIONS[key];
|
value = FONT_WEIGHT_OPTIONS.includes(value) ? value : DEFAULT_OPTIONS[key];
|
||||||
break;
|
break;
|
||||||
|
case 'blinkIntervalDuration':
|
||||||
|
value = Math.floor(value);
|
||||||
|
if (value < 0) {
|
||||||
|
throw new Error(`${key} cannot be less than 0, value: ${value}`);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'cursorWidth':
|
case 'cursorWidth':
|
||||||
value = Math.floor(value);
|
value = Math.floor(value);
|
||||||
// Fall through for bounds check
|
// Fall through for bounds check
|
||||||
|
|||||||
@@ -229,6 +229,7 @@ export interface ITerminalOptions {
|
|||||||
cols?: number;
|
cols?: number;
|
||||||
convertEol?: boolean;
|
convertEol?: boolean;
|
||||||
cursorBlink?: boolean;
|
cursorBlink?: boolean;
|
||||||
|
blinkIntervalDuration?: number;
|
||||||
cursorStyle?: CursorStyle;
|
cursorStyle?: CursorStyle;
|
||||||
cursorWidth?: number;
|
cursorWidth?: number;
|
||||||
cursorInactiveStyle?: CursorInactiveStyle;
|
cursorInactiveStyle?: CursorInactiveStyle;
|
||||||
|
|||||||
Vendored
+7
@@ -55,6 +55,13 @@ declare module '@xterm/headless' {
|
|||||||
*/
|
*/
|
||||||
cursorBlink?: boolean;
|
cursorBlink?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interval in milliseconds for the blink attribute. This is the amount
|
||||||
|
* of time text remains visible or hidden before toggling. Set to 0 to
|
||||||
|
* disable blinking. The default is 0.
|
||||||
|
*/
|
||||||
|
blinkIntervalDuration?: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The style of the cursor.
|
* The style of the cursor.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Vendored
+7
@@ -64,6 +64,13 @@ declare module '@xterm/xterm' {
|
|||||||
*/
|
*/
|
||||||
cursorBlink?: boolean;
|
cursorBlink?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interval in milliseconds for the blink attribute. This is the amount
|
||||||
|
* of time text remains visible or hidden before toggling. Set to 0 to
|
||||||
|
* disable blinking. The default is 0.
|
||||||
|
*/
|
||||||
|
blinkIntervalDuration?: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The style of the cursor when the terminal is focused.
|
* The style of the cursor when the terminal is focused.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user