diff options
Diffstat (limited to 'node_modules/xterm/src/browser/public/Terminal.ts')
-rw-r--r-- | node_modules/xterm/src/browser/public/Terminal.ts | 17 |
1 files changed, 15 insertions, 2 deletions
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'); + } + } + } } |