diff options
Diffstat (limited to 'node_modules/xterm/src/headless')
-rw-r--r-- | node_modules/xterm/src/headless/Terminal.ts | 170 | ||||
-rw-r--r-- | node_modules/xterm/src/headless/Types.d.ts | 31 | ||||
-rw-r--r-- | node_modules/xterm/src/headless/public/Terminal.ts | 216 |
3 files changed, 0 insertions, 417 deletions
diff --git a/node_modules/xterm/src/headless/Terminal.ts b/node_modules/xterm/src/headless/Terminal.ts deleted file mode 100644 index 7f138ce..0000000 --- a/node_modules/xterm/src/headless/Terminal.ts +++ /dev/null @@ -1,170 +0,0 @@ -/** - * Copyright (c) 2014 The xterm.js authors. All rights reserved. - * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License) - * @license MIT - * - * Originally forked from (with the author's permission): - * Fabrice Bellard's javascript vt100 for jslinux: - * http://bellard.org/jslinux/ - * Copyright (c) 2011 Fabrice Bellard - * The original design remains. The terminal itself - * has been extended to include xterm CSI codes, among - * other features. - * - * Terminal Emulation References: - * http://vt100.net/ - * http://invisible-island.net/xterm/ctlseqs/ctlseqs.txt - * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html - * http://invisible-island.net/vttest/ - * http://www.inwap.com/pdp10/ansicode.txt - * http://linux.die.net/man/4/console_codes - * http://linux.die.net/man/7/urxvt - */ - -import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; -import { IBuffer } from 'common/buffer/Types'; -import { CoreTerminal } from 'common/CoreTerminal'; -import { EventEmitter, forwardEvent, IEvent } from 'common/EventEmitter'; -import { ITerminalOptions as IInitializedTerminalOptions } from 'common/services/Services'; -import { IMarker, ITerminalOptions, ScrollSource } from 'common/Types'; - -export class Terminal extends CoreTerminal { - // TODO: We should remove options once components adopt optionsService - public get options(): IInitializedTerminalOptions { return this.optionsService.options; } - - private _onBell = new EventEmitter<void>(); - public get onBell(): IEvent<void> { return this._onBell.event; } - private _onCursorMove = new EventEmitter<void>(); - public get onCursorMove(): IEvent<void> { return this._onCursorMove.event; } - private _onTitleChange = new EventEmitter<string>(); - public get onTitleChange(): IEvent<string> { return this._onTitleChange.event; } - - private _onA11yCharEmitter = new EventEmitter<string>(); - public get onA11yChar(): IEvent<string> { return this._onA11yCharEmitter.event; } - private _onA11yTabEmitter = new EventEmitter<number>(); - public get onA11yTab(): IEvent<number> { return this._onA11yTabEmitter.event; } - - /** - * Creates a new `Terminal` object. - * - * @param options An object containing a set of options, the available options are: - * - `cursorBlink` (boolean): Whether the terminal cursor blinks - * - `cols` (number): The number of columns of the terminal (horizontal size) - * - `rows` (number): The number of rows of the terminal (vertical size) - * - * @public - * @class Xterm Xterm - * @alias module:xterm/src/xterm - */ - constructor( - options: ITerminalOptions = {} - ) { - super(options); - - this._setup(); - - // Setup InputHandler listeners - this.register(this._inputHandler.onRequestBell(() => this.bell())); - this.register(this._inputHandler.onRequestReset(() => this.reset())); - this.register(forwardEvent(this._inputHandler.onCursorMove, this._onCursorMove)); - this.register(forwardEvent(this._inputHandler.onTitleChange, this._onTitleChange)); - this.register(forwardEvent(this._inputHandler.onA11yChar, this._onA11yCharEmitter)); - this.register(forwardEvent(this._inputHandler.onA11yTab, this._onA11yTabEmitter)); - } - - public dispose(): void { - if (this._isDisposed) { - return; - } - super.dispose(); - this.write = () => { }; - } - - /** - * Convenience property to active buffer. - */ - public get buffer(): IBuffer { - return this.buffers.active; - } - - protected _updateOptions(key: string): void { - super._updateOptions(key); - - // TODO: These listeners should be owned by individual components - switch (key) { - case 'tabStopWidth': this.buffers.setupTabStops(); break; - } - } - - // TODO: Support paste here? - - public get markers(): IMarker[] { - return this.buffer.markers; - } - - public addMarker(cursorYOffset: number): IMarker | undefined { - // Disallow markers on the alt buffer - if (this.buffer !== this.buffers.normal) { - return; - } - - return this.buffer.addMarker(this.buffer.ybase + this.buffer.y + cursorYOffset); - } - - public bell(): void { - this._onBell.fire(); - } - - /** - * Resizes the terminal. - * - * @param x The number of columns to resize to. - * @param y The number of rows to resize to. - */ - public resize(x: number, y: number): void { - if (x === this.cols && y === this.rows) { - return; - } - - super.resize(x, y); - } - - /** - * Clear the entire buffer, making the prompt line the new first line. - */ - public clear(): void { - if (this.buffer.ybase === 0 && this.buffer.y === 0) { - // Don't clear if it's already clear - return; - } - this.buffer.lines.set(0, this.buffer.lines.get(this.buffer.ybase + this.buffer.y)!); - this.buffer.lines.length = 1; - this.buffer.ydisp = 0; - this.buffer.ybase = 0; - this.buffer.y = 0; - for (let i = 1; i < this.rows; i++) { - this.buffer.lines.push(this.buffer.getBlankLine(DEFAULT_ATTR_DATA)); - } - this._onScroll.fire({ position: this.buffer.ydisp, source: ScrollSource.TERMINAL }); - } - - /** - * Reset terminal. - * Note: Calling this directly from JS is synchronous but does not clear - * input buffers and does not reset the parser, thus the terminal will - * continue to apply pending input data. - * If you need in band reset (synchronous with input data) consider - * using DECSTR (soft reset, CSI ! p) or RIS instead (hard reset, ESC c). - */ - public reset(): void { - /** - * Since _setup handles a full terminal creation, we have to carry forward - * a few things that should not reset. - */ - this.options.rows = this.rows; - this.options.cols = this.cols; - - this._setup(); - super.reset(); - } -} diff --git a/node_modules/xterm/src/headless/Types.d.ts b/node_modules/xterm/src/headless/Types.d.ts deleted file mode 100644 index 868e5c1..0000000 --- a/node_modules/xterm/src/headless/Types.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { IBuffer, IBufferSet } from 'common/buffer/Types'; -import { IEvent } from 'common/EventEmitter'; -import { IFunctionIdentifier, IParams } from 'common/parser/Types'; -import { ICoreTerminal, IDisposable, IMarker, ITerminalOptions } from 'common/Types'; - -export interface ITerminal extends ICoreTerminal { - rows: number; - cols: number; - buffer: IBuffer; - buffers: IBufferSet; - markers: IMarker[]; - // TODO: We should remove options once components adopt optionsService - options: ITerminalOptions; - - onCursorMove: IEvent<void>; - onData: IEvent<string>; - onBinary: IEvent<string>; - onLineFeed: IEvent<void>; - onResize: IEvent<{ cols: number, rows: number }>; - onTitleChange: IEvent<string>; - resize(columns: number, rows: number): void; - addCsiHandler(id: IFunctionIdentifier, callback: (params: IParams) => boolean): IDisposable; - addDcsHandler(id: IFunctionIdentifier, callback: (data: string, param: IParams) => boolean): IDisposable; - addEscHandler(id: IFunctionIdentifier, callback: () => boolean): IDisposable; - addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable; - addMarker(cursorYOffset: number): IMarker | undefined; - dispose(): void; - clear(): void; - write(data: string | Uint8Array, callback?: () => void): void; - reset(): void; -} diff --git a/node_modules/xterm/src/headless/public/Terminal.ts b/node_modules/xterm/src/headless/public/Terminal.ts deleted file mode 100644 index 5a35fae..0000000 --- a/node_modules/xterm/src/headless/public/Terminal.ts +++ /dev/null @@ -1,216 +0,0 @@ -/** - * Copyright (c) 2018 The xterm.js authors. All rights reserved. - * @license MIT - */ - -import { IEvent } from 'common/EventEmitter'; -import { BufferNamespaceApi } from 'common/public/BufferNamespaceApi'; -import { ParserApi } from 'common/public/ParserApi'; -import { UnicodeApi } from 'common/public/UnicodeApi'; -import { IBufferNamespace as IBufferNamespaceApi, IMarker, IModes, IParser, ITerminalAddon, IUnicodeHandling, Terminal as ITerminalApi } from 'xterm-headless'; -import { Terminal as TerminalCore } from 'headless/Terminal'; -import { AddonManager } from 'common/public/AddonManager'; -import { ITerminalOptions } from 'common/Types'; - -/** - * The set of options that only have an effect when set in the Terminal constructor. - */ -const CONSTRUCTOR_ONLY_OPTIONS = ['cols', 'rows']; - -export class Terminal implements ITerminalApi { - private _core: TerminalCore; - private _addonManager: AddonManager; - private _parser: IParser | undefined; - private _buffer: BufferNamespaceApi | undefined; - private _publicOptions: ITerminalOptions; - - constructor(options?: ITerminalOptions) { - this._core = new TerminalCore(options); - this._addonManager = new AddonManager(); - - this._publicOptions = { ... this._core.options }; - const getter = (propName: string): any => { - return this._core.options[propName]; - }; - const setter = (propName: string, value: any): void => { - this._checkReadonlyOptions(propName); - this._core.options[propName] = value; - }; - - for (const propName in this._core.options) { - Object.defineProperty(this._publicOptions, propName, { - get: () => { - return this._core.options[propName]; - }, - set: (value: any) => { - this._checkReadonlyOptions(propName); - this._core.options[propName] = value; - } - }); - const desc = { - get: getter.bind(this, propName), - set: setter.bind(this, propName) - }; - Object.defineProperty(this._publicOptions, propName, desc); - } - } - - private _checkReadonlyOptions(propName: string): void { - // Throw an error if any constructor only option is modified - // from terminal.options - // Modifications from anywhere else are allowed - if (CONSTRUCTOR_ONLY_OPTIONS.includes(propName)) { - throw new Error(`Option "${propName}" can only be set in the constructor`); - } - } - - private _checkProposedApi(): void { - if (!this._core.optionsService.options.allowProposedApi) { - throw new Error('You must set the allowProposedApi option to true to use proposed API'); - } - } - - public get onBell(): IEvent<void> { return this._core.onBell; } - public get onBinary(): IEvent<string> { return this._core.onBinary; } - public get onCursorMove(): IEvent<void> { return this._core.onCursorMove; } - public get onData(): IEvent<string> { return this._core.onData; } - public get onLineFeed(): IEvent<void> { return this._core.onLineFeed; } - public get onResize(): IEvent<{ cols: number, rows: number }> { return this._core.onResize; } - public get onScroll(): IEvent<number> { return this._core.onScroll; } - public get onTitleChange(): IEvent<string> { return this._core.onTitleChange; } - - public get parser(): IParser { - this._checkProposedApi(); - if (!this._parser) { - this._parser = new ParserApi(this._core); - } - return this._parser; - } - public get unicode(): IUnicodeHandling { - this._checkProposedApi(); - return new UnicodeApi(this._core); - } - public get rows(): number { return this._core.rows; } - public get cols(): number { return this._core.cols; } - public get buffer(): IBufferNamespaceApi { - this._checkProposedApi(); - if (!this._buffer) { - this._buffer = new BufferNamespaceApi(this._core); - } - return this._buffer; - } - public get markers(): ReadonlyArray<IMarker> { - this._checkProposedApi(); - return this._core.markers; - } - public get modes(): IModes { - const m = this._core.coreService.decPrivateModes; - let mouseTrackingMode: 'none' | 'x10' | 'vt200' | 'drag' | 'any' = 'none'; - switch (this._core.coreMouseService.activeProtocol) { - case 'X10': mouseTrackingMode = 'x10'; break; - case 'VT200': mouseTrackingMode = 'vt200'; break; - case 'DRAG': mouseTrackingMode = 'drag'; break; - case 'ANY': mouseTrackingMode = 'any'; break; - } - return { - applicationCursorKeysMode: m.applicationCursorKeys, - applicationKeypadMode: m.applicationKeypad, - bracketedPasteMode: m.bracketedPasteMode, - insertMode: this._core.coreService.modes.insertMode, - mouseTrackingMode: mouseTrackingMode, - originMode: m.origin, - reverseWraparoundMode: m.reverseWraparound, - sendFocusMode: m.sendFocus, - wraparoundMode: m.wraparound - }; - } - public get options(): ITerminalOptions { - return this._publicOptions; - } - public set options(options: ITerminalOptions) { - for (const propName in options) { - this._publicOptions[propName] = options[propName]; - } - } - public resize(columns: number, rows: number): void { - this._verifyIntegers(columns, rows); - this._core.resize(columns, rows); - } - public registerMarker(cursorYOffset: number = 0): IMarker | undefined { - this._checkProposedApi(); - this._verifyIntegers(cursorYOffset); - return this._core.addMarker(cursorYOffset); - } - public addMarker(cursorYOffset: number): IMarker | undefined { - return this.registerMarker(cursorYOffset); - } - public dispose(): void { - this._addonManager.dispose(); - this._core.dispose(); - } - public scrollLines(amount: number): void { - this._verifyIntegers(amount); - this._core.scrollLines(amount); - } - public scrollPages(pageCount: number): void { - this._verifyIntegers(pageCount); - this._core.scrollPages(pageCount); - } - public scrollToTop(): void { - this._core.scrollToTop(); - } - public scrollToBottom(): void { - this._core.scrollToBottom(); - } - public scrollToLine(line: number): void { - this._verifyIntegers(line); - this._core.scrollToLine(line); - } - public clear(): void { - this._core.clear(); - } - public write(data: string | Uint8Array, callback?: () => void): void { - this._core.write(data, callback); - } - public writeUtf8(data: Uint8Array, callback?: () => void): void { - this._core.write(data, callback); - } - public writeln(data: string | Uint8Array, callback?: () => void): void { - this._core.write(data); - this._core.write('\r\n', callback); - } - public getOption(key: 'bellSound' | 'bellStyle' | 'cursorStyle' | 'fontFamily' | 'logLevel' | 'rendererType' | 'termName' | 'wordSeparator'): string; - public getOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell'): boolean; - public getOption(key: 'cols' | 'fontSize' | 'letterSpacing' | 'lineHeight' | 'rows' | 'tabStopWidth' | 'scrollback'): number; - public getOption(key: string): any; - public getOption(key: any): any { - return this._core.optionsService.getOption(key); - } - public setOption(key: 'bellSound' | 'fontFamily' | 'termName' | 'wordSeparator', value: string): void; - public setOption(key: 'fontWeight' | 'fontWeightBold', value: 'normal' | 'bold' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' | number): void; - public setOption(key: 'logLevel', value: 'debug' | 'info' | 'warn' | 'error' | 'off'): void; - public setOption(key: 'bellStyle', value: 'none' | 'visual' | 'sound' | 'both'): void; - public setOption(key: 'cursorStyle', value: 'block' | 'underline' | 'bar'): void; - public setOption(key: 'allowTransparency' | 'altClickMovesCursor' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'disableStdin' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'visualBell', value: boolean): void; - public setOption(key: 'fontSize' | 'letterSpacing' | 'lineHeight' | 'tabStopWidth' | 'scrollback', value: number): void; - public setOption(key: 'cols' | 'rows', value: number): void; - public setOption(key: string, value: any): void; - public setOption(key: any, value: any): void { - this._core.optionsService.setOption(key, value); - } - public reset(): void { - this._core.reset(); - } - public loadAddon(addon: ITerminalAddon): void { - // TODO: This could cause issues if the addon calls renderer apis - return this._addonManager.loadAddon(this as any, addon); - } - - private _verifyIntegers(...values: number[]): void { - for (const value of values) { - if (value === Infinity || isNaN(value) || value % 1 !== 0) { - throw new Error('This API only accepts integers'); - } - } - } -} |