diff options
Diffstat (limited to 'node_modules/xterm/src')
-rw-r--r-- | node_modules/xterm/src/browser/AccessibilityManager.ts | 1 | ||||
-rw-r--r-- | node_modules/xterm/src/browser/Terminal.ts | 13 | ||||
-rw-r--r-- | node_modules/xterm/src/browser/Types.d.ts | 5 | ||||
-rw-r--r-- | node_modules/xterm/src/browser/public/Terminal.ts | 17 | ||||
-rw-r--r-- | node_modules/xterm/src/browser/renderer/Renderer.ts | 5 | ||||
-rw-r--r-- | node_modules/xterm/src/browser/services/RenderService.ts | 3 | ||||
-rw-r--r-- | node_modules/xterm/src/browser/services/Services.ts | 10 | ||||
-rw-r--r-- | node_modules/xterm/src/common/InputHandler.ts | 3 | ||||
-rw-r--r-- | node_modules/xterm/src/common/buffer/Buffer.ts | 23 | ||||
-rw-r--r-- | node_modules/xterm/src/common/buffer/Types.d.ts | 1 | ||||
-rw-r--r-- | node_modules/xterm/src/headless/public/Terminal.ts | 2 |
11 files changed, 70 insertions, 13 deletions
diff --git a/node_modules/xterm/src/browser/AccessibilityManager.ts b/node_modules/xterm/src/browser/AccessibilityManager.ts index eda29c0..c162abc 100644 --- a/node_modules/xterm/src/browser/AccessibilityManager.ts +++ b/node_modules/xterm/src/browser/AccessibilityManager.ts @@ -53,7 +53,6 @@ export class AccessibilityManager extends Disposable { ) { super(); this._accessibilityTreeRoot = document.createElement('div'); - this._accessibilityTreeRoot.setAttribute('role', 'document'); this._accessibilityTreeRoot.classList.add('xterm-accessibility'); this._accessibilityTreeRoot.tabIndex = 0; diff --git a/node_modules/xterm/src/browser/Terminal.ts b/node_modules/xterm/src/browser/Terminal.ts index fe5c7f7..703c995 100644 --- a/node_modules/xterm/src/browser/Terminal.ts +++ b/node_modules/xterm/src/browser/Terminal.ts @@ -37,7 +37,7 @@ import * as Strings from 'browser/LocalizableStrings'; import { SoundService } from 'browser/services/SoundService'; import { MouseZoneManager } from 'browser/MouseZoneManager'; import { AccessibilityManager } from './AccessibilityManager'; -import { ITheme, IMarker, IDisposable, ISelectionPosition, ILinkProvider } from 'xterm'; +import { ITheme, IMarker, IDisposable, ISelectionPosition, ILinkProvider, IDecorationOptions, IDecoration } from 'xterm'; import { DomRenderer } from 'browser/renderer/dom/DomRenderer'; import { KeyboardResultType, CoreMouseEventType, CoreMouseButton, CoreMouseAction, ITerminalOptions, ScrollSource, IColorEvent, ColorIndex, ColorRequestType } from 'common/Types'; import { evaluateKeyboardEvent } from 'common/input/Keyboard'; @@ -45,7 +45,7 @@ import { EventEmitter, IEvent, forwardEvent } from 'common/EventEmitter'; import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; import { ColorManager } from 'browser/ColorManager'; import { RenderService } from 'browser/services/RenderService'; -import { ICharSizeService, IRenderService, IMouseService, ISelectionService, ISoundService, ICoreBrowserService, ICharacterJoinerService } from 'browser/services/Services'; +import { ICharSizeService, IRenderService, IMouseService, ISelectionService, ISoundService, ICoreBrowserService, ICharacterJoinerService, IDecorationService } from 'browser/services/Services'; import { CharSizeService } from 'browser/services/CharSizeService'; import { IBuffer } from 'common/buffer/Types'; import { MouseService } from 'browser/services/MouseService'; @@ -55,6 +55,7 @@ import { CoreTerminal } from 'common/CoreTerminal'; import { color, rgba } from 'browser/Color'; import { CharacterJoinerService } from 'browser/services/CharacterJoinerService'; import { toRgbString } from 'common/input/XParseColor'; +import { DecorationService } from 'browser/services/DecorationService'; // Let it work inside Node.js for automated testing purposes. const document: Document = (typeof window !== 'undefined') ? window.document : null as any; @@ -108,6 +109,7 @@ export class Terminal extends CoreTerminal implements ITerminal { public linkifier: ILinkifier; public linkifier2: ILinkifier2; public viewport: IViewport | undefined; + public decorationService: IDecorationService; private _compositionHelper: ICompositionHelper | undefined; private _mouseZoneManager: IMouseZoneManager | undefined; private _accessibilityManager: AccessibilityManager | undefined; @@ -157,6 +159,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this.linkifier = this._instantiationService.createInstance(Linkifier); this.linkifier2 = this.register(this._instantiationService.createInstance(Linkifier2)); + this.decorationService = this.register(this._instantiationService.createInstance(DecorationService)); // Setup InputHandler listeners this.register(this._inputHandler.onRequestBell(() => this.bell())); @@ -574,6 +577,7 @@ export class Terminal extends CoreTerminal implements ITerminal { this.linkifier.attachToDom(this.element, this._mouseZoneManager); this.linkifier2.attachToDom(this.screenElement, this._mouseService, this._renderService); + this.decorationService.attachToDom(this.screenElement, this._renderService, this._bufferService); // This event listener must be registered aftre MouseZoneManager is created this.register(addDisposableDomListener(this.element, 'mousedown', (e: MouseEvent) => this._selectionService!.onMouseDown(e))); @@ -998,6 +1002,10 @@ export class Terminal extends CoreTerminal implements ITerminal { return this.buffer.addMarker(this.buffer.ybase + this.buffer.y + cursorYOffset); } + public registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined { + return this.decorationService!.registerDecoration(decorationOptions); + } + /** * Gets whether the terminal has an active selection. */ @@ -1293,6 +1301,7 @@ export class Terminal extends CoreTerminal implements ITerminal { // Don't clear if it's already clear return; } + this.buffer.clearMarkers(); this.buffer.lines.set(0, this.buffer.lines.get(this.buffer.ybase + this.buffer.y)!); this.buffer.lines.length = 1; this.buffer.ydisp = 0; diff --git a/node_modules/xterm/src/browser/Types.d.ts b/node_modules/xterm/src/browser/Types.d.ts index a616584..35b52d6 100644 --- a/node_modules/xterm/src/browser/Types.d.ts +++ b/node_modules/xterm/src/browser/Types.d.ts @@ -3,11 +3,11 @@ * @license MIT */ -import { IDisposable, IMarker, ISelectionPosition } from 'xterm'; +import { IDecorationOptions, IDecoration, IDisposable, IMarker, ISelectionPosition } from 'xterm'; import { IEvent } from 'common/EventEmitter'; import { ICoreTerminal, CharData, ITerminalOptions } from 'common/Types'; import { IMouseService, IRenderService } from './services/Services'; -import { IBuffer, IBufferSet } from 'common/buffer/Types'; +import { IBuffer } from 'common/buffer/Types'; import { IFunctionIdentifier, IParams } from 'common/parser/Types'; export interface ITerminal extends IPublicTerminal, ICoreTerminal { @@ -61,6 +61,7 @@ export interface IPublicTerminal extends IDisposable { registerCharacterJoiner(handler: (text: string) => [number, number][]): number; deregisterCharacterJoiner(joinerId: number): void; addMarker(cursorYOffset: number): IMarker | undefined; + registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined; hasSelection(): boolean; getSelection(): string; getSelectionPosition(): ISelectionPosition | undefined; diff --git a/node_modules/xterm/src/browser/public/Terminal.ts b/node_modules/xterm/src/browser/public/Terminal.ts index 117805f..1acde93 100644 --- a/node_modules/xterm/src/browser/public/Terminal.ts +++ b/node_modules/xterm/src/browser/public/Terminal.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { Terminal as ITerminalApi, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBufferNamespace as IBufferNamespaceApi, IParser, ILinkProvider, IUnicodeHandling, FontWeight, IModes } from 'xterm'; +import { Terminal as ITerminalApi, IMarker, IDisposable, ILinkMatcherOptions, ITheme, ILocalizableStrings, ITerminalAddon, ISelectionPosition, IBufferNamespace as IBufferNamespaceApi, IParser, ILinkProvider, IUnicodeHandling, FontWeight, IModes, IDecorationOptions, IDecoration } from 'xterm'; import { ITerminal } from 'browser/Types'; import { Terminal as TerminalCore } from 'browser/Terminal'; import * as Strings from 'browser/LocalizableStrings'; @@ -166,11 +166,16 @@ export class Terminal implements ITerminalApi { this._checkProposedApi(); this._core.deregisterCharacterJoiner(joinerId); } - public registerMarker(cursorYOffset: number): IMarker | undefined { + public registerMarker(cursorYOffset: number = 0): IMarker | undefined { this._checkProposedApi(); this._verifyIntegers(cursorYOffset); return this._core.addMarker(cursorYOffset); } + public registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined { + this._checkProposedApi(); + this._verifyPositiveIntegers(decorationOptions.x ?? 0, decorationOptions.width ?? 0, decorationOptions.height ?? 0); + return this._core.registerDecoration(decorationOptions); + } public addMarker(cursorYOffset: number): IMarker | undefined { return this.registerMarker(cursorYOffset); } @@ -281,4 +286,12 @@ export class Terminal implements ITerminalApi { } } } + + private _verifyPositiveIntegers(...values: number[]): void { + for (const value of values) { + if (value && (value === Infinity || isNaN(value) || value % 1 !== 0 || value < 0)) { + throw new Error('This API only accepts positive integers'); + } + } + } } diff --git a/node_modules/xterm/src/browser/renderer/Renderer.ts b/node_modules/xterm/src/browser/renderer/Renderer.ts index 7a64257..a58893b 100644 --- a/node_modules/xterm/src/browser/renderer/Renderer.ts +++ b/node_modules/xterm/src/browser/renderer/Renderer.ts @@ -10,10 +10,11 @@ import { IRenderLayer, IRenderer, IRenderDimensions, IRequestRedrawEvent } from import { LinkRenderLayer } from 'browser/renderer/LinkRenderLayer'; import { Disposable } from 'common/Lifecycle'; import { IColorSet, ILinkifier, ILinkifier2 } from 'browser/Types'; -import { ICharSizeService, ICoreBrowserService } from 'browser/services/Services'; -import { IBufferService, IOptionsService, ICoreService, IInstantiationService } from 'common/services/Services'; +import { ICharSizeService } from 'browser/services/Services'; +import { IBufferService, IOptionsService, IInstantiationService } from 'common/services/Services'; import { removeTerminalFromCache } from 'browser/renderer/atlas/CharAtlasCache'; import { EventEmitter, IEvent } from 'common/EventEmitter'; +import { IDecorationOptions, IDecoration } from 'xterm'; let nextRendererId = 1; diff --git a/node_modules/xterm/src/browser/services/RenderService.ts b/node_modules/xterm/src/browser/services/RenderService.ts index b8283e0..da458ab 100644 --- a/node_modules/xterm/src/browser/services/RenderService.ts +++ b/node_modules/xterm/src/browser/services/RenderService.ts @@ -65,7 +65,8 @@ export class RenderService extends Disposable implements IRenderService { this._screenDprMonitor.setListener(() => this.onDevicePixelRatioChange()); this.register(this._screenDprMonitor); - this.register(bufferService.onResize(e => this._fullRefresh())); + this.register(bufferService.onResize(() => this._fullRefresh())); + this.register(bufferService.buffers.onBufferActivate(() => this._renderer?.clear())); this.register(optionsService.onOptionChange(() => this._renderer.onOptionsChanged())); this.register(this._charSizeService.onCharSizeChange(() => this.onCharSizeChanged())); diff --git a/node_modules/xterm/src/browser/services/Services.ts b/node_modules/xterm/src/browser/services/Services.ts index 4928fa2..7faf3f0 100644 --- a/node_modules/xterm/src/browser/services/Services.ts +++ b/node_modules/xterm/src/browser/services/Services.ts @@ -9,6 +9,8 @@ import { IColorSet } from 'browser/Types'; import { ISelectionRedrawRequestEvent as ISelectionRequestRedrawEvent, ISelectionRequestScrollLinesEvent } from 'browser/selection/Types'; import { createDecorator } from 'common/services/ServiceRegistry'; import { IDisposable } from 'common/Types'; +import { IDecorationOptions, IDecoration } from 'xterm'; +import { IBufferService } from 'common/services/Services'; export const ICharSizeService = createDecorator<ICharSizeService>('CharSizeService'); export interface ICharSizeService { @@ -113,3 +115,11 @@ export interface ICharacterJoinerService { deregister(joinerId: number): boolean; getJoinedCharacters(row: number): [number, number][]; } + + +export const IDecorationService = createDecorator<IDecorationService>('DecorationService'); +export interface IDecorationService extends IDisposable { + registerDecoration(decorationOptions: IDecorationOptions): IDecoration | undefined; + refresh(): void; + attachToDom(screenElement: HTMLElement, renderService: IRenderService, bufferService: IBufferService): void; +} diff --git a/node_modules/xterm/src/common/InputHandler.ts b/node_modules/xterm/src/common/InputHandler.ts index 68660f8..d5b8d94 100644 --- a/node_modules/xterm/src/common/InputHandler.ts +++ b/node_modules/xterm/src/common/InputHandler.ts @@ -546,7 +546,7 @@ export class InputHandler extends Disposable implements IInputHandler { // Log debug data, the log level gate is to prevent extra work in this hot path if (this._logService.logLevel <= LogLevelEnum.DEBUG) { - this._logService.debug(`parsing data${typeof data === 'string' ? ` "${data}"` : ''}`, typeof data === 'string' + this._logService.debug(`parsing data${typeof data === 'string' ? ` "${data}"` : ` "${Array.prototype.map.call(data, e => String.fromCharCode(e)).join('')}"`}`, typeof data === 'string' ? data.split('').map(e => e.charCodeAt(0)) : data ); @@ -1231,6 +1231,7 @@ export class InputHandler extends Disposable implements IInputHandler { private _resetBufferLine(y: number): void { const line = this._activeBuffer.lines.get(this._activeBuffer.ybase + y)!; line.fill(this._activeBuffer.getNullCell(this._eraseAttrData())); + this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase + y); line.isWrapped = false; } diff --git a/node_modules/xterm/src/common/buffer/Buffer.ts b/node_modules/xterm/src/common/buffer/Buffer.ts index 02ce7c8..7596fef 100644 --- a/node_modules/xterm/src/common/buffer/Buffer.ts +++ b/node_modules/xterm/src/common/buffer/Buffer.ts @@ -43,6 +43,7 @@ export class Buffer implements IBuffer { private _whitespaceCell: ICellData = CellData.fromCharData([0, WHITESPACE_CELL_CHAR, WHITESPACE_CELL_WIDTH, WHITESPACE_CELL_CODE]); private _cols: number; private _rows: number; + private _isClearing: boolean = false; constructor( private _hasScrollback: boolean, @@ -584,6 +585,24 @@ export class Buffer implements IBuffer { return x >= this._cols ? this._cols - 1 : x < 0 ? 0 : x; } + public clearMarkers(y?: number): void { + this._isClearing = true; + if (y !== undefined) { + for (let i = 0; i < this.markers.length; i++) { + if (this.markers[i].line === y) { + this.markers[i].dispose(); + this.markers.splice(i--, 1); + } + } + } else { + for (const marker of this.markers) { + marker.dispose(); + } + this.markers = []; + } + this._isClearing = false; + } + public addMarker(y: number): Marker { const marker = new Marker(y); this.markers.push(marker); @@ -615,7 +634,9 @@ export class Buffer implements IBuffer { } private _removeMarker(marker: Marker): void { - this.markers.splice(this.markers.indexOf(marker), 1); + if (!this._isClearing) { + this.markers.splice(this.markers.indexOf(marker), 1); + } } public iterator(trimRight: boolean, startIndex?: number, endIndex?: number, startOverscan?: number, endOverscan?: number): IBufferStringIterator { diff --git a/node_modules/xterm/src/common/buffer/Types.d.ts b/node_modules/xterm/src/common/buffer/Types.d.ts index cbf40a0..36b70b7 100644 --- a/node_modules/xterm/src/common/buffer/Types.d.ts +++ b/node_modules/xterm/src/common/buffer/Types.d.ts @@ -45,6 +45,7 @@ export interface IBuffer { getNullCell(attr?: IAttributeData): ICellData; getWhitespaceCell(attr?: IAttributeData): ICellData; addMarker(y: number): IMarker; + clearMarkers(y?: number): void; } export interface IBufferSet extends IDisposable { diff --git a/node_modules/xterm/src/headless/public/Terminal.ts b/node_modules/xterm/src/headless/public/Terminal.ts index 9aa171a..5a35fae 100644 --- a/node_modules/xterm/src/headless/public/Terminal.ts +++ b/node_modules/xterm/src/headless/public/Terminal.ts @@ -136,7 +136,7 @@ export class Terminal implements ITerminalApi { this._verifyIntegers(columns, rows); this._core.resize(columns, rows); } - public registerMarker(cursorYOffset: number): IMarker | undefined { + public registerMarker(cursorYOffset: number = 0): IMarker | undefined { this._checkProposedApi(); this._verifyIntegers(cursorYOffset); return this._core.addMarker(cursorYOffset); |