diff options
author | Neil Kollack <nkollack@gmail.com> | 2022-03-20 01:14:53 -0500 |
---|---|---|
committer | Neil Kollack <nkollack@gmail.com> | 2022-03-20 01:14:53 -0500 |
commit | 67f3eab7aba135fe669589927954d34c2fe30c3e (patch) | |
tree | a722457789171dfa5ac4185f277c3211ee0f3a6e /node_modules/xterm/src/browser/public | |
parent | a8cbe2ec227e2244457d12d99fb3cdb0fc599f37 (diff) |
feat: garbage terminal
Diffstat (limited to 'node_modules/xterm/src/browser/public')
-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'); + } + } + } } |